struct kinfo_file changes needed for lsof to work using only usermode APIs`
Add kf_pipe_buffer_[in/out/size] fields to kf_pipe, and populate them. Add a kf_kqueue struct to the kf_un union, to allow querying kqueue state, and populate it. Populate the kf_sock_rcv_sb_state and kf_sock_snd_sb_state fields in kf_sock for INET/INET6 sockets, and populate all other fields for all transport layer protocols, not just TCP. Bump __FreeBSD_version. Differential revision: https://reviews.freebsd.org/D34184 Reviewed by: jhb, kib, se MFC after: 1 week
This commit is contained in:
parent
8ae7694913
commit
8c309d48aa
@ -2324,8 +2324,12 @@ kqueue_close(struct file *fp, struct thread *td)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -341,6 +341,7 @@ eventfd_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp
|
||||
mtx_lock(&efd->efd_lock);
|
||||
kif->kf_un.kf_eventfd.kf_eventfd_value = efd->efd_count;
|
||||
kif->kf_un.kf_eventfd.kf_eventfd_flags = efd->efd_flags;
|
||||
kif->kf_un.kf_eventfd.kf_eventfd_addr = (uintptr_t)efd;
|
||||
mtx_unlock(&efd->efd_lock);
|
||||
return (0);
|
||||
}
|
||||
|
@ -1613,6 +1613,9 @@ pipe_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -382,17 +382,19 @@ soo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
|
||||
switch (kif->kf_un.kf_sock.kf_sock_domain0) {
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
if (kif->kf_un.kf_sock.kf_sock_protocol0 == IPPROTO_TCP) {
|
||||
if (so->so_pcb != NULL) {
|
||||
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_sendq =
|
||||
sbused(&so->so_snd);
|
||||
kif->kf_un.kf_sock.kf_sock_recvq =
|
||||
sbused(&so->so_rcv);
|
||||
}
|
||||
if (so->so_pcb != NULL) {
|
||||
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 =
|
||||
sbused(&so->so_rcv);
|
||||
break;
|
||||
case AF_UNIX:
|
||||
if (so->so_pcb != NULL) {
|
||||
|
@ -76,7 +76,7 @@
|
||||
* cannot include sys/param.h and should only be updated here.
|
||||
*/
|
||||
#undef __FreeBSD_version
|
||||
#define __FreeBSD_version 1400061
|
||||
#define __FreeBSD_version 1400062
|
||||
|
||||
/*
|
||||
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
|
||||
|
@ -420,8 +420,9 @@ struct kinfo_file {
|
||||
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];
|
||||
@ -440,7 +441,14 @@ struct kinfo_file {
|
||||
struct {
|
||||
uint64_t kf_eventfd_value;
|
||||
uint32_t kf_eventfd_flags;
|
||||
uint32_t kf_eventfd_spareint[3];
|
||||
uint64_t kf_eventfd_addr;
|
||||
} 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. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user