diff options
-rw-r--r-- | firmware/common/file.c | 19 | ||||
-rw-r--r-- | firmware/drivers/fat.c | 6 | ||||
-rw-r--r-- | firmware/export/fat.h | 7 | ||||
-rw-r--r-- | firmware/include/file.h | 4 | ||||
-rw-r--r-- | firmware/include/filesystem-native.h | 2 | ||||
-rw-r--r-- | firmware/libc/include/time.h | 6 |
6 files changed, 16 insertions, 28 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index c090c40be5..c048d182f4 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c | |||
@@ -1123,9 +1123,11 @@ file_error: | |||
1123 | return rc; | 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 | int rc, open1rc = -1; | 1132 | int rc, open1rc = -1; |
1131 | struct filestr_base pathstr; | 1133 | struct filestr_base pathstr; |
@@ -1133,25 +1135,22 @@ int utime(const char *path, const struct utimbuf* times) | |||
1133 | 1135 | ||
1134 | file_internal_lock_WRITER(); | 1136 | file_internal_lock_WRITER(); |
1135 | 1137 | ||
1136 | if (!times) | ||
1137 | FILE_ERROR(EINVAL, -1); | ||
1138 | |||
1139 | open1rc = open_stream_internal(path, FF_ANYTYPE | FF_PARENTINFO, | 1138 | open1rc = open_stream_internal(path, FF_ANYTYPE | FF_PARENTINFO, |
1140 | &pathstr, &pathinfo); | 1139 | &pathstr, &pathinfo); |
1141 | if (open1rc <= 0) | 1140 | if (open1rc <= 0) |
1142 | { | 1141 | { |
1143 | DEBUGF("Failed opening path: %d\n", open1rc); | 1142 | DEBUGF("Failed opening path: %d\n", open1rc); |
1144 | if (open1rc == 0) | 1143 | if (open1rc == 0) |
1145 | FILE_ERROR(ENOENT, -2); | 1144 | FILE_ERROR(ENOENT, -1); |
1146 | else | 1145 | else |
1147 | FILE_ERROR(ERRNO, open1rc * 10 - 1); | 1146 | FILE_ERROR(ERRNO, open1rc * 10 - 1); |
1148 | } | 1147 | } |
1149 | 1148 | ||
1150 | rc = fat_utime(&pathinfo.parentinfo.fatfile, pathstr.fatstr.fatfilep, | 1149 | rc = fat_modtime(&pathinfo.parentinfo.fatfile, pathstr.fatstr.fatfilep, |
1151 | times); | 1150 | modtime); |
1152 | if (rc < 0) | 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 | FILE_ERROR(ERRNO, rc * 10 - 2); | 1154 | FILE_ERROR(ERRNO, rc * 10 - 2); |
1156 | } | 1155 | } |
1157 | 1156 | ||
@@ -1162,8 +1161,6 @@ file_error: | |||
1162 | return rc; | 1161 | return rc; |
1163 | } | 1162 | } |
1164 | 1163 | ||
1165 | /** Extensions **/ | ||
1166 | |||
1167 | /* get the binary size of a file (in bytes) */ | 1164 | /* get the binary size of a file (in bytes) */ |
1168 | off_t filesize(int fildes) | 1165 | off_t filesize(int fildes) |
1169 | { | 1166 | { |
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 28d4eb1987..0c02c8224f 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -2276,8 +2276,8 @@ fat_error: | |||
2276 | return rc; | 2276 | return rc; |
2277 | } | 2277 | } |
2278 | 2278 | ||
2279 | int fat_utime(struct fat_file *parent, struct fat_file *file, | 2279 | int fat_modtime(struct fat_file *parent, struct fat_file *file, |
2280 | const struct utimbuf *times) | 2280 | time_t modtime) |
2281 | { | 2281 | { |
2282 | struct bpb * const fat_bpb = FAT_BPB(parent->volume); | 2282 | struct bpb * const fat_bpb = FAT_BPB(parent->volume); |
2283 | 2283 | ||
@@ -2297,7 +2297,7 @@ int fat_utime(struct fat_file *parent, struct fat_file *file, | |||
2297 | 2297 | ||
2298 | uint16_t date; | 2298 | uint16_t date; |
2299 | uint16_t time; | 2299 | uint16_t time; |
2300 | dostime_localtime(times->modtime, &date, &time); | 2300 | dostime_localtime(modtime, &date, &time); |
2301 | 2301 | ||
2302 | ent->wrttime = htole16(time); | 2302 | ent->wrttime = htole16(time); |
2303 | ent->wrtdate = htole16(date); | 2303 | ent->wrtdate = htole16(date); |
diff --git a/firmware/export/fat.h b/firmware/export/fat.h index f2aae4f5f0..70152985b5 100644 --- a/firmware/export/fat.h +++ b/firmware/export/fat.h | |||
@@ -23,9 +23,6 @@ | |||
23 | 23 | ||
24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
25 | #include <sys/types.h> | 25 | #include <sys/types.h> |
26 | #if defined(__PCTOOL__) || defined(SIMULATOR) || ((CONFIG_PLATFORM & PLATFORM_HOSTED) == PLATFORM_HOSTED) | ||
27 | #include <utime.h> | ||
28 | #endif | ||
29 | #include <time.h> | 26 | #include <time.h> |
30 | #include "config.h" | 27 | #include "config.h" |
31 | #include "system.h" | 28 | #include "system.h" |
@@ -143,8 +140,8 @@ enum fat_remove_op /* what should fat_remove(), remove? */ | |||
143 | int fat_remove(struct fat_file *file, enum fat_remove_op what); | 140 | int fat_remove(struct fat_file *file, enum fat_remove_op what); |
144 | int fat_rename(struct fat_file *parent, struct fat_file *file, | 141 | int fat_rename(struct fat_file *parent, struct fat_file *file, |
145 | const unsigned char *newname); | 142 | const unsigned char *newname); |
146 | int fat_utime(struct fat_file *parent, struct fat_file *file, | 143 | int fat_modtime(struct fat_file *parent, struct fat_file *file, |
147 | const struct utimbuf *utimes); | 144 | time_t modtime); |
148 | 145 | ||
149 | /** File stream functions **/ | 146 | /** File stream functions **/ |
150 | int fat_closewrite(struct fat_filestr *filestr, uint32_t size, | 147 | int fat_closewrite(struct fat_filestr *filestr, uint32_t size, |
diff --git a/firmware/include/file.h b/firmware/include/file.h index f17f14f98e..02d2077977 100644 --- a/firmware/include/file.h +++ b/firmware/include/file.h | |||
@@ -85,8 +85,8 @@ int fdprintf(int fildes, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3); | |||
85 | #ifndef rename | 85 | #ifndef rename |
86 | #define rename FS_PREFIX(rename) | 86 | #define rename FS_PREFIX(rename) |
87 | #endif | 87 | #endif |
88 | #ifndef utime | 88 | #ifndef modtime |
89 | #define utime FS_PREFIX(utime) | 89 | #define modtime FS_PREFIX(modtime) |
90 | #endif | 90 | #endif |
91 | #ifndef filesize | 91 | #ifndef filesize |
92 | #define filesize FS_PREFIX(filesize) | 92 | #define filesize FS_PREFIX(filesize) |
diff --git a/firmware/include/filesystem-native.h b/firmware/include/filesystem-native.h index 800e7bb23b..5bd61eea76 100644 --- a/firmware/include/filesystem-native.h +++ b/firmware/include/filesystem-native.h | |||
@@ -55,7 +55,7 @@ ssize_t read(int fildes, void *buf, size_t nbyte); | |||
55 | ssize_t write(int fildes, const void *buf, size_t nbyte); | 55 | ssize_t write(int fildes, const void *buf, size_t nbyte); |
56 | int remove(const char *path); | 56 | int remove(const char *path); |
57 | int rename(const char *old, const char *new); | 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 | off_t filesize(int fildes); | 59 | off_t filesize(int fildes); |
60 | int fsamefile(int fildes1, int fildes2); | 60 | int fsamefile(int fildes1, int fildes2); |
61 | int relate(const char *path1, const char *path2); | 61 | int relate(const char *path1, const char *path2); |
diff --git a/firmware/libc/include/time.h b/firmware/libc/include/time.h index 217b454321..4796b8b083 100644 --- a/firmware/libc/include/time.h +++ b/firmware/libc/include/time.h | |||
@@ -28,12 +28,6 @@ struct tm | |||
28 | #if !defined(_TIME_T_DEFINED) && !defined(_TIME_T_DECLARED) | 28 | #if !defined(_TIME_T_DEFINED) && !defined(_TIME_T_DECLARED) |
29 | typedef long time_t; | 29 | typedef long time_t; |
30 | 30 | ||
31 | struct utimbuf | ||
32 | { | ||
33 | time_t actime; | ||
34 | time_t modtime; | ||
35 | }; | ||
36 | |||
37 | /* this define below is used by the mingw headers to prevent duplicate | 31 | /* this define below is used by the mingw headers to prevent duplicate |
38 | typedefs */ | 32 | typedefs */ |
39 | #define _TIME_T_DEFINED | 33 | #define _TIME_T_DEFINED |