FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/services/ffs/ffs.c @ 217:30a173257f4a
gsm-fw/services/ffs: ffs_target.c generation and compilation
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 06 Jan 2014 08:07:36 +0000 |
parents | ef7d7da61c56 |
children |
comparison
equal
deleted
inserted
replaced
216:0eb85790c0ed | 217:30a173257f4a |
---|---|
6 * | 6 * |
7 * $Id: ffs.c 1.69.1.24.1.40 Thu, 08 Jan 2004 15:05:23 +0100 tsj $ | 7 * $Id: ffs.c 1.69.1.24.1.40 Thu, 08 Jan 2004 15:05:23 +0100 tsj $ |
8 * | 8 * |
9 f ******************************************************************************/ | 9 f ******************************************************************************/ |
10 | 10 |
11 #ifndef TARGET | 11 #include "ffs.h" |
12 #include "ffs.cfg" | |
13 #endif | |
14 | 12 |
15 #if ((TARGET == 1) || (RIV_ENV== 1)) | 13 #if ((TARGET == 1) || (RIV_ENV== 1)) |
16 #include "ffs/board/task.h" | 14 #include "task.h" |
17 #endif | 15 #endif |
18 | 16 |
19 #if (TARGET == 0) | 17 #if (TARGET == 0) |
20 #include <stdlib.h> | 18 #include <stdlib.h> |
21 #endif | 19 #endif |
22 | 20 |
23 #include <string.h> | 21 #include <string.h> |
24 #include <limits.h> | 22 #include <limits.h> |
25 | 23 |
26 #include "ffs/ffs.h" | 24 #include "core.h" |
27 #include "ffs/board/core.h" | 25 #include "ffstrace.h" |
28 #include "ffs/board/ffstrace.h" | |
29 | 26 |
30 /****************************************************************************** | 27 /****************************************************************************** |
31 * | 28 * |
32 ******************************************************************************/ | 29 ******************************************************************************/ |
33 | 30 |
93 } | 90 } |
94 | 91 |
95 else { | 92 else { |
96 // Object found, continue like fupdate() | 93 // Object found, continue like fupdate() |
97 if (is_open_option(option, (FFS_O_CREATE)) | 94 if (is_open_option(option, (FFS_O_CREATE)) |
98 && is_open_option(option, (FFS_O_EXCL))) | 95 && is_open_option(option, (FFS_O_EXCL))) |
99 return EFFS_EXISTS; | 96 return EFFS_EXISTS; |
100 | 97 |
101 if (get_fdi(i) >= 0) | 98 if (get_fdi(i) >= 0) |
102 return EFFS_LOCKED; | 99 return EFFS_LOCKED; |
103 | 100 |
141 | 138 |
142 while (size_remaining > 0) { | 139 while (size_remaining > 0) { |
143 | 140 |
144 chunk_size = (size_remaining > fs.chunk_size_max ? | 141 chunk_size = (size_remaining > fs.chunk_size_max ? |
145 fs.chunk_size_max : size_remaining); | 142 fs.chunk_size_max : size_remaining); |
146 | 143 |
147 journal_begin(0); | 144 journal_begin(0); |
148 | 145 |
149 if ((i = segment_create((char*) src + size - size_remaining, | 146 if ((i = segment_create((char*) src + size - size_remaining, |
150 chunk_size, fs.i_backup)) < 0) | 147 chunk_size, fs.i_backup)) < 0) |
151 return i; | 148 return i; |
277 effs_t ffs_stat(const char *name, struct stat_s *stat) | 274 effs_t ffs_stat(const char *name, struct stat_s *stat) |
278 { | 275 { |
279 iref_t i; | 276 iref_t i; |
280 | 277 |
281 tw(tr(TR_FUNC, TrApi, "ffs_stat('%s', ?) ?\n", name)); | 278 tw(tr(TR_FUNC, TrApi, "ffs_stat('%s', ?) ?\n", name)); |
282 ttw(ttr(TTrApi, "ffs_stat('%s', ?) ?" NL, name)); | 279 ttw(ttr(TTrApi, "ffs_stat('%s', ?) ?" NL, name)); |
283 | 280 |
284 if (name == NULL) | 281 if (name == NULL) |
285 return EFFS_BADNAME; | 282 return EFFS_BADNAME; |
286 | 283 |
287 if ((i = ffs_begin()) == EFFS_OK) | 284 if ((i = ffs_begin()) == EFFS_OK) |
296 effs_t ffs_lstat(const char *name, struct stat_s *stat) | 293 effs_t ffs_lstat(const char *name, struct stat_s *stat) |
297 { | 294 { |
298 iref_t i; | 295 iref_t i; |
299 | 296 |
300 tw(tr(TR_FUNC, TrApi, "ffs_lstat('%s', ?) ?\n", name)); | 297 tw(tr(TR_FUNC, TrApi, "ffs_lstat('%s', ?) ?\n", name)); |
301 ttw(ttr(TTrApi, "ffs_lstat('%s', ?) ?" NL, name)); | 298 ttw(ttr(TTrApi, "ffs_lstat('%s', ?) ?" NL, name)); |
302 | 299 |
303 if ((i = ffs_begin()) == EFFS_OK) { | 300 if ((i = ffs_begin()) == EFFS_OK) { |
304 if ((i = object_stat(name, (struct xstat_s*)stat, 1, 0, 0)) > 0) | 301 if ((i = object_stat(name, (struct xstat_s*)stat, 1, 0, 0)) > 0) |
305 i = EFFS_OK; | 302 i = EFFS_OK; |
306 } | 303 } |
311 effs_t ffs_xlstat(const char *name, struct xstat_s *stat) | 308 effs_t ffs_xlstat(const char *name, struct xstat_s *stat) |
312 { | 309 { |
313 iref_t i; | 310 iref_t i; |
314 | 311 |
315 tw(tr(TR_FUNC, TrApi, "ffs_xlstat('%s', ?) ?\n", name)); | 312 tw(tr(TR_FUNC, TrApi, "ffs_xlstat('%s', ?) ?\n", name)); |
316 ttw(ttr(TTrApi, "ffs_xlstat('%s', ?) ?" NL, name)); | 313 ttw(ttr(TTrApi, "ffs_xlstat('%s', ?) ?" NL, name)); |
317 | 314 |
318 if ((i = ffs_begin()) == EFFS_OK) { | 315 if ((i = ffs_begin()) == EFFS_OK) { |
319 if ((i = object_stat(name, stat, 1, 0, 1)) > 0) | 316 if ((i = object_stat(name, stat, 1, 0, 1)) > 0) |
320 i = EFFS_OK; | 317 i = EFFS_OK; |
321 } | 318 } |
326 effs_t ffs_fstat(fd_t fdi, struct stat_s *stat) | 323 effs_t ffs_fstat(fd_t fdi, struct stat_s *stat) |
327 { | 324 { |
328 iref_t i; | 325 iref_t i; |
329 | 326 |
330 tw(tr(TR_FUNC, TrApi, "ffs_fstat('%d', ?) ?\n", fdi)); | 327 tw(tr(TR_FUNC, TrApi, "ffs_fstat('%d', ?) ?\n", fdi)); |
331 ttw(ttr(TTrApi, "ffs_fstat('%d', ?) ?" NL, fdi)); | 328 ttw(ttr(TTrApi, "ffs_fstat('%d', ?) ?" NL, fdi)); |
332 | 329 |
333 if ((i = ffs_begin()) == EFFS_OK) { | 330 if ((i = ffs_begin()) == EFFS_OK) { |
334 if ((i = object_stat( 0, (struct xstat_s*) stat, 0, fdi, 0)) > 0) | 331 if ((i = object_stat( 0, (struct xstat_s*) stat, 0, fdi, 0)) > 0) |
335 i = EFFS_OK; | 332 i = EFFS_OK; |
336 } | 333 } |
344 iref_t i, dir; | 341 iref_t i, dir; |
345 char *name; | 342 char *name; |
346 int size; | 343 int size; |
347 | 344 |
348 tw(tr(TR_FUNC, TrApi, "ffs_symlink('%s', '%s') ?\n", pathname, src)); | 345 tw(tr(TR_FUNC, TrApi, "ffs_symlink('%s', '%s') ?\n", pathname, src)); |
349 ttw(ttr(TTrApi, "ffs_symlink('%s', '%s') ?" NL, pathname, src)); | 346 ttw(ttr(TTrApi, "ffs_symlink('%s', '%s') ?" NL, pathname, src)); |
350 | 347 |
351 // TASKBEGIN effs_t SYMLINK(path=pathname, src=src) iref_t i, dir; int size; char *name; | 348 // TASKBEGIN effs_t SYMLINK(path=pathname, src=src) iref_t i, dir; int size; char *name; |
352 | 349 |
353 if (fs.initerror) | 350 if (fs.initerror) |
354 return fs.initerror; | 351 return fs.initerror; |
412 struct ffs_blocking_s *fb) | 409 struct ffs_blocking_s *fb) |
413 { | 410 { |
414 iref_t i; | 411 iref_t i; |
415 | 412 |
416 tw(tr(TR_FUNC, TrApi, "ffs_remove('%s')\n", pathname)); | 413 tw(tr(TR_FUNC, TrApi, "ffs_remove('%s')\n", pathname)); |
417 ttw(ttr(TTrApi, "ffs_remove('%s') ?" NL, pathname)); | 414 ttw(ttr(TTrApi, "ffs_remove('%s') ?" NL, pathname)); |
418 | 415 |
419 // TASKBEGIN effs_t REMOVE(path=pathname) iref_t i; | 416 // TASKBEGIN effs_t REMOVE(path=pathname) iref_t i; |
420 | 417 |
421 if (fs.initerror) | 418 if (fs.initerror) |
422 return fs.initerror; | 419 return fs.initerror; |
461 { | 458 { |
462 iref_t i; | 459 iref_t i; |
463 | 460 |
464 tw(tr(TR_FUNC, TrApi, "ffs_fcontrol('%s', %d, 0x%x) ?\n", | 461 tw(tr(TR_FUNC, TrApi, "ffs_fcontrol('%s', %d, 0x%x) ?\n", |
465 pathname, action, param)); | 462 pathname, action, param)); |
466 ttw(ttr(TTrApi, "ffs_fcontrol('%s', %d, 0x%x) ?" NL, | 463 ttw(ttr(TTrApi, "ffs_fcontrol('%s', %d, 0x%x) ?" NL, |
467 pathname, action, param)); | 464 pathname, action, param)); |
468 | 465 |
469 // TASKBEGIN effs_t FCONTROL(path=pathname, value16=action, size=param) iref_t i; | 466 // TASKBEGIN effs_t FCONTROL(path=pathname, value16=action, size=param) iref_t i; |
470 | 467 |
471 if (fs.initerror) | 468 if (fs.initerror) |
472 return fs.initerror; | 469 return fs.initerror; |
516 iref_t i, oldi, dir; | 513 iref_t i, oldi, dir; |
517 char *name; | 514 char *name; |
518 struct inode_s *ip; | 515 struct inode_s *ip; |
519 | 516 |
520 tw(tr(TR_FUNC, TrApi, "ffs_rename('%s', '%s') ?\n", pathname, newname)); | 517 tw(tr(TR_FUNC, TrApi, "ffs_rename('%s', '%s') ?\n", pathname, newname)); |
521 ttw(ttr(TTrApi, "ffs_rename('%s', '%s') ?" NL, pathname, newname)); | 518 ttw(ttr(TTrApi, "ffs_rename('%s', '%s') ?" NL, pathname, newname)); |
522 | 519 |
523 // TASKBEGIN effs_t RENAME(path=pathname, src=newname) iref_t i, oldi, dir; char *name; struct inode_s *ip; | 520 // TASKBEGIN effs_t RENAME(path=pathname, src=newname) iref_t i, oldi, dir; char *name; struct inode_s *ip; |
524 | 521 |
525 if (fs.initerror) | 522 if (fs.initerror) |
526 return fs.initerror; | 523 return fs.initerror; |
598 { | 595 { |
599 iref_t i, dir; | 596 iref_t i, dir; |
600 char *name; | 597 char *name; |
601 | 598 |
602 tw(tr(TR_FUNC, TrApi, "ffs_mkdir('%s')\n", pathname)); | 599 tw(tr(TR_FUNC, TrApi, "ffs_mkdir('%s')\n", pathname)); |
603 ttw(ttr(TTrApi, "ffs_mkdir('%s') ?" NL, pathname)); | 600 ttw(ttr(TTrApi, "ffs_mkdir('%s') ?" NL, pathname)); |
604 | 601 |
605 // TASKBEGIN effs_t MKDIR(path=pathname) iref_t i, dir; char *name; | 602 // TASKBEGIN effs_t MKDIR(path=pathname) iref_t i, dir; char *name; |
606 | 603 |
607 if (fs.initerror) | 604 if (fs.initerror) |
608 return fs.initerror; | 605 return fs.initerror; |
609 | 606 |
646 int ffs_opendir(const char *name, struct dir_s *dir) | 643 int ffs_opendir(const char *name, struct dir_s *dir) |
647 { | 644 { |
648 int i; | 645 int i; |
649 | 646 |
650 tw(tr(TR_FUNC, TrApi, "ffs_opendir('%s', ?)\n", name)); | 647 tw(tr(TR_FUNC, TrApi, "ffs_opendir('%s', ?)\n", name)); |
651 ttw(ttr(TTrApi, "ffs_opendir('%s', ?) ?" NL, name)); | 648 ttw(ttr(TTrApi, "ffs_opendir('%s', ?) ?" NL, name)); |
652 | 649 |
653 if (dir == NULL) | 650 if (dir == NULL) |
654 return EFFS_INVALID; | 651 return EFFS_INVALID; |
655 | 652 |
656 if ((i = ffs_begin()) == EFFS_OK) | 653 if ((i = ffs_begin()) == EFFS_OK) |
670 int ffs_readdir(struct dir_s *dir, char *name, int size) | 667 int ffs_readdir(struct dir_s *dir, char *name, int size) |
671 { | 668 { |
672 iref_t i; | 669 iref_t i; |
673 | 670 |
674 tw(tr(TR_BEGIN, TrApi, "ffs_readdir(?, ?, ?) {\n")); | 671 tw(tr(TR_BEGIN, TrApi, "ffs_readdir(?, ?, ?) {\n")); |
675 ttw(ttr(TTrApi, "ffs_readdir(?, ?, ?) ?" NL)); | 672 ttw(ttr(TTrApi, "ffs_readdir(?, ?, ?) ?" NL)); |
676 | 673 |
677 if (dir == NULL || name == NULL || size < 0) { | 674 if (dir == NULL || name == NULL || size < 0) { |
678 tw(tr(TR_END, TrApi, "} %d\n", EFFS_INVALID)); | 675 tw(tr(TR_END, TrApi, "} %d\n", EFFS_INVALID)); |
679 return EFFS_INVALID; | 676 return EFFS_INVALID; |
680 } | 677 } |
698 // EFFS_NOFORMAT! | 695 // EFFS_NOFORMAT! |
699 req_id_t ffs_format_b(const char *name, uint16 magic, T_RV_RETURN *cp, | 696 req_id_t ffs_format_b(const char *name, uint16 magic, T_RV_RETURN *cp, |
700 struct ffs_blocking_s *fb) | 697 struct ffs_blocking_s *fb) |
701 { | 698 { |
702 effs_t i; | 699 effs_t i; |
703 | 700 |
704 tw(tr(TR_BEGIN, TrApi, "ffs_format('%s', 0x%x) {\n", name, magic)); | 701 tw(tr(TR_BEGIN, TrApi, "ffs_format('%s', 0x%x) {\n", name, magic)); |
705 ttw(ttr(TTrApi, "ffs_format('%s', 0x%x) ?" NL, name, magic)); | 702 ttw(ttr(TTrApi, "ffs_format('%s', 0x%x) ?" NL, name, magic)); |
706 | 703 |
707 // TASKBEGIN effs_t FORMAT(path=name, size=magic) iref_t i; | 704 // TASKBEGIN effs_t FORMAT(path=name, size=magic) iref_t i; |
708 | 705 |
709 if (magic != 0x2BAD) { | 706 if (magic != 0x2BAD) { |
710 tw(tr(TR_END, TrApi, "} %d\n", EFFS_INVALID)); | 707 tw(tr(TR_END, TrApi, "} %d\n", EFFS_INVALID)); |
711 return EFFS_INVALID; | 708 return EFFS_INVALID; |
712 } | 709 } |
713 | 710 |
714 if (name == NULL) { | 711 if (name == NULL) { |
715 name = "/ffs-5.54"; | 712 name = "/ffs-5.54"; |
716 } | 713 } |
717 | 714 |
718 if (*name != '/') { | 715 if (*name != '/') { |
719 tw(tr(TR_END, TrApi, "} %d\n", EFFS_BADNAME)); | 716 tw(tr(TR_END, TrApi, "} %d\n", EFFS_BADNAME)); |
720 return EFFS_BADNAME; | 717 return EFFS_BADNAME; |
721 } | 718 } |
757 struct ffs_blocking_s *fb) | 754 struct ffs_blocking_s *fb) |
758 { | 755 { |
759 effs_t i; | 756 effs_t i; |
760 | 757 |
761 tw(tr(TR_BEGIN, TrApi, "ffs_preformat(0x%x) {\n", magic)); | 758 tw(tr(TR_BEGIN, TrApi, "ffs_preformat(0x%x) {\n", magic)); |
762 ttw(ttr(TTrApi, "ffs_preformat(0x%x) ?" NL, magic)); | 759 ttw(ttr(TTrApi, "ffs_preformat(0x%x) ?" NL, magic)); |
763 | 760 |
764 // TASKBEGIN effs_t PREFORMAT(path="/", size=magic) effs_t i; | 761 // TASKBEGIN effs_t PREFORMAT(path="/", size=magic) effs_t i; |
765 | 762 |
766 if (magic != 0xDEAD) { | 763 if (magic != 0xDEAD) { |
767 tw(tr(TR_END, TrApi, "} %d\n", EFFS_INVALID)); | 764 tw(tr(TR_END, TrApi, "} %d\n", EFFS_INVALID)); |
817 fd_t other_fdi, fdi = 0; | 814 fd_t other_fdi, fdi = 0; |
818 int error; | 815 int error; |
819 struct inode_s *ip; | 816 struct inode_s *ip; |
820 | 817 |
821 tw(tr(TR_FUNC, TrApi, "ffs_open('%s', 0x%x) ?\n", pathname, option)); | 818 tw(tr(TR_FUNC, TrApi, "ffs_open('%s', 0x%x) ?\n", pathname, option)); |
822 ttw(ttr(TTrApi, "ffs_open('%s', 0x%x) ?" NL, pathname, option)); | 819 ttw(ttr(TTrApi, "ffs_open('%s', 0x%x) ?" NL, pathname, option)); |
823 | 820 |
824 // TASKBEGIN fd_t OPEN(path=pathname, value16=option) iref_t i, dir, dummy; char *name; fd_t other_fdi, fdi = 0; int error; struct inode_s *ip; | 821 // TASKBEGIN fd_t OPEN(path=pathname, value16=option) iref_t i, dir, dummy; char *name; fd_t other_fdi, fdi = 0; int error; struct inode_s *ip; |
825 | 822 |
826 if (fs.initerror) | 823 if (fs.initerror) |
827 return fs.initerror; | 824 return fs.initerror; |
852 return i; | 849 return i; |
853 | 850 |
854 // Open one file several times in RD is okay but only one time in WR | 851 // Open one file several times in RD is okay but only one time in WR |
855 if (i != EFFS_NOTFOUND && (other_fdi = get_fdi(i)) >= 0) { | 852 if (i != EFFS_NOTFOUND && (other_fdi = get_fdi(i)) >= 0) { |
856 if (is_open_option(fs.fd[other_fdi].options, FFS_O_WRONLY) || | 853 if (is_open_option(fs.fd[other_fdi].options, FFS_O_WRONLY) || |
857 is_open_option(option, FFS_O_WRONLY)) | 854 is_open_option(option, FFS_O_WRONLY)) |
858 return EFFS_LOCKED; | 855 return EFFS_LOCKED; |
859 } | 856 } |
860 | 857 |
861 // Init default values | 858 // Init default values |
862 fs.fd[fdi].fp = fs.fd[fdi].size = fs.fd[fdi].wfp = fs.fd[fdi].dirty = 0; | 859 fs.fd[fdi].fp = fs.fd[fdi].size = fs.fd[fdi].wfp = fs.fd[fdi].dirty = 0; |
905 | 902 |
906 // Do not link child | 903 // Do not link child |
907 fs.link_child = 0; | 904 fs.link_child = 0; |
908 journal_end(0); | 905 journal_end(0); |
909 | 906 |
910 // If any further segments exist then remove them now | 907 // If any further segments exist then remove them now |
911 if (fs.i_backup > 0) | 908 if (fs.i_backup > 0) |
912 if ((error = object_remove(fs.i_backup)) < 0) | 909 if ((error = object_remove(fs.i_backup)) < 0) |
913 return error; | 910 return error; |
914 | 911 |
915 tw(tr_bstat()); | 912 tw(tr_bstat()); |
934 return EFFS_MEMORY; | 931 return EFFS_MEMORY; |
935 #endif | 932 #endif |
936 } | 933 } |
937 | 934 |
938 // Save data in file descriptor | 935 // Save data in file descriptor |
939 fs.fd[fdi].seghead = i; | 936 fs.fd[fdi].seghead = i; |
940 fs.fd[fdi].options = option; | 937 fs.fd[fdi].options = option; |
941 | 938 |
942 return fdi + FFS_FD_OFFSET; | 939 return fdi + FFS_FD_OFFSET; |
943 | 940 |
944 // TASKEND | 941 // TASKEND |
945 } | 942 } |
946 | 943 |
965 req_id_t ffs_close_b(fd_t fdi, T_RV_RETURN *cp, struct ffs_blocking_s *fb) | 962 req_id_t ffs_close_b(fd_t fdi, T_RV_RETURN *cp, struct ffs_blocking_s *fb) |
966 { | 963 { |
967 int error; | 964 int error; |
968 | 965 |
969 tw(tr(TR_FUNC, TrApi, "ffs_close(%d) ?\n", fdi)); | 966 tw(tr(TR_FUNC, TrApi, "ffs_close(%d) ?\n", fdi)); |
970 ttw(ttr(TTrApi, "ffs_close(%d) ?" NL, fdi)); | 967 ttw(ttr(TTrApi, "ffs_close(%d) ?" NL, fdi)); |
971 | 968 |
972 // TASKBEGIN effs_t CLOSE(fdi=fdi) iref_t i; int error; | 969 // TASKBEGIN effs_t CLOSE(fdi=fdi) iref_t i; int error; |
973 | 970 |
974 if (fs.initerror) | 971 if (fs.initerror) |
975 return fs.initerror; | 972 return fs.initerror; |
1053 if (fs.fd[fdi].fp >= (fs.fd[fdi].wfp + fs.chunk_size_max)) { | 1050 if (fs.fd[fdi].fp >= (fs.fd[fdi].wfp + fs.chunk_size_max)) { |
1054 if ((error = datasync(fdi)) < 0) | 1051 if ((error = datasync(fdi)) < 0) |
1055 return error; | 1052 return error; |
1056 } | 1053 } |
1057 | 1054 |
1058 size_done = 0; | 1055 size_done = 0; |
1059 size_remaining = amount; | 1056 size_remaining = amount; |
1060 | 1057 |
1061 do { | 1058 do { |
1062 if (!fs.fd[fdi].dirty ) { | 1059 if (!fs.fd[fdi].dirty ) { |
1063 // Buffer is not dirty so find the chunk that fp points to. | 1060 // Buffer is not dirty so find the chunk that fp points to. |
1064 segfile_seek(fs.fd[fdi].seghead, fs.fd[fdi].fp, &i, | 1061 segfile_seek(fs.fd[fdi].seghead, fs.fd[fdi].fp, &i, |
1065 &chunk_offset); | 1062 &chunk_offset); |
1076 fs.fd[fdi].wfp = fs.fd[fdi].fp - chunk_offset; | 1073 fs.fd[fdi].wfp = fs.fd[fdi].fp - chunk_offset; |
1077 fs.fd[fdi].wch = i; | 1074 fs.fd[fdi].wch = i; |
1078 } | 1075 } |
1079 } | 1076 } |
1080 | 1077 |
1081 fs.fd[fdi].dirty = 1; | 1078 fs.fd[fdi].dirty = 1; |
1082 fp_offset = fs.fd[fdi].fp - fs.fd[fdi].wfp; | 1079 fp_offset = fs.fd[fdi].fp - fs.fd[fdi].wfp; |
1083 | 1080 |
1084 // Fill the buffer to max or just add the rest | 1081 // Fill the buffer to max or just add the rest |
1085 size = fs.chunk_size_max - fp_offset; | 1082 size = fs.chunk_size_max - fp_offset; |
1086 | 1083 |
1087 if (size_remaining <= fs.chunk_size_max - fp_offset) | 1084 if (size_remaining <= fs.chunk_size_max - fp_offset) |
1088 size = size_remaining; | 1085 size = size_remaining; |
1089 | 1086 |
1090 tw(tr(TR_FUNC, TrApi, "Copy data to buffer (size: %d)\n", size)); | 1087 tw(tr(TR_FUNC, TrApi, "Copy data to buffer (size: %d)\n", size)); |
1091 | 1088 |
1092 memcpy(fs.fd[fdi].buf + fp_offset, (uint8*)src + size_done, | 1089 memcpy(fs.fd[fdi].buf + fp_offset, (uint8*)src + size_done, |
1093 size); | 1090 size); |
1094 | 1091 |
1095 fs.fd[fdi].fp += size; | 1092 fs.fd[fdi].fp += size; |
1150 // The seek function will not allow the file offset to be set beyond the end | 1147 // The seek function will not allow the file offset to be set beyond the end |
1151 // of the existing data in the file or the final offset to be negative. | 1148 // of the existing data in the file or the final offset to be negative. |
1152 req_id_t ffs_seek_b(fd_t fdi, int offset, int whence, T_RV_RETURN *cp, | 1149 req_id_t ffs_seek_b(fd_t fdi, int offset, int whence, T_RV_RETURN *cp, |
1153 struct ffs_blocking_s *fb) | 1150 struct ffs_blocking_s *fb) |
1154 { | 1151 { |
1155 effs_t error; | 1152 effs_t error; |
1156 int fp_new; | 1153 int fp_new; |
1157 | 1154 |
1158 tw(tr(TR_FUNC, TrApi, "ffs_seek(%d, %d, %d) ?\n", fdi, offset, whence)); | 1155 tw(tr(TR_FUNC, TrApi, "ffs_seek(%d, %d, %d) ?\n", fdi, offset, whence)); |
1159 ttw(ttr(TTrApi, "ffs_seek(%d, %d, %d) ?" NL, fdi, offset, whence)); | 1156 ttw(ttr(TTrApi, "ffs_seek(%d, %d, %d) ?" NL, fdi, offset, whence)); |
1160 | 1157 |
1309 | 1306 |
1310 req_id_t ffs_fdatasync_nb(fd_t fdi, T_RV_RETURN *cp) | 1307 req_id_t ffs_fdatasync_nb(fd_t fdi, T_RV_RETURN *cp) |
1311 { | 1308 { |
1312 return ffs_fdatasync_b(fdi, cp, 0); | 1309 return ffs_fdatasync_b(fdi, cp, 0); |
1313 } | 1310 } |
1314 |