aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--configure.in2
-rw-r--r--include/fuse_compat.h4
-rw-r--r--include/fuse_lowlevel_compat.h4
-rw-r--r--lib/Makefile.am4
-rw-r--r--lib/fuse.c12
-rw-r--r--lib/fuse_lowlevel.c8
-rw-r--r--lib/helper.c4
-rw-r--r--lib/mount.c18
-rw-r--r--lib/mount_util.c8
10 files changed, 53 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 8c399e7..5c6e74e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/configure.in b/configure.in
index 1664204..9d13f33 100644
--- a/configure.in
+++ b/configure.in
@@ -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])
diff --git a/include/fuse_compat.h b/include/fuse_compat.h
index 225276f..e7497a9 100644
--- a/include/fuse_compat.h
+++ b/include/fuse_compat.h
@@ -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__ */
diff --git a/include/fuse_lowlevel_compat.h b/include/fuse_lowlevel_compat.h
index aba45e6..8de220b 100644
--- a/include/fuse_lowlevel_compat.h
+++ b/include/fuse_lowlevel_compat.h
@@ -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);
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 22075b2..fe011cb 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -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
diff --git a/lib/fuse.c b/lib/fuse.c
index 6af4be3..c64e596 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -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,
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index 388ab04..50c4715 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -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,
diff --git a/lib/helper.c b/lib/helper.c
index 3d0db4a..81eedec 100644
--- a/lib/helper.c
+++ b/lib/helper.c
@@ -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[],
diff --git a/lib/mount.c b/lib/mount.c
index c3b16a4..b525da5 100644
--- a/lib/mount.c
+++ b/lib/mount.c
@@ -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);
diff --git a/lib/mount_util.c b/lib/mount_util.c
index 33e6697..9926fe8 100644
--- a/lib/mount_util.c
+++ b/lib/mount_util.c
@@ -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)