diff options
Diffstat (limited to 'fs/uimagefs.c')
-rw-r--r-- | fs/uimagefs.c | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/fs/uimagefs.c b/fs/uimagefs.c index daaa3ad24b..735a35e500 100644 --- a/fs/uimagefs.c +++ b/fs/uimagefs.c @@ -68,7 +68,7 @@ static struct uimagefs_handle_data *uimagefs_get_by_name( return NULL; } -static int uimagefs_open(struct device_d *dev, FILE *file, const char *filename) +static int uimagefs_open(struct device *dev, FILE *file, const char *filename) { struct uimagefs_handle *priv = dev->priv; struct uimagefs_handle_data *d; @@ -94,7 +94,7 @@ static int uimagefs_open(struct device_d *dev, FILE *file, const char *filename) return 0; } -static int uimagefs_close(struct device_d *dev, FILE *file) +static int uimagefs_close(struct device *dev, FILE *file) { struct uimagefs_handle_data *d = file->priv; @@ -103,7 +103,8 @@ static int uimagefs_close(struct device_d *dev, FILE *file) return 0; } -static int uimagefs_read(struct device_d *dev, FILE *file, void *buf, size_t insize) +static int uimagefs_read(struct device *dev, FILE *file, void *buf, + size_t insize) { struct uimagefs_handle_data *d = file->priv; @@ -115,7 +116,7 @@ static int uimagefs_read(struct device_d *dev, FILE *file, void *buf, size_t ins } } -static int uimagefs_lseek(struct device_d *dev, FILE *file, loff_t pos) +static int uimagefs_lseek(struct device *dev, FILE *file, loff_t pos) { struct uimagefs_handle_data *d = file->priv; @@ -127,7 +128,7 @@ static int uimagefs_lseek(struct device_d *dev, FILE *file, loff_t pos) return 0; } -static DIR *uimagefs_opendir(struct device_d *dev, const char *pathname) +static DIR *uimagefs_opendir(struct device *dev, const char *pathname) { struct uimagefs_handle *priv = dev->priv; DIR *dir; @@ -142,7 +143,7 @@ static DIR *uimagefs_opendir(struct device_d *dev, const char *pathname) return dir; } -static struct dirent *uimagefs_readdir(struct device_d *dev, DIR *dir) +static struct dirent *uimagefs_readdir(struct device *dev, DIR *dir) { struct uimagefs_handle *priv = dev->priv; struct uimagefs_handle_data *d = dir->priv; @@ -155,13 +156,14 @@ static struct dirent *uimagefs_readdir(struct device_d *dev, DIR *dir) return &dir->d; } -static int uimagefs_closedir(struct device_d *dev, DIR *dir) +static int uimagefs_closedir(struct device *dev, DIR *dir) { free(dir); return 0; } -static int uimagefs_stat(struct device_d *dev, const char *filename, struct stat *s) +static int uimagefs_stat(struct device *dev, const char *filename, + struct stat *s) { struct uimagefs_handle *priv = dev->priv; struct uimagefs_handle_data *d; @@ -179,7 +181,7 @@ static int uimagefs_stat(struct device_d *dev, const char *filename, struct stat return 0; } -static int uimagefs_ioctl(struct device_d *dev, FILE *f, int request, void *buf) +static int uimagefs_ioctl(struct device *dev, FILE *f, int request, void *buf) { struct uimagefs_handle *priv = dev->priv; @@ -191,7 +193,7 @@ static int uimagefs_ioctl(struct device_d *dev, FILE *f, int request, void *buf) return 0; } -static void uimagefs_remove(struct device_d *dev) +static void uimagefs_remove(struct device *dev) { struct uimagefs_handle *priv = dev->priv; struct uimagefs_handle_data *d, *tmp; @@ -295,28 +297,24 @@ static int uimagefs_add_data_entry(struct uimagefs_handle *priv, size_t offset, return 0; } -#if defined(CONFIG_TIMESTAMP) static int uimagefs_add_time(struct uimagefs_handle *priv) { struct image_header *header = &priv->header; - struct rtc_time tm; - char *val; - to_tm(header->ih_time, &tm); - val = basprintf("%4d-%02d-%02d %2d:%02d:%02d UTC", - tm.tm_year, tm.tm_mon, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); + if (IS_ENABLED(CONFIG_TIMESTAMP)) { + struct rtc_time tm; + char *val; - return uimagefs_add_str(priv, UIMAGEFS_TIME, val); -} -#else -static int uimagefs_add_time(struct uimagefs_handle *priv) -{ - struct image_header *header = &priv->header; + to_tm(header->ih_time, &tm); + val = basprintf("%4d-%02d-%02d %2d:%02d:%02d UTC", + tm.tm_year, tm.tm_mon, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); + + return uimagefs_add_str(priv, UIMAGEFS_TIME, val); + } return uimagefs_add_hex(priv, UIMAGEFS_TIME, header->ih_time); } -#endif static int uimagefs_add_os(struct uimagefs_handle *priv) { @@ -373,7 +371,7 @@ static int __uimage_open(struct uimagefs_handle *priv) fd = open(filename, O_RDONLY); if (fd < 0) { - printf("could not open: %s\n", errno_str()); + printf("could not open: %m\n"); return fd; } @@ -381,7 +379,7 @@ static int __uimage_open(struct uimagefs_handle *priv) ret = read(fd, header, sizeof(*header)); if (ret < 0) { - printf("could not read: %s\n", errno_str()); + printf("could not read: %m\n"); goto err_out; } offset += sizeof(*header); @@ -493,9 +491,9 @@ err_out: return ret; } -static int uimagefs_probe(struct device_d *dev) +static int uimagefs_probe(struct device *dev) { - struct fs_device_d *fsdev = dev_to_fs_device(dev); + struct fs_device *fsdev = dev_to_fs_device(dev); struct uimagefs_handle *priv; int ret = 0; @@ -518,7 +516,7 @@ err: return ret; } -static struct fs_driver_d uimagefs_driver = { +static struct fs_driver uimagefs_driver = { .open = uimagefs_open, .close = uimagefs_close, .read = uimagefs_read, |