Skip to content

[CI] Test makefs-related header changes #1726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions lib/libprocstat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,23 @@ MLINKS+=libprocstat.3 procstat_close.3 \
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>
3 changes: 1 addition & 2 deletions lib/libprocstat/cd9660.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@

#include <err.h>

#define _KERNEL
#define _WANT_ISO_MNT
#include <isofs/cd9660/iso.h>
#undef _KERNEL
#include <isofs/cd9660/cd9660_node.h>

#include <kvm.h>
Expand Down
15 changes: 3 additions & 12 deletions lib/libprocstat/msdosfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,22 @@
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/vnode.h>
#include <sys/mount.h>

#include <netinet/in.h>

#define _KERNEL
#include <sys/mount.h>
#define _WANT_MSDOSFS_INTERNALS
#include <fs/msdosfs/bpb.h>
#include <fs/msdosfs/msdosfsmount.h>
#undef _KERNEL

#include <fs/msdosfs/denode.h>
#include <fs/msdosfs/direntry.h>
#include <fs/msdosfs/denode.h>
#include <fs/msdosfs/fat.h>

#include <err.h>
#include <kvm.h>
#include <stdio.h>
#include <stdlib.h>

/*
* XXX -
* VTODE is defined in denode.h only if _KERNEL is defined, but that leads to
* header explosion
*/
#define VTODE(vp) ((struct denode *)getvnodedata(vp))

#include "libprocstat.h"
#include "common_kvm.h"

Expand Down
3 changes: 1 addition & 2 deletions lib/libprocstat/smbfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/vnode.h>
#define _KERNEL
#define _WANT_MOUNT
#include <sys/mount.h>
#undef _KERNEL

#include <netinet/in.h>

Expand Down
2 changes: 0 additions & 2 deletions lib/libprocstat/udf.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/vnode.h>
#define _KERNEL
#include <sys/mount.h>
#undef _KERNEL

#include <netinet/in.h>

Expand Down
52 changes: 25 additions & 27 deletions lib/libprocstat/zfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,36 @@
* SUCH DAMAGE.
*/

#include <sys/cdefs.h> /* __RENAME */

#include <stdbool.h>

#include <sys/param.h>
#define _KERNEL
#define _WANT_MOUNT
#include <sys/mount.h>
#undef _KERNEL
#include <sys/queue.h>
#include <sys/stat.h>
#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;

Expand All @@ -67,27 +64,30 @@ zfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
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;
}

Expand All @@ -103,12 +103,10 @@ zfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
* 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);
}
30 changes: 0 additions & 30 deletions lib/libprocstat/zfs/Makefile

This file was deleted.

11 changes: 0 additions & 11 deletions lib/libprocstat/zfs/Makefile.depend

This file was deleted.

81 changes: 0 additions & 81 deletions lib/libprocstat/zfs_defs.c

This file was deleted.

36 changes: 0 additions & 36 deletions lib/libprocstat/zfs_defs.h

This file was deleted.

Loading
Loading