Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

file/fat: rework utime function as modtime extension

This eliminates the dependence on a special struct since we were only
using the modtime anyway. But it no longer fits any known standard APIs
so I have converted it to our own extension instead. This can still be
adapted to existing hosted APIs if the need arises.

Change-Id: Ic8800698ddfd3a1a48b7cf921c0d0f865302d034

+16 -28
+8 -11
firmware/common/file.c
··· 1123 1123 return rc; 1124 1124 } 1125 1125 1126 - int utime(const char *path, const struct utimbuf* times) 1126 + /** Extensions **/ 1127 + 1128 + int modtime(const char *path, time_t modtime) 1127 1129 { 1128 - DEBUGF("utime(path=\"%s\",times->modtime=%u)\n", path, times->modtime); 1130 + DEBUGF("modtime(path=\"%s\",modtime=%d)\n", path, (int) modtime); 1129 1131 1130 1132 int rc, open1rc = -1; 1131 1133 struct filestr_base pathstr; ··· 1133 1135 1134 1136 file_internal_lock_WRITER(); 1135 1137 1136 - if (!times) 1137 - FILE_ERROR(EINVAL, -1); 1138 - 1139 1138 open1rc = open_stream_internal(path, FF_ANYTYPE | FF_PARENTINFO, 1140 1139 &pathstr, &pathinfo); 1141 1140 if (open1rc <= 0) 1142 1141 { 1143 1142 DEBUGF("Failed opening path: %d\n", open1rc); 1144 1143 if (open1rc == 0) 1145 - FILE_ERROR(ENOENT, -2); 1144 + FILE_ERROR(ENOENT, -1); 1146 1145 else 1147 1146 FILE_ERROR(ERRNO, open1rc * 10 - 1); 1148 1147 } 1149 1148 1150 - rc = fat_utime(&pathinfo.parentinfo.fatfile, pathstr.fatstr.fatfilep, 1151 - times); 1149 + rc = fat_modtime(&pathinfo.parentinfo.fatfile, pathstr.fatstr.fatfilep, 1150 + modtime); 1152 1151 if (rc < 0) 1153 1152 { 1154 - DEBUGF("I/O error during utime: %d\n", rc); 1153 + DEBUGF("I/O error during modtime: %d\n", rc); 1155 1154 FILE_ERROR(ERRNO, rc * 10 - 2); 1156 1155 } 1157 1156 ··· 1161 1160 file_internal_unlock_WRITER(); 1162 1161 return rc; 1163 1162 } 1164 - 1165 - /** Extensions **/ 1166 1163 1167 1164 /* get the binary size of a file (in bytes) */ 1168 1165 off_t filesize(int fildes)
+3 -3
firmware/drivers/fat.c
··· 2276 2276 return rc; 2277 2277 } 2278 2278 2279 - int fat_utime(struct fat_file *parent, struct fat_file *file, 2280 - const struct utimbuf *times) 2279 + int fat_modtime(struct fat_file *parent, struct fat_file *file, 2280 + time_t modtime) 2281 2281 { 2282 2282 struct bpb * const fat_bpb = FAT_BPB(parent->volume); 2283 2283 ··· 2297 2297 2298 2298 uint16_t date; 2299 2299 uint16_t time; 2300 - dostime_localtime(times->modtime, &date, &time); 2300 + dostime_localtime(modtime, &date, &time); 2301 2301 2302 2302 ent->wrttime = htole16(time); 2303 2303 ent->wrtdate = htole16(date);
+2 -5
firmware/export/fat.h
··· 23 23 24 24 #include <stdbool.h> 25 25 #include <sys/types.h> 26 - #if defined(__PCTOOL__) || defined(SIMULATOR) || ((CONFIG_PLATFORM & PLATFORM_HOSTED) == PLATFORM_HOSTED) 27 - #include <utime.h> 28 - #endif 29 26 #include <time.h> 30 27 #include "config.h" 31 28 #include "system.h" ··· 143 140 int fat_remove(struct fat_file *file, enum fat_remove_op what); 144 141 int fat_rename(struct fat_file *parent, struct fat_file *file, 145 142 const unsigned char *newname); 146 - int fat_utime(struct fat_file *parent, struct fat_file *file, 147 - const struct utimbuf *utimes); 143 + int fat_modtime(struct fat_file *parent, struct fat_file *file, 144 + time_t modtime); 148 145 149 146 /** File stream functions **/ 150 147 int fat_closewrite(struct fat_filestr *filestr, uint32_t size,
+2 -2
firmware/include/file.h
··· 85 85 #ifndef rename 86 86 #define rename FS_PREFIX(rename) 87 87 #endif 88 - #ifndef utime 89 - #define utime FS_PREFIX(utime) 88 + #ifndef modtime 89 + #define modtime FS_PREFIX(modtime) 90 90 #endif 91 91 #ifndef filesize 92 92 #define filesize FS_PREFIX(filesize)
+1 -1
firmware/include/filesystem-native.h
··· 55 55 ssize_t write(int fildes, const void *buf, size_t nbyte); 56 56 int remove(const char *path); 57 57 int rename(const char *old, const char *new); 58 - int utime(const char *path, const struct utimbuf* times); 58 + int modtime(const char *path, time_t modtime); 59 59 off_t filesize(int fildes); 60 60 int fsamefile(int fildes1, int fildes2); 61 61 int relate(const char *path1, const char *path2);
-6
firmware/libc/include/time.h
··· 28 28 #if !defined(_TIME_T_DEFINED) && !defined(_TIME_T_DECLARED) 29 29 typedef long time_t; 30 30 31 - struct utimbuf 32 - { 33 - time_t actime; 34 - time_t modtime; 35 - }; 36 - 37 31 /* this define below is used by the mingw headers to prevent duplicate 38 32 typedefs */ 39 33 #define _TIME_T_DEFINED