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.
This commit is contained in:
Matthew Dillon 2003-01-12 01:37:13 +00:00
parent 1bd6f83d4d
commit cd72f2180b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=109123
51 changed files with 231 additions and 213 deletions

View File

@ -222,7 +222,7 @@ struct tcpiphdr *ti;
}
s = (struct socket *)calloc(1, sizeof(*s));
if (KMCPY(s, f->f_data, sizeof(*s)) == -1)
if (KMCPY(s, f->un_data.socket, sizeof(*s)) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) - f_data - failed\n",
o[fd], s, sizeof(*s));
@ -316,10 +316,11 @@ struct tcpiphdr *ti;
}
s = (struct socket *)calloc(1, sizeof(*s));
if (KMCPY(s, f->f_data, sizeof(*s)) == -1)
if (KMCPY(s, f->un_data.socket, sizeof(*s)) == -1)
{
fprintf(stderr, "read(%#lx,%#lx,%lu) - f_data - failed\n",
(u_long)f->f_data, (u_long)s, (u_long)sizeof(*s));
(u_long)f->un_data.socket, (u_long)s,
(u_long)sizeof(*s));
return NULL;
}

View File

@ -159,7 +159,7 @@ osf1_fstatfs(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)))
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
mp = (fp->un_data.vnode)->v_mount;
#ifdef MAC
error = mac_check_mount_stat(td->td_proc->p_ucred, mp);
if (error) {

View File

@ -270,7 +270,7 @@ getdents_common(struct thread *td, struct linux_getdents64_args *args,
return (EBADF);
}
vp = (struct vnode *) fp->f_data;
vp = fp->un_data.vnode;
if (vp->v_type != VDIR) {
fdrop(fp, td);
return (EINVAL);

View File

@ -289,7 +289,7 @@ linux_fstatfs(struct thread *td, struct linux_fstatfs_args *args)
error = getvnode(td->td_proc->p_fd, args->fd, &fp);
if (error)
return error;
mp = ((struct vnode *)fp->f_data)->v_mount;
mp = fp->un_data.vnode->v_mount;
#ifdef MAC
error = mac_check_mount_stat(td->td_proc->p_ucred, mp);
if (error) {

View File

@ -311,7 +311,7 @@ fd_truncate(td, fd, flp)
if ((error = fget(td, fd, &fp)) != 0)
return (error);
vp = (struct vnode *) fp->f_data;
vp = fp->un_data.vnode;
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
fdrop(fp, td);

View File

@ -115,7 +115,7 @@ svr4_sys_read(td, uap)
}
if (fp->f_type == DTYPE_SOCKET) {
so = (struct socket *)fp->f_data;
so = fp->un_data.socket;
DPRINTF(("fd %d is a socket\n", uap->fd));
if (so->so_state & SS_ASYNC) {
DPRINTF(("fd %d is an ASYNC socket!\n", uap->fd));

View File

@ -112,7 +112,7 @@ svr4_sys_ioctl(td, uap)
#if defined(DEBUG_SVR4)
if (fp->f_type == DTYPE_SOCKET) {
struct socket *so = (struct socket *)fp->f_data;
struct socket *so = fp->un_data.socket;
DPRINTF(("<<< IN: so_state = 0x%x\n", so->so_state));
}
#endif
@ -157,7 +157,7 @@ svr4_sys_ioctl(td, uap)
if (fp->f_type == DTYPE_SOCKET) {
struct socket *so;
so = (struct socket *)fp->f_data;
so = fp->un_data.socket;
DPRINTF((">>> OUT: so_state = 0x%x\n", so->so_state));
}
#endif

View File

@ -271,7 +271,7 @@ svr4_sys_getdents64(td, uap)
return (EBADF);
}
vp = (struct vnode *) fp->f_data;
vp = fp->un_data.vnode;
if (vp->v_type != VDIR) {
fdrop(fp, td);
@ -451,7 +451,7 @@ svr4_sys_getdents(td, uap)
return (EBADF);
}
vp = (struct vnode *)fp->f_data;
vp = fp->un_data.vnode;
if (vp->v_type != VDIR) {
fdrop(fp, td);
return (EINVAL);
@ -627,7 +627,7 @@ svr4_sys_fchroot(td, uap)
return error;
if ((error = getvnode(fdp, uap->fd, &fp)) != 0)
return error;
vp = (struct vnode *) fp->f_data;
vp = fp->un_data.vnode;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
if (vp->v_type != VDIR)
error = ENOTDIR;

View File

@ -82,7 +82,7 @@ svr4_find_socket(td, fp, dev, ino)
ino_t ino;
{
struct svr4_sockcache_entry *e;
void *cookie = ((struct socket *) fp->f_data)->so_emuldata;
void *cookie = fp->un_data.socket->so_emuldata;
if (svr4_str_initialized != 2) {
if (atomic_cmpset_acq_int(&svr4_str_initialized, 0, 1)) {

View File

@ -644,7 +644,7 @@ getparm(fp, pa)
if (st == NULL)
return;
so = (struct socket *) fp->f_data;
so = fp->un_data.socket;
pa->family = st->s_family;

View File

@ -274,7 +274,7 @@ streamsopen(dev_t dev, int oflags, int devtype, struct thread *td)
}
FILEDESC_LOCK(p->p_fd);
fp->f_data = (caddr_t)so;
fp->un_data.socket = so;
fp->f_flag = FREAD|FWRITE;
fp->f_ops = &svr4_netops;
fp->f_type = DTYPE_SOCKET;
@ -357,7 +357,7 @@ svr4_stream_get(fp)
if (fp == NULL || fp->f_type != DTYPE_SOCKET)
return NULL;
so = (struct socket *) fp->f_data;
so = fp->un_data.socket;
/*
* mpfixme: lock socketbuffer here
@ -395,7 +395,7 @@ svr4_delete_socket(p, fp)
struct file *fp;
{
struct svr4_sockcache_entry *e;
void *cookie = ((struct socket *) fp->f_data)->so_emuldata;
void *cookie = fp->un_data.socket->so_emuldata;
while (svr4_str_initialized != 2) {
if (atomic_cmpset_acq_int(&svr4_str_initialized, 0, 1)) {
@ -418,7 +418,7 @@ svr4_delete_socket(p, fp)
static int
svr4_soo_close(struct file *fp, struct thread *td)
{
struct socket *so = (struct socket *)fp->f_data;
struct socket *so = fp->un_data.socket;
/* CHECKUNIT_DIAG(ENXIO);*/

View File

@ -395,7 +395,7 @@ fdesc_setattr(ap)
}
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, ap->a_td);
return (error);

View File

@ -352,7 +352,7 @@ fifo_ioctl(ap)
if (ap->a_command == FIONBIO)
return (0);
if (ap->a_fflag & FREAD) {
filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock;
filetmp.un_data.socket = ap->a_vp->v_fifoinfo->fi_readsock;
filetmp.f_cred = ap->a_cred;
error = soo_ioctl(&filetmp, ap->a_command, ap->a_data,
ap->a_td->td_ucred, ap->a_td);
@ -360,7 +360,7 @@ fifo_ioctl(ap)
return (error);
}
if (ap->a_fflag & FWRITE) {
filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock;
filetmp.un_data.socket = ap->a_vp->v_fifoinfo->fi_writesock;
filetmp.f_cred = ap->a_cred;
error = soo_ioctl(&filetmp, ap->a_command, ap->a_data,
ap->a_td->td_ucred, ap->a_td);
@ -482,9 +482,9 @@ fifo_poll(ap)
events |= POLLINIGNEOF;
}
filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock;
filetmp.un_data.socket = ap->a_vp->v_fifoinfo->fi_readsock;
filetmp.f_cred = ap->a_cred;
if (filetmp.f_data)
if (filetmp.un_data.socket)
revents |= soo_poll(&filetmp, events,
ap->a_td->td_ucred, ap->a_td);
@ -497,9 +497,9 @@ fifo_poll(ap)
}
events = ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND);
if (events) {
filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock;
filetmp.un_data.socket = ap->a_vp->v_fifoinfo->fi_writesock;
filetmp.f_cred = ap->a_cred;
if (filetmp.f_data)
if (filetmp.un_data.socket)
revents |= soo_poll(&filetmp, events,
ap->a_td->td_ucred, ap->a_td);
}

View File

@ -106,7 +106,7 @@ portal_mount(mp, path, data, ndp, td)
fdrop(fp, td);
return(ENOTSOCK);
}
so = (struct socket *) fp->f_data; /* XXX race against userland */
so = fp->un_data.socket; /* XXX race against userland */
if (so->so_proto->pr_domain->dom_family != AF_UNIX) {
fdrop(fp, td);
return (ESOCKTNOSUPPORT);
@ -186,7 +186,7 @@ portal_unmount(mp, mntflags, td)
* daemon to wake up, and then the accept will get ECONNABORTED
* which it interprets as a request to go and bury itself.
*/
soshutdown((struct socket *) VFSTOPORTAL(mp)->pm_server->f_data, 2);
soshutdown(VFSTOPORTAL(mp)->pm_server->un_data.socket, 2);
/*
* Discard reference to underlying file. Must call closef because
* this may be the last reference.

View File

@ -269,7 +269,7 @@ portal_open(ap)
/*
* Kick off connection
*/
error = portal_connect(so, (struct socket *)fmp->pm_server->f_data);
error = portal_connect(so, fmp->pm_server->un_data.socket);
if (error)
goto bad;

View File

@ -1329,7 +1329,7 @@ union_dircheck(struct thread *td, struct vnode **vp, struct file *fp)
}
VOP_UNLOCK(lvp, 0, td);
FILE_LOCK(fp);
fp->f_data = (caddr_t) lvp;
fp->un_data.vnode = lvp;
fp->f_offset = 0;
FILE_UNLOCK(fp);
error = vn_close(*vp, FREAD, fp->f_cred, td);

View File

@ -323,7 +323,7 @@ ibcs2_getdents(td, uap)
fdrop(fp, td);
return (EBADF);
}
vp = (struct vnode *)fp->f_data;
vp = fp->un_data.vnode;
if (vp->v_type != VDIR) { /* XXX vnode readdir op should do this */
fdrop(fp, td);
return (EINVAL);
@ -480,7 +480,7 @@ ibcs2_read(td, uap)
fdrop(fp, td);
return (EBADF);
}
vp = (struct vnode *)fp->f_data;
vp = fp->un_data.vnode;
if (vp->v_type != VDIR) {
fdrop(fp, td);
return read(td, (struct read_args *)uap);

View File

@ -132,7 +132,7 @@ ibcs2_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;
sp = &mp->mnt_stat;
error = VFS_STATFS(mp, sp, td);
fdrop(fp, td);

View File

@ -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);
}

View File

@ -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));

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -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)

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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 @@ _aio_aqueue(struct thread *td, struct aiocb *job, struct aio_liojob *lj, int typ
* 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();

View File

@ -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 @@ ogetdirentries(td, uap)
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 @@ getdirentries(td, uap)
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);

View File

@ -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 @@ ogetdirentries(td, uap)
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 @@ getdirentries(td, uap)
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);

View File

@ -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));
}
/*

View File

@ -601,7 +601,7 @@ ng_internalize(struct mbuf *control, struct thread *td)
* shortcut straight to the node. */
switch (fp->f_type) {
case DTYPE_VNODE:
vn = (struct vnode *) fp->f_data;
vn = fp->un_data.vnode;
if (vn && (vn->v_type == VCHR)) {
/* for a VCHR, actually reference the FILE */
fp->f_count++;

View File

@ -420,7 +420,7 @@ smb_dev2share(int fd, int mode, struct smb_cred *scred,
fp = nsmb_getfp(scred->scr_td->td_proc->p_fd, fd, FREAD | FWRITE);
if (fp == NULL)
return EBADF;
vp = (struct vnode*)fp->f_data;
vp = fp->un_data.vnode;
if (vp == NULL) {
fdrop(fp, curthread);
return EBADF;

View File

@ -200,7 +200,7 @@ nfssvc_addsock(struct file *fp, struct sockaddr *mynam, struct thread *td)
struct socket *so;
int error, s;
so = (struct socket *)fp->f_data;
so = fp->un_data.socket;
#if 0
tslp = NULL;
/*

View File

@ -134,7 +134,7 @@ cryptof_ioctl(
struct thread *td)
{
struct cryptoini cria, crie;
struct fcrypt *fcr = (struct fcrypt *)fp->f_data;
struct fcrypt *fcr = fp->un_data.fcrypt;
struct csession *cse;
struct session_op *sop;
struct crypt_op *cop;
@ -608,7 +608,7 @@ cryptof_stat(
static int
cryptof_close(struct file *fp, struct thread *td)
{
struct fcrypt *fcr = (struct fcrypt *)fp->f_data;
struct fcrypt *fcr = fp->un_data.fcrypt;
struct csession *cse;
while ((cse = TAILQ_FIRST(&fcr->csessions))) {
@ -616,7 +616,7 @@ cryptof_close(struct file *fp, struct thread *td)
(void)csefree(cse);
}
FREE(fcr, M_XDATA);
fp->f_data = NULL;
fp->un_data.fcrypt = NULL;
return 0;
}
@ -733,7 +733,7 @@ cryptoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
f->f_flag = FREAD | FWRITE;
f->f_type = DTYPE_CRYPTO;
f->f_ops = &cryptofops;
f->f_data = (caddr_t) fcr;
f->un_data.fcrypt = fcr;
*(u_int32_t *)data = fd;
fdrop(f, td);
break;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -52,6 +52,11 @@ struct uio;
struct knote;
struct vnode;
struct socket;
struct kqueue;
struct pipe;
struct fcrypt;
struct vm_object;
#endif /* _KERNEL */
@ -100,6 +105,7 @@ struct fileops {
* (f) f_mtx in struct file
* none not locked
*/
struct file {
LIST_ENTRY(file) f_list;/* (fl) list of active files */
short f_gcflag; /* used by thread doing fd garbage collection */
@ -116,7 +122,15 @@ struct file {
* offset of next expected read or write
*/
off_t f_offset;
void *f_data; /* vnode or socket */
union { /* file descriptor specific data */
void *generic;
struct vnode *vnode;
struct socket *socket;
struct kqueue *kqueue;
struct pipe *pipe;
struct fcrypt *fcrypt;
struct vm_object *object;
} un_data;
u_int f_flag; /* see fcntl.h */
struct mtx *f_mtxp; /* mutex to protect data */
};
@ -136,7 +150,15 @@ struct xfile {
int xf_count; /* reference count */
int xf_msgcount; /* references from message queue */
off_t xf_offset; /* file offset */
void *xf_data; /* pointer to vnode or socket */
union {
void *generic;
struct vnode *vnode;
struct socket *socket;
struct kqueue *kqueue;
struct pipe *pipe;
struct fcrypt *fcrypt;
struct vm_object *object;
} xun_data;
u_int xf_flag; /* flags (see fcntl.h) */
};

View File

@ -2184,7 +2184,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
return (ERPCMISMATCH);
if ((error = getvnode(curproc->p_fd, cmd.handle, &fp)) != 0)
return (error);
vn_start_write((struct vnode *)fp->f_data, &mp, V_WAIT);
vn_start_write(fp->un_data.vnode, &mp, V_WAIT);
if (mp == 0 || strncmp(mp->mnt_stat.f_fstypename, "ufs", MFSNAMELEN)) {
vn_finished_write(mp);
fdrop(fp, curthread);

View File

@ -309,7 +309,7 @@ mmap(td, uap)
*/
if (fp->f_flag & FPOSIXSHM)
flags |= MAP_NOSYNC;
vp = (struct vnode *) fp->f_data;
vp = fp->un_data.vnode;
error = vget(vp, LK_EXCLUSIVE, td);
if (error)
goto done;

View File

@ -381,23 +381,21 @@ dofiles(kp)
continue;
}
if (file.f_type == DTYPE_VNODE)
vtrans((struct vnode *)file.f_data, i, file.f_flag);
vtrans(file.un_data.vnode, i, file.f_flag);
else if (file.f_type == DTYPE_SOCKET) {
if (checkfile == 0)
socktrans((struct socket *)file.f_data, i);
socktrans(file.un_data.socket, i);
}
#ifdef DTYPE_PIPE
else if (file.f_type == DTYPE_PIPE) {
if (checkfile == 0)
pipetrans((struct pipe *)file.f_data, i,
file.f_flag);
pipetrans(file.un_data.pipe, i, file.f_flag);
}
#endif
#ifdef DTYPE_FIFO
else if (file.f_type == DTYPE_FIFO) {
if (checkfile == 0)
vtrans((struct vnode *)file.f_data, i,
file.f_flag);
vtrans(file.un_data.vnode, i, file.f_flag);
}
#endif
else {

View File

@ -470,9 +470,9 @@ display(void)
"LOCAL ADDRESS", "FOREIGN ADDRESS");
setpassent(1);
for (xf = xfiles, n = 0; n < nxfiles; ++n, ++xf) {
hash = (int)((uintptr_t)xf->xf_data % HASHSIZE);
hash = (int)((uintptr_t)xf->xun_data.generic % HASHSIZE);
for (s = sockhash[hash]; s != NULL; s = s->next)
if (s->socket == xf->xf_data)
if (s->socket == xf->xun_data.socket)
break;
if (s == NULL)
continue;

View File

@ -418,7 +418,7 @@ filemode(void)
*fbp = '\0';
(void)printf("%6s %3d", flagbuf, fp->xf_count);
(void)printf(" %3d", fp->xf_msgcount);
(void)printf(" %8lx", (u_long)(void *)fp->xf_data);
(void)printf(" %8lx", (u_long)fp->xun_data.generic);
(void)printf(" %jx\n", (uintmax_t)fp->xf_offset);
}
free(buf);