Bug #35

unmount-ncp.diff (see comments on kernel@)

Added by csaba.henk over 8 years ago. Updated over 7 years ago.

Status:ClosedStart date:
Priority:LowDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

# HG changeset patch
# User root@
# Node ID 758f5a725024e40c276e253651f9115aa4ba9fbe
# Parent 322bdf54fc0aeddb365a01452e57c144bf8986aa
imported patch ncp_unmount

diff -r 322bdf54fc0a -r 758f5a725024 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c Mon Jan 2 11:41:48 2006 +0000
+++ b/sys/kern/vfs_syscalls.c Mon Jan 2 11:42:05 2006 +0000
@@ -453,7 +453,6 @@
{
struct thread *td = curthread;
struct proc *p = td->td_proc;
- struct vnode *vp;
struct mount *mp;
int error;
struct nlookupdata nd;
@@ -464,44 +463,42 @@
if (usermount == 0 && (error = suser(td)))
return (error);

- vp = NULL;
error = nlookup_init(&nd, uap->path, UIO_USERSPACE, NLC_FOLLOW);
if (error == 0)
error = nlookup(&nd);
- if (error == 0)
- error = cache_vget(nd.nl_ncp, nd.nl_cred, LK_EXCLUSIVE, &vp);
+ if (error)
+ goto out;
+
+ mp = nd.nl_ncp->nc_mount;
+
+ /*
+ * Only root, or the user that did the original mount is
+ * permitted to unmount this filesystem.
+ */
+ if ((mp->mnt_stat.f_owner != p->p_ucred->cr_uid) &&
+ (error = suser(td)))
+ goto out;
+
+ /*
+ * Don't allow unmounting the root file system.
+ */
+ if (mp->mnt_flag & MNT_ROOTFS) {
+ error = EINVAL;
+ goto out;
+ }
+
+ /*
+ * Must be the root of the filesystem
+ */
+ if (! (nd.nl_ncp->nc_flag & NCF_MOUNTPT)) {
+ error = EINVAL;
+ goto out;
+ }
+
+out:
nlookup_done(&nd);
if (error)
return (error);
-
- mp = vp->v_mount;
-
- /*
- * Only root, or the user that did the original mount is
- * permitted to unmount this filesystem.
- */
- if ((mp->mnt_stat.f_owner != p->p_ucred->cr_uid) &&
- (error = suser(td))) {
- vput(vp);
- return (error);
- }
-
- /*
- * Don't allow unmounting the root file system.
- */
- if (mp->mnt_flag & MNT_ROOTFS) {
- vput(vp);
- return (EINVAL);
- }
-
- /*
- * Must be the root of the filesystem
- */
- if ((vp->v_flag & VROOT) == 0) {
- vput(vp);
- return (EINVAL);
- }
- vput(vp);
return (dounmount(mp, uap->flags, td));
}

History

#1 Updated by corecode over 8 years ago

committed by dillon

Also available in: Atom PDF