vfs: Remove fs_env from struct proc
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 7 Mar 2018 21:26:18 +0000 (13:26 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 30 Apr 2018 18:31:44 +0000 (14:31 -0400)
Part of removing the VFS.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/include/env.h
kern/src/process.c
kern/src/syscall.c
kern/src/vfs.c

index 255a5b9..712b9d5 100644 (file)
@@ -98,8 +98,7 @@ struct proc {
        sysevent_front_ring_t syseventfrontring;
 
        /* Filesystem info */
-       struct namespace                        *ns;
-       struct fs_struct                        fs_env;
+       int                                                     umask;
        struct fd_table                         open_files;
        struct pgrp                                     *pgrp;
        struct chan                                     *slash;
index fd2d646..141cc04 100644 (file)
@@ -421,14 +421,7 @@ error_t proc_alloc(struct proc **pp, struct proc *parent, int flags)
                        SYSEVENTRINGSIZE);
 
        /* Init FS structures TODO: cleanup (might pull this out) */
-       kref_get(&default_ns.kref, 1);
-       p->ns = &default_ns;
-       spinlock_init(&p->fs_env.lock);
-       p->fs_env.umask = parent ? parent->fs_env.umask : S_IWGRP | S_IWOTH;
-       p->fs_env.root = p->ns->root->mnt_root;
-       kref_get(&p->fs_env.root->d_kref, 1);
-       p->fs_env.pwd = parent ? parent->fs_env.pwd : p->fs_env.root;
-       kref_get(&p->fs_env.pwd->d_kref, 1);
+       p->umask = parent ? parent->umask : S_IWGRP | S_IWOTH;
        memset(&p->open_files, 0, sizeof(p->open_files));       /* slightly ghetto */
        spinlock_init(&p->open_files.lock);
        p->open_files.max_files = NR_OPEN_FILES_DEFAULT;
@@ -519,8 +512,6 @@ static void __proc_free(struct kref *kref)
        cclose(p->dot);
        cclose(p->slash);
        p->dot = p->slash = 0; /* catch bugs */
-       kref_put(&p->fs_env.root->d_kref);
-       kref_put(&p->fs_env.pwd->d_kref);
        /* now we'll finally decref files for the file-backed vmrs */
        unmap_and_destroy_vmrs(p);
        /* Remove us from the pid_hash and give our PID back (in that order). */
index d6eec31..c88ecd1 100644 (file)
@@ -1696,7 +1696,7 @@ static intreg_t sys_openat(struct proc *p, int fromfd, const char *path,
        if (!t_path)
                return -1;
        sysc_save_str("open %s at fd %d", t_path, fromfd);
-       mode &= ~p->fs_env.umask;
+       mode &= ~p->umask;
        fd = sysopenat(fromfd, t_path, oflag);
        /* successful lookup with CREATE and EXCL is an error */
        if (fd != -1) {
@@ -1843,8 +1843,9 @@ out:
 
 intreg_t sys_umask(struct proc *p, int mask)
 {
-       int old_mask = p->fs_env.umask;
-       p->fs_env.umask = mask & S_PMASK;
+       int old_mask = p->umask;
+
+       p->umask = mask & S_PMASK;
        return old_mask;
 }
 
@@ -2007,7 +2008,7 @@ intreg_t sys_mkdir(struct proc *p, const char *path, size_t path_l, int mode)
        if (!t_path)
                return -1;
        mode &= S_PMASK;
-       mode &= ~p->fs_env.umask;
+       mode &= ~p->umask;
        /* mixing plan9 and glibc here, make sure DMDIR doesn't overlap with any
         * permissions */
        static_assert(!(S_PMASK & DMDIR));
index f704a2e..f668f73 100644 (file)
@@ -337,7 +337,7 @@ static int follow_symlink(struct nameidata *nd)
                if (!current)
                        nd->dentry = default_ns.root->mnt_root;
                else
-                       nd->dentry = current->fs_env.root;
+                       nd->dentry = NULL; // current->fs_env.root;
                nd->mnt = nd->dentry->d_sb->s_mount;
                kref_get(&nd->mnt->mnt_kref, 1);
                kref_get(&nd->dentry->d_kref, 1);
@@ -540,11 +540,11 @@ int path_lookup(char *path, int flags, struct nameidata *nd)
                if (!current)
                        nd->dentry = default_ns.root->mnt_root;
                else
-                       nd->dentry = current->fs_env.root;
+                       nd->dentry = NULL; // current->fs_env.root;
        } else {                                                /* relative lookup */
                assert(current);
                /* Don't need to lock on the fs_env since we're reading one item */
-               nd->dentry = current->fs_env.pwd;
+               nd->dentry = NULL; // current->fs_env.pwd;
        }
        nd->mnt = nd->dentry->d_sb->s_mount;
        /* Whenever references get put in the nd, incref them.  Whenever they are