summaryrefslogtreecommitdiff
path: root/firmware/common/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common/file.c')
-rw-r--r--firmware/common/file.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c
index 7d3b5092ae..6444918f1b 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -595,8 +595,8 @@ static inline ssize_t readwrite_partial(struct filestr_desc *file,
595static ssize_t readwrite(struct filestr_desc *file, void *buf, size_t nbyte, 595static ssize_t readwrite(struct filestr_desc *file, void *buf, size_t nbyte,
596 bool write) 596 bool write)
597{ 597{
598 DEBUGF("readwrite(%p,%lx,%ld,%s)\n", 598 DEBUGF("readwrite(%p,%lx,%lu,%s)\n",
599 file, (long)buf, nbyte, write ? "write" : "read"); 599 file, (long)buf, (unsigned long)nbyte, write ? "write" : "read");
600 600
601 const file_size_t size = *file->sizep; 601 const file_size_t size = *file->sizep;
602 file_size_t filerem; 602 file_size_t filerem;
@@ -705,8 +705,8 @@ static ssize_t readwrite(struct filestr_desc *file, void *buf, size_t nbyte,
705 rc = fat_readwrite(&file->stream.fatstr, runlen, buf, write); 705 rc = fat_readwrite(&file->stream.fatstr, runlen, buf, write);
706 if (rc < 0) 706 if (rc < 0)
707 { 707 {
708 DEBUGF("I/O error %sing %ld sectors\n", sectors, 708 DEBUGF("I/O error %sing %ld sectors\n",
709 write ? "writ" : "read"); 709 write ? "writ" : "read", runlen);
710 FILE_ERROR(rc == FAT_RC_ENOSPC ? ENOSPC : EIO, 710 FILE_ERROR(rc == FAT_RC_ENOSPC ? ENOSPC : EIO,
711 rc * 10 - 6); 711 rc * 10 - 6);
712 } 712 }
@@ -874,7 +874,7 @@ int fsync(int fildes)
874 874
875 if (!(file->stream.flags & FD_WRITE)) 875 if (!(file->stream.flags & FD_WRITE))
876 { 876 {
877 DEBUGF("Descriptor is read-only mode\n", fd); 877 DEBUGF("Descriptor is read-only mode\n");
878 FILE_ERROR(EINVAL, -2); 878 FILE_ERROR(EINVAL, -2);
879 } 879 }
880 880
@@ -917,7 +917,8 @@ ssize_t read(int fildes, void *buf, size_t nbyte)
917 if (file->stream.flags & FD_WRONLY) 917 if (file->stream.flags & FD_WRONLY)
918 { 918 {
919 DEBUGF("read(fd=%d,buf=%p,nb=%lu) - " 919 DEBUGF("read(fd=%d,buf=%p,nb=%lu) - "
920 "descriptor is write-only mode\n", fildes, buf, nbyte); 920 "descriptor is write-only mode\n",
921 fildes, buf, (unsigned long)nbyte);
921 FILE_ERROR(EBADF, -2); 922 FILE_ERROR(EBADF, -2);
922 } 923 }
923 924
@@ -942,7 +943,8 @@ ssize_t write(int fildes, const void *buf, size_t nbyte)
942 if (!(file->stream.flags & FD_WRITE)) 943 if (!(file->stream.flags & FD_WRITE))
943 { 944 {
944 DEBUGF("write(fd=%d,buf=%p,nb=%lu) - " 945 DEBUGF("write(fd=%d,buf=%p,nb=%lu) - "
945 "descriptor is read-only mode\n", fildes, buf, nbyte); 946 "descriptor is read-only mode\n",
947 fildes, buf, (unsigned long)nbyte);
946 FILE_ERROR(EBADF, -2); 948 FILE_ERROR(EBADF, -2);
947 } 949 }
948 950
@@ -981,7 +983,7 @@ int rename(const char *old, const char *new)
981 open1rc = open_stream_internal(old, FF_ANYTYPE, &oldstr, &oldinfo); 983 open1rc = open_stream_internal(old, FF_ANYTYPE, &oldstr, &oldinfo);
982 if (open1rc <= 0) 984 if (open1rc <= 0)
983 { 985 {
984 DEBUGF("Failed opening old: %d\n", rc); 986 DEBUGF("Failed opening old: %d\n", open1rc);
985 if (open1rc == 0) 987 if (open1rc == 0)
986 FILE_ERROR(ENOENT, -1); 988 FILE_ERROR(ENOENT, -1);
987 else 989 else
@@ -1006,7 +1008,7 @@ int rename(const char *old, const char *new)
1006 open2rc = open_stream_internal(new, callflags, &newstr, &newinfo); 1008 open2rc = open_stream_internal(new, callflags, &newstr, &newinfo);
1007 if (open2rc < 0) 1009 if (open2rc < 0)
1008 { 1010 {
1009 DEBUGF("Failed opening new file: %d\n", rc); 1011 DEBUGF("Failed opening new file: %d\n", open2rc);
1010 FILE_ERROR(ERRNO, open2rc * 10 - 2); 1012 FILE_ERROR(ERRNO, open2rc * 10 - 2);
1011 } 1013 }
1012 1014
@@ -1165,7 +1167,7 @@ int relate(const char *path1, const char *path2)
1165 open1rc = open_stream_internal(path1, FF_ANYTYPE, &str1, &info1); 1167 open1rc = open_stream_internal(path1, FF_ANYTYPE, &str1, &info1);
1166 if (open1rc <= 0) 1168 if (open1rc <= 0)
1167 { 1169 {
1168 DEBUGF("Failed opening path1: %d\n", rc); 1170 DEBUGF("Failed opening path1: %d\n", open1rc);
1169 if (open1rc < 0) 1171 if (open1rc < 0)
1170 FILE_ERROR(ERRNO, open1rc * 10 - 1); 1172 FILE_ERROR(ERRNO, open1rc * 10 - 1);
1171 else 1173 else
@@ -1177,7 +1179,7 @@ int relate(const char *path1, const char *path2)
1177 &str2, &info2); 1179 &str2, &info2);
1178 if (open2rc < 0) 1180 if (open2rc < 0)
1179 { 1181 {
1180 DEBUGF("Failed opening path2: %d\n", rc); 1182 DEBUGF("Failed opening path2: %d\n", open2rc);
1181 FILE_ERROR(ERRNO, open2rc * 10 - 2); 1183 FILE_ERROR(ERRNO, open2rc * 10 - 2);
1182 } 1184 }
1183 1185