summaryrefslogtreecommitdiff
path: root/firmware/common/file.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-03-15 00:45:00 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2022-03-15 00:45:00 -0400
commita5c16d2990ba951832f126f5aa9da0221c68f609 (patch)
treef72a33893925da892edb0463186d320794f1774b /firmware/common/file.c
parent20b9ce5497c6a02c520e879e6c39a72b2c858b48 (diff)
downloadrockbox-a5c16d2990ba951832f126f5aa9da0221c68f609.tar.gz
rockbox-a5c16d2990ba951832f126f5aa9da0221c68f609.zip
rb_namespace add logf
add logging to the namespace file to allow debug of root redirect Change-Id: I6032aea880998c05dacf3d0d2e0d222205b9376e
Diffstat (limited to 'firmware/common/file.c')
-rw-r--r--firmware/common/file.c17
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,
600static ssize_t readwrite(struct filestr_desc *file, void *buf, size_t nbyte, 609static 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 */
902off_t lseek(int fildes, off_t offset, int whence) 914off_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);