diff options
author | Robert Watson <rwatson@FreeBSD.org> | 2004-07-22 17:03:14 +0000 |
---|---|---|
committer | Robert Watson <rwatson@FreeBSD.org> | 2004-07-22 17:03:14 +0000 |
commit | de592112e1083b4ac4e4fc2c090db7ef2ef01570 (patch) | |
tree | cdb057b665021dafc3545bb0c6e6512858681ed2 /sys/fs/devfs | |
parent | 17ee0667ebd851aa014c69f47d99febcf664629e (diff) | |
download | src-de592112e1083b4ac4e4fc2c090db7ef2ef01570.tar.gz src-de592112e1083b4ac4e4fc2c090db7ef2ef01570.zip |
In devfs_allocv(), rather than assigning 'td = curthread', assert that
the caller passes in a td that is curthread, and consistently pass 'td'
into vget(). Remove some bogus logic that passed in td or curthread
conditional on td being non-NULL, which seems redundant in the face of
the earlier assignment of td to curthread if td is NULL.
In devfs_symlink(), cache the passed thread in 'td' so we don't have
to keep retrieving it from the 'ap' structure, and assert that td is
curthread (since we dereference it to get thread-local td_ucred). Use
'td' in preference to curthread for later lockmgr calls, since they are
equal.
Notes
Notes:
svn path=/head/; revision=132547
Diffstat (limited to 'sys/fs/devfs')
-rw-r--r-- | sys/fs/devfs/devfs_vnops.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 2d7468a12718..88cff6af4084 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -125,12 +125,11 @@ devfs_allocv(struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, stru struct vnode *vp; struct cdev *dev; - if (td == NULL) - td = curthread; /* XXX */ + KASSERT(td == curthread, ("devfs_allocv: td != curthread")); loop: vp = de->de_vnode; if (vp != NULL) { - if (vget(vp, LK_EXCLUSIVE, td ? td : curthread)) + if (vget(vp, LK_EXCLUSIVE, td)) goto loop; *vpp = vp; return (0); @@ -849,8 +848,11 @@ devfs_symlink(ap) struct devfs_dirent *dd; struct devfs_dirent *de; struct devfs_mount *dmp; + struct thread *td; - error = suser(ap->a_cnp->cn_thread); + td = ap->a_cnp->cn_thread; + KASSERT(td == curthread, ("devfs_symlink: td != curthread")); + error = suser(td); if (error) return(error); dmp = VFSTODEVFS(ap->a_dvp->v_mount); @@ -864,13 +866,13 @@ devfs_symlink(ap) i = strlen(ap->a_target) + 1; MALLOC(de->de_symlink, char *, i, M_DEVFS, M_WAITOK); bcopy(ap->a_target, de->de_symlink, i); - lockmgr(&dmp->dm_lock, LK_EXCLUSIVE, 0, curthread); + lockmgr(&dmp->dm_lock, LK_EXCLUSIVE, 0, td); #ifdef MAC mac_create_devfs_symlink(ap->a_cnp->cn_cred, dmp->dm_mount, dd, de); #endif TAILQ_INSERT_TAIL(&dd->de_dlist, de, de_list); - devfs_allocv(de, ap->a_dvp->v_mount, ap->a_vpp, 0); - lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curthread); + devfs_allocv(de, ap->a_dvp->v_mount, ap->a_vpp, td); + lockmgr(&dmp->dm_lock, LK_RELEASE, 0, td); return (0); } |