Date: Wed, 29 Jul 2009 21:09:03 +0000 (UTC) From: Stanislav Sedov <stas@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r195951 - in projects/libprocstat: sys/kern sys/sys usr.bin/fstat Message-ID: <200907292109.n6TL93mg082360@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: stas Date: Wed Jul 29 21:09:03 2009 New Revision: 195951 URL: http://svn.freebsd.org/changeset/base/195951 Log: - Rearrange kf_un fields to eliminate possible architecture-dependent paddings. Also name fields more consistently. - Pad all kf_un elements explicitly to avoid confusion. Suggested by: rwatson Modified: projects/libprocstat/sys/kern/kern_descrip.c projects/libprocstat/sys/sys/user.h projects/libprocstat/usr.bin/fstat/libprocstat.c Modified: projects/libprocstat/sys/kern/kern_descrip.c ============================================================================== --- projects/libprocstat/sys/kern/kern_descrip.c Wed Jul 29 20:32:28 2009 (r195950) +++ projects/libprocstat/sys/kern/kern_descrip.c Wed Jul 29 21:09:03 2009 (r195951) @@ -3183,11 +3183,11 @@ fill_vnode_info(struct vnode *vp, struct VFS_UNLOCK_GIANT(vfslocked); if (error != 0) return (error); - kif->kf_un.file.kf_file_fsid = va.va_fsid; - kif->kf_un.file.kf_file_fileid = va.va_fileid; - kif->kf_un.file.kf_file_mode = MAKEIMODE(va.va_type, va.va_mode); - kif->kf_un.file.kf_file_size = va.va_size; - kif->kf_un.file.kf_file_rdev = va.va_rdev; + kif->kf_un.kf_file.kf_file_fsid = va.va_fsid; + kif->kf_un.kf_file.kf_file_fileid = va.va_fileid; + kif->kf_un.kf_file.kf_file_mode = MAKEIMODE(va.va_type, va.va_mode); + kif->kf_un.kf_file.kf_file_size = va.va_size; + kif->kf_un.kf_file.kf_file_rdev = va.va_rdev; return (0); } @@ -3204,14 +3204,14 @@ fill_socket_info(struct socket *so, stru kif->kf_sock_domain = so->so_proto->pr_domain->dom_family; kif->kf_sock_type = so->so_type; kif->kf_sock_protocol = so->so_proto->pr_protocol; - kif->kf_un.sock.kf_sock_pcb = (uintptr_t)so->so_pcb; + kif->kf_un.kf_sock.kf_sock_pcb = (uintptr_t)so->so_pcb; switch(kif->kf_sock_domain) { case AF_INET: case AF_INET6: if (kif->kf_sock_protocol == IPPROTO_TCP) { if (so->so_pcb != NULL) { inpcb = (struct inpcb *)(so->so_pcb); - kif->kf_un.sock.kf_sock_inpcb = + kif->kf_un.kf_sock.kf_sock_inpcb = (uintptr_t)inpcb->inp_ppcb; } } @@ -3220,11 +3220,11 @@ fill_socket_info(struct socket *so, stru if (so->so_pcb != NULL) { unpcb = (struct unpcb *)(so->so_pcb); if (unpcb->unp_conn) { - kif->kf_un.sock.kf_sock_unpconn = + kif->kf_un.kf_sock.kf_sock_unpconn = (uintptr_t)unpcb->unp_conn; - kif->kf_un.sock.kf_sock_rcv_sb_state = + kif->kf_un.kf_sock.kf_sock_rcv_sb_state = so->so_rcv.sb_state; - kif->kf_un.sock.kf_sock_snd_sb_state = + kif->kf_un.kf_sock.kf_sock_snd_sb_state = so->so_snd.sb_state; } } @@ -3251,7 +3251,7 @@ fill_pts_info(struct tty *tp, struct kin if (tp == NULL) return (1); - kif->kf_un.pts.pts_dev = tty_udev(tp); + kif->kf_un.kf_pts.kf_pts_dev = tty_udev(tp); strlcpy(kif->kf_path, tty_devname(tp), sizeof(kif->kf_path)); return (0); } @@ -3262,9 +3262,9 @@ fill_pipe_info(struct pipe *pi, struct k if (pi == NULL) return (1); - kif->kf_un.pipe.pipe_addr = (uintptr_t)pi; - kif->kf_un.pipe.pipe_peer = (uintptr_t)pi->pipe_peer; - kif->kf_un.pipe.pipe_buffer_cnt = pi->pipe_buffer.cnt; + 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; return (0); } Modified: projects/libprocstat/sys/sys/user.h ============================================================================== --- projects/libprocstat/sys/sys/user.h Wed Jul 29 20:32:28 2009 (r195950) +++ projects/libprocstat/sys/sys/user.h Wed Jul 29 21:09:03 2009 (r195951) @@ -336,39 +336,46 @@ struct kinfo_file { struct sockaddr_storage kf_sa_peer; /* Peer address. */ union { struct { - /* Send buffer state. */ - uint16_t kf_sock_snd_sb_state; - /* Receive buffer state. */ - uint16_t kf_sock_rcv_sb_state; /* Address of so_pcb. */ uint64_t kf_sock_pcb; /* Address of inp_ppcb. */ uint64_t kf_sock_inpcb; /* Address of unp_conn. */ uint64_t kf_sock_unpconn; - /* Round to 64-bit alignment. */ - int kf_sock_pad; - } sock; + /* Send buffer state. */ + uint16_t kf_sock_snd_sb_state; + /* Receive buffer state. */ + uint16_t kf_sock_rcv_sb_state; + /* Round to 64 bit alignment. */ + uint32_t kf_sock_pad0; + } kf_sock; struct { - /* Vnode filesystem id. */ - dev_t kf_file_fsid; - /* File device. */ - dev_t kf_file_rdev; /* Global file id. */ uint64_t kf_file_fileid; /* File size. */ off_t kf_file_size; + /* Vnode filesystem id. */ + dev_t kf_file_fsid; + /* File device. */ + dev_t kf_file_rdev; /* File mode. */ mode_t kf_file_mode; - } file; + /* Round to 64 bit alignment. */ + uint16_t kf_file_pad0; + uint32_t kf_file_pad1; + } kf_file; struct { - uint32_t pipe_buffer_cnt; - uint64_t pipe_addr; - uint64_t pipe_peer; - } pipe; + 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]; + } kf_pipe; struct { - dev_t pts_dev; - } pts; + dev_t kf_pts_dev; + /* Round to 64 bit alignment. */ + uint32_t kf_pts_pad0[7]; + } kf_pts; } kf_un; uint16_t kf_status; /* Status flags. */ uint16_t kf_pad1; /* Round to 32 bit alignment. */ Modified: projects/libprocstat/usr.bin/fstat/libprocstat.c ============================================================================== --- projects/libprocstat/usr.bin/fstat/libprocstat.c Wed Jul 29 20:32:28 2009 (r195950) +++ projects/libprocstat/usr.bin/fstat/libprocstat.c Wed Jul 29 21:09:03 2009 (r195951) @@ -650,9 +650,9 @@ procstat_get_pipe_info_sysctl(struct fil kif = fst->fs_typedep; if (kif == NULL) return (1); - ps->addr = kif->kf_un.pipe.pipe_addr; - ps->peer = kif->kf_un.pipe.pipe_peer; - ps->buffer_cnt = kif->kf_un.pipe.pipe_buffer_cnt; + ps->addr = kif->kf_un.kf_pipe.kf_pipe_addr; + ps->peer = kif->kf_un.kf_pipe.kf_pipe_peer; + ps->buffer_cnt = kif->kf_un.kf_pipe.kf_pipe_buffer_cnt; return (0); } @@ -713,7 +713,7 @@ procstat_get_pts_info_sysctl(struct file kif = fst->fs_typedep; if (kif == NULL) return (0); - pts->dev = kif->kf_un.pts.pts_dev; + pts->dev = kif->kf_un.kf_pts.kf_pts_dev; strlcpy(pts->devname, kif->kf_path, sizeof(pts->devname)); return (0); } @@ -883,12 +883,12 @@ procstat_get_vnode_info_sysctl(struct fi status = kve->kve_status; } else { kif = fst->fs_typedep; - fileid = kif->kf_un.file.kf_file_fileid; - fsid = kif->kf_un.file.kf_file_fsid; - mode = kif->kf_un.file.kf_file_mode; + fileid = kif->kf_un.kf_file.kf_file_fileid; + fsid = kif->kf_un.kf_file.kf_file_fsid; + mode = kif->kf_un.kf_file.kf_file_mode; path = kif->kf_path; - rdev = kif->kf_un.file.kf_file_rdev; - size = kif->kf_un.file.kf_file_size; + rdev = kif->kf_un.kf_file.kf_file_rdev; + size = kif->kf_un.kf_file.kf_file_size; vntype = kinfo_vtype2fst(kif->kf_vnode_type); status = kif->kf_status; } @@ -1053,7 +1053,7 @@ procstat_get_socket_info_sysctl(struct f sock->type = kif->kf_sock_type; sock->proto = kif->kf_sock_protocol; sock->dom_family = kif->kf_sock_domain; - sock->so_pcb = kif->kf_un.sock.kf_sock_pcb; + sock->so_pcb = kif->kf_un.kf_sock.kf_sock_pcb; strlcpy(sock->dname, kif->kf_path, sizeof(sock->dname)); /* @@ -1063,16 +1063,16 @@ procstat_get_socket_info_sysctl(struct f case AF_INET: case AF_INET6: if (sock->proto == IPPROTO_TCP) - sock->inp_ppcb = kif->kf_un.sock.kf_sock_inpcb; + sock->inp_ppcb = kif->kf_un.kf_sock.kf_sock_inpcb; break; case AF_UNIX: - if (kif->kf_un.sock.kf_sock_unpconn != 0) { + if (kif->kf_un.kf_sock.kf_sock_unpconn != 0) { sock->so_rcv_sb_state = - kif->kf_un.sock.kf_sock_rcv_sb_state; + kif->kf_un.kf_sock.kf_sock_rcv_sb_state; sock->so_snd_sb_state = - kif->kf_un.sock.kf_sock_snd_sb_state; + kif->kf_un.kf_sock.kf_sock_snd_sb_state; sock->unp_conn = - kif->kf_un.sock.kf_sock_unpconn; + kif->kf_un.kf_sock.kf_sock_unpconn; } break; default:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907292109.n6TL93mg082360>