pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

qemu-virtfs-netbsd: provide statfs(2) compatibility code for NetBSD



Module Name:	pkgsrc-wip
Committed By:	Tobias Nygren <tnn%NetBSD.org@localhost>
Pushed By:	tnn
Date:		Sun Sep 17 12:59:51 2023 +0200
Changeset:	41aaac4890b32f29919b8d138afe4c72e73b5458

Modified Files:
	qemu-virtfs-netbsd/distinfo
Added Files:
	qemu-virtfs-netbsd/patches/patch-fsdev_file-op-9p.h
	qemu-virtfs-netbsd/patches/patch-hw_9pfs_9p.h
	qemu-virtfs-netbsd/patches/patch-hw_9pfs_netbsd-statfs-compat.h

Log Message:
qemu-virtfs-netbsd: provide statfs(2) compatibility code for NetBSD

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=41aaac4890b32f29919b8d138afe4c72e73b5458

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 qemu-virtfs-netbsd/distinfo                        |  3 ++
 .../patches/patch-fsdev_file-op-9p.h               | 15 ++++++
 qemu-virtfs-netbsd/patches/patch-hw_9pfs_9p.h      | 16 ++++++
 .../patches/patch-hw_9pfs_netbsd-statfs-compat.h   | 61 ++++++++++++++++++++++
 4 files changed, 95 insertions(+)

diffs:
diff --git a/qemu-virtfs-netbsd/distinfo b/qemu-virtfs-netbsd/distinfo
index ca18c6b7e6..4053237bf5 100644
--- a/qemu-virtfs-netbsd/distinfo
+++ b/qemu-virtfs-netbsd/distinfo
@@ -7,9 +7,12 @@ BLAKE2s (qemu-8.1.0.tar.xz) = 1cc9e5b6997ea9700a6dead14fa02cfa18a72e74f6c4a92c28
 SHA512 (qemu-8.1.0.tar.xz) = c5f5e7ce2d8e3c93a02012b136c866e8577df07da4705a0045916c71caeaa21fa1b2d59a4b22a660789a4159b192e12a443e7cbb0724ee85fea258251731724c
 Size (qemu-8.1.0.tar.xz) = 123550284 bytes
 SHA1 (patch-audio_jackaudio.c) = 771c2779e565242a500adc0223ef6b1ae5b2b91f
+SHA1 (patch-fsdev_file-op-9p.h) = 76d29b1975495f671ab5b699958c92855e5f1b67
 SHA1 (patch-fsdev_meson.build) = 39cbbcabae262f7ecfd77e5c2d61da4f37340dfe
 SHA1 (patch-hw-mips-Kconfig) = c7199ad26ac45116ab4d38252db4234ae93bdf9a
 SHA1 (patch-hw-mips-mipssim.c) = 1f682b74b34398b3ff15f9e7f24a85f4b8bb4853
+SHA1 (patch-hw_9pfs_9p.h) = 695f764db7ba8412d790f9dff928754891a7469a
+SHA1 (patch-hw_9pfs_netbsd-statfs-compat.h) = 650d2825f34c031de9cc564fa13aa95036802376
 SHA1 (patch-hw_display_omap__dss.c) = 68f6f5e86335114de64b397959a2238de84fcde2
 SHA1 (patch-hw_mips_meson.build) = d9a07a81fe6d3c9e2bd45f41fe876cd927a40ced
 SHA1 (patch-hw_net_etraxfs__eth.c) = e5dd1661d60dbcd27b332403e0843500ba9544bc
