diff --git a/common/cmd_exec.c b/common/cmd_exec.c index f7ae918fc..2cba50751 100644 --- a/common/cmd_exec.c +++ b/common/cmd_exec.c @@ -11,39 +11,6 @@ #include #endif -static void *read_file(const char *file) -{ - struct stat s; - void *buf = NULL; - int fd = 0; - - if (stat(file, &s)) { - perror("stat"); - return NULL; - } - - fd = open(file, O_RDONLY); - if (fd < 0) { - perror("open"); - return NULL; - } - - buf = xzalloc(s.st_size + 1); - - if (read(fd, buf, s.st_size) < s.st_size) { - perror("read"); - goto out; - } - - close(fd); - return buf; - -out: - free(buf); - close(fd); - return NULL; -} - static int do_exec(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { int i; diff --git a/fs/fs.c b/fs/fs.c index 616514142..5cee5a769 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -8,6 +8,34 @@ #include #include +void *read_file(const char *filename) +{ + int fd; + struct stat s; + void *buf = NULL; + + if (stat(filename, &s)) + return NULL; + + buf = xzalloc(s.st_size + 1); + + fd = open(filename, O_RDONLY); + if (fd < 0) + goto err_out; + + if (read(fd, buf, s.st_size) < s.st_size) + goto err_out1; + + close(fd); + return buf; + +err_out1: + close(fd); +err_out: + free(buf); + return NULL; +} + char *mkmodestr(unsigned long mode, char *str) { static const char *l = "xwr"; @@ -490,7 +518,7 @@ int mount(const char *device, const char *fsname, const char *path) int ret; errno = 0; - +printf("mount: %s on %s type %s\n", device, path, fsname); drv = get_driver_by_name(fsname); if (!drv) { errno = -ENODEV; diff --git a/include/fs.h b/include/fs.h index d0a2636f3..a16702136 100644 --- a/include/fs.h +++ b/include/fs.h @@ -118,6 +118,7 @@ struct mtab_entry { struct device_d *parent_device; }; +void *read_file(const char *filename); char *normalise_path(const char *path); #endif /* __FS_H */