diff options
Diffstat (limited to 'firmware/common/file.c')
-rw-r--r-- | firmware/common/file.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index a204cf71cc..202410db81 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c | |||
@@ -31,6 +31,15 @@ | |||
31 | #include "rb_namespace.h" | 31 | #include "rb_namespace.h" |
32 | #include "string-extra.h" | 32 | #include "string-extra.h" |
33 | 33 | ||
34 | /* Define LOGF_ENABLE to enable logf output in this file */ | ||
35 | //#define LOGF_ENABLE | ||
36 | #ifdef LOGF_ENABLE | ||
37 | #include "logf.h" | ||
38 | #undef DEBUGF | ||
39 | #define DEBUGF logf | ||
40 | #endif | ||
41 | |||
42 | |||
34 | /** | 43 | /** |
35 | * These functions provide a roughly POSIX-compatible file I/O API. | 44 | * These functions provide a roughly POSIX-compatible file I/O API. |
36 | */ | 45 | */ |
@@ -600,8 +609,10 @@ static inline ssize_t readwrite_partial(struct filestr_desc *file, | |||
600 | static ssize_t readwrite(struct filestr_desc *file, void *buf, size_t nbyte, | 609 | static ssize_t readwrite(struct filestr_desc *file, void *buf, size_t nbyte, |
601 | bool write) | 610 | bool write) |
602 | { | 611 | { |
612 | #ifndef LOGF_ENABLE /* wipes out log before you can save it */ | ||
603 | DEBUGF("readwrite(%p,%lx,%lu,%s)\n", | 613 | DEBUGF("readwrite(%p,%lx,%lu,%s)\n", |
604 | file, (long)buf, (unsigned long)nbyte, write ? "write" : "read"); | 614 | file, (long)buf, (unsigned long)nbyte, write ? "write" : "read"); |
615 | #endif | ||
605 | 616 | ||
606 | const file_size_t size = *file->sizep; | 617 | const file_size_t size = *file->sizep; |
607 | file_size_t filerem; | 618 | file_size_t filerem; |
@@ -766,8 +777,9 @@ file_error:; | |||
766 | /* error or not, update the file offset and size if anything was | 777 | /* error or not, update the file offset and size if anything was |
767 | transferred */ | 778 | transferred */ |
768 | file->offset += done; | 779 | file->offset += done; |
780 | #ifndef LOGF_ENABLE /* wipes out log before you can save it */ | ||
769 | DEBUGF("file offset: %ld\n", file->offset); | 781 | DEBUGF("file offset: %ld\n", file->offset); |
770 | 782 | #endif | |
771 | /* adjust file size to length written */ | 783 | /* adjust file size to length written */ |
772 | if (write && file->offset > size) | 784 | if (write && file->offset > size) |
773 | *file->sizep = file->offset; | 785 | *file->sizep = file->offset; |
@@ -901,8 +913,9 @@ file_error: | |||
901 | /* move the read/write file offset */ | 913 | /* move the read/write file offset */ |
902 | off_t lseek(int fildes, off_t offset, int whence) | 914 | off_t lseek(int fildes, off_t offset, int whence) |
903 | { | 915 | { |
916 | #ifndef LOGF_ENABLE /* wipes out log before you can save it */ | ||
904 | DEBUGF("lseek(fd=%d,ofs=%ld,wh=%d)\n", fildes, (long)offset, whence); | 917 | DEBUGF("lseek(fd=%d,ofs=%ld,wh=%d)\n", fildes, (long)offset, whence); |
905 | 918 | #endif | |
906 | struct filestr_desc * const file = GET_FILESTR(READER, fildes); | 919 | struct filestr_desc * const file = GET_FILESTR(READER, fildes); |
907 | if (!file) | 920 | if (!file) |
908 | FILE_ERROR_RETURN(ERRNO, -1); | 921 | FILE_ERROR_RETURN(ERRNO, -1); |