diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -4085,6 +4086,40 @@ CTLFLAG_RD|CTLFLAG_CAPRD|CTLFLAG_MPSAFE, sysctl_kern_proc_nfds, "Number of open file descriptors"); +struct lock_info { + struct xfile *xf; + u_int flags; +}; + +static int +lock_iterate(struct vnode *vn, struct flock *lk, void *arg) +{ + struct lock_info *lk_info; + + lk_info = (struct lock_info *)arg; + if (lk->l_sysid == 0 && lk_info->xf->xf_pid == lk->l_pid) { + if (lk->l_type == F_RDLCK) + lk_info->flags |= O_SHLOCK; + if (lk->l_type == F_WRLCK) + lk_info->flags |= O_EXLOCK; + if (lk->l_start == 0 && lk->l_len == 0) + lk_info->flags |= O_LOCKWHOLEFILE; + } + return 0; +} + +static u_int +get_lock_flags(struct xfile *xf) +{ + int ret; + struct lock_info lk_info; + + lk_info.xf = xf; + lk_info.flags = 0; + ret = lf_iteratelocks_vnode((struct vnode *)xf->xf_vnode, lock_iterate, &lk_info); + return lk_info.flags; +} + /* * Get file structures globally. */ @@ -4155,6 +4190,8 @@ xf.xf_msgcount = 0; xf.xf_offset = foffset_get(fp); xf.xf_flag = fp->f_flag; + if (xf.xf_type == DTYPE_VNODE && fp->f_ops != &path_fileops) + xf.xf_flag |= get_lock_flags(&xf); error = SYSCTL_OUT(req, &xf, sizeof(xf)); if (error) break; diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -2325,8 +2325,11 @@ static int kqueue_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) { - + struct kqueue *kq = fp->f_data; kif->kf_type = KF_TYPE_KQUEUE; + kif->kf_un.kf_kqueue.kf_kqueue_addr = (uintptr_t)kq; + kif->kf_un.kf_kqueue.kf_kqueue_count = kq->kq_count; + kif->kf_un.kf_kqueue.kf_kqueue_state = kq->kq_state; return (0); } diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c --- a/sys/kern/kern_lockf.c +++ b/sys/kern/kern_lockf.c @@ -1901,7 +1901,7 @@ ldesc->fl.l_len = lf->lf_end - lf->lf_start + 1; ldesc->fl.l_whence = SEEK_SET; - ldesc->fl.l_type = F_UNLCK; + ldesc->fl.l_type = lf->lf_type; ldesc->fl.l_pid = lf->lf_owner->lo_pid; ldesc->fl.l_sysid = sysid; STAILQ_INSERT_TAIL(&locks, ldesc, link); @@ -1968,7 +1968,7 @@ ldesc->fl.l_len = lf->lf_end - lf->lf_start + 1; ldesc->fl.l_whence = SEEK_SET; - ldesc->fl.l_type = F_UNLCK; + ldesc->fl.l_type = lf->lf_type; ldesc->fl.l_pid = lf->lf_owner->lo_pid; ldesc->fl.l_sysid = lf->lf_owner->lo_sysid; STAILQ_INSERT_TAIL(&locks, ldesc, link); diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -1614,6 +1614,9 @@ kif->kf_un.kf_pipe.kf_pipe_addr = (uintptr_t)pi; kif->kf_un.kf_pipe.kf_pipe_peer = (uintptr_t)pi->pipe_peer; kif->kf_un.kf_pipe.kf_pipe_buffer_cnt = pi->pipe_buffer.cnt; + kif->kf_un.kf_pipe.kf_pipe_buffer_in = pi->pipe_buffer.in; + kif->kf_un.kf_pipe.kf_pipe_buffer_out = pi->pipe_buffer.out; + kif->kf_un.kf_pipe.kf_pipe_buffer_size = pi->pipe_buffer.size; return (0); } diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -387,6 +387,10 @@ inpcb = (struct inpcb *)(so->so_pcb); kif->kf_un.kf_sock.kf_sock_inpcb = (uintptr_t)inpcb->inp_ppcb; + kif->kf_un.kf_sock.kf_sock_rcv_sb_state = + so->so_rcv.sb_state; + kif->kf_un.kf_sock.kf_sock_snd_sb_state = + so->so_snd.sb_state; kif->kf_un.kf_sock.kf_sock_sendq = sbused(&so->so_snd); kif->kf_un.kf_sock.kf_sock_recvq = diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -4586,7 +4586,6 @@ #endif /* !BURN_BRIDGES */ #define KINFO_VNODESLOP 10 -#ifdef notyet /* * Dump vnode list (via sysctl). */ @@ -4623,17 +4622,18 @@ break; vref(vp); xvn[n].xv_size = sizeof *xvn; - xvn[n].xv_vnode = vp; + xvn[n].xv_vnode = (uint64_t)vp; xvn[n].xv_id = 0; /* XXX compat */ #define XV_COPY(field) xvn[n].xv_##field = vp->v_##field XV_COPY(usecount); XV_COPY(writecount); XV_COPY(holdcnt); - XV_COPY(mount); - XV_COPY(numoutput); XV_COPY(type); #undef XV_COPY xvn[n].xv_flag = vp->v_vflag; + xvn[n].xv_mount = (uint64_t)vp->v_mount; + xvn[n].xv_numoutput = (int32_t)vp->v_writecount; + xvn[n].xv_lockf = (uint64_t)vp->v_lockf; switch (vp->v_type) { case VREG: @@ -4649,10 +4649,10 @@ xvn[n].xv_dev = dev2udev(vp->v_rdev); break; case VSOCK: - xvn[n].xv_socket = vp->v_socket; + xvn[n].xv_socket = (uint64_t)vp->v_unpcb; break; case VFIFO: - xvn[n].xv_fifo = vp->v_fifoinfo; + xvn[n].xv_fifo = (uint64_t)vp->v_fifoinfo; break; case VNON: case VBAD: @@ -4680,7 +4680,6 @@ SYSCTL_PROC(_kern, KERN_VNODE, vnode, CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, sysctl_vnode, "S,xvnode", ""); -#endif static void unmount_or_warn(struct mount *mp) diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h --- a/sys/sys/fcntl.h +++ b/sys/sys/fcntl.h @@ -145,6 +145,10 @@ #define O_EMPTY_PATH 0x02000000 #endif +#if __BSD_VISIBLE +#define O_LOCKWHOLEFILE 0x04000000 /* the O_SHLOCK/O_EXLOCK applies to the entire file */ +#endif + /* * XXX missing O_RSYNC. */ diff --git a/sys/sys/param.h b/sys/sys/param.h --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -76,7 +76,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1400051 +#define __FreeBSD_version 1400052 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/sys/sys/user.h b/sys/sys/user.h --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -420,8 +420,9 @@ uint64_t kf_pipe_addr; uint64_t kf_pipe_peer; uint32_t kf_pipe_buffer_cnt; - /* Round to 64 bit alignment. */ - uint32_t kf_pipe_pad0[3]; + uint32_t kf_pipe_buffer_in; + uint32_t kf_pipe_buffer_out; + uint32_t kf_pipe_buffer_size; } kf_pipe; struct { uint32_t kf_spareint[4]; @@ -441,6 +442,11 @@ uint64_t kf_eventfd_value; uint32_t kf_eventfd_flags; } kf_eventfd; + struct { + uint64_t kf_kqueue_addr; + int32_t kf_kqueue_count; + int32_t kf_kqueue_state; + } kf_kqueue; } kf_un; }; uint16_t kf_status; /* Status flags. */ diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -197,20 +197,21 @@ * Userland version of struct vnode, for sysctl. */ struct xvnode { - size_t xv_size; /* sizeof(struct xvnode) */ - void *xv_vnode; /* address of real vnode */ - u_long xv_flag; /* vnode vflags */ - int xv_usecount; /* reference count of users */ - int xv_writecount; /* reference count of writers */ - int xv_holdcnt; /* page & buffer references */ - u_long xv_id; /* capability identifier */ - void *xv_mount; /* address of parent mount */ - long xv_numoutput; /* num of writes in progress */ - enum vtype xv_type; /* vnode type */ + ksize_t xv_size; /* sizeof(struct xvnode) */ + uint64_t xv_vnode; /* address of real vnode */ + uint32_t xv_flag; /* vnode vflags */ + int xv_usecount; /* reference count of users */ + int xv_writecount; /* reference count of writers */ + int xv_holdcnt; /* page & buffer references */ + uint64_t xv_id; /* capability identifier */ + uint64_t xv_mount; /* address of parent mount */ + int32_t xv_numoutput; /* num of writes in progress */ + uint32_t xv_type; /* vnode type */ + uint64_t xv_lockf; /* byte-level advisory lock list */ union { - void *xvu_socket; /* unpcb, if VSOCK */ - void *xvu_fifo; /* fifo, if VFIFO */ - dev_t xvu_rdev; /* maj/min, if VBLK/VCHR */ + uint64_t xvu_socket; /* unpcb, if VSOCK */ + uint64_t xvu_fifo; /* fifo, if VFIFO */ + dev_t xvu_rdev; /* maj/min, if VBLK/VCHR */ struct { dev_t xvu_dev; /* device, if VDIR/VREG/VLNK */ ino_t xvu_ino; /* id, if VDIR/VREG/VLNK */