summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2003-01-12 01:37:13 +0000
committerdillon <dillon@FreeBSD.org>2003-01-12 01:37:13 +0000
commitddf9ef103e0a611c9a01425a28baf8a612b0d114 (patch)
tree19da0d56c468b8e0f6d0361d7d39157f561aa69f /sys/kern
parent07cbccc353d7afbe8948b6025965ca36739d7373 (diff)
downloadFreeBSD-src-ddf9ef103e0a611c9a01425a28baf8a612b0d114.zip
FreeBSD-src-ddf9ef103e0a611c9a01425a28baf8a612b0d114.tar.gz
Change struct file f_data to un_data, a union of the correct struct
pointer types, and remove a huge number of casts from code using it. Change struct xfile xf_data to xun_data (ABI is still compatible). If we need to add a #define for f_data and xf_data we can, but I don't think it will be necessary. There are no operational changes in this commit.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_acl.c9
-rw-r--r--sys/kern/kern_descrip.c22
-rw-r--r--sys/kern/kern_event.c20
-rw-r--r--sys/kern/kern_mac.c8
-rw-r--r--sys/kern/subr_acl_posix1e.c9
-rw-r--r--sys/kern/sys_pipe.c24
-rw-r--r--sys/kern/sys_socket.c14
-rw-r--r--sys/kern/uipc_socket.c12
-rw-r--r--sys/kern/uipc_syscalls.c8
-rw-r--r--sys/kern/uipc_usrreq.c7
-rw-r--r--sys/kern/vfs_acl.c9
-rw-r--r--sys/kern/vfs_aio.c12
-rw-r--r--sys/kern/vfs_extattr.c42
-rw-r--r--sys/kern/vfs_syscalls.c42
-rw-r--r--sys/kern/vfs_vnops.c15
15 files changed, 125 insertions, 128 deletions
diff --git a/sys/kern/kern_acl.c b/sys/kern/kern_acl.c
index 3b48a82..1611614 100644
--- a/sys/kern/kern_acl.c
+++ b/sys/kern/kern_acl.c
@@ -780,7 +780,7 @@ __acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
- error = vacl_get_acl(td, (struct vnode *)fp->f_data,
+ error = vacl_get_acl(td, fp->un_data.vnode,
uap->type, uap->aclp);
fdrop(fp, td);
}
@@ -802,7 +802,7 @@ __acl_set_fd(struct thread *td, struct __acl_set_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
- error = vacl_set_acl(td, (struct vnode *)fp->f_data,
+ error = vacl_set_acl(td, fp->un_data.vnode,
uap->type, uap->aclp);
fdrop(fp, td);
}
@@ -868,8 +868,7 @@ __acl_delete_fd(struct thread *td, struct __acl_delete_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
- error = vacl_delete(td, (struct vnode *)fp->f_data,
- uap->type);
+ error = vacl_delete(td, fp->un_data.vnode, uap->type);
fdrop(fp, td);
}
mtx_unlock(&Giant);
@@ -934,7 +933,7 @@ __acl_aclcheck_fd(struct thread *td, struct __acl_aclcheck_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
- error = vacl_aclcheck(td, (struct vnode *)fp->f_data,
+ error = vacl_aclcheck(td, fp->un_data.vnode,
uap->type, uap->aclp);
fdrop(fp, td);
}
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index e5a2114..c11762b 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -355,7 +355,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
*/
fhold(fp);
FILEDESC_UNLOCK(fdp);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
switch (flp->l_type) {
case F_RDLCK:
@@ -420,7 +420,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
*/
fhold(fp);
FILEDESC_UNLOCK(fdp);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_GETLK, flp,
F_POSIX);
fdrop(fp, td);
@@ -979,7 +979,7 @@ fpathconf(td, uap)
break;
case DTYPE_FIFO:
case DTYPE_VNODE:
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
mtx_lock(&Giant);
error = VOP_PATHCONF(vp, uap->name, td->td_retval);
mtx_unlock(&Giant);
@@ -1424,7 +1424,7 @@ static int
is_unsafe(struct file *fp)
{
if (fp->f_type == DTYPE_VNODE) {
- struct vnode *vp = (struct vnode *)fp->f_data;
+ struct vnode *vp = fp->un_data.vnode;
if ((vp->v_vflag & VV_PROCDEP) != 0)
return (1);
@@ -1582,7 +1582,7 @@ fdcheckstd(td)
break;
}
NDFREE(&nd, NDF_ONLY_PNBUF);
- fp->f_data = nd.ni_vp;
+ fp->un_data.vnode = nd.ni_vp;
fp->f_flag = flags;
fp->f_ops = &vnops;
fp->f_type = DTYPE_VNODE;
@@ -1627,7 +1627,7 @@ closef(fp, td)
lf.l_start = 0;
lf.l_len = 0;
lf.l_type = F_UNLCK;
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
(void) VOP_ADVLOCK(vp, (caddr_t)td->td_proc->p_leader,
F_UNLCK, &lf, F_POSIX);
}
@@ -1741,7 +1741,7 @@ _fgetvp(struct thread *td, int fd, struct vnode **vpp, int flags)
if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_FIFO) {
error = EINVAL;
} else {
- *vpp = (struct vnode *)fp->f_data;
+ *vpp = fp->un_data.vnode;
vref(*vpp);
}
FILEDESC_UNLOCK(td->td_proc->p_fd);
@@ -1790,7 +1790,7 @@ fgetsock(struct thread *td, int fd, struct socket **spp, u_int *fflagp)
if (fp->f_type != DTYPE_SOCKET) {
error = ENOTSOCK;
} else {
- *spp = (struct socket *)fp->f_data;
+ *spp = fp->un_data.socket;
if (fflagp)
*fflagp = fp->f_flag;
soref(*spp);
@@ -1838,7 +1838,7 @@ fdrop_locked(fp, td)
lf.l_start = 0;
lf.l_len = 0;
lf.l_type = F_UNLCK;
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
FILE_UNLOCK(fp);
(void) VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK);
} else
@@ -1886,7 +1886,7 @@ flock(td, uap)
}
mtx_lock(&Giant);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;
@@ -2110,12 +2110,12 @@ sysctl_kern_file(SYSCTL_HANDLER_ARGS)
continue;
xf.xf_fd = n;
xf.xf_file = fp;
+ xf.xun_data.generic = fp->un_data.generic;
#define XF_COPY(field) xf.xf_##field = fp->f_##field
XF_COPY(type);
XF_COPY(count);
XF_COPY(msgcount);
XF_COPY(offset);
- XF_COPY(data);
XF_COPY(flag);
#undef XF_COPY
error = SYSCTL_OUT(req, &xf, sizeof(xf));
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index a6d0eb1..e36fdb4 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -157,7 +157,7 @@ filt_fileattach(struct knote *kn)
static int
kqueue_kqfilter(struct file *fp, struct knote *kn)
{
- struct kqueue *kq = (struct kqueue *)kn->kn_fp->f_data;
+ struct kqueue *kq = kn->kn_fp->un_data.kqueue;
if (kn->kn_filter != EVFILT_READ)
return (1);
@@ -170,7 +170,7 @@ kqueue_kqfilter(struct file *fp, struct knote *kn)
static void
filt_kqdetach(struct knote *kn)
{
- struct kqueue *kq = (struct kqueue *)kn->kn_fp->f_data;
+ struct kqueue *kq = kn->kn_fp->un_data.kqueue;
SLIST_REMOVE(&kq->kq_sel.si_note, kn, knote, kn_selnext);
}
@@ -179,7 +179,7 @@ filt_kqdetach(struct knote *kn)
static int
filt_kqueue(struct knote *kn, long hint)
{
- struct kqueue *kq = (struct kqueue *)kn->kn_fp->f_data;
+ struct kqueue *kq = kn->kn_fp->un_data.kqueue;
kn->kn_data = kq->kq_count;
return (kn->kn_data > 0);
@@ -378,7 +378,7 @@ kqueue(struct thread *td, struct kqueue_args *uap)
fp->f_type = DTYPE_KQUEUE;
fp->f_ops = &kqueueops;
TAILQ_INIT(&kq->kq_head);
- fp->f_data = kq;
+ fp->un_data.kqueue = kq;
FILE_UNLOCK(fp);
FILEDESC_LOCK(fdp);
td->td_retval[0] = fd;
@@ -427,7 +427,7 @@ kevent(struct thread *td, struct kevent_args *uap)
}
mtx_lock(&Giant);
- kq = (struct kqueue *)fp->f_data;
+ kq = fp->un_data.kqueue;
nerrors = 0;
while (uap->nchanges > 0) {
@@ -650,7 +650,7 @@ kqueue_scan(struct file *fp, int maxevents, struct kevent *ulistp,
FILE_LOCK_ASSERT(fp, MA_NOTOWNED);
- kq = (struct kqueue *)fp->f_data;
+ kq = fp->un_data.kqueue;
count = maxevents;
if (count == 0)
goto done;
@@ -806,7 +806,7 @@ kqueue_poll(struct file *fp, int events, struct ucred *active_cred,
int revents = 0;
int s = splnet();
- kq = (struct kqueue *)fp->f_data;
+ kq = fp->un_data.kqueue;
if (events & (POLLIN | POLLRDNORM)) {
if (kq->kq_count) {
revents |= events & (POLLIN | POLLRDNORM);
@@ -826,7 +826,7 @@ kqueue_stat(struct file *fp, struct stat *st, struct ucred *active_cred,
{
struct kqueue *kq;
- kq = (struct kqueue *)fp->f_data;
+ kq = fp->un_data.kqueue;
bzero((void *)st, sizeof(*st));
st->st_size = kq->kq_count;
st->st_blksize = sizeof(struct kevent);
@@ -838,7 +838,7 @@ kqueue_stat(struct file *fp, struct stat *st, struct ucred *active_cred,
static int
kqueue_close(struct file *fp, struct thread *td)
{
- struct kqueue *kq = (struct kqueue *)fp->f_data;
+ struct kqueue *kq = fp->un_data.kqueue;
struct filedesc *fdp = td->td_proc->p_fd;
struct knote **knp, *kn, *kn0;
int i;
@@ -885,7 +885,7 @@ kqueue_close(struct file *fp, struct thread *td)
}
FILEDESC_UNLOCK(fdp);
free(kq, M_KQUEUE);
- fp->f_data = NULL;
+ fp->un_data.kqueue = NULL;
return (0);
}
diff --git a/sys/kern/kern_mac.c b/sys/kern/kern_mac.c
index 6542a73..299ad50 100644
--- a/sys/kern/kern_mac.c
+++ b/sys/kern/kern_mac.c
@@ -3211,7 +3211,7 @@ __mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
switch (fp->f_type) {
case DTYPE_FIFO:
case DTYPE_VNODE:
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
mac_init_vnode_label(&intlabel);
@@ -3221,7 +3221,7 @@ __mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
break;
case DTYPE_PIPE:
- pipe = (struct pipe *)fp->f_data;
+ pipe = fp->un_data.pipe;
mac_init_pipe_label(&intlabel);
@@ -3419,7 +3419,7 @@ __mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
break;
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error != 0) {
mac_destroy_vnode_label(&intlabel);
@@ -3438,7 +3438,7 @@ __mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
mac_init_pipe_label(&intlabel);
error = mac_internalize_pipe_label(&intlabel, buffer);
if (error == 0) {
- pipe = (struct pipe *)fp->f_data;
+ pipe = fp->un_data.pipe;
PIPE_LOCK(pipe);
error = mac_pipe_label_set(td->td_ucred, pipe,
&intlabel);
diff --git a/sys/kern/subr_acl_posix1e.c b/sys/kern/subr_acl_posix1e.c
index 3b48a82..1611614 100644
--- a/sys/kern/subr_acl_posix1e.c
+++ b/sys/kern/subr_acl_posix1e.c
@@ -780,7 +780,7 @@ __acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
- error = vacl_get_acl(td, (struct vnode *)fp->f_data,
+ error = vacl_get_acl(td, fp->un_data.vnode,
uap->type, uap->aclp);
fdrop(fp, td);
}
@@ -802,7 +802,7 @@ __acl_set_fd(struct thread *td, struct __acl_set_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
- error = vacl_set_acl(td, (struct vnode *)fp->f_data,
+ error = vacl_set_acl(td, fp->un_data.vnode,
uap->type, uap->aclp);
fdrop(fp, td);
}
@@ -868,8 +868,7 @@ __acl_delete_fd(struct thread *td, struct __acl_delete_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
- error = vacl_delete(td, (struct vnode *)fp->f_data,
- uap->type);
+ error = vacl_delete(td, fp->un_data.vnode, uap->type);
fdrop(fp, td);
}
mtx_unlock(&Giant);
@@ -934,7 +933,7 @@ __acl_aclcheck_fd(struct thread *td, struct __acl_aclcheck_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
- error = vacl_aclcheck(td, (struct vnode *)fp->f_data,
+ error = vacl_aclcheck(td, fp->un_data.vnode,
uap->type, uap->aclp);
fdrop(fp, td);
}
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 65d41e9..84ce363 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -238,7 +238,7 @@ pipe(td, uap)
FILE_LOCK(rf);
rf->f_flag = FREAD | FWRITE;
rf->f_type = DTYPE_PIPE;
- rf->f_data = rpipe;
+ rf->un_data.pipe = rpipe;
rf->f_ops = &pipeops;
FILE_UNLOCK(rf);
error = falloc(td, &wf, &fd);
@@ -259,7 +259,7 @@ pipe(td, uap)
FILE_LOCK(wf);
wf->f_flag = FREAD | FWRITE;
wf->f_type = DTYPE_PIPE;
- wf->f_data = wpipe;
+ wf->un_data.pipe = wpipe;
wf->f_ops = &pipeops;
FILE_UNLOCK(wf);
td->td_retval[1] = fd;
@@ -452,7 +452,7 @@ pipe_read(fp, uio, active_cred, flags, td)
struct thread *td;
int flags;
{
- struct pipe *rpipe = (struct pipe *) fp->f_data;
+ struct pipe *rpipe = fp->un_data.pipe;
int error;
int nread = 0;
u_int size;
@@ -868,7 +868,7 @@ pipe_write(fp, uio, active_cred, flags, td)
int orig_resid;
struct pipe *wpipe, *rpipe;
- rpipe = (struct pipe *) fp->f_data;
+ rpipe = fp->un_data.pipe;
wpipe = rpipe->pipe_peer;
PIPE_LOCK(rpipe);
@@ -1155,7 +1155,7 @@ pipe_ioctl(fp, cmd, data, active_cred, td)
struct ucred *active_cred;
struct thread *td;
{
- struct pipe *mpipe = (struct pipe *)fp->f_data;
+ struct pipe *mpipe = fp->un_data.pipe;
#ifdef MAC
int error;
#endif
@@ -1223,7 +1223,7 @@ pipe_poll(fp, events, active_cred, td)
struct ucred *active_cred;
struct thread *td;
{
- struct pipe *rpipe = (struct pipe *)fp->f_data;
+ struct pipe *rpipe = fp->un_data.pipe;
struct pipe *wpipe;
int revents = 0;
#ifdef MAC
@@ -1284,7 +1284,7 @@ pipe_stat(fp, ub, active_cred, td)
struct ucred *active_cred;
struct thread *td;
{
- struct pipe *pipe = (struct pipe *)fp->f_data;
+ struct pipe *pipe = fp->un_data.pipe;
#ifdef MAC
int error;
@@ -1317,10 +1317,10 @@ pipe_close(fp, td)
struct file *fp;
struct thread *td;
{
- struct pipe *cpipe = (struct pipe *)fp->f_data;
+ struct pipe *cpipe = fp->un_data.pipe;
fp->f_ops = &badfileops;
- fp->f_data = NULL;
+ fp->un_data.pipe = NULL;
funsetown(&cpipe->pipe_sigio);
pipeclose(cpipe);
return (0);
@@ -1428,7 +1428,7 @@ pipe_kqfilter(struct file *fp, struct knote *kn)
{
struct pipe *cpipe;
- cpipe = (struct pipe *)kn->kn_fp->f_data;
+ cpipe = kn->kn_fp->un_data.pipe;
switch (kn->kn_filter) {
case EVFILT_READ:
kn->kn_fop = &pipe_rfiltops;
@@ -1465,7 +1465,7 @@ filt_pipedetach(struct knote *kn)
static int
filt_piperead(struct knote *kn, long hint)
{
- struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
+ struct pipe *rpipe = kn->kn_fp->un_data.pipe;
struct pipe *wpipe = rpipe->pipe_peer;
PIPE_LOCK(rpipe);
@@ -1487,7 +1487,7 @@ filt_piperead(struct knote *kn, long hint)
static int
filt_pipewrite(struct knote *kn, long hint)
{
- struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
+ struct pipe *rpipe = kn->kn_fp->un_data.pipe;
struct pipe *wpipe = rpipe->pipe_peer;
PIPE_LOCK(rpipe);
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c
index c31a903..c2c3076 100644
--- a/sys/kern/sys_socket.c
+++ b/sys/kern/sys_socket.c
@@ -69,7 +69,7 @@ soo_read(fp, uio, active_cred, flags, td)
struct thread *td;
int flags;
{
- struct socket *so = (struct socket *)fp->f_data;
+ struct socket *so = fp->un_data.socket;
int error;
mtx_lock(&Giant);
@@ -94,7 +94,7 @@ soo_write(fp, uio, active_cred, flags, td)
struct thread *td;
int flags;
{
- struct socket *so = (struct socket *)fp->f_data;
+ struct socket *so = fp->un_data.socket;
int error;
mtx_lock(&Giant);
@@ -119,7 +119,7 @@ soo_ioctl(fp, cmd, data, active_cred, td)
struct ucred *active_cred;
struct thread *td;
{
- register struct socket *so = (struct socket *)fp->f_data;
+ register struct socket *so = fp->un_data.socket;
switch (cmd) {
@@ -183,7 +183,7 @@ soo_poll(fp, events, active_cred, td)
struct ucred *active_cred;
struct thread *td;
{
- struct socket *so = (struct socket *)fp->f_data;
+ struct socket *so = fp->un_data.socket;
return so->so_proto->pr_usrreqs->pru_sopoll(so, events,
fp->f_cred, td);
}
@@ -195,7 +195,7 @@ soo_stat(fp, ub, active_cred, td)
struct ucred *active_cred;
struct thread *td;
{
- struct socket *so = (struct socket *)fp->f_data;
+ struct socket *so = fp->un_data.socket;
bzero((caddr_t)ub, sizeof (*ub));
ub->st_mode = S_IFSOCK;
@@ -229,9 +229,9 @@ soo_close(fp, td)
int error = 0;
struct socket *so;
- so = (struct socket *)fp->f_data;
+ so = fp->un_data.socket;
fp->f_ops = &badfileops;
- fp->f_data = 0;
+ fp->un_data.socket = 0;
if (so)
error = soclose(so);
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index fe8a2e0..aedcecc 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1735,7 +1735,7 @@ sopoll(struct socket *so, int events, struct ucred *active_cred,
int
soo_kqfilter(struct file *fp, struct knote *kn)
{
- struct socket *so = (struct socket *)kn->kn_fp->f_data;
+ struct socket *so = kn->kn_fp->un_data.socket;
struct sockbuf *sb;
int s;
@@ -1765,7 +1765,7 @@ soo_kqfilter(struct file *fp, struct knote *kn)
static void
filt_sordetach(struct knote *kn)
{
- struct socket *so = (struct socket *)kn->kn_fp->f_data;
+ struct socket *so = kn->kn_fp->un_data.socket;
int s = splnet();
SLIST_REMOVE(&so->so_rcv.sb_sel.si_note, kn, knote, kn_selnext);
@@ -1778,7 +1778,7 @@ filt_sordetach(struct knote *kn)
static int
filt_soread(struct knote *kn, long hint)
{
- struct socket *so = (struct socket *)kn->kn_fp->f_data;
+ struct socket *so = kn->kn_fp->un_data.socket;
kn->kn_data = so->so_rcv.sb_cc - so->so_rcv.sb_ctl;
if (so->so_state & SS_CANTRCVMORE) {
@@ -1796,7 +1796,7 @@ filt_soread(struct knote *kn, long hint)
static void
filt_sowdetach(struct knote *kn)
{
- struct socket *so = (struct socket *)kn->kn_fp->f_data;
+ struct socket *so = kn->kn_fp->un_data.socket;
int s = splnet();
SLIST_REMOVE(&so->so_snd.sb_sel.si_note, kn, knote, kn_selnext);
@@ -1809,7 +1809,7 @@ filt_sowdetach(struct knote *kn)
static int
filt_sowrite(struct knote *kn, long hint)
{
- struct socket *so = (struct socket *)kn->kn_fp->f_data;
+ struct socket *so = kn->kn_fp->un_data.socket;
kn->kn_data = sbspace(&so->so_snd);
if (so->so_state & SS_CANTSENDMORE) {
@@ -1831,7 +1831,7 @@ filt_sowrite(struct knote *kn, long hint)
static int
filt_solisten(struct knote *kn, long hint)
{
- struct socket *so = (struct socket *)kn->kn_fp->f_data;
+ struct socket *so = kn->kn_fp->un_data.socket;
kn->kn_data = so->so_qlen;
return (! TAILQ_EMPTY(&so->so_comp));
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 48ba50d..c0ffa9d 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -141,7 +141,7 @@ socket(td, uap)
} else
FILEDESC_UNLOCK(fdp);
} else {
- fp->f_data = so; /* already has ref count */
+ fp->un_data.socket = so; /* already has ref count */
fp->f_flag = FREAD|FWRITE;
fp->f_ops = &socketops;
fp->f_type = DTYPE_SOCKET;
@@ -329,7 +329,7 @@ accept1(td, uap, compat)
FILE_LOCK(nfp);
soref(so); /* file descriptor reference */
- nfp->f_data = so; /* nfp has ref count from falloc */
+ nfp->un_data.socket = so; /* nfp has ref count from falloc */
nfp->f_flag = fflag;
nfp->f_ops = &socketops;
nfp->f_type = DTYPE_SOCKET;
@@ -524,12 +524,12 @@ socketpair(td, uap)
goto free2;
fhold(fp1);
sv[0] = fd;
- fp1->f_data = so1; /* so1 already has ref count */
+ fp1->un_data.socket = so1; /* so1 already has ref count */
error = falloc(td, &fp2, &fd);
if (error)
goto free3;
fhold(fp2);
- fp2->f_data = so2; /* so2 already has ref count */
+ fp2->un_data.socket = so2; /* so2 already has ref count */
sv[1] = fd;
error = soconnect2(so1, so2);
if (error)
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 5ca7c39..6846352 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1305,7 +1305,7 @@ unp_gc()
* Now check if it is possibly one of OUR sockets.
*/
if (fp->f_type != DTYPE_SOCKET ||
- (so = (struct socket *)fp->f_data) == 0) {
+ (so = fp->un_data.socket) == 0) {
FILE_UNLOCK(fp);
continue;
}
@@ -1412,9 +1412,10 @@ unp_gc()
for (i = nunref, fpp = extra_ref; --i >= 0; ++fpp) {
struct file *tfp = *fpp;
FILE_LOCK(tfp);
- if (tfp->f_type == DTYPE_SOCKET && tfp->f_data != NULL) {
+ if (tfp->f_type == DTYPE_SOCKET &&
+ tfp->un_data.socket != NULL) {
FILE_UNLOCK(tfp);
- sorflush((struct socket *)(tfp->f_data));
+ sorflush(tfp->un_data.socket);
} else
FILE_UNLOCK(tfp);
}
diff --git a/sys/kern/vfs_acl.c b/sys/kern/vfs_acl.c
index 3b48a82..1611614 100644
--- a/sys/kern/vfs_acl.c
+++ b/sys/kern/vfs_acl.c
@@ -780,7 +780,7 @@ __acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
- error = vacl_get_acl(td, (struct vnode *)fp->f_data,
+ error = vacl_get_acl(td, fp->un_data.vnode,
uap->type, uap->aclp);
fdrop(fp, td);
}
@@ -802,7 +802,7 @@ __acl_set_fd(struct thread *td, struct __acl_set_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
- error = vacl_set_acl(td, (struct vnode *)fp->f_data,
+ error = vacl_set_acl(td, fp->un_data.vnode,
uap->type, uap->aclp);
fdrop(fp, td);
}
@@ -868,8 +868,7 @@ __acl_delete_fd(struct thread *td, struct __acl_delete_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
- error = vacl_delete(td, (struct vnode *)fp->f_data,
- uap->type);
+ error = vacl_delete(td, fp->un_data.vnode, uap->type);
fdrop(fp, td);
}
mtx_unlock(&Giant);
@@ -934,7 +933,7 @@ __acl_aclcheck_fd(struct thread *td, struct __acl_aclcheck_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
- error = vacl_aclcheck(td, (struct vnode *)fp->f_data,
+ error = vacl_aclcheck(td, fp->un_data.vnode,
uap->type, uap->aclp);
fdrop(fp, td);
}
diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c
index 2f63af9..3b8f1d8 100644
--- a/sys/kern/vfs_aio.c
+++ b/sys/kern/vfs_aio.c
@@ -555,7 +555,7 @@ aio_proc_rundown(struct proc *p)
aiocbn = TAILQ_NEXT(aiocbe, plist);
fp = aiocbe->fd_file;
if (fp != NULL) {
- so = (struct socket *)fp->f_data;
+ so = fp->un_data.socket;
TAILQ_REMOVE(&so->so_aiojobq, aiocbe, list);
if (TAILQ_EMPTY(&so->so_aiojobq)) {
so->so_snd.sb_flags &= ~SB_AIO;
@@ -1059,7 +1059,7 @@ aio_qphysio(struct proc *p, struct aiocblist *aiocbe)
if (fp->f_type != DTYPE_VNODE)
return (-1);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
/*
* If its not a disk, we don't want to return a positive error.
@@ -1406,7 +1406,7 @@ _aio_aqueue(struct thread *td, struct aiocb *job, struct aio_liojob *lj, int typ
error = EBADF;
goto aqueue_fail;
}
- kq = (struct kqueue *)kq_fp->f_data;
+ kq = kq_fp->un_data.kqueue;
kev.ident = (uintptr_t)aiocbe->uuaiocb;
kev.filter = EVFILT_AIO;
kev.flags = EV_ADD | EV_ENABLE | EV_FLAG1;
@@ -1441,7 +1441,7 @@ no_kqueue:
* socket, and set the flags so we get a call when sbnotify()
* happens.
*/
- so = (struct socket *)fp->f_data;
+ so = fp->un_data.socket;
s = splnet();
if (((opcode == LIO_READ) && (!soreadable(so))) || ((opcode ==
LIO_WRITE) && (!sowriteable(so)))) {
@@ -1731,14 +1731,14 @@ aio_cancel(struct thread *td, struct aio_cancel_args *uap)
return (EBADF);
if (fp->f_type == DTYPE_VNODE) {
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
if (vn_isdisk(vp,&error)) {
td->td_retval[0] = AIO_NOTCANCELED;
return 0;
}
} else if (fp->f_type == DTYPE_SOCKET) {
- so = (struct socket *)fp->f_data;
+ so = fp->un_data.socket;
s = splnet();
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index 5592bbc..0948c31 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -278,7 +278,7 @@ fstatfs(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
- mp = ((struct vnode *)fp->f_data)->v_mount;
+ mp = (fp->un_data.vnode)->v_mount;
fdrop(fp, td);
if (mp == NULL)
return (EBADF);
@@ -399,7 +399,7 @@ fchdir(td, uap)
if ((error = getvnode(fdp, uap->fd, &fp)) != 0)
return (error);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
VREF(vp);
fdrop(fp, td);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
@@ -492,7 +492,7 @@ chroot_refuse_vdir_fds(fdp)
if (fp == NULL)
continue;
if (fp->f_type == DTYPE_VNODE) {
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
if (vp->v_type == VDIR)
return (EPERM);
}
@@ -724,7 +724,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
KASSERT(!vn_canvmio(vp) || VOP_GETVOBJECT(vp, NULL) == 0,
("open: vmio vnode has no backing object after vn_open"));
- fp->f_data = vp;
+ fp->un_data.vnode = vp;
fp->f_flag = flags & FMASK;
fp->f_ops = &vnops;
fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE);
@@ -1319,7 +1319,7 @@ lseek(td, uap)
fdrop(fp, td);
return (ESPIPE);
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
noneg = (vp->v_type != VCHR);
offset = uap->offset;
switch (uap->whence) {
@@ -2032,7 +2032,7 @@ fchflags(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
- error = setfflags(td, (struct vnode *) fp->f_data, uap->flags);
+ error = setfflags(td, fp->un_data.vnode, uap->flags);
fdrop(fp, td);
return (error);
}
@@ -2157,8 +2157,8 @@ fchmod(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
- vp = (struct vnode *)fp->f_data;
- error = setfmode(td, (struct vnode *)fp->f_data, uap->mode);
+ vp = fp->un_data.vnode;
+ error = setfmode(td, fp->un_data.vnode, uap->mode);
fdrop(fp, td);
return (error);
}
@@ -2301,8 +2301,8 @@ fchown(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
- vp = (struct vnode *)fp->f_data;
- error = setfown(td, (struct vnode *)fp->f_data, uap->uid, uap->gid);
+ vp = fp->un_data.vnode;
+ error = setfown(td, fp->un_data.vnode, uap->uid, uap->gid);
fdrop(fp, td);
return (error);
}
@@ -2500,7 +2500,7 @@ kern_futimes(struct thread *td, int fd, struct timeval *tptr,
return (error);
if ((error = getvnode(td->td_proc->p_fd, fd, &fp)) != 0)
return (error);
- error = setutimes(td, (struct vnode *)fp->f_data, ts, 2, tptr == NULL);
+ error = setutimes(td, fp->un_data.vnode, ts, 2, tptr == NULL);
fdrop(fp, td);
return (error);
}
@@ -2602,7 +2602,7 @@ ftruncate(td, uap)
fdrop(fp, td);
return (EINVAL);
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
fdrop(fp, td);
return (error);
@@ -2713,7 +2713,7 @@ fsync(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
fdrop(fp, td);
return (error);
@@ -3074,7 +3074,7 @@ ogetdirentries(td, uap)
fdrop(fp, td);
return (EBADF);
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
unionread:
if (vp->v_type != VDIR) {
fdrop(fp, td);
@@ -3174,7 +3174,7 @@ unionread:
struct vnode *tvp = vp;
vp = vp->v_mount->mnt_vnodecovered;
VREF(vp);
- fp->f_data = vp;
+ fp->un_data.vnode = vp;
fp->f_offset = 0;
vput(tvp);
goto unionread;
@@ -3222,7 +3222,7 @@ getdirentries(td, uap)
fdrop(fp, td);
return (EBADF);
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
unionread:
if (vp->v_type != VDIR) {
fdrop(fp, td);
@@ -3271,7 +3271,7 @@ unionread:
struct vnode *tvp = vp;
vp = vp->v_mount->mnt_vnodecovered;
VREF(vp);
- fp->f_data = vp;
+ fp->un_data.vnode = vp;
fp->f_offset = 0;
vput(tvp);
goto unionread;
@@ -3624,7 +3624,7 @@ fhopen(td, uap)
* from under us while we block in the lock op
*/
fhold(fp);
- nfp->f_data = vp;
+ nfp->un_data.vnode = vp;
nfp->f_flag = fmode & FMASK;
nfp->f_ops = &vnops;
nfp->f_type = DTYPE_VNODE;
@@ -3945,7 +3945,7 @@ extattr_set_fd(td, uap)
if (error)
return (error);
- error = extattr_set_vp((struct vnode *)fp->f_data, uap->attrnamespace,
+ error = extattr_set_vp(fp->un_data.vnode, uap->attrnamespace,
attrname, uap->data, uap->nbytes, td);
fdrop(fp, td);
@@ -4109,7 +4109,7 @@ extattr_get_fd(td, uap)
if (error)
return (error);
- error = extattr_get_vp((struct vnode *)fp->f_data, uap->attrnamespace,
+ error = extattr_get_vp(fp->un_data.vnode, uap->attrnamespace,
attrname, uap->data, uap->nbytes, td);
fdrop(fp, td);
@@ -4241,7 +4241,7 @@ extattr_delete_fd(td, uap)
error = getvnode(td->td_proc->p_fd, uap->fd, &fp);
if (error)
return (error);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
error = extattr_delete_vp(vp, uap->attrnamespace, attrname, td);
fdrop(fp, td);
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 5592bbc..0948c31 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -278,7 +278,7 @@ fstatfs(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
- mp = ((struct vnode *)fp->f_data)->v_mount;
+ mp = (fp->un_data.vnode)->v_mount;
fdrop(fp, td);
if (mp == NULL)
return (EBADF);
@@ -399,7 +399,7 @@ fchdir(td, uap)
if ((error = getvnode(fdp, uap->fd, &fp)) != 0)
return (error);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
VREF(vp);
fdrop(fp, td);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
@@ -492,7 +492,7 @@ chroot_refuse_vdir_fds(fdp)
if (fp == NULL)
continue;
if (fp->f_type == DTYPE_VNODE) {
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
if (vp->v_type == VDIR)
return (EPERM);
}
@@ -724,7 +724,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
KASSERT(!vn_canvmio(vp) || VOP_GETVOBJECT(vp, NULL) == 0,
("open: vmio vnode has no backing object after vn_open"));
- fp->f_data = vp;
+ fp->un_data.vnode = vp;
fp->f_flag = flags & FMASK;
fp->f_ops = &vnops;
fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE);
@@ -1319,7 +1319,7 @@ lseek(td, uap)
fdrop(fp, td);
return (ESPIPE);
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
noneg = (vp->v_type != VCHR);
offset = uap->offset;
switch (uap->whence) {
@@ -2032,7 +2032,7 @@ fchflags(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
- error = setfflags(td, (struct vnode *) fp->f_data, uap->flags);
+ error = setfflags(td, fp->un_data.vnode, uap->flags);
fdrop(fp, td);
return (error);
}
@@ -2157,8 +2157,8 @@ fchmod(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
- vp = (struct vnode *)fp->f_data;
- error = setfmode(td, (struct vnode *)fp->f_data, uap->mode);
+ vp = fp->un_data.vnode;
+ error = setfmode(td, fp->un_data.vnode, uap->mode);
fdrop(fp, td);
return (error);
}
@@ -2301,8 +2301,8 @@ fchown(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
- vp = (struct vnode *)fp->f_data;
- error = setfown(td, (struct vnode *)fp->f_data, uap->uid, uap->gid);
+ vp = fp->un_data.vnode;
+ error = setfown(td, fp->un_data.vnode, uap->uid, uap->gid);
fdrop(fp, td);
return (error);
}
@@ -2500,7 +2500,7 @@ kern_futimes(struct thread *td, int fd, struct timeval *tptr,
return (error);
if ((error = getvnode(td->td_proc->p_fd, fd, &fp)) != 0)
return (error);
- error = setutimes(td, (struct vnode *)fp->f_data, ts, 2, tptr == NULL);
+ error = setutimes(td, fp->un_data.vnode, ts, 2, tptr == NULL);
fdrop(fp, td);
return (error);
}
@@ -2602,7 +2602,7 @@ ftruncate(td, uap)
fdrop(fp, td);
return (EINVAL);
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
fdrop(fp, td);
return (error);
@@ -2713,7 +2713,7 @@ fsync(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
fdrop(fp, td);
return (error);
@@ -3074,7 +3074,7 @@ ogetdirentries(td, uap)
fdrop(fp, td);
return (EBADF);
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
unionread:
if (vp->v_type != VDIR) {
fdrop(fp, td);
@@ -3174,7 +3174,7 @@ unionread:
struct vnode *tvp = vp;
vp = vp->v_mount->mnt_vnodecovered;
VREF(vp);
- fp->f_data = vp;
+ fp->un_data.vnode = vp;
fp->f_offset = 0;
vput(tvp);
goto unionread;
@@ -3222,7 +3222,7 @@ getdirentries(td, uap)
fdrop(fp, td);
return (EBADF);
}
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
unionread:
if (vp->v_type != VDIR) {
fdrop(fp, td);
@@ -3271,7 +3271,7 @@ unionread:
struct vnode *tvp = vp;
vp = vp->v_mount->mnt_vnodecovered;
VREF(vp);
- fp->f_data = vp;
+ fp->un_data.vnode = vp;
fp->f_offset = 0;
vput(tvp);
goto unionread;
@@ -3624,7 +3624,7 @@ fhopen(td, uap)
* from under us while we block in the lock op
*/
fhold(fp);
- nfp->f_data = vp;
+ nfp->un_data.vnode = vp;
nfp->f_flag = fmode & FMASK;
nfp->f_ops = &vnops;
nfp->f_type = DTYPE_VNODE;
@@ -3945,7 +3945,7 @@ extattr_set_fd(td, uap)
if (error)
return (error);
- error = extattr_set_vp((struct vnode *)fp->f_data, uap->attrnamespace,
+ error = extattr_set_vp(fp->un_data.vnode, uap->attrnamespace,
attrname, uap->data, uap->nbytes, td);
fdrop(fp, td);
@@ -4109,7 +4109,7 @@ extattr_get_fd(td, uap)
if (error)
return (error);
- error = extattr_get_vp((struct vnode *)fp->f_data, uap->attrnamespace,
+ error = extattr_get_vp(fp->un_data.vnode, uap->attrnamespace,
attrname, uap->data, uap->nbytes, td);
fdrop(fp, td);
@@ -4241,7 +4241,7 @@ extattr_delete_fd(td, uap)
error = getvnode(td->td_proc->p_fd, uap->fd, &fp);
if (error)
return (error);
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
error = extattr_delete_vp(vp, uap->attrnamespace, attrname, td);
fdrop(fp, td);
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 8929705..67a4abf 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -502,7 +502,7 @@ vn_read(fp, uio, active_cred, flags, td)
mtx_lock(&Giant);
KASSERT(uio->uio_td == td, ("uio_td %p is not td %p",
uio->uio_td, td));
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
ioflag = 0;
if (fp->f_flag & FNONBLOCK)
ioflag |= IO_NDELAY;
@@ -550,7 +550,7 @@ vn_write(fp, uio, active_cred, flags, td)
mtx_lock(&Giant);
KASSERT(uio->uio_td == td, ("uio_td %p is not td %p",
uio->uio_td, td));
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
if (vp->v_type == VREG)
bwillwrite();
ioflag = IO_UNIT;
@@ -598,7 +598,7 @@ vn_statfile(fp, sb, active_cred, td)
struct ucred *active_cred;
struct thread *td;
{
- struct vnode *vp = (struct vnode *)fp->f_data;
+ struct vnode *vp = fp->un_data.vnode;
int error;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
@@ -741,7 +741,7 @@ vn_ioctl(fp, com, data, active_cred, td)
struct ucred *active_cred;
struct thread *td;
{
- register struct vnode *vp = ((struct vnode *)fp->f_data);
+ struct vnode *vp = fp->un_data.vnode;
struct vnode *vpold;
struct vattr vattr;
int error;
@@ -823,7 +823,7 @@ vn_poll(fp, events, active_cred, td)
int error;
#endif
- vp = (struct vnode *)fp->f_data;
+ vp = fp->un_data.vnode;
#ifdef MAC
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
error = mac_check_vnode_poll(active_cred, fp->f_cred, vp);
@@ -891,8 +891,7 @@ vn_closefile(fp, td)
{
fp->f_ops = &badfileops;
- return (vn_close(((struct vnode *)fp->f_data), fp->f_flag,
- fp->f_cred, td));
+ return (vn_close(fp->un_data.vnode, fp->f_flag, fp->f_cred, td));
}
/*
@@ -1043,7 +1042,7 @@ static int
vn_kqfilter(struct file *fp, struct knote *kn)
{
- return (VOP_KQFILTER(((struct vnode *)fp->f_data), kn));
+ return (VOP_KQFILTER(fp->un_data.vnode, kn));
}
/*
OpenPOWER on IntegriCloud