[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [PATCH] vfscore: set errno in all cases during mount
'errno' is a global variable which is part of the API. It is used to pass failure codes to calling functions when system calls fail. Modify the 'mount' system call to set this global variable in all failure cases to provide more information to the caller. Signed-off-by: Joel Nider <joel@xxxxxxxxx> --- lib/vfscore/mount.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/vfscore/mount.c b/lib/vfscore/mount.c index 9d7ace1..2a93453 100644 --- a/lib/vfscore/mount.c +++ b/lib/vfscore/mount.c@@ -116,16 +116,19 @@ mount(const char *dev, const char *dir, const char *fsname, int flags, const voi struct device *device; struct dentry *dp_covered = NULL; struct vnode *vp = NULL; - int error; uk_pr_info("VFS: mounting %s at %s\n", fsname, dir); - if (!dir || *dir == '\0') + if (!dir || *dir == '\0') { + errno = ENOENT; return ENOENT; + } /* Find a file system. */ - if (!(fs = fs_getfs(fsname))) + if (!(fs = fs_getfs(fsname))) { + errno = ENODEV; return ENODEV; /* No such file system */ + } /* Open device. NULL can be specified as a device. */ // Allow device_open() to fail, in which case dev is interpreted@@ -151,7 +154,7 @@ mount(const char *dev, const char *dir, const char *fsname, int flags, const voi 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 */ + errno = EBUSY; /* Already mounted */ uk_mutex_unlock(&mount_lock); goto err1; }@@ -162,7 +165,7 @@ mount(const char *dev, const char *dir, const char *fsname, int flags, const voi */ mp = malloc(sizeof(struct mount)); if (!mp) { - error = ENOMEM; + errno = ENOMEM; goto err1; } mp->m_count = 0;@@ -180,13 +183,12 @@ mount(const char *dev, const char *dir, const char *fsname, int flags, const voi /* Ignore if it mounts to global root directory. */ dp_covered = NULL; } else { - if ((error = namei(dir, &dp_covered)) != 0) { - - error = ENOENT; + if ((namei(dir, &dp_covered)) != 0) { + errno = ENOENT; goto err2; } if (dp_covered->d_vnode->v_type != VDIR) { - error = ENOTDIR; + errno = ENOTDIR; goto err3; } }@@ -197,7 +199,7 @@ mount(const char *dev, const char *dir, const char *fsname, int flags, const voi */ vfscore_vget(mp, 0, &vp); if (vp == NULL) { - error = ENOMEM; + errno = ENOMEM; goto err3; } vp->v_type = VDIR;@@ -205,16 +207,15 @@ mount(const char *dev, const char *dir, const char *fsname, int flags, const voi vp->v_mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR; mp->m_root = dentry_alloc(NULL, vp, "/"); - if (!mp->m_root) { - vput(vp); - goto err3; - } vput(vp); + if (!mp->m_root) + goto err3; /* * Call a file system specific routine. */ - if ((error = VFS_MOUNT(mp, dev, flags, data)) != 0) + errno = VFS_MOUNT(mp, dev, flags, data); + if (errno != 0) goto err4; if (mp->m_flags & MNT_RDONLY)@@ -239,7 +240,7 @@ mount(const char *dev, const char *dir, const char *fsname, int flags, const voi if (device) device_close(device); - return error; + return errno; } void -- 2.20.1 -- Joel Nider Electrical and Computer Engineering University of British Columbia 778-838-9345 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |