summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-07-22 17:03:14 +0000
committerrwatson <rwatson@FreeBSD.org>2004-07-22 17:03:14 +0000
commit01be595ab33612b855914baf3ef7b67166cbe2ed (patch)
treecdb057b665021dafc3545bb0c6e6512858681ed2 /sys
parentaafe09f5863c0dee265c3ee3ba4f537356c44af2 (diff)
downloadFreeBSD-src-01be595ab33612b855914baf3ef7b67166cbe2ed.zip
FreeBSD-src-01be595ab33612b855914baf3ef7b67166cbe2ed.tar.gz
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.
Diffstat (limited to 'sys')
-rw-r--r--sys/fs/devfs/devfs_vnops.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c
index 2d7468a..88cff6a 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);
}
OpenPOWER on IntegriCloud