[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH v3 09/23] lib/vfscore: use Unikraft types and functions



Hello Yuri,

Please find the comments inline:

Thanks & Regards
Sharan

On 2/7/19 2:58 PM, Yuri Volchkov wrote:
Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
  lib/vfscore/dentry.c                 | 137 ++++++++++++++-------------
  lib/vfscore/fops.c                   |   2 +-
  lib/vfscore/include/vfscore/dentry.h |  10 +-
  lib/vfscore/include/vfscore/mount.h  |   1 +
  lib/vfscore/include/vfscore/vnode.h  |  29 +++---
  lib/vfscore/lookup.c                 |  30 +++---
  lib/vfscore/main.c                   | 121 +++++++++++------------
  lib/vfscore/mount.c                  | 114 ++++++++++++----------
  lib/vfscore/subr_uio.c               |   2 +-
  lib/vfscore/syscalls.c               | 128 ++++++++++++-------------
  lib/vfscore/vfs.h                    |  38 ++++----
  lib/vfscore/vnode.c                  | 122 ++++++++++++------------
  12 files changed, 376 insertions(+), 358 deletions(-)

diff --git a/lib/vfscore/dentry.c b/lib/vfscore/dentry.c
index ccce07d1..fe1841bb 100644
--- a/lib/vfscore/dentry.c
+++ b/lib/vfscore/dentry.c
@@ -41,18 +41,18 @@
#define DENTRY_BUCKETS 32 -static LIST_HEAD(dentry_hash_head, dentry) dentry_hash_table[DENTRY_BUCKETS];
-static LIST_HEAD(fake, dentry) fake;
-static mutex dentry_hash_lock;
+static struct uk_hlist_head dentry_hash_table[DENTRY_BUCKETS];
+static UK_HLIST_HEAD(fake);
+static struct uk_mutex dentry_hash_lock;
dentry_hash_lock isn't initialized?

/*
   * Get the hash value from the mount point and path name.
   * XXX: replace with a better hash for 64-bit pointers.
   */
