Add flags option to mount

This commit is contained in:
Theodore Dubois
2019-05-01 18:12:53 -07:00
parent a94a56cfb4
commit cc08b17c48
5 changed files with 16 additions and 9 deletions
+2 -2
View File
@@ -134,8 +134,8 @@ static void ios_handle_die(const char *msg) {
fd_close(fd);
}
do_mount(&procfs, "proc", "/proc");
do_mount(&devptsfs, "devpts", "/dev/pts");
do_mount(&procfs, "proc", "/proc", 0);
do_mount(&devptsfs, "devpts", "/dev/pts", 0);
task_start(current);
return 0;
+9 -3
View File
@@ -37,12 +37,13 @@ void mount_release(struct mount *mount) {
unlock(&mounts_lock);
}
int do_mount(const struct fs_ops *fs, const char *source, const char *point) {
int do_mount(const struct fs_ops *fs, const char *source, const char *point, int flags) {
struct mount *new_mount = malloc(sizeof(struct mount));
if (new_mount == NULL)
return _ENOMEM;
new_mount->point = strdup(point);
new_mount->source = strdup(source);
new_mount->flags = flags;
new_mount->fs = fs;
new_mount->data = NULL;
new_mount->refcount = 0;
@@ -91,8 +92,13 @@ int do_umount(const char *point) {
return mount_remove(mount);
}
#define MS_READONLY_ (1 << 0)
#define MS_NOSUID_ (1 << 1)
#define MS_NODEV_ (1 << 2)
#define MS_NOEXEC_ (1 << 3)
#define MS_SILENT_ (1 << 15)
#define MS_SUPPORTED (MS_SILENT_)
#define MS_SUPPORTED (MS_READONLY_|MS_NOSUID_|MS_NODEV_|MS_NOEXEC_|MS_SILENT_)
#define MS_FLAGS (MS_READONLY_|MS_NOSUID_|MS_NODEV_|MS_NOEXEC_)
dword_t sys_mount(addr_t source_addr, addr_t point_addr, addr_t type_addr, dword_t flags, addr_t data_addr) {
char source[MAX_PATH];
@@ -134,7 +140,7 @@ dword_t sys_mount(addr_t source_addr, addr_t point_addr, addr_t type_addr, dword
return err;
lock(&mounts_lock);
err = do_mount(fs, source, point);
err = do_mount(fs, source, point, flags & MS_FLAGS);
unlock(&mounts_lock);
return err;
}
+2 -1
View File
@@ -67,6 +67,7 @@ int generic_mkdirat(struct fd *at, const char *path, mode_t_ mode);
struct mount {
const char *point;
const char *source;
int flags;
const struct fs_ops *fs;
unsigned refcount;
struct list mounts;
@@ -104,7 +105,7 @@ void mount_retain(struct mount *mount);
void mount_release(struct mount *mount);
// must hold mounts_lock while calling these, or traversing mounts
int do_mount(const struct fs_ops *fs, const char *source, const char *point);
int do_mount(const struct fs_ops *fs, const char *source, const char *point, int flags);
int do_umount(const char *point);
int mount_remove(struct mount *mount);
extern struct list mounts;
+1 -1
View File
@@ -10,7 +10,7 @@ int mount_root(const struct fs_ops *fs, const char *source) {
char source_realpath[MAX_PATH + 1];
if (realpath(source, source_realpath) == NULL)
return errno_map();
int err = do_mount(fs, source_realpath, "");
int err = do_mount(fs, source_realpath, "", 0);
if (err < 0)
return err;
return 0;
+2 -2
View File
@@ -13,7 +13,7 @@ int main(int argc, char *const argv[]) {
fprintf(stderr, "%s\n", strerror(-err));
return err;
}
do_mount(&procfs, "proc", "/proc");
do_mount(&devptsfs, "devpts", "/dev/pts");
do_mount(&procfs, "proc", "/proc", 0);
do_mount(&devptsfs, "devpts", "/dev/pts", 0);
cpu_run(&current->cpu);
}