parent
9d0f3063a7
commit
e2f1a28306
|
@ -11,39 +11,6 @@
|
||||||
#include <hush.h>
|
#include <hush.h>
|
||||||
#endif
|
#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[])
|
static int do_exec(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
30
fs/fs.c
30
fs/fs.c
|
@ -8,6 +8,34 @@
|
||||||
#include <xfuncs.h>
|
#include <xfuncs.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
|
|
||||||
|
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)
|
char *mkmodestr(unsigned long mode, char *str)
|
||||||
{
|
{
|
||||||
static const char *l = "xwr";
|
static const char *l = "xwr";
|
||||||
|
@ -490,7 +518,7 @@ int mount(const char *device, const char *fsname, const char *path)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
printf("mount: %s on %s type %s\n", device, path, fsname);
|
||||||
drv = get_driver_by_name(fsname);
|
drv = get_driver_by_name(fsname);
|
||||||
if (!drv) {
|
if (!drv) {
|
||||||
errno = -ENODEV;
|
errno = -ENODEV;
|
||||||
|
|
|
@ -118,6 +118,7 @@ struct mtab_entry {
|
||||||
struct device_d *parent_device;
|
struct device_d *parent_device;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void *read_file(const char *filename);
|
||||||
char *normalise_path(const char *path);
|
char *normalise_path(const char *path);
|
||||||
|
|
||||||
#endif /* __FS_H */
|
#endif /* __FS_H */
|
||||||
|
|
Loading…
Reference in New Issue