-static u_int
+static unsigned int
  dentry_hash(struct mount *mp, const char *path)
  {
-       u_int val = 0;
+       unsigned int val = 0;
if (path) {
                while (*path) {
@@ -67,10 +67,10 @@ struct dentry *
  dentry_alloc(struct dentry *parent_dp, struct vnode *vp, const char *path)
  {
        struct mount *mp = vp->v_mount;
-       struct dentry *dp = (dentry*)calloc(sizeof(*dp), 1);
+       struct dentry *dp = (struct dentry*)calloc(sizeof(*dp), 1);
if (!dp) {
-               return nullptr;
+               return NULL;
        }
vref(vp);
@@ -79,22 +79,24 @@ dentry_alloc(struct dentry *parent_dp, struct vnode *vp, 
const char *path)
        dp->d_vnode = vp;
        dp->d_mount = mp;
        dp->d_path = strdup(path);
-       LIST_INIT(&dp->d_children);
+       UK_INIT_LIST_HEAD(&dp->d_child_list);
if (parent_dp) {
                dref(parent_dp);
-               WITH_LOCK(parent_dp->d_lock) {
-                       // Insert dp into its parent's children list.
-                       LIST_INSERT_HEAD(&parent_dp->d_children, dp, 
d_children_link);
-               }
+
+               uk_mutex_lock(&parent_dp->d_lock);
+               // Insert dp into its parent's children list.
+               uk_list_add(&dp->d_child_link, &parent_dp->d_child_list);
+               uk_mutex_unlock(&parent_dp->d_lock);
        }
        dp->d_parent = parent_dp;
vn_add_name(vp, dp); - mutex_lock(&dentry_hash_lock);
-       LIST_INSERT_HEAD(&dentry_hash_table[dentry_hash(mp, path)], dp, d_link);
-       mutex_unlock(&dentry_hash_lock);
+       uk_mutex_lock(&dentry_hash_lock);
+       uk_hlist_add_head(&dp->d_link,
+                         &dentry_hash_table[dentry_hash(mp, path)]);
+       uk_mutex_unlock(&dentry_hash_lock);
        return dp;
  };
@@ -103,29 +105,30 @@ dentry_lookup(struct mount *mp, char *path)
  {
        struct dentry *dp;
- mutex_lock(&dentry_hash_lock);
-       LIST_FOREACH(dp, &dentry_hash_table[dentry_hash(mp, path)], d_link) {
+       uk_mutex_lock(&dentry_hash_lock);
+       uk_hlist_for_each_entry(dp, &dentry_hash_table[dentry_hash(mp, path)], 
d_link) {
                if (dp->d_mount == mp && !strncmp(dp->d_path, path, PATH_MAX)) {
                        dp->d_refcnt++;
We could use <uk/refcount.h> to implement the reference counting scheme. It is fine for the initial version but we must consider using unikraft library for it.


-                       mutex_unlock(&dentry_hash_lock);
+                       uk_mutex_unlock(&dentry_hash_lock);
                        return dp;
                }
        }
-       mutex_unlock(&dentry_hash_lock);
-       return nullptr;                /* not found */
+       uk_mutex_unlock(&dentry_hash_lock);
+       return NULL;                /* not found */
  }
static void dentry_children_remove(struct dentry *dp)
  {
-       struct dentry *entry = nullptr;
+       struct dentry *entry = NULL;
- WITH_LOCK(dp->d_lock) {
-               LIST_FOREACH(entry, &dp->d_children, d_children_link) {
-                       ASSERT(entry);
-                       ASSERT(entry->d_refcnt > 0);
-                       LIST_REMOVE(entry, d_link);
-               }
+       uk_mutex_lock(&dp->d_lock);
+       uk_list_for_each_entry(entry, &dp->d_child_list, d_child_link) {
+               UK_ASSERT(entry);
+               UK_ASSERT(entry->d_refcnt > 0);
+               uk_hlist_del(&entry->d_link);
        }
+       uk_mutex_unlock(&dp->d_lock);
+
  }
void
@@ -135,33 +138,34 @@ dentry_move(struct dentry *dp, struct dentry *parent_dp, 
char *path)
        char *old_path = dp->d_path;
if (old_pdp) {
-               WITH_LOCK(old_pdp->d_lock) {
-                       // Remove dp from its old parent's children list.
-                       LIST_REMOVE(dp, d_children_link);
-               }
+               uk_mutex_lock(&old_pdp->d_lock);
+               // Remove dp from its old parent's children list.
+               uk_list_del(&dp->d_child_link);
+               uk_mutex_unlock(&old_pdp->d_lock);
        }
if (parent_dp) {
                dref(parent_dp);
-               WITH_LOCK(parent_dp->d_lock) {
-                       // Insert dp into its new parent's children list.
-                       LIST_INSERT_HEAD(&parent_dp->d_children, dp, 
d_children_link);
-               }
-       }
- WITH_LOCK(dentry_hash_lock) {
-               // Remove all dp's child dentries from the hashtable.
-               dentry_children_remove(dp);
-               // Remove dp with outdated hash info from the hashtable.
-               LIST_REMOVE(dp, d_link);
-               // Update dp.
-               dp->d_path = strdup(path);
-               dp->d_parent = parent_dp;
-               // Insert dp updated hash info into the hashtable.
-               LIST_INSERT_HEAD(&dentry_hash_table[dentry_hash(dp->d_mount, 
path)],
-                       dp, d_link);
+               uk_mutex_lock(&parent_dp->d_lock);
+               // Insert dp into its new parent's children list.
+               uk_list_add(&dp->d_child_link, &parent_dp->d_child_list);
+               uk_mutex_unlock(&parent_dp->d_lock);
        }
+ uk_mutex_lock(&dentry_hash_lock);
+       // Remove all dp's child dentries from the hashtable.
+       dentry_children_remove(dp);
+       // Remove dp with outdated hash info from the hashtable.
+       uk_hlist_del(&dp->d_link);
+       // Update dp.
+       dp->d_path = strdup(path);
+       dp->d_parent = parent_dp;
+       // Insert dp updated hash info into the hashtable.
+       uk_hlist_add_head(&dp->d_link,
+                         &dentry_hash_table[dentry_hash(dp->d_mount, path)]);
+       uk_mutex_unlock(&dentry_hash_lock);
+
        if (old_pdp) {
                drele(old_pdp);
        }
@@ -172,45 +176,46 @@ dentry_move(struct dentry *dp, struct dentry *parent_dp, 
char *path)
  void
  dentry_remove(struct dentry *dp)
  {
-       mutex_lock(&dentry_hash_lock);
-       LIST_REMOVE(dp, d_link);
+       uk_mutex_lock(&dentry_hash_lock);
+       uk_hlist_del(&dp->d_link);
        /* put it on a fake list for drele() to work*/
-       LIST_INSERT_HEAD(&fake, dp, d_link);
-       mutex_unlock(&dentry_hash_lock);
+       uk_hlist_add_head(&dp->d_link, &fake);
+       uk_mutex_unlock(&dentry_hash_lock);
  }
void
  dref(struct dentry *dp)
  {
-       ASSERT(dp);
-       ASSERT(dp->d_refcnt > 0);
+       UK_ASSERT(dp);
+       UK_ASSERT(dp->d_refcnt > 0);
- mutex_lock(&dentry_hash_lock);
+       uk_mutex_lock(&dentry_hash_lock);
        dp->d_refcnt++;
-       mutex_unlock(&dentry_hash_lock);
+       uk_mutex_unlock(&dentry_hash_lock);
  }
void
  drele(struct dentry *dp)
  {
-       ASSERT(dp);
-       ASSERT(dp->d_refcnt > 0);
+       UK_ASSERT(dp);
+       UK_ASSERT(dp->d_refcnt > 0);
- mutex_lock(&dentry_hash_lock);
+       uk_mutex_lock(&dentry_hash_lock);
        if (--dp->d_refcnt) {
-               mutex_unlock(&dentry_hash_lock);
+               uk_mutex_unlock(&dentry_hash_lock);
                return;
        }
-       LIST_REMOVE(dp, d_link);
+       uk_hlist_del(&dp->d_link);
        vn_del_name(dp->d_vnode, dp);
- mutex_unlock(&dentry_hash_lock);
+       uk_mutex_unlock(&dentry_hash_lock);
if (dp->d_parent) {
-               WITH_LOCK(dp->d_parent->d_lock) {
-                       // Remove dp from its parent's children list.
-                       LIST_REMOVE(dp, d_children_link);
-               }
+               uk_mutex_lock(&dp->d_parent->d_lock);
+               // Remove dp from its parent's children list.
+               uk_list_del(&dp->d_child_link);
+               uk_mutex_unlock(&dp->d_parent->d_lock);
+
                drele(dp->d_parent);
        }
@@ -226,6 +231,6 @@ dentry_init(void)
        int i;
for (i = 0; i < DENTRY_BUCKETS; i++) {
-               LIST_INIT(&dentry_hash_table[i]);
+               UK_INIT_HLIST_HEAD(&dentry_hash_table[i]);
        }
  }
diff --git a/lib/vfscore/fops.c b/lib/vfscore/fops.c
index b4583d20..79114e21 100644
--- a/lib/vfscore/fops.c
+++ b/lib/vfscore/fops.c
@@ -115,7 +115,7 @@ int vfs_write(struct vfscore_file *fp, struct uio *uio, int 
flags)
        return error;
  }
-int vfs_ioctl(struct vfscore_file *fp, u_long com, void *data)
+int vfs_ioctl(struct vfscore_file *fp, unsigned long com, void *data)
  {
        struct vnode *vp = fp->f_dentry->d_vnode;
        int error;
diff --git a/lib/vfscore/include/vfscore/dentry.h 
b/lib/vfscore/include/vfscore/dentry.h
index ba1c3457..85f37ab7 100644
--- a/lib/vfscore/include/vfscore/dentry.h
+++ b/lib/vfscore/include/vfscore/dentry.h
@@ -42,16 +42,16 @@
  struct vnode;
struct dentry {
-       LIST_ENTRY(dentry) d_link;      /* link for hash list */
+       struct uk_hlist_node d_link;    /* link for hash list */
        int             d_refcnt;       /* reference count */
        char            *d_path;        /* pointer to path in fs */
        struct vnode    *d_vnode;
        struct mount    *d_mount;
        struct dentry   *d_parent; /* pointer to parent */
-       LIST_ENTRY(dentry) d_names_link; /* link fo vnode::d_names */
-       mutex_t         d_lock;
-       LIST_HEAD(, dentry) d_children;
-       LIST_ENTRY(dentry) d_children_link;
+       struct uk_list_head d_names_link; /* link fo vnode::d_names */
+       struct uk_mutex d_lock;
+       struct uk_list_head d_child_list;
+       struct uk_list_head d_child_link;
  };
#endif /* _OSV_DENTRY_H */
diff --git a/lib/vfscore/include/vfscore/mount.h 
b/lib/vfscore/include/vfscore/mount.h
index e12a1039..7a638dbe 100644
--- a/lib/vfscore/include/vfscore/mount.h
+++ b/lib/vfscore/include/vfscore/mount.h
@@ -52,6 +52,7 @@ struct mount {
        struct dentry   *m_root;        /* root vnode */
        struct dentry   *m_covered;     /* vnode covered on parent fs */
        void            *m_data;        /* private data for fs */
+       struct uk_list_head mnt_list;
        fsid_t          m_fsid;         /* id that uniquely identifies the fs */
  };
diff --git a/lib/vfscore/include/vfscore/vnode.h b/lib/vfscore/include/vfscore/vnode.h
index 49fd4d36..a4db9c13 100644
--- a/lib/vfscore/include/vfscore/vnode.h
+++ b/lib/vfscore/include/vfscore/vnode.h
@@ -47,7 +47,7 @@
  struct vfsops;
  struct vnops;
  struct vnode;
-struct file;
+struct vfscore_file;
/*
   * Vnode types.
@@ -70,7 +70,7 @@ enum vtype {
   */
  struct vnode {
        uint64_t        v_ino;          /* inode number */
-       LIST_ENTRY(vnode) v_link;       /* link for hash list */
+       struct uk_list_head v_link;     /* link for hash list */
        struct mount    *v_mount;       /* mounted vfs pointer */
        struct vnops    *v_op;          /* vnode operations */
        int             v_refcnt;       /* reference count */
@@ -78,9 +78,8 @@ struct vnode {
        int             v_flags;        /* vnode flag */
        mode_t          v_mode;         /* file mode */
        off_t           v_size;         /* file size */
-       mutex_t         v_lock;         /* lock for this vnode */
-       LIST_HEAD(, dentry) v_names;    /* directory entries pointing at this */
-       int             v_nrlocks;      /* lock count (for debug) */
+       struct uk_mutex v_lock;         /* lock for this vnode */
+       struct uk_list_head v_names;    /* directory entries pointing at this */
        void            *v_data;        /* private data for fs */
  };
@@ -127,14 +126,14 @@ struct vattr {
  #define ARC_ACTION_HOLD     1
  #define ARC_ACTION_RELEASE  2
-typedef int (*vnop_open_t) (struct file *);
-typedef        int (*vnop_close_t)     (struct vnode *, struct file *);
-typedef        int (*vnop_read_t)      (struct vnode *, struct file *, struct 
uio *, int);
-typedef        int (*vnop_write_t)     (struct vnode *, struct uio *, int);
-typedef        int (*vnop_seek_t)      (struct vnode *, struct file *, off_t, 
off_t);
-typedef        int (*vnop_ioctl_t)     (struct vnode *, struct file *, u_long, 
void *);
-typedef        int (*vnop_fsync_t)     (struct vnode *, struct file *);
-typedef        int (*vnop_readdir_t)   (struct vnode *, struct file *, struct 
dirent *);
+typedef        int (*vnop_open_t)      (struct vfscore_file *);
+typedef        int (*vnop_close_t)     (struct vnode *, struct vfscore_file *);
+typedef        ssize_t (*vnop_read_t)  (struct vnode *, struct vfscore_file *, 
struct uio *, int);
+typedef        ssize_t (*vnop_write_t) (struct vnode *, struct uio *, int);
+typedef        off_t (*vnop_seek_t)    (struct vnode *, struct vfscore_file *, 
off_t, off_t);
+typedef        int (*vnop_ioctl_t)     (struct vnode *, struct vfscore_file *, 
unsigned long, void *);
+typedef        int (*vnop_fsync_t)     (struct vnode *, struct vfscore_file *);
+typedef        int (*vnop_readdir_t)   (struct vnode *, struct vfscore_file *, 
struct dirent *);
  typedef       int (*vnop_lookup_t)    (struct vnode *, char *, struct vnode 
**);
  typedef       int (*vnop_create_t)    (struct vnode *, char *, mode_t);
  typedef       int (*vnop_remove_t)    (struct vnode *, struct vnode *, char 
*);
@@ -147,8 +146,8 @@ typedef     int (*vnop_setattr_t)   (struct vnode *, struct 
vattr *);
  typedef       int (*vnop_inactive_t)  (struct vnode *);
  typedef       int (*vnop_truncate_t)  (struct vnode *, off_t);
  typedef       int (*vnop_link_t)      (struct vnode *, struct vnode *, char 
*);
-typedef int (*vnop_cache_t) (struct vnode *, struct file *, struct uio *);
-typedef int (*vnop_fallocate_t) (struct vnode *, int, loff_t, loff_t);
+typedef int (*vnop_cache_t) (struct vnode *, struct vfscore_file *, struct uio 
*);
+typedef int (*vnop_fallocate_t) (struct vnode *, int, off_t, off_t);
  typedef int (*vnop_readlink_t)  (struct vnode *, struct uio *);
  typedef int (*vnop_symlink_t)   (struct vnode *, char *, char *);
diff --git a/lib/vfscore/lookup.c b/lib/vfscore/lookup.c
index 9837e81f..1e2c4005 100644
--- a/lib/vfscore/lookup.c
+++ b/lib/vfscore/lookup.c
@@ -111,7 +111,7 @@ namei(const char *path, struct dentry **dpp)
        struct vnode *dvp, *vp;
        int error, i;
        int links_followed;
-       bool need_continue;
+       int need_continue;
DPRINTF(VFSDB_VNODE, ("namei: path=%s\n", path)); @@ -119,7 +119,7 @@ namei(const char *path, struct dentry **dpp)
        strlcpy(fp, path, PATH_MAX);
do {
-               need_continue = false;
+               need_continue = 0;
                /*
                 * Convert a full path name to its mount point and
                 * the local node in the file system.
@@ -143,7 +143,7 @@ namei(const char *path, struct dentry **dpp)
                 */
                ddp = mp->m_root;
                if (!ddp) {
-                       sys_panic("VFS: no root");
+                       UK_CRASH("VFS: no root");
                }
                dref(ddp);
@@ -177,7 +177,7 @@ namei(const char *path, struct dentry **dpp)
                        dvp = ddp->d_vnode;
                        vn_lock(dvp);
                        dp = dentry_lookup(mp, node);
-                       if (dp == nullptr) {
+                       if (dp == NULL) {
                                /* Find a vnode in this directory. */
                                error = VOP_LOOKUP(dvp, name, &vp);
                                if (error) {
@@ -209,17 +209,17 @@ namei(const char *path, struct dentry **dpp)
                                drele(dp);
p = fp;
-                               dp      = nullptr;
-                               ddp     = nullptr;
-                               vp      = nullptr;
-                               dvp     = nullptr;
+                               dp      = NULL;
+                               ddp     = NULL;
+                               vp      = NULL;
+                               dvp     = NULL;
                                name[0] = 0;
                                node[0] = 0;
if (++links_followed >= MAXSYMLINKS) {
                                        return (ELOOP);
                                }
-                               need_continue = true;
+                               need_continue = 1;
                                break;
                        }
@@ -228,7 +228,7 @@ namei(const char *path, struct dentry **dpp)
                                return ENOTDIR;
                        }
                }
-       } while (need_continue == true);
+       } while (need_continue);
*dpp = dp;
        return 0;
@@ -253,14 +253,14 @@ namei_last_nofollow(char *path, struct dentry *ddp, 
struct dentry **dpp)
        struct vnode  *vp;
        char node[PATH_MAX];
- dvp = nullptr;
+       dvp  = NULL;
if (path[0] != '/') {
                return (ENOTDIR);
        }
name = strrchr(path, '/');
-       if (name == nullptr) {
+       if (name == NULL) {
                return (ENOENT);
        }
        name++;
@@ -283,7 +283,7 @@ namei_last_nofollow(char *path, struct dentry *ddp, struct 
dentry **dpp)
        dvp = ddp->d_vnode;
        vn_lock(dvp);
        dp = dentry_lookup(mp, node);
-       if (dp == nullptr) {
+       if (dp == NULL) {
                error = VOP_LOOKUP(dvp, name, &vp);
                if (error != 0) {
                        goto out;
@@ -292,7 +292,7 @@ namei_last_nofollow(char *path, struct dentry *ddp, struct 
dentry **dpp)
                dp = dentry_alloc(ddp, vp, node);
                vput(vp);
- if (dp == nullptr) {
+               if (dp == NULL) {
                        error = ENOMEM;
                        goto out;
                }
@@ -301,7 +301,7 @@ namei_last_nofollow(char *path, struct dentry *ddp, struct 
dentry **dpp)
        *dpp  = dp;
        error = 0;
  out:
-       if (dvp != nullptr) {
+       if (dvp != NULL) {
                vn_unlock(dvp);
        }
        return (error);
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 90df3d71..82e45917 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -79,7 +79,7 @@ int open(const char *pathname, int flags, ...)
struct task *t = main_task;
        char path[PATH_MAX];
-       struct file *fp;
+       struct vfscore_file *fp;
        int fd, error;
        int acc;
@@ -135,7 +135,7 @@ int openat(int dirfd, const char *pathname, int flags, ...)
                return open(pathname, flags, mode);
        }
- struct file *fp;
+       struct vfscore_file *fp;
        int error = fget(dirfd, &fp);
        if (error) {
                errno = error;
@@ -197,7 +197,7 @@ TRACEPOINT(trace_vfs_mknod_err, "%d", int);
int __xmknod(int ver, const char *pathname, mode_t mode, dev_t *dev)
  {
-       assert(ver == 0); // On x86-64 Linux, _MKNOD_VER_LINUX is 0.
+       UK_ASSERT(ver == 0); // On x86-64 Linux, _MKNOD_VER_LINUX is 0.
        struct task *t = main_task;
        char path[PATH_MAX];
        int error;
@@ -231,7 +231,7 @@ TRACEPOINT(trace_vfs_lseek_err, "%d", int);
off_t lseek(int fd, off_t offset, int whence)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        off_t org;
        int error;
@@ -265,11 +265,12 @@ TRACEPOINT(trace_vfs_pread_err, "%d", int);
  // *and* a non-zero number of written bytes. In that case, we need to zero the
  // error, so the system call appear a successful partial read/write.
  // In FreeBSD, dofilewrite() and dofileread() (sys_generic.c) do this too.
-static inline bool has_error(int error, int bytes)
+static inline int has_error(int error, int bytes)
  {
+       /* TODO: OSv checks also for ERESTART */
        return error && (
                        (bytes == 0) ||
-                       (error != EWOULDBLOCK && error != EINTR && error != 
ERESTART));
+                       (error != EWOULDBLOCK && error != EINTR));
  }
@@ -280,7 +281,7 @@ ssize_t pread(int fd, void *buf, size_t count, off_t offset)
                        .iov_base       = buf,
                        .iov_len        = count,
        };
-       struct file *fp;
+       struct vfscore_file *fp;
        size_t bytes;
        int error;
@@ -320,7 +321,7 @@ ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
                        .iov_base       = (void *)buf,
                        .iov_len        = count,
        };
-       struct file *fp;
+       struct vfscore_file *fp;
        size_t bytes;
        int error;
@@ -351,7 +352,7 @@ ssize_t write(int fd, const void *buf, size_t count) ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        size_t bytes;
        int error;
@@ -384,7 +385,7 @@ TRACEPOINT(trace_vfs_pwritev_err, "%d", int); ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        size_t bytes;
        int error;
@@ -419,7 +420,7 @@ TRACEPOINT(trace_vfs_ioctl_err, "%d", int); int ioctl(int fd, unsigned long int request, ...)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        int error;
        va_list ap;
        void* arg;
@@ -456,7 +457,7 @@ TRACEPOINT(trace_vfs_fsync_err, "%d", int);
int fsync(int fd)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        int error;
trace_vfs_fsync(fd);
@@ -490,7 +491,7 @@ TRACEPOINT(trace_vfs_fstat_err, "%d", int);
int __fxstat(int ver, int fd, struct stat *st)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        int error;
trace_vfs_fstat(fd, st);
@@ -526,7 +527,7 @@ int __fxstatat(int ver, int dirfd, const char *pathname, 
struct stat *st,
                int flags)
  {
        if (flags & AT_SYMLINK_NOFOLLOW) {
-               UNIMPLEMENTED("fstatat() with AT_SYMLINK_NOFOLLOW");
+               UK_CRASH("UNIMPLEMENTED: fstatat() with AT_SYMLINK_NOFOLLOW");
        }
if (pathname[0] == '/' || dirfd == AT_FDCWD) {
@@ -538,7 +539,7 @@ int __fxstatat(int ver, int dirfd, const char *pathname, 
struct stat *st,
                return fstat(dirfd, st);
        }
- struct file *fp;
+       struct vfscore_file *fp;
        int error = fget(dirfd, &fp);
        if (error) {
                errno = error;
@@ -574,7 +575,9 @@ LFS64(fstatat);
int flock(int fd, int operation)
  {
-       if (!fileref_from_fd(fd)) {
+       struct vfscore_file *file;
+
+       if (!fget(fd, &file)) {
                return libc_error(EBADF);
        }
@@ -592,7 +595,7 @@ int flock(int fd, int operation)
        return 0;
  }
-TRACEPOINT(trace_vfs_readdir, "%d %p", int, dirent*);
+TRACEPOINT(trace_vfs_readdir, "%d %p", int, struct dirent*);
  TRACEPOINT(trace_vfs_readdir_ret, "");
  TRACEPOINT(trace_vfs_readdir_err, "%d", int);
@@ -611,7 +614,7 @@ DIR *opendir(const char *path)
        dir->fd = open(path, O_RDONLY);
        if (dir->fd < 0) {
                free(dir);
-               return nullptr;
+               return NULL;
        }
        return dir;
  }
@@ -621,11 +624,11 @@ DIR *fdopendir(int fd)
        DIR *dir;
        struct stat st;
        if (fstat(fd, &st) < 0) {
-               return nullptr;
+               return NULL;
        }
        if (!S_ISDIR(st.st_mode)) {
                errno = ENOTDIR;
-               return nullptr;
+               return NULL;
        }
        dir = malloc(sizeof(*dir));
        if (!dir) {
@@ -669,13 +672,11 @@ struct dirent *readdir(DIR *dir)
  int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result)
  {
        int error;
-       struct file *fp;
+       struct vfscore_file *fp;
trace_vfs_readdir(dir->fd, entry);
        error = fget(dir->fd, &fp);
-       if (error) {
-               trace_vfs_readdir_err(error);
-       } else {
+       if (!error) {
                error = sys_readdir(fp, entry);
                fdrop(fp);
                if (error) {
@@ -688,7 +689,7 @@ int readdir_r(DIR *dir, struct dirent *entry, struct dirent 
**result)
        entry->d_reclen = sizeof(*entry);
if (error) {
-               *result = nullptr;
+               *result = NULL;
        } else {
                *result = entry;
        }
@@ -706,7 +707,7 @@ struct dirent *readdir64(DIR *dir) 
__attribute__((alias("readdir")));
void rewinddir(DIR *dirp)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
int error = fget(dirp->fd, &fp);
        if (error) {
@@ -722,7 +723,7 @@ void rewinddir(DIR *dirp)
long telldir(DIR *dirp)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        int error = fget(dirp->fd, &fp);
        if (error) {
                return libc_error(error);
@@ -739,7 +740,7 @@ long telldir(DIR *dirp)
void seekdir(DIR *dirp, long loc)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        int error = fget(dirp->fd, &fp);
        if (error) {
                // POSIX specifies seekdir() cannot return errors.
@@ -790,7 +791,7 @@ int rmdir(const char *pathname)
trace_vfs_rmdir(pathname);
        error = ENOENT;
-       if (pathname == nullptr)
+       if (pathname == NULL)
                goto out_errno;
        if ((error = task_conv(t, pathname, VWRITE, path)) != 0)
                goto out_errno;
@@ -826,9 +827,9 @@ get_last_component(const char *path, char *dst)
        dst[len] = 0;
  }
-static bool null_or_empty(const char *str)
+static int null_or_empty(const char *str)
  {
-       return str == nullptr || *str == '\0';
+       return str == NULL || *str == '\0';
  }
TRACEPOINT(trace_vfs_rename, "\"%s\" \"%s\"", const char*, const char*);
@@ -883,7 +884,7 @@ TRACEPOINT(trace_vfs_chdir_err, "%d", int);
  static int
  __do_fchdir(struct vfscore_file *fp, struct task *t)
  {
-       struct file *old = nullptr;
+       struct vfscore_file *old = NULL;
UK_ASSERT(t); @@ -907,11 +908,11 @@ int chdir(const char *pathname)
        trace_vfs_chdir(pathname);
        struct task *t = main_task;
        char path[PATH_MAX];
-       struct file *fp;
+       struct vfscore_file *fp;
        int error;
error = ENOENT;
-       if (pathname == nullptr)
+       if (pathname == NULL)
                goto out_errno;
if ((error = task_conv(t, pathname, VREAD, path)) != 0)
@@ -945,7 +946,7 @@ int fchdir(int fd)
  {
        trace_vfs_fchdir(fd);
        struct task *t = main_task;
-       struct file *fp;
+       struct vfscore_file *fp;
        int error;
error = fget(fd, &fp);
@@ -981,7 +982,7 @@ int link(const char *oldpath, const char *newpath)
        trace_vfs_link(oldpath, newpath);
error = ENOENT;
-       if (oldpath == nullptr || newpath == nullptr)
+       if (oldpath == NULL || newpath == NULL)
                goto out_errno;
        if ((error = task_conv(t, oldpath, VWRITE, path1)) != 0)
                goto out_errno;
@@ -1011,7 +1012,7 @@ int symlink(const char *oldpath, const char *newpath)
        trace_vfs_symlink(oldpath, newpath);
error = ENOENT;
-       if (oldpath == nullptr || newpath == nullptr) {
+       if (oldpath == NULL || newpath == NULL) {
                errno = ENOENT;
                trace_vfs_symlink_err(error);
                return (-1);
@@ -1040,7 +1041,7 @@ int unlink(const char *pathname)
        int error;
error = ENOENT;
-       if (pathname == nullptr)
+       if (pathname == NULL)
                goto out_errno;
        if ((error = task_conv(t, pathname, VWRITE, path)) != 0)
                goto out_errno;
@@ -1156,7 +1157,7 @@ int __statfs(const char *pathname, struct statfs *buf)
        errno = error;
        return -1;
  }
-weak_alias(__statfs, statfs);
+__weak_alias(__statfs, statfs);
LFS64(statfs); @@ -1166,7 +1167,7 @@ TRACEPOINT(trace_vfs_fstatfs_err, "%d", int); int __fstatfs(int fd, struct statfs *buf)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        int error;
trace_vfs_fstatfs(fd, buf);
@@ -1187,7 +1188,7 @@ int __fstatfs(int fd, struct statfs *buf)
        errno = error;
        return -1;
  }
-weak_alias(__fstatfs, fstatfs);
+__weak_alias(__fstatfs, fstatfs);
LFS64(fstatfs); @@ -1241,7 +1242,7 @@ char *getcwd(char *path, size_t size)
  {
        trace_vfs_getcwd(path, size);
        struct task *t = main_task;
-       int len = strlen(t->t_cwd) + 1;
+       size_t len = strlen(t->t_cwd) + 1;
        int error;
if (!path) {
@@ -1271,7 +1272,7 @@ char *getcwd(char *path, size_t size)
        out_errno:
        trace_vfs_getcwd_err(error);
        errno = error;
-       return nullptr;
+       return NULL;
  }
TRACEPOINT(trace_vfs_dup, "%d", int);
@@ -1282,7 +1283,7 @@ TRACEPOINT(trace_vfs_dup_err, "%d", int);
   */
  int dup(int oldfd)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        int newfd;
        int error;
@@ -1315,7 +1316,7 @@ TRACEPOINT(trace_vfs_dup3_err, "%d", int);
   */
  int dup3(int oldfd, int newfd, int flags)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        int error;
trace_vfs_dup3(oldfd, newfd, flags);
@@ -1337,7 +1338,7 @@ int dup3(int oldfd, int newfd, int flags)
        if (error)
                goto out_errno;
- error = fdset(newfd, fp);
+       error = vfscore_install_fd(newfd, fp);
        if (error) {
                fdrop(fp);
                goto out_errno;
@@ -1373,7 +1374,7 @@ TRACEPOINT(trace_vfs_fcntl_err, "%d", int);
int fcntl(int fd, int cmd, int arg)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        int ret = 0, error;
        int tmp;
@@ -1490,14 +1491,14 @@ int access(const char *pathname, int mode)
  int faccessat(int dirfd, const char *pathname, int mode, int flags)
  {
        if (flags & AT_SYMLINK_NOFOLLOW) {
-               UNIMPLEMENTED("faccessat() with AT_SYMLINK_NOFOLLOW");
+               UK_CRASH("UNIMPLEMENTED: faccessat() with AT_SYMLINK_NOFOLLOW");
        }
if (pathname[0] == '/' || dirfd == AT_FDCWD) {
                return access(pathname, mode);
        }
- struct file *fp;
+       struct vfscore_file *fp;
        int error = fget(dirfd, &fp);
        if (error) {
                errno = error;
@@ -1528,7 +1529,7 @@ int euidaccess(const char *pathname, int mode)
        return access(pathname, mode);
  }
-weak_alias(euidaccess,eaccess);
+__weak_alias(euidaccess,eaccess);
#if 0
  /*
@@ -1536,7 +1537,7 @@ weak_alias(euidaccess,eaccess);
   */
  int isatty(int fd)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        int istty = 0;
trace_vfs_isatty(fd);
@@ -1570,7 +1571,7 @@ int truncate(const char *pathname, off_t length)
        int error;
error = ENOENT;
-       if (pathname == nullptr)
+       if (pathname == NULL)
                goto out_errno;
        if ((error = task_conv(t, pathname, VWRITE, path)) != 0)
                goto out_errno;
@@ -1595,7 +1596,7 @@ TRACEPOINT(trace_vfs_ftruncate_err, "%d", int);
  int ftruncate(int fd, off_t length)
  {
        trace_vfs_ftruncate(fd, length);
-       struct file *fp;
+       struct vfscore_file *fp;
        int error;
error = fget(fd, &fp);
@@ -1630,7 +1631,7 @@ ssize_t readlink(const char *pathname, char *buf, size_t 
bufsize)
                goto out_errno;
error = ENOENT;
-       if (pathname == nullptr)
+       if (pathname == NULL)
                goto out_errno;
        error = task_conv(t, pathname, VWRITE, path);
        if (error)
@@ -1654,7 +1655,7 @@ TRACEPOINT(trace_vfs_fallocate_err, "%d", int);
int fallocate(int fd, int mode, loff_t offset, loff_t len)
  {
-       struct file *fp;
+       struct vfscore_file *fp;
        int error;
trace_vfs_fallocate(fd, mode, offset, len);
@@ -1682,14 +1683,14 @@ LFS64(fallocate);
  int futimesat(int dirfd, const char *pathname, const struct timeval times[2])
  {
        struct stat st;
-       struct file *fp;
+       struct vfscore_file *fp;
        int error;
        char *absolute_path;
if ((pathname && pathname[0] == '/') || dirfd == AT_FDCWD)
                return utimes(pathname, times);
- // Note: if pathname == nullptr, futimesat operates on dirfd itself, and in
+       // Note: if pathname == NULL, futimesat operates on dirfd itself, and in
        // that case it doesn't have to be a directory.
        if (pathname) {
                error = fstat(dirfd, &st);
@@ -1835,7 +1836,7 @@ int chmod(const char *pathname, mode_t mode)
        struct task *t = main_task;
        char path[PATH_MAX];
        int error = ENOENT;
-       if (pathname == nullptr)
+       if (pathname == NULL)
                goto out_errno;
        if ((error = task_conv(t, pathname, VWRITE, path)) != 0)
                goto out_errno;
@@ -1893,8 +1894,8 @@ int lchown(const char *path, uid_t owner, gid_t group)
  #if 0
  ssize_t sendfile(int out_fd, int in_fd, off_t *_offset, size_t count)
  {
-       struct file *in_fp;
-       struct file *out_fp;
+       struct vfscore_file *in_fp;
+       struct vfscore_file *out_fp;
        fileref in_f{fileref_from_fd(in_fd)};
        fileref out_f{fileref_from_fd(out_fd)};
diff --git a/lib/vfscore/mount.c b/lib/vfscore/mount.c
index 06922ffb..7d083d6f 100644
--- a/lib/vfscore/mount.c
+++ b/lib/vfscore/mount.c
@@ -54,12 +54,13 @@
  /*
   * List for VFS mount points.
   */
-static std::list<mount*> mount_list;
+
+UK_LIST_HEAD(mount_list);
/*
   * Global lock to access mount point.
   */
-static mutex mount_lock;
+static struct uk_mutex mount_lock;
Intialization?

/*
   * Lookup file system.
@@ -84,11 +85,11 @@ sys_mount(const char *dev, const char *dir, const char 
*fsname, int flags, const
        const struct vfssw *fs;
        struct mount *mp;
        struct device *device;
-       struct dentry *dp_covered;
-       struct vnode *vp;
+       struct dentry *dp_covered = NULL;
+       struct vnode *vp = NULL;
        int error;
- kprintf("VFS: mounting %s at %s\n", fsname, dir);
+       uk_pr_info("VFS: mounting %s at %s\n", fsname, dir);
if (!dir || *dir == '\0')
                return ENOENT;
@@ -97,7 +98,7 @@ sys_mount(const char *dev, const char *dir, const char 
*fsname, int flags, const
        if (!(fs = fs_getfs(fsname)))
                return ENODEV;  /* No such file system */
- /* Open device. nullptr can be specified as a device. */
+       /* Open device. NULL can be specified as a device. */
        // Allow device_open() to fail, in which case dev is interpreted
        // by the file system mount routine (e.g zfs pools)
        device = 0;
@@ -111,17 +112,21 @@ sys_mount(const char *dev, const char *dir, const char 
*fsname, int flags, const
        // that only one sys_mount() runs at a time. We cannot reuse the 
existing
        // mount_lock for this purpose: If we take mount_lock and then do
        // lookups, this is lock order inversion and can result in deadlock.
-       static mutex sys_mount_lock;
-       SCOPE_LOCK(sys_mount_lock);
-       WITH_LOCK(mount_lock) {
-               for (auto&& mp : mount_list) {
-                       if (!strcmp(mp->m_path, dir) ||
-                               (device && mp->m_dev == device)) {
-                               error = EBUSY;  /* Already mounted */
-                               goto err1;
-                       }
+
+       /* TODO: protect the function from reentrance, as described in
+        * the comment above */
+       /* static mutex sys_mount_lock; */
+       /* SCOPE_LOCK(sys_mount_lock); */
+
+       uk_mutex_lock(&mount_lock);
+       uk_list_for_each_entry(mp, &mount_list, mnt_list) {
+               if (!strcmp(mp->m_path, dir) ||
+                   (device && mp->m_dev == device)) {
+                       error = EBUSY;  /* Already mounted */
+                       goto err1;
I think in the error case we are not releasing the lock.

                }
        }
+       uk_mutex_unlock(&mount_lock);
        /*
         * Create VFS mount entry.
         */
@@ -134,7 +139,7 @@ sys_mount(const char *dev, const char *dir, const char 
*fsname, int flags, const
        mp->m_op = fs->vs_op;
        mp->m_flags = flags;
        mp->m_dev = device;
-       mp->m_data = nullptr;
+       mp->m_data = NULL;
        strlcpy(mp->m_path, dir, sizeof(mp->m_path));
        strlcpy(mp->m_special, dev, sizeof(mp->m_special));
@@ -143,7 +148,7 @@ sys_mount(const char *dev, const char *dir, const char *fsname, int flags, const
         */
        if (*dir == '/' && *(dir + 1) == '\0') {
                /* Ignore if it mounts to global root directory. */
-               dp_covered = nullptr;
+               dp_covered = NULL;
        } else {
                if ((error = namei(dir, &dp_covered)) != 0) {
@@ -160,8 +165,8 @@ sys_mount(const char *dev, const char *dir, const char *fsname, int flags, const
        /*
         * Create a root vnode for this file system.
         */
-       vget(mp, 0, &vp);
-       if (vp == nullptr) {
+       vfscore_vget(mp, 0, &vp);
+       if (vp == NULL) {
                error = ENOMEM;
                goto err3;
        }
@@ -169,7 +174,7 @@ sys_mount(const char *dev, const char *dir, const char 
*fsname, int flags, const
        vp->v_flags = VROOT;
        vp->v_mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR;
- mp->m_root = dentry_alloc(nullptr, vp, "/");
+       mp->m_root = dentry_alloc(NULL, vp, "/");
        if (!mp->m_root) {
                vput(vp);
                goto err3;
@@ -188,9 +193,9 @@ sys_mount(const char *dev, const char *dir, const char 
*fsname, int flags, const
        /*
         * Insert to mount list
         */
-       WITH_LOCK(mount_lock) {
-               mount_list.push_back(mp);
-       }
+       uk_mutex_lock(&mount_lock);
+       uk_list_add_tail(&mp->mnt_list, &mount_list);
+       uk_mutex_unlock(&mount_lock);
return 0; /* success */
   err4:
@@ -222,12 +227,12 @@ release_mp_dentries(struct mount *mp)
  int
  sys_umount2(const char *path, int flags)
  {
-       struct mount *mp;
+       struct mount *mp, *tmp;
        int error, pathlen;
- kprintf("VFS: unmounting %s\n", path);
+       uk_pr_info("VFS: unmounting %s\n", path);
- SCOPE_LOCK(mount_lock);
+       uk_mutex_lock(&mount_lock);
pathlen = strlen(path);
        if (pathlen >= MAXPATHLEN) {
@@ -236,7 +241,7 @@ sys_umount2(const char *path, int flags)
        }
/* Get mount entry */
-       for (auto&& tmp : mount_list) {
+       uk_list_for_each_entry(tmp, &mount_list, mnt_list) {
                if (!strcmp(path, tmp->m_path)) {
                        mp = tmp;
                        goto found;
@@ -250,14 +255,14 @@ found:
        /*
         * Root fs can not be unmounted.
         */
-       if (mp->m_covered == nullptr && !(flags & MNT_FORCE)) {
+       if (mp->m_covered == NULL && !(flags & MNT_FORCE)) {
                error = EINVAL;
                goto out;
        }
if ((error = VFS_UNMOUNT(mp, flags)) != 0)
                goto out;
-       mount_list.remove(mp);
+       uk_list_del_init(&mp->mnt_list);
#ifdef HAVE_BUFFERS
        /* Flush all buffers */
@@ -268,6 +273,7 @@ found:
                device_close(mp->m_dev);
        free(mp);
   out:
+       uk_mutex_unlock(&mount_lock);
        return error;
  }
@@ -281,7 +287,7 @@ sys_umount(const char *path)
  int
  sys_pivot_root(const char *new_root, const char *put_old)
  {
-       struct mount *newmp = nullptr, *oldmp = nullptr;
+       struct mount *newmp = NULL, *oldmp = NULL;
        int error;
WITH_LOCK(mount_lock) {
@@ -314,12 +320,12 @@ sys_pivot_root(const char *new_root, const char *put_old)
                if (newmp->m_covered) {
                        drele(newmp->m_covered);
                }
-               newmp->m_covered = nullptr;
+               newmp->m_covered = NULL;
if (newmp->m_root->d_parent) {
                        drele(newmp->m_root->d_parent);
                }
-               newmp->m_root->d_parent = nullptr;
+               newmp->m_root->d_parent = NULL;
strlcpy(newmp->m_path, "/", sizeof(newmp->m_path));
        }
@@ -330,11 +336,12 @@ sys_pivot_root(const char *new_root, const char *put_old)
  int
  sys_sync(void)
  {
+       struct mount *mp;
+       uk_mutex_lock(&mount_lock);
+
We are not releasing the lock

        /* Call each mounted file system. */
-       WITH_LOCK(mount_lock) {
-               for (auto&& mp : mount_list) {
-                       VFS_SYNC(mp);
-               }
+       uk_list_for_each_entry(mp, &mount_list, mnt_list) {
+               VFS_SYNC(mp);
        }
  #ifdef HAVE_BUFFERS
        bio_sync();
@@ -380,22 +387,23 @@ count_match(const char *path, char *mount_root)
  int
  vfs_findroot(const char *path, struct mount **mp, char **root)
  {
-       struct mount *m = nullptr;
+       struct mount *m = NULL, *tmp;
        size_t len, max_len = 0;
if (!path)
                return -1;
/* Find mount point from nearest path */
-       SCOPE_LOCK(mount_lock);
-       for (auto&& tmp : mount_list) {
+       uk_mutex_lock(&mount_lock);
+       uk_list_for_each_entry(tmp, &mount_list, mnt_list) {
                len = count_match(path, tmp->m_path);
                if (len > max_len) {
                        max_len = len;
                        m = tmp;
                }
        }
-       if (m == nullptr)
+       uk_mutex_unlock(&mount_lock);
+       if (m == NULL)
                return -1;
        *root = (char *)(path + max_len);
        if (**root == '/')
@@ -410,8 +418,10 @@ vfs_findroot(const char *path, struct mount **mp, char 
**root)
  void
  vfs_busy(struct mount *mp)
  {
-       SCOPE_LOCK(mount_lock);
-       mp->m_count++;
+       /* The m_count is not really checked anywhere
+        * currently. Atomic is enough. But it could be that obtaining
+        * mount_lock will be needed in the future */
+       ukarch_inc(&mp->m_count);
  }
@@ -421,8 +431,10 @@ vfs_busy(struct mount *mp)
  void
  vfs_unbusy(struct mount *mp)
  {
-       SCOPE_LOCK(mount_lock);
-       mp->m_count--;
+       /* The m_count is not really checked anywhere
+        * currently. Atomic is enough. But it could be that obtaining
+        * mount_lock will be needed in the future */
+       ukarch_dec(&mp->m_count);
  }
int
@@ -441,14 +453,16 @@ vfs_einval(void)
  void
  mount_dump(void)
  {
-       SCOPE_LOCK(mount_lock);
+       struct mount *mp;
+       uk_mutex_lock(&mount_lock);
- kprintf("mount_dump\n");
-       kprintf("dev      count root\n");
-       kprintf("-------- ----- --------\n");
+       uk_pr_debug("mount_dump\n");
+       uk_pr_debug("dev      count root\n");
+       uk_pr_debug("-------- ----- --------\n");
- for (auto&& mp : mount_list) {
-               kprintf("%8x %5d %s\n", mp->m_dev, mp->m_count, mp->m_path);
+       uk_list_for_each_entry(mp, &mount_list, mnt_list) {
+               uk_pr_debug("%8p %5d %s\n", mp->m_dev, mp->m_count, mp->m_path);
        }
+       uk_mutex_unlock(&mount_lock);
  }
  #endif
diff --git a/lib/vfscore/subr_uio.c b/lib/vfscore/subr_uio.c
index bbca3362..d8e9d1be 100644
--- a/lib/vfscore/subr_uio.c
+++ b/lib/vfscore/subr_uio.c
@@ -48,7 +48,7 @@
  int
  uiomove(void *cp, int n, struct uio *uio)
  {
-       assert(uio->uio_rw == UIO_READ || uio->uio_rw == UIO_WRITE);
+       UK_ASSERT(uio->uio_rw == UIO_READ || uio->uio_rw == UIO_WRITE);
while (n > 0 && uio->uio_resid) {
                struct iovec *iov = uio->uio_iov;
diff --git a/lib/vfscore/syscalls.c b/lib/vfscore/syscalls.c
index f50fb38f..fa0498e7 100644
--- a/lib/vfscore/syscalls.c
+++ b/lib/vfscore/syscalls.c
@@ -65,9 +65,9 @@ open_no_follow_chk(char *path)
        struct dentry *dp;
        struct vnode  *vp;
- ddp = nullptr;
-       dp  = nullptr;
-       vp  = nullptr;
+       ddp = NULL;
+       dp  = NULL;
+       vp  = NULL;
error = lookup(path, &ddp, &name);
        if (error) {
@@ -88,15 +88,15 @@ open_no_follow_chk(char *path)
error = 0;
  out:
-       if (vp != nullptr) {
+       if (vp != NULL) {
                vn_unlock(vp);
        }
- if (dp != nullptr) {
+       if (dp != NULL) {
                drele(dp);
        }
- if (ddp != nullptr) {
+       if (ddp != NULL) {
                drele(ddp);
        }
@@ -104,9 +104,9 @@ out:
  }
int
-sys_open(char *path, int flags, mode_t mode, struct file **fpp)
+sys_open(char *path, int flags, mode_t mode, struct vfscore_file **fpp)
  {
-       file *fp;
+       struct vfscore_file *fp;
        struct dentry *dp, *ddp;
        struct vnode *vp;
        char *filename;
@@ -115,11 +115,11 @@ sys_open(char *path, int flags, mode_t mode, struct file 
**fpp)
        DPRINTF(VFSDB_SYSCALL, ("sys_open: path=%s flags=%x mode=%x\n",
                                path, flags, mode));
- flags = fflags(flags);
+       flags = vfscore_fflags(flags);
        if (flags & O_CREAT) {
                error = namei(path, &dp);
                if (error == ENOENT) {
-                       /* Create new file. */
+                       /* Create new struct vfscore_file. */
                        if ((error = lookup(path, &ddp, &filename)) != 0)
                                return error;
@@ -233,14 +233,14 @@ out_drele:
  }
int
-sys_close(struct file *fp)
+sys_close(struct vfscore_file *fp __unused)
  {
return 0;
  }
int
-sys_read(struct file *fp, const struct iovec *iov, size_t niov,
+sys_read(struct vfscore_file *fp, const struct iovec *iov, size_t niov,
                off_t offset, size_t *count)
  {
        int error = 0;
@@ -290,7 +290,7 @@ sys_read(struct file *fp, const struct iovec *iov, size_t 
niov,
  }
int
-sys_write(struct file *fp, const struct iovec *iov, size_t niov,
+sys_write(struct vfscore_file *fp, const struct iovec *iov, size_t niov,
                off_t offset, size_t *count)
  {
        struct iovec *copy_iov;
@@ -337,12 +337,12 @@ sys_write(struct file *fp, const struct iovec *iov, 
size_t niov,
  }
int
-sys_lseek(struct file *fp, off_t off, int type, off_t *origin)
+sys_lseek(struct vfscore_file *fp, off_t off, int type, off_t *origin)
  {
        struct vnode *vp;
- DPRINTF(VFSDB_SYSCALL, ("sys_seek: fp=%x off=%d type=%d\n",
-                               (u_long)fp, (u_int)off, type));
+       DPRINTF(VFSDB_SYSCALL, ("sys_seek: fp=%p off=%ud type=%d\n",
+                               fp, (unsigned int)off, type));
if (!fp->f_dentry) {
            // Linux doesn't implement lseek() on pipes, sockets, or ttys.
@@ -373,11 +373,11 @@ sys_lseek(struct file *fp, off_t off, int type, off_t 
*origin)
  }
int
-sys_ioctl(struct file *fp, u_long request, void *buf)
+sys_ioctl(struct vfscore_file *fp, unsigned long request, void *buf)
  {
        int error;
- DPRINTF(VFSDB_SYSCALL, ("sys_ioctl: fp=%x request=%x\n", fp, request));
+       DPRINTF(VFSDB_SYSCALL, ("sys_ioctl: fp=%p request=%lux\n", fp, 
request));
if ((fp->f_flags & (FREAD | FWRITE)) == 0)
                return EBADF;
@@ -389,7 +389,7 @@ sys_ioctl(struct file *fp, u_long request, void *buf)
  }
int
-sys_fsync(struct file *fp)
+sys_fsync(struct vfscore_file *fp)
  {
        struct vnode *vp;
        int error;
@@ -407,7 +407,7 @@ sys_fsync(struct file *fp)
  }
int
-sys_fstat(struct file *fp, struct stat *st)
+sys_fstat(struct vfscore_file *fp, struct stat *st)
  {
        int error = 0;
@@ -425,7 +425,7 @@ static int
  check_dir_empty(char *path)
  {
        int error;
-       struct file *fp;
+       struct vfscore_file *fp;
        struct dirent dir;
DPRINTF(VFSDB_SYSCALL, ("check_dir_empty\n"));
@@ -453,7 +453,7 @@ out_error:
  }
int
-sys_readdir(struct file *fp, struct dirent *dir)
+sys_readdir(struct vfscore_file *fp, struct dirent *dir)
  {
        struct vnode *dvp;
        int error;
@@ -477,7 +477,7 @@ sys_readdir(struct file *fp, struct dirent *dir)
  }
int
-sys_rewinddir(struct file *fp)
+sys_rewinddir(struct vfscore_file *fp)
  {
        struct vnode *dvp;
@@ -496,7 +496,7 @@ sys_rewinddir(struct file *fp)
  }
int
-sys_seekdir(struct file *fp, long loc)
+sys_seekdir(struct vfscore_file *fp, long loc)
  {
        struct vnode *dvp;
@@ -515,7 +515,7 @@ sys_seekdir(struct file *fp, long loc)
  }
int
-sys_telldir(struct file *fp, long *loc)
+sys_telldir(struct vfscore_file *fp, long *loc)
  {
        struct vnode *dvp;
@@ -662,14 +662,14 @@ sys_mknod(char *path, mode_t mode)
   *
   * Assumes both paths do not have trailing slashes.
   */
-static bool
+static int
  is_parent(const char *parent, const char *child)
  {
        size_t p_len = strlen(parent);
        return !strncmp(parent, child, p_len) && (parent[p_len-1] == '/' || 
child[p_len] == '/');
  }
-static bool
+static int
  has_trailing(const char *path, char ch)
  {
        size_t len = strlen(path);
@@ -695,16 +695,16 @@ sys_rename(char *src, char *dest)
        char *sname, *dname;
        int error;
        char root[] = "/";
-       bool ts; /* trailing slash */
+       int ts; /* trailing slash */
DPRINTF(VFSDB_SYSCALL, ("sys_rename: src=%s dest=%s\n", src, dest)); - ts = false;
-       if (has_trailing(src, '/') == true) {
+       ts = 0;
+       if (has_trailing(src, '/')) {
                if (strlen(src) != 1) {
                        /* remove trailing slash iff path is none root */
                        strip_trailing(src, '/');
-                       ts = true;
+                       ts = 1;
                }
        }
@@ -722,17 +722,17 @@ sys_rename(char *src, char *dest)
        vp1 = dp1->d_vnode;
        vn_lock(vp1);
- if (vp1->v_type != VDIR && ts == true) {
+       if (vp1->v_type != VDIR && ts) {
                error = ENOTDIR;
                goto err1;
        }
- ts = false;
-       if (has_trailing(dest, '/') == true) {
+       ts = 0;
+       if (has_trailing(dest, '/')) {
                if (strlen(dest) != 1) {
                        /* remove trailing slash iff path is none root */
                        strip_trailing(dest, '/');
-                       ts = true;
+                       ts = 1;
                }
        }
@@ -749,7 +749,7 @@ sys_rename(char *src, char *dest)
                vn_lock(vp2);
if (vp2->v_type != VDIR && vp2->v_type != VLNK) {
-                       if (vp1->v_type == VDIR || ts == true) {
+                       if (vp1->v_type == VDIR || ts) {
                                error = ENOTDIR;
                                goto err2;
                        }
@@ -762,7 +762,7 @@ sys_rename(char *src, char *dest)
                        goto err2;
                }
        } else if (error == ENOENT) {
-               if (vp1->v_type != VDIR && ts == true) {
+               if (vp1->v_type != VDIR && ts) {
                        error = ENOTDIR;
                        goto err2;
                }
@@ -787,7 +787,7 @@ sys_rename(char *src, char *dest)
        }
dname = strrchr(dest, '/');
-       if (dname == nullptr) {
+       if (dname == NULL) {
                error = ENOTDIR;
                goto err2;
        }
@@ -848,15 +848,15 @@ sys_symlink(const char *oldpath, const char *newpath)
        struct dentry   *newdirdp;
        char            *name;
- if (oldpath == nullptr || newpath == nullptr) {
+       if (oldpath == NULL || newpath == NULL) {
                return (EFAULT);
        }
DPRINTF(VFSDB_SYSCALL, ("sys_link: oldpath=%s newpath=%s\n",
                                oldpath, newpath));
- newdp = nullptr;
-       newdirdp        = nullptr;
+       newdp           = NULL;
+       newdirdp        = NULL;
error = task_conv(t, newpath, VWRITE, np);
        if (error != 0) {
@@ -892,7 +892,7 @@ sys_symlink(const char *oldpath, const char *newpath)
        error = VOP_SYMLINK(newdirdp->d_vnode, name, op);
out:
-       if (newdirdp != nullptr) {
+       if (newdirdp != NULL) {
                vn_unlock(newdirdp->d_vnode);
                drele(newdirdp);
        }
@@ -972,9 +972,9 @@ sys_unlink(char *path)
DPRINTF(VFSDB_SYSCALL, ("sys_unlink: path=%s\n", path)); - ddp = nullptr;
-       dp    = nullptr;
-       vp    = nullptr;
+       ddp   = NULL;
+       dp    = NULL;
+       vp    = NULL;
error = lookup(path, &ddp, &name);
        if (error != 0) {
@@ -1013,15 +1013,15 @@ sys_unlink(char *path)
        drele(dp);
        return error;
   out:
-       if (vp != nullptr) {
+       if (vp != NULL) {
                vn_unlock(vp);
        }
- if (dp != nullptr) {
+       if (dp != NULL) {
                drele(dp);
        }
- if (ddp != nullptr) {
+       if (ddp != NULL) {
                drele(ddp);
        }
        return error;
@@ -1115,7 +1115,7 @@ sys_statfs(char *path, struct statfs *buf)
  }
int
-sys_fstatfs(struct file *fp, struct statfs *buf)
+sys_fstatfs(struct vfscore_file *fp, struct statfs *buf)
  {
        struct vnode *vp;
        int error = 0;
@@ -1152,7 +1152,7 @@ sys_truncate(char *path, off_t length)
  }
int
-sys_ftruncate(struct file *fp, off_t length)
+sys_ftruncate(struct vfscore_file *fp, off_t length)
  {
        struct vnode *vp;
        int error;
@@ -1169,7 +1169,7 @@ sys_ftruncate(struct file *fp, off_t length)
  }
int
-sys_fchdir(struct file *fp, char *cwd)
+sys_fchdir(struct vfscore_file *fp, char *cwd)
  {
        struct vnode *dvp;
@@ -1244,7 +1244,7 @@ sys_readlink(char *path, char *buf, size_t bufsize, ssize_t *size)
  /*
   * Check the validity of the members of a struct timeval.
   */
-static bool is_timeval_valid(const struct timeval *time)
+static int is_timeval_valid(const struct timeval *time)
  {
        return (time->tv_sec >= 0) &&
                   (time->tv_usec >= 0 && time->tv_usec < 1000000);
@@ -1276,18 +1276,18 @@ sys_utimes(char *path, const struct timeval times[2], 
int flags)
                return EINVAL;
// Convert each element of timeval array to the timespec type
-       convert_timeval(timespec_times[0], times ? times + 0 : nullptr);
-       convert_timeval(timespec_times[1], times ? times + 1 : nullptr);
+       convert_timeval(timespec_times[0], times ? times + 0 : NULL);
+       convert_timeval(timespec_times[1], times ? times + 1 : NULL);
if (flags & AT_SYMLINK_NOFOLLOW) {
                struct dentry *ddp;
-               error = lookup(path, &ddp, nullptr);
+               error = lookup(path, &ddp, NULL);
                if (error) {
                        return error;
                }
error = namei_last_nofollow(path, ddp, &dp);
-               if (ddp != nullptr) {
+               if (ddp != NULL) {
                        drele(ddp);
                }
                if (error) {
@@ -1312,7 +1312,7 @@ sys_utimes(char *path, const struct timeval times[2], int 
flags)
  /*
   * Check the validity of members of a struct timespec
   */
-static bool is_timespec_valid(const struct timespec &time)
+static int is_timespec_valid(const struct timespec &time)
  {
        return (time.tv_sec >= 0) &&
           ((time.tv_nsec >= 0 && time.tv_nsec <= 999999999) ||
@@ -1322,7 +1322,7 @@ static bool is_timespec_valid(const struct timespec &time)
void init_timespec(struct timespec &_times, const struct timespec *times)
  {
-       if (times == nullptr || times->tv_nsec == UTIME_NOW) {
+       if (times == NULL || times->tv_nsec == UTIME_NOW) {
                clock_gettime(CLOCK_REALTIME, &_times);
        } else {
                _times.tv_sec = times->tv_sec;
@@ -1350,8 +1350,8 @@ sys_utimensat(int dirfd, const char *pathname, const 
struct timespec times[2], i
        if (times && (!is_timespec_valid(times[0]) || 
!is_timespec_valid(times[1])))
                return EINVAL;
- init_timespec(timespec_times[0], times ? times + 0 : nullptr);
-       init_timespec(timespec_times[1], times ? times + 1 : nullptr);
+       init_timespec(timespec_times[0], times ? times + 0 : NULL);
+       init_timespec(timespec_times[1], times ? times + 1 : NULL);
if (pathname && pathname[0] == '/') {
        ap = pathname;
@@ -1360,7 +1360,7 @@ sys_utimensat(int dirfd, const char *pathname, const 
struct timespec times[2], i
            return EFAULT;
        ap = std::string(main_task->t_cwd) + "/" + pathname;
        } else {
-               struct file *fp;
+               struct vfscore_file *fp;
                fileref f(fileref_from_fd(dirfd));
if (!f)
@@ -1410,7 +1410,7 @@ sys_utimensat(int dirfd, const char *pathname, const 
struct timespec times[2], i
  int
  sys_futimens(int fd, const struct timespec times[2])
  {
-       struct file *fp;
+       struct vfscore_file *fp;
fileref f(fileref_from_fd(fd));
        if (!f)
@@ -1428,7 +1428,7 @@ sys_futimens(int fd, const struct timespec times[2])
  #endif
int
-sys_fallocate(struct file *fp, int mode, loff_t offset, loff_t len)
+sys_fallocate(struct vfscore_file *fp, int mode, off_t offset, off_t len)
  {
        int error;
        struct vnode *vp;
@@ -1493,7 +1493,7 @@ sys_chmod(const char *path, mode_t mode)
  int
  sys_fchmod(int fd, mode_t mode)
  {
-       fileref f(fileref_from_fd(fd));
+       struct vfscore_file *f = vfscore_get_file(fd);
        if (!f)
                return EBADF;
        // Posix is ambivalent on what fchmod() should do on an fd that does not
diff --git a/lib/vfscore/vfs.h b/lib/vfscore/vfs.h
index 2531f730..19f8ac87 100644
--- a/lib/vfscore/vfs.h
+++ b/lib/vfscore/vfs.h
@@ -57,7 +57,7 @@ extern int vfs_debug;
#define VFSDB_FLAGS 0x00000013 -#define DPRINTF(_m,X) if (vfs_debug & (_m)) kprintf X
+#define        DPRINTF(_m,X)   if (vfs_debug & (_m)) uk_pr_debug X
  #else
  #define       DPRINTF(_m, X)
  #endif
@@ -71,28 +71,26 @@ extern int vfs_debug;
   */
  struct task {
        char        t_cwd[PATH_MAX];    /* current working directory */
-       struct file *t_cwdfp;           /* directory for cwd */
+       struct vfscore_file *t_cwdfp;           /* directory for cwd */
  };
-extern const struct vfssw vfssw[];
-
-int     sys_open(char *path, int flags, mode_t mode, struct file **fp);
-int     sys_read(struct file *fp, const struct iovec *iov, size_t niov,
+int     sys_open(char *path, int flags, mode_t mode, struct vfscore_file **fp);
+int     sys_read(struct vfscore_file *fp, const struct iovec *iov, size_t niov,
                off_t offset, size_t *count);
-int     sys_write(struct file *fp, const struct iovec *iov, size_t niov,
+int     sys_write(struct vfscore_file *fp, const struct iovec *iov, size_t 
niov,
                off_t offset, size_t *count);
-int     sys_lseek(struct file *fp, off_t off, int type, off_t * cur_off);
-int     sys_ioctl(struct file *fp, u_long request, void *buf);
-int     sys_fstat(struct file *fp, struct stat *st);
-int     sys_fstatfs(struct file *fp, struct statfs *buf);
-int     sys_fsync(struct file *fp);
-int     sys_ftruncate(struct file *fp, off_t length);
-
-int     sys_readdir(struct file *fp, struct dirent *dirent);
-int     sys_rewinddir(struct file *fp);
-int     sys_seekdir(struct file *fp, long loc);
-int     sys_telldir(struct file *fp, long *loc);
-int     sys_fchdir(struct file *fp, char *path);
+int     sys_lseek(struct vfscore_file *fp, off_t off, int type, off_t * 
cur_off);
+int     sys_ioctl(struct vfscore_file *fp, unsigned long request, void *buf);
+int     sys_fstat(struct vfscore_file *fp, struct stat *st);
+int     sys_fstatfs(struct vfscore_file *fp, struct statfs *buf);
+int     sys_fsync(struct vfscore_file *fp);
+int     sys_ftruncate(struct vfscore_file *fp, off_t length);
+
+int     sys_readdir(struct vfscore_file *fp, struct dirent *dirent);
+int     sys_rewinddir(struct vfscore_file *fp);
+int     sys_seekdir(struct vfscore_file *fp, long loc);
+int     sys_telldir(struct vfscore_file *fp, long *loc);
+int     sys_fchdir(struct vfscore_file *fp, char *path);
int sys_mkdir(char *path, mode_t mode);
  int    sys_rmdir(char *path);
@@ -111,7 +109,7 @@ int  sys_utimes(char *path, const struct timeval times[2], 
int flags);
  int  sys_utimensat(int dirfd, const char *pathname,
                                   const struct timespec times[2], int flags);
  int  sys_futimens(int fd, const struct timespec times[2]);
-int  sys_fallocate(struct file *fp, int mode, loff_t offset, loff_t len);
+int  sys_fallocate(struct vfscore_file *fp, int mode, loff_t offset, loff_t 
len);
int sys_mount(const char *dev, const char *dir, const char *fsname, int flags, const void *data);
  int    sys_umount2(const char *path, int flags);
diff --git a/lib/vfscore/vnode.c b/lib/vfscore/vnode.c
index 81f78be8..a2f45596 100644
--- a/lib/vfscore/vnode.c
+++ b/lib/vfscore/vnode.c
@@ -77,24 +77,27 @@ int vttoif_tab[10] = {
   * All active (opened) vnodes are stored on this hash table.
   * They can be accessed by its path name.
   */
-static LIST_HEAD(vnode_hash_head, vnode) vnode_table[VNODE_BUCKETS];
+static struct uk_list_head vnode_table[VNODE_BUCKETS];
/*
   * Global lock to access all vnodes and vnode table.
   * If a vnode is already locked, there is no need to
   * lock this global lock to access internal data.
   */
-static mutex_t vnode_lock = MUTEX_INITIALIZER;
-#define VNODE_LOCK()   mutex_lock(&vnode_lock)
-#define VNODE_UNLOCK() mutex_unlock(&vnode_lock)
-#define VNODE_OWNED()  mutex_owned(&vnode_lock)
+static struct uk_mutex vnode_lock = UK_MUTEX_INITIALIZER(vnode_lock);
+#define VNODE_LOCK()   uk_mutex_lock(&vnode_lock)
+#define VNODE_UNLOCK() uk_mutex_unlock(&vnode_lock)
+
+/* TODO: implement mutex_owned */
+#define VNODE_OWNED()  (1)
+/* #define VNODE_OWNED()       mutex_owned(&vnode_lock) */
+
/*
   * Get the hash value from the mount point and path name.
   * XXX(hch): replace with a better hash for 64-bit pointers.
   */
-static u_int
-vn_hash(struct mount *mp, uint64_t ino)
+static unsigned int vn_hash(struct mount *mp, uint64_t ino)
  {
        return (ino ^ (unsigned long)mp) & (VNODE_BUCKETS - 1);
  }
@@ -110,16 +113,15 @@ vn_lookup(struct mount *mp, uint64_t ino)
  {
        struct vnode *vp;
- assert(VNODE_OWNED());
-       LIST_FOREACH(vp, &vnode_table[vn_hash(mp, ino)], v_link) {
+       UK_ASSERT(VNODE_OWNED());
+       uk_list_for_each_entry(vp, &vnode_table[vn_hash(mp, ino)], v_link) {
                if (vp->v_mount == mp && vp->v_ino == ino) {
                        vp->v_refcnt++;
-                       mutex_lock(&vp->v_lock);
-                       vp->v_nrlocks++;
+                       uk_mutex_lock(&vp->v_lock);
                        return vp;
                }
        }
-       return nullptr;         /* not found */
+       return NULL;            /* not found */
  }
#ifdef DEBUG_VFS
@@ -128,10 +130,10 @@ vn_path(struct vnode *vp)
  {
        struct dentry *dp;
- if (LIST_EMPTY(&vp->v_names) == 1) {
+       if (uk_list_empty(&vp->v_names) == 1) {
                return (" ");
        }
-       dp = LIST_FIRST(&vp->v_names);
+       dp = uk_list_first_entry(&vp->v_names, struct dentry, d_names_link);
        return (dp->d_path);
  }
  #endif
@@ -142,11 +144,10 @@ vn_path(struct vnode *vp)
  void
  vn_lock(struct vnode *vp)
  {
-       ASSERT(vp);
-       ASSERT(vp->v_refcnt > 0);
+       UK_ASSERT(vp);
+       UK_ASSERT(vp->v_refcnt > 0);
- mutex_lock(&vp->v_lock);
-       vp->v_nrlocks++;
+       uk_mutex_lock(&vp->v_lock);
        DPRINTF(VFSDB_VNODE, ("vn_lock:   %s\n", vn_path(vp)));
  }
@@ -156,12 +157,10 @@ vn_lock(struct vnode *vp)
  void
  vn_unlock(struct vnode *vp)
  {
-       ASSERT(vp);
-       ASSERT(vp->v_refcnt > 0);
-       ASSERT(vp->v_nrlocks > 0);
+       UK_ASSERT(vp);
+       UK_ASSERT(vp->v_refcnt >= 0);
- vp->v_nrlocks--;
-       mutex_unlock(&vp->v_lock);
+       uk_mutex_unlock(&vp->v_lock);
        DPRINTF(VFSDB_VNODE, ("vn_lock:   %s\n", vn_path(vp)));
  }
@@ -176,7 +175,7 @@ vget(struct mount *mp, uint64_t ino, struct vnode **vpp)
        struct vnode *vp;
        int error;
- *vpp = nullptr;
+       *vpp = NULL;
DPRINTF(VFSDB_VNODE, ("vget %LLu\n", ino)); @@ -195,26 +194,24 @@ vget(struct mount *mp, uint64_t ino, struct vnode **vpp)
                return 0;
        }
- LIST_INIT(&vp->v_names);
+       UK_INIT_LIST_HEAD(&vp->v_names);
        vp->v_ino = ino;
        vp->v_mount = mp;
        vp->v_refcnt = 1;
        vp->v_op = mp->m_op->vfs_vnops;
-       vp->v_nrlocks = 0;
-
+       uk_mutex_init(&vp->v_lock);
        /*
         * Request to allocate fs specific data for vnode.
         */
        if ((error = VFS_VGET(mp, vp)) != 0) {
                VNODE_UNLOCK();
-               delete vp;
+               free(vp);
                return error;
        }
        vfs_busy(vp->v_mount);
-       mutex_lock(&vp->v_lock);
-       vp->v_nrlocks++;
+       uk_mutex_lock(&vp->v_lock);
- LIST_INSERT_HEAD(&vnode_table[vn_hash(mp, ino)], vp, v_link);
+       uk_list_add(&vp->v_link, &vnode_table[vn_hash(mp, ino)]);
        VNODE_UNLOCK();
*vpp = vp;
@@ -228,9 +225,8 @@ vget(struct mount *mp, uint64_t ino, struct vnode **vpp)
  void
  vput(struct vnode *vp)
  {
-       ASSERT(vp);
-       ASSERT(vp->v_nrlocks > 0);
-       ASSERT(vp->v_refcnt > 0);
+       UK_ASSERT(vp);
+       UK_ASSERT(vp->v_refcnt > 0);
        DPRINTF(VFSDB_VNODE, ("vput: ref=%d %s\n", vp->v_refcnt, vn_path(vp)));
VNODE_LOCK();
@@ -240,7 +236,7 @@ vput(struct vnode *vp)
                vn_unlock(vp);
                return;
        }
-       LIST_REMOVE(vp, v_link);
+       uk_list_del(&vp->v_link);
        VNODE_UNLOCK();
/*
@@ -249,10 +245,8 @@ vput(struct vnode *vp)
        if (vp->v_op->vop_inactive)
                VOP_INACTIVE(vp);
        vfs_unbusy(vp->v_mount);
-       vp->v_nrlocks--;
-       ASSERT(vp->v_nrlocks == 0);
-       mutex_unlock(&vp->v_lock);
-       delete vp;
+       uk_mutex_unlock(&vp->v_lock);
+       free(vp);
  }
/*
@@ -261,8 +255,8 @@ vput(struct vnode *vp)
  void
  vref(struct vnode *vp)
  {
-       ASSERT(vp);
-       ASSERT(vp->v_refcnt > 0); /* Need vget */
+       UK_ASSERT(vp);
+       UK_ASSERT(vp->v_refcnt > 0);      /* Need vfscore_vget */
VNODE_LOCK();
        DPRINTF(VFSDB_VNODE, ("vref: ref=%d\n", vp->v_refcnt));
@@ -279,8 +273,8 @@ vref(struct vnode *vp)
  void
  vrele(struct vnode *vp)
  {
-       ASSERT(vp);
-       ASSERT(vp->v_refcnt > 0);
+       UK_ASSERT(vp);
+       UK_ASSERT(vp->v_refcnt > 0);
VNODE_LOCK();
        DPRINTF(VFSDB_VNODE, ("vrele: ref=%d\n", vp->v_refcnt));
@@ -289,7 +283,7 @@ vrele(struct vnode *vp)
                VNODE_UNLOCK();
                return;
        }
-       LIST_REMOVE(vp, v_link);
+       uk_list_del(&vp->v_link);
        VNODE_UNLOCK();
/*
@@ -297,7 +291,7 @@ vrele(struct vnode *vp)
         */
        VOP_INACTIVE(vp);
        vfs_unbusy(vp->v_mount);
-       delete vp;
+       free(vp);
  }
/*
@@ -456,21 +450,25 @@ vnode_dump(void)
                           "VLNK ", "VSOCK", "VFIFO" };
VNODE_LOCK();
-       kprintf("Dump vnode\n");
-       kprintf(" vnode    mount    type  refcnt blkno    path\n");
-       kprintf(" -------- -------- ----- ------ -------- 
------------------------------\n");
+
+       uk_pr_debug("Dump vnode\n");
+       uk_pr_debug(" vnode            mount            type  refcnt path\n");
+       uk_pr_debug(" ---------------- ---------------- ----- ------ 
------------------------------\n");
for (i = 0; i < VNODE_BUCKETS; i++) {
-               LIST_FOREACH(vp, &vnode_table[i], v_link) {
+               uk_list_for_each_entry(vp, &vnode_table[i], v_link) {
                        mp = vp->v_mount;
- kprintf(" %08x %08x %s %6d %8d %s%s\n", (u_long)vp,
-                               (u_long)mp, type[vp->v_type], vp->v_refcnt,
-                               (strlen(mp->m_path) == 1) ? "\0" : mp->m_path,
-                               vn_path(vp));
+
+                       uk_pr_debug(" %016lx %016lx %s %6d %s%s\n",
+                                   (unsigned long) vp,
+                                   (unsigned long) mp, type[vp->v_type],
+                                   vp->v_refcnt,
+                                   (strlen(mp->m_path) == 1) ? "\0" : 
mp->m_path,
+                                   vn_path(vp));
                }
        }
-       kprintf("\n");
+       uk_pr_debug("\n");
        VNODE_UNLOCK();
  }
  #endif
@@ -509,20 +507,22 @@ vnode_init(void)
        int i;
for (i = 0; i < VNODE_BUCKETS; i++)
-               LIST_INIT(&vnode_table[i]);
+               UK_INIT_LIST_HEAD(&vnode_table[i]);
  }
void vn_add_name(struct vnode *vp, struct dentry *dp)
  {
-       vn_lock(vp);
-       LIST_INSERT_HEAD(&vp->v_names, dp, d_names_link);
-       vn_unlock(vp);
+       /* TODO: Re-enable this check when preemption and/or smp is
+        * here */
+       /* UK_ASSERT(uk_mutex_is_locked(&vp->v_lock)); */
+       uk_list_add(&dp->d_names_link, &vp->v_names);
  }
void vn_del_name(struct vnode *vp, struct dentry *dp)
  {
-       vn_lock(vp);
-       LIST_REMOVE(dp, d_names_link);
-       vn_unlock(vp);
+       /* TODO: Re-enable this check when preemption and/or smp is
+        * here */
+       /* UK_ASSERT(uk_mutex_is_locked(&vp->v_lock)); */
+       uk_list_del(&dp->d_names_link);
  }

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.