diff options
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/utils.c b/src/utils.c index 0959cee..9e09216 100644 --- a/src/utils.c +++ b/src/utils.c @@ -311,6 +311,20 @@ int mount_pts(const char *mount_path) return 0; } +int mount_proc(const char *mount_path) +{ + int s; + + s = mount("proc", mount_path, "proc", + MS_RELATIME, "rw"); + if (s) { + E_STRERR("Mount proc filesystem to %s", mount_path); + return 1; + } + + return 0; +} + int create_device_file_checked(const char *mount_path, const char *device_file, mode_t mode, int add_mode, dev_t dev) { @@ -321,14 +335,17 @@ int create_device_file_checked(const char *mount_path, const char *device_file, size_t plen = strnlen(mount_path, PATH_MAX); size_t dlen = strnlen(device_file, PATH_MAX); struct stat devbuf = {0}; - char devpath[plen+dlen+1]; + char devpath[plen+dlen+2]; - snprintf(devpath, plen+dlen+1, "%s/%s", mount_path, device_file); + snprintf(devpath, plen+dlen+2, "%s/%s", mount_path, device_file); s = stat(devpath, &devbuf); - if (s && errno != EEXIST) { + if (s && errno != EEXIST && errno != ENOENT) { return 1; - } else if (s && errno == EEXIST) { + } + if (errno == EEXIST) { + if (remove(devpath)) + return 1; } D2("Create device file: %s", devpath); @@ -345,7 +362,9 @@ int create_device_file_checked(const char *mount_path, const char *device_file, int create_device_files(const char *mount_path) { - create_device_file_checked(mount_path, "ptmx", 0, 1, makedev(5,2)); + int s = 0; - return 0; + s |= create_device_file_checked(mount_path, "ptmx", S_IFCHR, 1, makedev(5,2)); + + return s; } |