$NetBSD: patch-as,v 1.3 2016/10/09 03:41:56 ryoon Exp $ --- lib/include/mntinfo.h.orig 2016-02-16 20:06:46.000000000 +0000 +++ lib/include/mntinfo.h @@ -34,8 +34,11 @@ # include #elif defined(__linux__) # include -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__NetBSD__) # include +#if defined(__NetBSD__) +# include +#endif #endif #include "posix.h" @@ -106,17 +109,27 @@ # define MNTINFO_FSTYPE(mnt) mnt->mnt_type # define MNTINFO_MNTPT(mnt) mnt->mnt_dir # define MNTINFO_MNT_IS_RO(mnt) (hasmntopt((mnt), "rw") == NULL) -#elif defined(__FreeBSD__) || defined(__APPLE__) +#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__NetBSD__) struct mntHandle { +#if defined(__NetBSD__) + struct statvfs *mountPoints; // array of mountpoints per getmntinfo(3) +#else struct statfs *mountPoints; // array of mountpoints per getmntinfo(3) +#endif int numMountPoints; // number of elements in mntArray int mountIndex; // current location within mountPoints array }; # define MNTFILE _PATH_FSTAB # define MNTHANDLE struct mntHandle * +#if defined(__NetBSD__) +# define MNTINFO struct statvfs +# define DECLARE_MNTINFO(name) struct statvfs __ ## name; \ + struct statvfs *name = &__ ## name +#else # define MNTINFO struct statfs # define DECLARE_MNTINFO(name) struct statfs __ ## name; \ struct statfs *name = &__ ## name +#endif # define OPEN_MNTFILE(mode) \ ({ \ @@ -155,7 +168,11 @@ struct mntHandle { # define MNTINFO_NAME(mnt) mnt->f_mntfromname # define MNTINFO_FSTYPE(mnt) mnt->f_fstypename # define MNTINFO_MNTPT(mnt) mnt->f_mntonname +#if defined(__NetBSD__) +# define MNTINFO_MNT_IS_RO(mnt) ((mnt)->f_flag & MNT_RDONLY) +#else # define MNTINFO_MNT_IS_RO(mnt) ((mnt)->f_flags & MNT_RDONLY) +#endif #else # error "Define mount information macros for your OS type" #endif