diff --git a/qemu-virtfs-netbsd/patches/patch-fsdev_file-op-9p.h b/qemu-virtfs-netbsd/patches/patch-fsdev_file-op-9p.h
new file mode 100644
index 0000000000..0e48af402e
--- /dev/null
+++ b/qemu-virtfs-netbsd/patches/patch-fsdev_file-op-9p.h
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Provide forward declaration of struct statfs.
+
+--- fsdev/file-op-9p.h.orig	2023-08-22 15:34:01.000000000 +0000
++++ fsdev/file-op-9p.h
+@@ -119,6 +119,8 @@ typedef union V9fsFidOpenState V9fsFidOp
+ 
+ void cred_init(FsCred *);
+ 
++struct statfs;
++
+ struct FileOperations {
+     int (*parse_opts)(QemuOpts *, FsDriverEntry *, Error **errp);
+     int (*init)(FsContext *, Error **errp);
diff --git a/qemu-virtfs-netbsd/patches/patch-hw_9pfs_9p.h b/qemu-virtfs-netbsd/patches/patch-hw_9pfs_9p.h
new file mode 100644
index 0000000000..c97d472a03
--- /dev/null
+++ b/qemu-virtfs-netbsd/patches/patch-hw_9pfs_9p.h
@@ -0,0 +1,16 @@
+$NetBSD$
+
+Emulate statfs(2) on NetBSD via statvfs(2).
+
+--- hw/9pfs/9p.h.orig	2023-08-22 15:34:01.000000000 +0000
++++ hw/9pfs/9p.h
+@@ -4,6 +4,9 @@
+ #include <dirent.h>
+ #include <utime.h>
+ #include <sys/resource.h>
++#if defined(__NetBSD__)
++#include "netbsd-statfs-compat.h"
++#endif
+ #include "fsdev/file-op-9p.h"
+ #include "fsdev/9p-iov-marshal.h"
+ #include "qemu/thread.h"
diff --git a/qemu-virtfs-netbsd/patches/patch-hw_9pfs_netbsd-statfs-compat.h b/qemu-virtfs-netbsd/patches/patch-hw_9pfs_netbsd-statfs-compat.h
new file mode 100644
index 0000000000..fa849125b3
--- /dev/null
+++ b/qemu-virtfs-netbsd/patches/patch-hw_9pfs_netbsd-statfs-compat.h
@@ -0,0 +1,61 @@
+$NetBSD$
+
+9pfs uses statfs(2) alot. Rather than patching all the code to use
+statvfs(2) on NetBSD, provide wrapper functions that emulate statfs(2).
+
+--- hw/9pfs/netbsd-statfs-compat.h.orig	2023-09-17 10:56:07.671982907 +0000
++++ hw/9pfs/netbsd-statfs-compat.h
+@@ -0,0 +1,53 @@
++#ifndef QEMU_NETBSD_STATFS_COMPAT_H
++#define QEMU_NETBSD_STATFS_COMPAT_H
++
++#include <sys/statvfs.h>
++
++/* this is just struct statvfs from sys/statvfs.h */
++
++struct statfs {
++	unsigned long	f_flag;		/* copy of mount exported flags */
++	unsigned long	f_bsize;	/* file system block size */
++	unsigned long	f_frsize;	/* fundamental file system block size */
++	unsigned long	f_iosize;	/* optimal file system block size */
++
++	/* The following are in units of f_frsize */
++	fsblkcnt_t	f_blocks;	/* number of blocks in file system, */
++	fsblkcnt_t	f_bfree;	/* free blocks avail in file system */
++	fsblkcnt_t	f_bavail;	/* free blocks avail to non-root */
++	fsblkcnt_t	f_bresvd;	/* blocks reserved for root */
++
++	fsfilcnt_t	f_files;	/* total file nodes in file system */
++	fsfilcnt_t	f_ffree;	/* free file nodes in file system */
++	fsfilcnt_t	f_favail;	/* free file nodes avail to non-root */
++	fsfilcnt_t	f_fresvd;	/* file nodes reserved for root */
++
++	uint64_t  	f_syncreads;	/* count of sync reads since mount */
++	uint64_t  	f_syncwrites;	/* count of sync writes since mount */
++
++	uint64_t  	f_asyncreads;	/* count of async reads since mount */
++	uint64_t  	f_asyncwrites;	/* count of async writes since mount */
++
++	fsid_t		f_fsidx;	/* NetBSD compatible fsid */
++	unsigned long	f_fsid;		/* Posix compatible fsid */
++	unsigned long	f_namemax;	/* maximum filename length */
++	uid_t		f_owner;	/* user that mounted the file system */
++
++	uint64_t	f_spare[4];	/* spare space */
++
++	char	f_fstypename[_VFS_NAMELEN];	/* fs type name */
++	char	f_mntonname[_VFS_MNAMELEN];	/* directory on which mounted */
++	char	f_mntfromname[_VFS_MNAMELEN];	/* mounted file system */
++	char	f_mntfromlabel[_VFS_MNAMELEN];  /* disk label name if avail */
++
++};
++
++static inline int statfs(const char *path, struct statfs *buf) {
++	return statvfs(path, (struct statvfs *)buf);
++}
++
++static inline int fstatfs(int fd, struct statfs *buf) {
++	return fstatvfs(fd, (struct statvfs *)buf);
++}
++
++#endif


Home | Main Index | Thread Index | Old Index