diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2017-05-23 09:29:05 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2017-05-23 09:29:05 +0000 |
| commit | 69921123490b99c2588b0c743bc4af32bbe6601c (patch) | |
| tree | 4828066c23bd9bbd1672af14fbf0a9e31e47f4a0 /lib/libprocstat | |
| parent | 5f7c516f216995249523ed43e57e3f91bd8f5ff0 (diff) | |
Commit the 64-bit inode project.
Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment. Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.
ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks. Unfortunately, not everything can be
fixed, especially outside the base system. For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.
Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.
Struct xvnode changed layout, no compat shims are provided.
For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.
Update note: strictly follow the instructions in UPDATING. Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.
Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver. Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).
Sponsored by: The FreeBSD Foundation (emaste, kib)
Differential revision: https://reviews.freebsd.org/D10439
Notes
svn path=/head/; revision=318736
Diffstat (limited to 'lib/libprocstat')
| -rw-r--r-- | lib/libprocstat/Makefile | 4 | ||||
| -rw-r--r-- | lib/libprocstat/Symbol.map | 8 | ||||
| -rw-r--r-- | lib/libprocstat/libprocstat.c | 12 | ||||
| -rw-r--r-- | lib/libprocstat/libprocstat.h | 6 | ||||
| -rw-r--r-- | lib/libprocstat/libprocstat_compat.c | 144 |
5 files changed, 162 insertions, 12 deletions
diff --git a/lib/libprocstat/Makefile b/lib/libprocstat/Makefile index 8d4fae0dffe9..9d80d17e16a8 100644 --- a/lib/libprocstat/Makefile +++ b/lib/libprocstat/Makefile @@ -13,6 +13,10 @@ SRCS= cd9660.c \ smbfs.c \ udf.c +.if ${MK_SYMVER} == yes +SRCS+= libprocstat_compat.c +.endif + VERSION_DEF= ${LIBCSRCDIR}/Versions.def SYMBOL_MAPS= ${.CURDIR}/Symbol.map diff --git a/lib/libprocstat/Symbol.map b/lib/libprocstat/Symbol.map index 75a8916aca67..a78a4691fe5d 100644 --- a/lib/libprocstat/Symbol.map +++ b/lib/libprocstat/Symbol.map @@ -6,9 +6,7 @@ FBSD_1.2 { procstat_freefiles; procstat_freeprocs; procstat_get_pipe_info; - procstat_get_pts_info; procstat_get_socket_info; - procstat_get_vnode_info; procstat_getfiles; procstat_getprocs; procstat_open_kvm; @@ -22,8 +20,6 @@ FBSD_1.3 { procstat_freegroups; procstat_freekstack; procstat_freevmmap; - procstat_get_sem_info; - procstat_get_shm_info; procstat_getargv; procstat_getauxv; procstat_getenvv; @@ -40,4 +36,8 @@ FBSD_1.3 { FBSD_1.5 { procstat_freeptlwpinfo; procstat_getptlwpinfo; + procstat_get_pts_info; + procstat_get_sem_info; + procstat_get_shm_info; + procstat_get_vnode_info; }; diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 7d42acce4201..d674adc4f9ea 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -1337,12 +1337,12 @@ procstat_get_vnode_info_sysctl(struct filestat *fst, struct vnstat *vn, struct statfs stbuf; struct kinfo_file *kif; struct kinfo_vmentry *kve; + char *name, *path; uint64_t fileid; uint64_t size; - char *name, *path; - uint32_t fsid; + uint64_t fsid; + uint64_t rdev; uint16_t mode; - uint32_t rdev; int vntype; int status; @@ -1545,8 +1545,10 @@ procstat_get_socket_info_sysctl(struct filestat *fst, struct sockstat *sock, sock->dom_family = kif->kf_sock_domain; sock->so_pcb = kif->kf_un.kf_sock.kf_sock_pcb; strlcpy(sock->dname, kif->kf_path, sizeof(sock->dname)); - bcopy(&kif->kf_sa_local, &sock->sa_local, kif->kf_sa_local.ss_len); - bcopy(&kif->kf_sa_peer, &sock->sa_peer, kif->kf_sa_peer.ss_len); + bcopy(&kif->kf_un.kf_sock.kf_sa_local, &sock->sa_local, + kif->kf_un.kf_sock.kf_sa_local.ss_len); + bcopy(&kif->kf_un.kf_sock.kf_sa_peer, &sock->sa_peer, + kif->kf_un.kf_sock.kf_sa_peer.ss_len); /* * Protocol specific data. diff --git a/lib/libprocstat/libprocstat.h b/lib/libprocstat/libprocstat.h index 00b6f1c1c110..7584878252d4 100644 --- a/lib/libprocstat/libprocstat.h +++ b/lib/libprocstat/libprocstat.h @@ -120,15 +120,15 @@ struct filestat { struct vnstat { uint64_t vn_fileid; uint64_t vn_size; + uint64_t vn_dev; + uint64_t vn_fsid; char *vn_mntdir; - uint32_t vn_dev; - uint32_t vn_fsid; int vn_type; uint16_t vn_mode; char vn_devname[SPECNAMELEN + 1]; }; struct ptsstat { - uint32_t dev; + uint64_t dev; char devname[SPECNAMELEN + 1]; }; struct pipestat { diff --git a/lib/libprocstat/libprocstat_compat.c b/lib/libprocstat/libprocstat_compat.c new file mode 100644 index 000000000000..52d80c7afab4 --- /dev/null +++ b/lib/libprocstat/libprocstat_compat.c @@ -0,0 +1,144 @@ +/*- + * Copyright (c) 2014 Gleb Kurtsou <gleb@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/user.h> +#include <sys/socket.h> +#include <string.h> + +#include "libprocstat.h" + +struct freebsd11_ptsstat { + uint32_t dev; + char devname[SPECNAMELEN + 1]; +}; + +struct freebsd11_vnstat { + uint64_t vn_fileid; + uint64_t vn_size; + char *vn_mntdir; + uint32_t vn_dev; + uint32_t vn_fsid; + int vn_type; + uint16_t vn_mode; + char vn_devname[SPECNAMELEN + 1]; +}; +struct freebsd11_semstat { + uint32_t value; + uint16_t mode; +}; +struct freebsd11_shmstat { + uint64_t size; + uint16_t mode; +}; + +int freebsd11_procstat_get_pts_info(struct procstat *procstat, + struct filestat *fst, struct freebsd11_ptsstat *pts, char *errbuf); +int freebsd11_procstat_get_sem_info(struct procstat *procstat, + struct filestat *fst, struct freebsd11_semstat *sem, char *errbuf); +int freebsd11_procstat_get_shm_info(struct procstat *procstat, + struct filestat *fst, struct freebsd11_shmstat *shm, char *errbuf); +int freebsd11_procstat_get_vnode_info(struct procstat *procstat, + struct filestat *fst, struct freebsd11_vnstat *vn, char *errbuf); + +int +freebsd11_procstat_get_pts_info(struct procstat *procstat, + struct filestat *fst, struct freebsd11_ptsstat *pts_compat, char *errbuf) +{ + struct ptsstat pts; + int r; + + r = procstat_get_pts_info(procstat, fst, &pts, errbuf); + if (r != 0) + return (r); + pts_compat->dev = pts.dev; + memcpy(pts_compat->devname, pts.devname, + sizeof(pts_compat->devname)); + return (0); +} + +int +freebsd11_procstat_get_sem_info(struct procstat *procstat, + struct filestat *fst, struct freebsd11_semstat *sem_compat, char *errbuf) +{ + struct semstat sem; + int r; + + r = procstat_get_sem_info(procstat, fst, &sem, errbuf); + if (r != 0) + return (r); + sem_compat->value = sem.value; + sem_compat->mode = sem.mode; + return (0); +} + +int +freebsd11_procstat_get_shm_info(struct procstat *procstat, + struct filestat *fst, struct freebsd11_shmstat *shm_compat, char *errbuf) +{ + struct shmstat shm; + int r; + + r = procstat_get_shm_info(procstat, fst, &shm, errbuf); + if (r != 0) + return (r); + shm_compat->size = shm.size; + shm_compat->mode = shm.mode; + return (0); +} + +int +freebsd11_procstat_get_vnode_info(struct procstat *procstat, + struct filestat *fst, struct freebsd11_vnstat *vn_compat, char *errbuf) +{ + struct vnstat vn; + int r; + + r = procstat_get_vnode_info(procstat, fst, &vn, errbuf); + if (r != 0) + return (r); + vn_compat->vn_fileid = vn.vn_fileid; + vn_compat->vn_size = vn.vn_size; + vn_compat->vn_mntdir = vn.vn_mntdir; + vn_compat->vn_dev = vn.vn_dev; + vn_compat->vn_fsid = vn.vn_fsid; + vn_compat->vn_type = vn.vn_type; + vn_compat->vn_mode = vn.vn_mode; + memcpy(vn_compat->vn_devname, vn.vn_devname, + sizeof(vn_compat->vn_devname)); + return (0); +} + +__sym_compat(procstat_get_pts_info, freebsd11_procstat_get_pts_info, FBSD_1.2); +__sym_compat(procstat_get_vnode_info, freebsd11_procstat_get_vnode_info, + FBSD_1.2); +__sym_compat(procstat_get_sem_info, freebsd11_procstat_get_sem_info, FBSD_1.3); +__sym_compat(procstat_get_shm_info, freebsd11_procstat_get_shm_info, FBSD_1.3); |
