Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145525304
D50721.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
D50721.diff
View Options
diff --git a/lib/libprocstat/Makefile b/lib/libprocstat/Makefile
--- a/lib/libprocstat/Makefile
+++ b/lib/libprocstat/Makefile
@@ -52,18 +52,23 @@
libprocstat.3 procstat_open_kvm.3 \
libprocstat.3 procstat_open_sysctl.3
-# XXX This is a hack.
.if ${MK_CDDL} != "no"
CFLAGS+= -DLIBPROCSTAT_ZFS
SRCS+= zfs.c
-OBJS+= zfs/zfs_defs.o
-SUBDIR= zfs
-zfs/zfs_defs.o: .PHONY
- @cd ${.CURDIR}/zfs && ${MAKE} zfs_defs.o
-zfs/zfs_defs.pico: .PHONY
- @cd ${.CURDIR}/zfs && ${MAKE} zfs_defs.pico
-zfs/zfs_defs.pieo: .PHONY
- @cd ${.CURDIR}/zfs && ${MAKE} zfs_defs.pieo
+ZFSTOP= ${SRCTOP}/sys/contrib/openzfs
+CFLAGS.zfs.c+= -DIN_BASE
+CFLAGS.zfs.c+= -DHAVE_ISSETUGID
+CFLAGS.zfs.c+= -DZFS_DEBUG
+CFLAGS.zfs.c+= -I${ZFSTOP}/include
+CFLAGS.zfs.c+= -I${ZFSTOP}/lib/libspl/include
+CFLAGS.zfs.c+= -I${ZFSTOP}/lib/libspl/include/os/freebsd
+CFLAGS.zfs.c+= -I${ZFSTOP}/include/os/freebsd/zfs
+CFLAGS.zfs.c+= -I${ZFSTOP}/module/icp/include
+CFLAGS.zfs.c+= -I${SRCTOP}/sys
+CFLAGS.zfs.c+= -I${SRCTOP}/sys/modules/zfs
+CFLAGS.zfs.c+= -include ${ZFSTOP}/include/os/freebsd/spl/sys/ccompile.h
+CFLAGS.zfs.c+= -include ${SRCTOP}/sys/modules/zfs/zfs_config.h
+CFLAGS.zfs.c+= -Wno-cast-qual
.endif
.include <bsd.lib.mk>
diff --git a/lib/libprocstat/zfs.c b/lib/libprocstat/zfs.c
--- a/lib/libprocstat/zfs.c
+++ b/lib/libprocstat/zfs.c
@@ -26,10 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h> /* __RENAME */
-
-#include <stdbool.h>
-
#include <sys/param.h>
#define _WANT_MOUNT
#include <sys/mount.h>
@@ -38,26 +34,28 @@
#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/vnode.h>
+#define _WANT_ZNODE
+#include <sys/zfs_context.h>
+#include <sys/zfs_znode.h>
#include <netinet/in.h>
#include <err.h>
#include <kvm.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#define ZFS
#include "libprocstat.h"
#include "common_kvm.h"
-#include "zfs_defs.h"
int
zfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
{
struct mount mount, *mountptr;
- void *znodeptr;
- char *dataptr;
+ znode_t *kznodeptr, *znode;
size_t len;
int size;
@@ -66,27 +64,30 @@
warnx("error getting sysctl");
return (1);
}
- dataptr = malloc(size);
- if (dataptr == NULL) {
+ znode = malloc(size);
+ if (znode == NULL) {
warnx("error allocating memory for znode storage");
return (1);
}
- if ((size_t)size < offsetof_z_id + sizeof(uint64_t) ||
- (size_t)size < offsetof_z_mode + sizeof(mode_t) ||
- (size_t)size < offsetof_z_size + sizeof(uint64_t)) {
+ if ((size_t)size != sizeof(znode_t))
+ warnx("znode_t size mismatch, data could be wrong");
+
+ if ((size_t)size < offsetof(znode_t, z_id) + sizeof(znode->z_id) ||
+ (size_t)size < offsetof(znode_t, z_mode) + sizeof(znode->z_mode) ||
+ (size_t)size < offsetof(znode_t, z_size) + sizeof(znode->z_size)) {
warnx("znode_t size is too small");
goto bad;
}
- if ((size_t)size != sizeof_znode_t)
- warnx("znode_t size mismatch, data could be wrong");
-
- /* Since we have problems including vnode.h, we'll use the wrappers. */
- znodeptr = getvnodedata(vp);
- if (!kvm_read_all(kd, (unsigned long)znodeptr, dataptr,
- (size_t)size)) {
- warnx("can't read znode at %p", (void *)znodeptr);
+ /*
+ * OpenZFS's libspl provides a dummy sys/vnode.h that shadows ours so
+ * struct vnode is an incomplete type. Use the wrapper until that is
+ * resolved.
+ */
+ kznodeptr = getvnodedata(vp);
+ if (!kvm_read_all(kd, (unsigned long)kznodeptr, znode, (size_t)size)) {
+ warnx("can't read znode at %p", (void *)kznodeptr);
goto bad;
}
@@ -102,12 +103,10 @@
* under .zfs/.
*/
vn->vn_fsid = mount.mnt_stat.f_fsid.val[0];
- vn->vn_fileid = *(uint64_t *)(void *)(dataptr + offsetof_z_id);
- vn->vn_mode = *(mode_t *)(void *)(dataptr + offsetof_z_mode);
- vn->vn_size = *(uint64_t *)(void *)(dataptr + offsetof_z_size);
- free(dataptr);
+ vn->vn_fileid = znode->z_id;
+ vn->vn_mode = znode->z_mode;
+ vn->vn_size = znode->z_size;
return (0);
bad:
- free(dataptr);
return (1);
}
diff --git a/lib/libprocstat/zfs/Makefile b/lib/libprocstat/zfs/Makefile
deleted file mode 100644
--- a/lib/libprocstat/zfs/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-.PATH: ${.CURDIR:H}
-
-SRCS= zfs_defs.c
-OBJS= zfs_defs.o
-WARNS?= 1
-
-FORTIFY_SOURCE= 0
-
-# We fake a kernel compilation environment in order to get the definition for
-# 'zpool_t'.
-CFLAGS+= -DIN_BASE -D__KERNEL__ -D_KERNEL -UKLD_TIED -DKLD_MODULE
-CFLAGS+= -DHAVE_ISSETUGID -D_SYS_VMEM_H_
-
-CFLAGS+= -fno-builtin -nostdlib
-
-CFLAGS+= -I${.CURDIR}
-CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include
-CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl
-CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/zfs
-CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd
-CFLAGS+= -I${SRCTOP}/sys/contrib/ck/include
-CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include
-CFLAGS+= -I${SRCTOP}/sys -I. -I..
-
-CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
-
-all: ${OBJS}
-CLEANFILES= ${OBJS}
-
-.include <bsd.lib.mk>
diff --git a/lib/libprocstat/zfs/Makefile.depend b/lib/libprocstat/zfs/Makefile.depend
deleted file mode 100644
--- a/lib/libprocstat/zfs/Makefile.depend
+++ /dev/null
@@ -1,11 +0,0 @@
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- include \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/lib/libprocstat/zfs_defs.h b/lib/libprocstat/zfs_defs.h
deleted file mode 100644
--- a/lib/libprocstat/zfs_defs.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2020 Andriy Gapon <avg@FreeBSD.org>
- *
- * 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.
- */
-
-#ifndef _LIBPROCSTAT_ZFS_DEFS_H
-#define _LIBPROCSTAT_ZFS_DEFS_H
-
-extern size_t sizeof_znode_t;
-extern size_t offsetof_z_id;
-extern size_t offsetof_z_size;
-extern size_t offsetof_z_mode;
-
-#endif /* _LIBPROCSTAT_ZFS_DEFS_H */
diff --git a/lib/libprocstat/zfs_defs.c b/lib/libprocstat/zfs_defs.c
deleted file mode 100644
--- a/lib/libprocstat/zfs_defs.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2020 Andriy Gapon <avg@FreeBSD.org>
- *
- * 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.
- */
-
-#include <sys/types.h>
-/*
- * Prevent some headers from getting included and fake some types
- * in order to allow this file to compile without bringing in
- * too many kernel build dependencies.
- */
-#define _OPENSOLARIS_SYS_PATHNAME_H_
-#define _OPENSOLARIS_SYS_POLICY_H_
-#define _VNODE_PAGER_
-
-
-enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD,
- VMARKER };
-
-/*
- * Vnode attributes. A field value of VNOVAL represents a field whose value
- * is unavailable (getattr) or which is not to be changed (setattr).
- */
-struct vattr {
- enum vtype va_type; /* vnode type (for create) */
- u_short va_mode; /* files access mode and type */
- u_short va_padding0;
- uid_t va_uid; /* owner user id */
- gid_t va_gid; /* owner group id */
- nlink_t va_nlink; /* number of references to file */
- dev_t va_fsid; /* filesystem id */
- ino_t va_fileid; /* file id */
- u_quad_t va_size; /* file size in bytes */
- long va_blocksize; /* blocksize preferred for i/o */
- struct timespec va_atime; /* time of last access */
- struct timespec va_mtime; /* time of last modification */
- struct timespec va_ctime; /* time file changed */
- struct timespec va_birthtime; /* time file created */
- u_long va_gen; /* generation number of file */
- u_long va_flags; /* flags defined for file */
- dev_t va_rdev; /* device the special file represents */
- u_quad_t va_bytes; /* bytes of disk space held by file */
- u_quad_t va_filerev; /* file modification number */
- u_int va_vaflags; /* operations flags, see below */
- long va_spare; /* remain quad aligned */
-};
-
-#define _WANT_MOUNT
-#include <sys/zfs_context.h>
-#include <sys/zfs_znode.h>
-
-size_t sizeof_znode_t = sizeof(znode_t);
-size_t offsetof_z_id = offsetof(znode_t, z_id);
-size_t offsetof_z_size = offsetof(znode_t, z_size);
-size_t offsetof_z_mode = offsetof(znode_t, z_mode);
-
-/* Keep pcpu.h satisfied. */
-uintptr_t *__start_set_pcpu;
-uintptr_t *__stop_set_pcpu;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 22, 12:10 AM (18 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28929182
Default Alt Text
D50721.diff (10 KB)
Attached To
Mode
D50721: libprocstat: Drop zfs_defs.c hack, including its _KERNEL define
Attached
Detach File
Event Timeline
Log In to Comment