Add NetBSD support

The bulk of it is just about adding ifdef __NetBSD__ where there is
already an ifdef __FreeBSD__

Add a arch=netbsd to deal with NetBSD specifics. I suggests that
arch=bsd could be renamed to arch=freebsd

NetBSD specific linking with -lperfuse

NetBSD patches to lib/mount.c. It turned to be less itrusive to patch
mount;c than mount_bsd.c. I suggest mount_bsd.c could be renamed to 
mount_freebsd.c

Patch from Emmanuel Dreyfus
This commit is contained in:
Miklos Szeredi
2010-08-27 17:16:54 +02:00
parent 7cc73a47dd
commit 64222fbcbd
10 changed files with 53 additions and 15 deletions
+4
View File
@@ -1,3 +1,7 @@
2010-08-27 Miklos Szeredi <miklos@szeredi.hu>
* Add NetBSD support. Patch from Emmanuel Dreyfus
2010-07-12 Miklos Szeredi <miklos@szeredi.hu>
* libfuse: add buffer interface. Add a generic buffer interface
+2
View File
@@ -16,6 +16,7 @@ fi
case $target_os in
*linux*) arch=linux;;
*netbsd*) arch=netbsd;;
*bsd*) arch=bsd;;
*) arch=unknown;;
esac
@@ -91,6 +92,7 @@ AC_SUBST(INIT_D_PATH)
AC_SUBST(subdirs2)
AM_CONDITIONAL(LINUX, test "$arch" = linux)
AM_CONDITIONAL(NETBSD, test "$arch" = netbsd)
AM_CONDITIONAL(BSD, test "$arch" = bsd)
AC_CONFIG_FILES([fuse.pc Makefile lib/Makefile util/Makefile example/Makefile include/Makefile])
+2 -2
View File
@@ -65,7 +65,7 @@ struct fuse *fuse_setup_compat25(int argc, char *argv[],
void fuse_teardown_compat22(struct fuse *fuse, int fd, char *mountpoint);
#ifndef __FreeBSD__
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#include <sys/statfs.h>
struct fuse_operations_compat22 {
@@ -198,4 +198,4 @@ struct fuse *fuse_new_compat1(int fd, int flags,
void fuse_main_compat1(int argc, char *argv[],
const struct fuse_operations_compat1 *op);
#endif /* __FreeBSD__ */
#endif /* __FreeBSD__ || __NetBSD__ */
+2 -2
View File
@@ -72,7 +72,7 @@ size_t fuse_dirent_size(size_t namelen);
char *fuse_add_dirent(char *buf, const char *name, const struct stat *stbuf,
off_t off);
#ifndef __FreeBSD__
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#include <sys/statfs.h>
@@ -139,7 +139,7 @@ struct fuse_session *fuse_lowlevel_new_compat(const char *opts,
const struct fuse_lowlevel_ops_compat *op,
size_t op_size, void *userdata);
#endif /* __FreeBSD__ */
#endif /* __FreeBSD__ || __NetBSD__ */
struct fuse_chan_ops_compat24 {
int (*receive)(struct fuse_chan *ch, char *buf, size_t size);
+4
View File
@@ -39,6 +39,10 @@ libfuse_la_SOURCES = \
libfuse_la_LDFLAGS = @libfuse_libs@ -version-number 2:8:4 \
-Wl,--version-script,$(srcdir)/fuse_versionscript
if NETBSD
libfuse_la_LIBADD = -lperfuse -lpuffs
endif
libulockmgr_la_SOURCES = ulockmgr.c
libulockmgr_la_LDFLAGS = -pthread -version-number 1:0:1
+6 -6
View File
@@ -960,7 +960,7 @@ static inline void fuse_prepare_interrupt(struct fuse *f, fuse_req_t req,
fuse_do_prepare_interrupt(req, d);
}
#ifndef __FreeBSD__
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
static int fuse_compat_open(struct fuse_fs *fs, const char *path,
struct fuse_file_info *fi)
@@ -1055,7 +1055,7 @@ static int fuse_compat_statfs(struct fuse_fs *fs, const char *path,
return err;
}
#else /* __FreeBSD__ */
#else /* __FreeBSD__ || __NetBSD__ */
static inline int fuse_compat_open(struct fuse_fs *fs, char *path,
struct fuse_file_info *fi)
@@ -1081,7 +1081,7 @@ static inline int fuse_compat_statfs(struct fuse_fs *fs, const char *path,
return fs->op.statfs(fs->compat == 25 ? "/" : path, buf);
}
#endif /* __FreeBSD__ */
#endif /* __FreeBSD__ || __NetBSD__ */
int fuse_fs_getattr(struct fuse_fs *fs, const char *path, struct stat *buf)
{
@@ -3763,7 +3763,7 @@ struct fuse *fuse_new_common(struct fuse_chan *ch, struct fuse_args *args,
if (!f->conf.ac_attr_timeout_set)
f->conf.ac_attr_timeout = f->conf.attr_timeout;
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__NetBSD__)
/*
* In FreeBSD, we always use these settings as inode numbers
* are needed to make getcwd(3) work.
@@ -3941,7 +3941,7 @@ void fuse_register_module(struct fuse_module *mod)
fuse_modules = mod;
}
#ifndef __FreeBSD__
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
static struct fuse *fuse_new_common_compat(int fd, const char *opts,
const struct fuse_operations *op,
@@ -3998,7 +3998,7 @@ FUSE_SYMVER(".symver fuse_set_getcontext_func,__fuse_set_getcontext_func@");
FUSE_SYMVER(".symver fuse_new_compat2,fuse_new@");
FUSE_SYMVER(".symver fuse_new_compat22,fuse_new@FUSE_2.2");
#endif /* __FreeBSD__ */
#endif /* __FreeBSD__ || __NetBSD__ */
struct fuse *fuse_new_compat25(int fd, struct fuse_args *args,
const struct fuse_operations_compat25 *op,
+5 -3
View File
@@ -1732,7 +1732,9 @@ const struct fuse_ctx *fuse_req_ctx_compat24(fuse_req_t req)
{
return fuse_req_ctx(req);
}
#ifndef __NetBSD__
FUSE_SYMVER(".symver fuse_req_ctx_compat24,fuse_req_ctx@FUSE_2.4");
#endif
void fuse_req_interrupt_func(fuse_req_t req, fuse_interrupt_func_t func,
@@ -2130,7 +2132,7 @@ int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[])
}
#endif
#ifndef __FreeBSD__
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
static void fill_open_compat(struct fuse_open_out *arg,
const struct fuse_file_info_compat *f)
@@ -2232,7 +2234,7 @@ FUSE_SYMVER(".symver fuse_reply_statfs_compat,fuse_reply_statfs@FUSE_2.4");
FUSE_SYMVER(".symver fuse_reply_open_compat,fuse_reply_open@FUSE_2.4");
FUSE_SYMVER(".symver fuse_lowlevel_new_compat,fuse_lowlevel_new@FUSE_2.4");
#else /* __FreeBSD__ */
#else /* __FreeBSD__ || __NetBSD__ */
int fuse_sync_compat_args(struct fuse_args *args)
{
@@ -2240,7 +2242,7 @@ int fuse_sync_compat_args(struct fuse_args *args)
return 0;
}
#endif /* __FreeBSD__ */
#endif /* __FreeBSD__ || __NetBSD__ */
struct fuse_session *fuse_lowlevel_new_compat25(struct fuse_args *args,
const struct fuse_lowlevel_ops_compat25 *op,
+2 -2
View File
@@ -357,7 +357,7 @@ int fuse_version(void)
#include "fuse_compat.h"
#ifndef __FreeBSD__
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
struct fuse *fuse_setup_compat22(int argc, char *argv[],
const struct fuse_operations_compat22 *op,
@@ -415,7 +415,7 @@ FUSE_SYMVER(".symver fuse_teardown,__fuse_teardown@");
FUSE_SYMVER(".symver fuse_main_compat2,fuse_main@");
FUSE_SYMVER(".symver fuse_main_real_compat22,fuse_main_real@FUSE_2.2");
#endif /* __FreeBSD__ */
#endif /* __FreeBSD__ || __NetBSD__ */
struct fuse *fuse_setup_compat25(int argc, char *argv[],
+18
View File
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <stddef.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/poll.h>
@@ -25,6 +26,19 @@
#include <sys/wait.h>
#include <sys/mount.h>
#ifdef __NetBSD__
#include <perfuse.h>
#define MS_RDONLY MNT_RDONLY
#define MS_NOSUID MNT_NOSUID
#define MS_NODEV MNT_NODEV
#define MS_NOEXEC MNT_NOEXEC
#define MS_SYNCHRONOUS MNT_SYNCHRONOUS
#define MS_NOATIME MNT_NOATIME
#define umount2(mnt, flags) unmount(mnt, (flags == 2) ? MNT_FORCE : 0)
#endif
#define FUSERMOUNT_PROG "fusermount"
#define FUSE_COMMFD_ENV "_FUSE_COMMFD"
@@ -155,7 +169,9 @@ static struct mount_flags mount_flags[] = {
{"sync", MS_SYNCHRONOUS, 1},
{"atime", MS_NOATIME, 0},
{"noatime", MS_NOATIME, 1},
#ifndef __NetBSD__
{"dirsync", MS_DIRSYNC, 1},
#endif
{NULL, 0, 0}
};
@@ -484,6 +500,7 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo,
goto out_close;
}
#ifndef __NetBSD__
if (geteuid() == 0) {
char *newmnt = fuse_mnt_resolve_path("fuse", mnt);
res = -1;
@@ -496,6 +513,7 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo,
if (res == -1)
goto out_umount;
}
#endif /* __NetBSD__ */
free(type);
free(source);
+8
View File
@@ -11,16 +11,23 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#ifndef __NetBSD__
#include <mntent.h>
#endif
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/mount.h>
#include <sys/param.h>
#ifdef __NetBSD__
#define umount2(mnt, flags) unmount(mnt, (flags == 2) ? MNT_FORCE : 0)
#define mtab_needs_update(mnt) 0
#else
static int mtab_needs_update(const char *mnt)
{
int res;
@@ -53,6 +60,7 @@ static int mtab_needs_update(const char *mnt)
return 1;
}
#endif /* __NetBSD__ */
static int add_mount_legacy(const char *progname, const char *fsname,
const char *mnt, const char *type, const char *opts)