diff --git a/lib/libprocstat/Symbol.map b/lib/libprocstat/Symbol.map index 31f19d02d724..cea784900536 100644 --- a/lib/libprocstat/Symbol.map +++ b/lib/libprocstat/Symbol.map @@ -35,9 +35,12 @@ FBSD_1.3 { FBSD_1.5 { procstat_freeptlwpinfo; procstat_getptlwpinfo; - procstat_get_pts_info; procstat_get_sem_info; procstat_get_shm_info; procstat_get_socket_info; +}; + +FBSD_1.6 { + procstat_get_pts_info; procstat_get_vnode_info; }; diff --git a/lib/libprocstat/libprocstat_compat.c b/lib/libprocstat/libprocstat_compat.c index 3b867e4cbe2f..580f2c89794f 100644 --- a/lib/libprocstat/libprocstat_compat.c +++ b/lib/libprocstat/libprocstat_compat.c @@ -36,9 +36,11 @@ __FBSDID("$FreeBSD$"); #include "libprocstat.h" +#define SPECNAMELEN_COMPAT12 63 + struct freebsd11_ptsstat { uint32_t dev; - char devname[SPECNAMELEN + 1]; + char devname[SPECNAMELEN_COMPAT12 + 1]; }; struct freebsd11_vnstat { @@ -49,7 +51,7 @@ struct freebsd11_vnstat { uint32_t vn_fsid; int vn_type; uint16_t vn_mode; - char vn_devname[SPECNAMELEN + 1]; + char vn_devname[SPECNAMELEN_COMPAT12 + 1]; }; struct freebsd11_semstat { uint32_t value; @@ -75,8 +77,25 @@ struct freebsd11_sockstat { char dname[32]; }; +struct freebsd12_vnstat { + uint64_t vn_fileid; + uint64_t vn_size; + uint64_t vn_dev; + uint64_t vn_fsid; + char *vn_mntdir; + int vn_type; + uint16_t vn_mode; + char vn_devname[SPECNAMELEN_COMPAT12 + 1]; +}; +struct freebsd12_ptsstat { + uint64_t dev; + char devname[SPECNAMELEN_COMPAT12 + 1]; +}; + int freebsd11_procstat_get_pts_info(struct procstat *procstat, struct filestat *fst, struct freebsd11_ptsstat *pts, char *errbuf); +int freebsd12_procstat_get_pts_info(struct procstat *procstat, + struct filestat *fst, struct freebsd12_ptsstat *pts_compat, 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, @@ -85,6 +104,10 @@ int freebsd11_procstat_get_socket_info(struct procstat *procstat, struct filestat *fst, struct freebsd11_sockstat *sock, char *errbuf); int freebsd11_procstat_get_vnode_info(struct procstat *procstat, struct filestat *fst, struct freebsd11_vnstat *vn, char *errbuf); +int freebsd12_procstat_get_vnode_info(struct procstat *procstat, + struct filestat *fst, struct freebsd12_vnstat *vn_compat, char *errbuf); + +static const char trunc_name[] = ""; int freebsd11_procstat_get_pts_info(struct procstat *procstat, @@ -97,8 +120,30 @@ freebsd11_procstat_get_pts_info(struct procstat *procstat, if (r != 0) return (r); pts_compat->dev = pts.dev; - memcpy(pts_compat->devname, pts.devname, - sizeof(pts_compat->devname)); + if (strlen(pts.devname) >= sizeof(pts_compat->devname)) + strcpy(pts_compat->devname, trunc_name); + else + memcpy(pts_compat->devname, pts.devname, + sizeof(pts_compat->devname)); + return (0); +} + +int +freebsd12_procstat_get_pts_info(struct procstat *procstat, + struct filestat *fst, struct freebsd12_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; + if (strlen(pts.devname) >= sizeof(pts_compat->devname)) + strcpy(pts_compat->devname, trunc_name); + else + memcpy(pts_compat->devname, pts.devname, + sizeof(pts_compat->devname)); return (0); } @@ -174,8 +219,36 @@ freebsd11_procstat_get_vnode_info(struct procstat *procstat, 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)); + if (strlen(vn.vn_devname) >= sizeof(vn_compat->vn_devname)) + strcpy(vn_compat->vn_devname, trunc_name); + else + memcpy(vn_compat->vn_devname, vn.vn_devname, + sizeof(vn_compat->vn_devname)); + return (0); +} + +int +freebsd12_procstat_get_vnode_info(struct procstat *procstat, + struct filestat *fst, struct freebsd12_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; + if (strlen(vn.vn_devname) >= sizeof(vn_compat->vn_devname)) + strcpy(vn_compat->vn_devname, trunc_name); + else + memcpy(vn_compat->vn_devname, vn.vn_devname, + sizeof(vn_compat->vn_devname)); return (0); } @@ -186,3 +259,6 @@ __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); +__sym_compat(procstat_get_pts_info, freebsd12_procstat_get_pts_info, FBSD_1.5); +__sym_compat(procstat_get_vnode_info, freebsd12_procstat_get_vnode_info, + FBSD_1.5); diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 5c2c485ae7a8..8fc1b0930096 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -630,7 +630,7 @@ prep_cdevsw(struct cdevsw *devsw, int flags) return (0); } - if (devsw->d_version != D_VERSION_03) { + if (devsw->d_version != D_VERSION_04) { printf( "WARNING: Device driver \"%s\" has wrong version %s\n", devsw->d_name == NULL ? "???" : devsw->d_name, diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 190562c6ef47..1e004ebebcef 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -166,7 +166,8 @@ typedef int dumper_hdr_t(struct dumperinfo *di, struct kerneldumpheader *kdh, #define D_VERSION_01 0x17032005 /* Add d_uid,gid,mode & kind */ #define D_VERSION_02 0x28042009 /* Add d_mmap_single */ #define D_VERSION_03 0x17122009 /* d_mmap takes memattr,vm_ooffset_t */ -#define D_VERSION D_VERSION_03 +#define D_VERSION_04 0x5c48c353 /* SPECNAMELEN bumped to MAXNAMLEN */ +#define D_VERSION D_VERSION_04 /* * Flags used for internal housekeeping diff --git a/sys/sys/param.h b/sys/sys/param.h index 291e54da8b7a..07b113f2747a 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300009 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300010 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, @@ -115,7 +115,7 @@ #define NOFILE OPEN_MAX /* max open files per process */ #define NOGROUP 65535 /* marker for empty group set member */ #define MAXHOSTNAMELEN 256 /* max hostname size */ -#define SPECNAMELEN 63 /* max length of devicename */ +#define SPECNAMELEN 255 /* max length of devicename */ /* More types and definitions used throughout the kernel. */ #ifdef _KERNEL