summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2008-08-28 15:23:18 +0000
committerattilio <attilio@FreeBSD.org>2008-08-28 15:23:18 +0000
commitdbf35e279f37ad4a573bf93923d141cb4a454c7d (patch)
tree61fe2ab5660fec327061e18eda0ed8c65276f262 /sys/kern
parentfb7f3b6363b61cead7eb5e94ac7f816358fc19ab (diff)
downloadFreeBSD-src-dbf35e279f37ad4a573bf93923d141cb4a454c7d.zip
FreeBSD-src-dbf35e279f37ad4a573bf93923d141cb4a454c7d.tar.gz
Decontextualize the couplet VOP_GETATTR / VOP_SETATTR as the passed thread
was always curthread and totally unuseful. Tested by: Giovanni Trematerra <giovanni dot trematerra at gmail dot com>
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/imgact_shell.c2
-rw-r--r--sys/kern/kern_exec.c4
-rw-r--r--sys/kern/kern_linker.c4
-rw-r--r--sys/kern/kern_sig.c4
-rw-r--r--sys/kern/uipc_mqueue.c16
-rw-r--r--sys/kern/vfs_default.c16
-rw-r--r--sys/kern/vfs_mount.c2
-rw-r--r--sys/kern/vfs_subr.c8
-rw-r--r--sys/kern/vfs_syscalls.c26
-rw-r--r--sys/kern/vfs_vnops.c6
-rw-r--r--sys/kern/vnode_if.src2
11 files changed, 46 insertions, 44 deletions
diff --git a/sys/kern/imgact_shell.c b/sys/kern/imgact_shell.c
index 99b4c27..e0248a7 100644
--- a/sys/kern/imgact_shell.c
+++ b/sys/kern/imgact_shell.c
@@ -121,7 +121,7 @@ exec_shell_imgact(imgp)
* valid -- the actual file might be much shorter than the page.
* So find out the file size.
*/
- error = VOP_GETATTR(imgp->vp, &vattr, imgp->proc->p_ucred, curthread);
+ error = VOP_GETATTR(imgp->vp, &vattr, imgp->proc->p_ucred);
if (error)
return (error);
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 8ea45d5..ab972f1 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -797,7 +797,7 @@ interpret:
exec_setregs(td, imgp->entry_addr,
(u_long)(uintptr_t)stack_base, imgp->ps_strings);
- vfs_mark_atime(imgp->vp, td);
+ vfs_mark_atime(imgp->vp, td->td_ucred);
done1:
@@ -1287,7 +1287,7 @@ exec_check_permissions(imgp)
td = curthread;
/* Get file attributes */
- error = VOP_GETATTR(vp, attr, td->td_ucred, td);
+ error = VOP_GETATTR(vp, attr, td->td_ucred);
if (error)
return (error);
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index a36c7be..9f322d7 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -1638,7 +1638,7 @@ linker_lookup_file(const char *path, int pathlen, const char *name,
NDFREE(&nd, NDF_ONLY_PNBUF);
type = nd.ni_vp->v_type;
if (vap)
- VOP_GETATTR(nd.ni_vp, vap, td->td_ucred, td);
+ VOP_GETATTR(nd.ni_vp, vap, td->td_ucred);
VOP_UNLOCK(nd.ni_vp, 0);
vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
VFS_UNLOCK_GIANT(vfslocked);
@@ -1691,7 +1691,7 @@ linker_hints_lookup(const char *path, int pathlen, const char *modname,
if (nd.ni_vp->v_type != VREG)
goto bad;
best = cp = NULL;
- error = VOP_GETATTR(nd.ni_vp, &vattr, cred, td);
+ error = VOP_GETATTR(nd.ni_vp, &vattr, cred);
if (error)
goto bad;
/*
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 00c29d1..d5d1813 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -2962,7 +2962,7 @@ restart:
/* Don't dump to non-regular files or files with links. */
if (vp->v_type != VREG ||
- VOP_GETATTR(vp, &vattr, cred, td) || vattr.va_nlink != 1) {
+ VOP_GETATTR(vp, &vattr, cred) || vattr.va_nlink != 1) {
VOP_UNLOCK(vp, 0);
error = EFAULT;
goto close;
@@ -2993,7 +2993,7 @@ restart:
vattr.va_flags = UF_NODUMP;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
VOP_LEASE(vp, td, cred, LEASE_WRITE);
- VOP_SETATTR(vp, &vattr, cred, td);
+ VOP_SETATTR(vp, &vattr, cred);
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
PROC_LOCK(p);
diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c
index 6013fe2..7063c99 100644
--- a/sys/kern/uipc_mqueue.c
+++ b/sys/kern/uipc_mqueue.c
@@ -1100,7 +1100,7 @@ mqfs_access(struct vop_access_args *ap)
struct vattr vattr;
int error;
- error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_td);
+ error = VOP_GETATTR(vp, &vattr, ap->a_cred);
if (error)
return (error);
error = vaccess(vp->v_type, vattr.va_mode, vattr.va_uid,
@@ -1114,7 +1114,6 @@ struct vop_getattr_args {
struct vnode *a_vp;
struct vattr *a_vap;
struct ucred *a_cred;
- struct thread *a_td;
};
#endif
@@ -1159,7 +1158,6 @@ struct vop_setattr_args {
struct vnode *a_vp;
struct vattr *a_vap;
struct ucred *a_cred;
- struct thread *a_td;
};
#endif
/*
@@ -1171,10 +1169,12 @@ mqfs_setattr(struct vop_setattr_args *ap)
struct mqfs_node *pn;
struct vattr *vap;
struct vnode *vp;
+ struct thread *td;
int c, error;
uid_t uid;
gid_t gid;
+ td = curthread;
vap = ap->a_vap;
vp = ap->a_vp;
if ((vap->va_type != VNON) ||
@@ -1206,7 +1206,7 @@ mqfs_setattr(struct vop_setattr_args *ap)
* To modify the ownership of a file, must possess VADMIN
* for that file.
*/
- if ((error = VOP_ACCESS(vp, VADMIN, ap->a_cred, ap->a_td)))
+ if ((error = VOP_ACCESS(vp, VADMIN, ap->a_cred, td)))
return (error);
/*
@@ -1216,7 +1216,7 @@ mqfs_setattr(struct vop_setattr_args *ap)
*/
if (((ap->a_cred->cr_uid != pn->mn_uid) || uid != pn->mn_uid ||
(gid != pn->mn_gid && !groupmember(gid, ap->a_cred))) &&
- (error = priv_check(ap->a_td, PRIV_MQ_ADMIN)) != 0)
+ (error = priv_check(td, PRIV_MQ_ADMIN)) != 0)
return (error);
pn->mn_uid = uid;
pn->mn_gid = gid;
@@ -1225,7 +1225,7 @@ mqfs_setattr(struct vop_setattr_args *ap)
if (vap->va_mode != (mode_t)VNOVAL) {
if ((ap->a_cred->cr_uid != pn->mn_uid) &&
- (error = priv_check(ap->a_td, PRIV_MQ_ADMIN)))
+ (error = priv_check(td, PRIV_MQ_ADMIN)))
return (error);
pn->mn_mode = vap->va_mode;
c = 1;
@@ -1233,9 +1233,9 @@ mqfs_setattr(struct vop_setattr_args *ap)
if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
/* See the comment in ufs_vnops::ufs_setattr(). */
- if ((error = VOP_ACCESS(vp, VADMIN, ap->a_cred, ap->a_td)) &&
+ if ((error = VOP_ACCESS(vp, VADMIN, ap->a_cred, td)) &&
((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
- (error = VOP_ACCESS(vp, VWRITE, ap->a_cred, ap->a_td))))
+ (error = VOP_ACCESS(vp, VWRITE, ap->a_cred, td))))
return (error);
if (vap->va_atime.tv_sec != VNOVAL) {
pn->mn_atime = vap->va_atime;
diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c
index 280623e..d46bf81 100644
--- a/sys/kern/vfs_default.c
+++ b/sys/kern/vfs_default.c
@@ -208,13 +208,15 @@ vop_nostrategy (struct vop_strategy_args *ap)
int
vop_stdadvlock(struct vop_advlock_args *ap)
{
- struct vnode *vp = ap->a_vp;
- struct thread *td = curthread;
+ struct vnode *vp;
+ struct ucred *cred;
struct vattr vattr;
int error;
+ vp = ap->a_vp;
+ cred = curthread->td_ucred;
vn_lock(vp, LK_SHARED | LK_RETRY);
- error = VOP_GETATTR(vp, &vattr, td->td_ucred, td);
+ error = VOP_GETATTR(vp, &vattr, cred);
VOP_UNLOCK(vp, 0);
if (error)
return (error);
@@ -225,13 +227,15 @@ vop_stdadvlock(struct vop_advlock_args *ap)
int
vop_stdadvlockasync(struct vop_advlockasync_args *ap)
{
- struct vnode *vp = ap->a_vp;
- struct thread *td = curthread;
+ struct vnode *vp;
+ struct ucred *cred;
struct vattr vattr;
int error;
+ vp = ap->a_vp;
+ cred = curthread->td_ucred;
vn_lock(vp, LK_SHARED | LK_RETRY);
- error = VOP_GETATTR(vp, &vattr, td->td_ucred, td);
+ error = VOP_GETATTR(vp, &vattr, cred);
VOP_UNLOCK(vp, 0);
if (error)
return (error);
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index ebee84b..b25ba3b 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -958,7 +958,7 @@ vfs_domount(
* If the user is not root, ensure that they own the directory
* onto which we are attempting to mount.
*/
- error = VOP_GETATTR(vp, &va, td->td_ucred, td);
+ error = VOP_GETATTR(vp, &va, td->td_ucred);
if (error) {
vput(vp);
return (error);
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 3bc2341..d097d13 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -2379,7 +2379,7 @@ loop:
* vnodes open for writing.
*/
if (flags & WRITECLOSE) {
- error = VOP_GETATTR(vp, &vattr, td->td_ucred, td);
+ error = VOP_GETATTR(vp, &vattr, td->td_ucred);
VI_LOCK(vp);
if ((vp->v_type == VNON ||
@@ -4111,7 +4111,7 @@ filt_vfsread(struct knote *kn, long hint)
return (1);
}
- if (VOP_GETATTR(vp, &va, curthread->td_ucred, curthread))
+ if (VOP_GETATTR(vp, &va, curthread->td_ucred))
return (0);
kn->kn_data = va.va_size - kn->kn_fp->f_offset;
@@ -4181,13 +4181,13 @@ vfs_read_dirent(struct vop_readdir_args *ap, struct dirent *dp, off_t off)
* directly setting va_atime for the sake of efficiency.
*/
void
-vfs_mark_atime(struct vnode *vp, struct thread *td)
+vfs_mark_atime(struct vnode *vp, struct ucred *cred)
{
struct vattr atimeattr;
if ((vp->v_mount->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0) {
VATTR_NULL(&atimeattr);
atimeattr.va_vaflags |= VA_MARK_ATIME;
- (void)VOP_SETATTR(vp, &atimeattr, td->td_ucred, td);
+ (void)VOP_SETATTR(vp, &atimeattr, cred);
}
}
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index e38f80e..ee66315 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1147,7 +1147,7 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
error = mac_vnode_check_write(td->td_ucred, fp->f_cred, vp);
if (error == 0)
#endif
- error = VOP_SETATTR(vp, &vat, td->td_ucred, td);
+ error = VOP_SETATTR(vp, &vat, td->td_ucred);
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
if (error)
@@ -1507,7 +1507,7 @@ SYSCTL_INT(_security_bsd, OID_AUTO, hardlink_check_gid, CTLFLAG_RW,
"groups");
static int
-can_hardlink(struct vnode *vp, struct thread *td, struct ucred *cred)
+can_hardlink(struct vnode *vp, struct ucred *cred)
{
struct vattr va;
int error;
@@ -1515,7 +1515,7 @@ can_hardlink(struct vnode *vp, struct thread *td, struct ucred *cred)
if (!hardlink_check_uid && !hardlink_check_gid)
return (0);
- error = VOP_GETATTR(vp, &va, cred, td);
+ error = VOP_GETATTR(vp, &va, cred);
if (error != 0)
return (error);
@@ -1586,7 +1586,7 @@ kern_linkat(struct thread *td, int fd1, int fd2, char *path1, char *path2,
== 0) {
VOP_LEASE(nd.ni_dvp, td, td->td_ucred, LEASE_WRITE);
VOP_LEASE(vp, td, td->td_ucred, LEASE_WRITE);
- error = can_hardlink(vp, td, td->td_ucred);
+ error = can_hardlink(vp, td->td_ucred);
if (error == 0)
#ifdef MAC
error = mac_vnode_check_link(td->td_ucred,
@@ -1939,7 +1939,7 @@ lseek(td, uap)
break;
case L_XTND:
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
- error = VOP_GETATTR(vp, &vattr, cred, td);
+ error = VOP_GETATTR(vp, &vattr, cred);
VOP_UNLOCK(vp, 0);
if (error)
break;
@@ -2637,7 +2637,7 @@ setfflags(td, vp, flags)
error = mac_vnode_check_setflags(td->td_ucred, vp, vattr.va_flags);
if (error == 0)
#endif
- error = VOP_SETATTR(vp, &vattr, td->td_ucred, td);
+ error = VOP_SETATTR(vp, &vattr, td->td_ucred);
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
return (error);
@@ -2765,7 +2765,7 @@ setfmode(td, vp, mode)
error = mac_vnode_check_setmode(td->td_ucred, vp, vattr.va_mode);
if (error == 0)
#endif
- error = VOP_SETATTR(vp, &vattr, td->td_ucred, td);
+ error = VOP_SETATTR(vp, &vattr, td->td_ucred);
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
return (error);
@@ -2930,7 +2930,7 @@ setfown(td, vp, uid, gid)
vattr.va_gid);
if (error == 0)
#endif
- error = VOP_SETATTR(vp, &vattr, td->td_ucred, td);
+ error = VOP_SETATTR(vp, &vattr, td->td_ucred);
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
return (error);
@@ -3137,7 +3137,7 @@ setutimes(td, vp, ts, numtimes, nullflag)
VOP_LEASE(vp, td, td->td_ucred, LEASE_WRITE);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
setbirthtime = 0;
- if (numtimes < 3 && VOP_GETATTR(vp, &vattr, td->td_ucred, td) == 0 &&
+ if (numtimes < 3 && !VOP_GETATTR(vp, &vattr, td->td_ucred) &&
timespeccmp(&ts[1], &vattr.va_birthtime, < ))
setbirthtime = 1;
VATTR_NULL(&vattr);
@@ -3154,7 +3154,7 @@ setutimes(td, vp, ts, numtimes, nullflag)
vattr.va_mtime);
#endif
if (error == 0)
- error = VOP_SETATTR(vp, &vattr, td->td_ucred, td);
+ error = VOP_SETATTR(vp, &vattr, td->td_ucred);
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
return (error);
@@ -3377,7 +3377,7 @@ kern_truncate(struct thread *td, char *path, enum uio_seg pathseg, off_t length)
(error = VOP_ACCESS(vp, VWRITE, td->td_ucred, td)) == 0) {
VATTR_NULL(&vattr);
vattr.va_size = length;
- error = VOP_SETATTR(vp, &vattr, td->td_ucred, td);
+ error = VOP_SETATTR(vp, &vattr, td->td_ucred);
}
vput(vp);
vn_finished_write(mp);
@@ -4172,7 +4172,7 @@ revoke(td, uap)
if (error)
goto out;
#endif
- error = VOP_GETATTR(vp, &vattr, td->td_ucred, td);
+ error = VOP_GETATTR(vp, &vattr, td->td_ucred);
if (error)
goto out;
if (td->td_ucred->cr_uid != vattr.va_uid) {
@@ -4418,7 +4418,7 @@ fhopen(td, uap)
#endif
VATTR_NULL(vap);
vap->va_size = 0;
- error = VOP_SETATTR(vp, vap, td->td_ucred, td);
+ error = VOP_SETATTR(vp, vap, td->td_ucred);
#ifdef MAC
}
#endif
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index fdc34f6..6e7c5a0 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -648,7 +648,7 @@ vn_truncate(fp, length, active_cred, td)
if (error == 0) {
VATTR_NULL(&vattr);
vattr.va_size = length;
- error = VOP_SETATTR(vp, &vattr, fp->f_cred, td);
+ error = VOP_SETATTR(vp, &vattr, fp->f_cred);
}
out:
VOP_UNLOCK(vp, 0);
@@ -703,7 +703,7 @@ vn_stat(vp, sb, active_cred, file_cred, td)
#endif
vap = &vattr;
- error = VOP_GETATTR(vp, vap, active_cred, td);
+ error = VOP_GETATTR(vp, vap, active_cred);
if (error)
return (error);
@@ -803,7 +803,7 @@ vn_ioctl(fp, com, data, active_cred, td)
case VDIR:
if (com == FIONREAD) {
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
- error = VOP_GETATTR(vp, &vattr, active_cred, td);
+ error = VOP_GETATTR(vp, &vattr, active_cred);
VOP_UNLOCK(vp, 0);
if (!error)
*(int *)data = vattr.va_size - fp->f_offset;
diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src
index 82156bf..0289fe8 100644
--- a/sys/kern/vnode_if.src
+++ b/sys/kern/vnode_if.src
@@ -159,7 +159,6 @@ vop_getattr {
IN struct vnode *vp;
OUT struct vattr *vap;
IN struct ucred *cred;
- IN struct thread *td;
};
@@ -170,7 +169,6 @@ vop_setattr {
IN struct vnode *vp;
IN struct vattr *vap;
IN struct ucred *cred;
- IN struct thread *td;
};
OpenPOWER on IntegriCloud