From dff5d4eab8d23462a4b334207444b9858e369f0d Mon Sep 17 00:00:00 2001 From: Gleb Popov <6yearold@gmail.com> Date: Mon, 28 Sep 2020 20:13:41 +0400 Subject: [PATCH 1/5] Perform check for some non-portable headers in configure.ac. --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 39aa8fe56..4d7ea065d 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,8 @@ AM_GNU_GETTEXT_VERSION(0.18.3) PKG_PROG_PKG_CONFIG([0.24]) +AC_CHECK_HEADERS([mntent.h sys/vfs.h sys/mount.h sys/statfs.h sys/xattr.h sys/extattr.h]) + AC_ARG_WITH(dbus_service_dir, AS_HELP_STRING([--with-dbus-service-dir=PATH],[choose directory for dbus service files, [default=PREFIX/share/dbus-1/services]]), with_dbus_service_dir="$withval", with_dbus_service_dir=$datadir/dbus-1/services) From b9f41ef36c2d4f5c63b9774ec282aea3f3e19e28 Mon Sep 17 00:00:00 2001 From: Gleb Popov <6yearold@gmail.com> Date: Mon, 28 Sep 2020 20:17:08 +0400 Subject: [PATCH 2/5] Trivial build fixes for FreeBSD. --- document-portal/permission-db.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/document-portal/permission-db.c b/document-portal/permission-db.c index 69db2676a..c3ca84176 100644 --- a/document-portal/permission-db.c +++ b/document-portal/permission-db.c @@ -25,7 +25,12 @@ #include #include #include +#ifdef HAVE_SYS_STATFS_H #include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif #include "permission-db.h" #include "gvdb/gvdb-reader.h" From b2973defbbe4a1172142695951b4ae2d4113179a Mon Sep 17 00:00:00 2001 From: Gleb Popov <6yearold@gmail.com> Date: Mon, 28 Sep 2020 20:18:47 +0400 Subject: [PATCH 3/5] Fix build of src/xdp-utils.c on FreeBSD. --- src/xdp-utils.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/xdp-utils.c b/src/xdp-utils.c index 1126859b0..87bf8252b 100644 --- a/src/xdp-utils.c +++ b/src/xdp-utils.c @@ -29,7 +29,14 @@ #include #include #include +#ifdef HAVE_MNTENT_H +#endif +#ifdef HAVE_SYS_VFS_H #include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif #include @@ -815,7 +822,7 @@ xdp_filter_options (GVariant *options, continue; } - + if (supported_options[i].validate) { g_autoptr(GError) local_error = NULL; From 9481527903aa93aa4e3010f7ce4674d6b782a4ea Mon Sep 17 00:00:00 2001 From: Gleb Popov <6yearold@gmail.com> Date: Mon, 28 Sep 2020 20:19:15 +0400 Subject: [PATCH 4/5] Fix build of document-portal/document-portal-fuse.c on FreeBSD. --- document-portal/document-portal-fuse.c | 54 ++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/document-portal/document-portal-fuse.c b/document-portal/document-portal-fuse.c index ad8f39aa4..9ed8f8553 100644 --- a/document-portal/document-portal-fuse.c +++ b/document-portal/document-portal-fuse.c @@ -14,9 +14,19 @@ #include #include #include +#ifdef HAVE_SYS_STATFS_H #include +#endif #include +#ifdef HAVE_SYS_MOUNT_H +#include +#endif +#ifdef HAVE_SYS_XATTR_H #include +#endif +#ifdef HAVE_SYS_EXTATTR_H +#include +#endif #include #include @@ -28,6 +38,10 @@ #define O_FSYNC O_SYNC #endif +#ifndef ENODATA +#define ENODATA ENOATTR +#endif + /* Inode ownership model * * The document portal exposes something as a filesystem that it @@ -286,8 +300,10 @@ open_flags_to_string (int flags) g_string_append (s, ",ASYNC"); if (flags & O_FSYNC) g_string_append (s, ",FSYNC"); +#ifdef O_DSYNC if (flags & O_DSYNC) g_string_append (s, ",DSYNC"); +#endif if (flags & O_CREAT) g_string_append (s, ",CREAT"); if (flags & O_TRUNC) @@ -298,16 +314,22 @@ open_flags_to_string (int flags) g_string_append (s, ",CLOEXEC"); if (flags & O_DIRECT) g_string_append (s, ",DIRECT"); +#ifdef O_LARGEFILE if (flags & O_LARGEFILE) g_string_append (s, ",LARGEFILE"); +#endif +#ifdef O_NOATIME if (flags & O_NOATIME) g_string_append (s, ",NOATIME"); +#endif if (flags & O_NOCTTY) g_string_append (s, ",NOCTTY"); if (flags & O_PATH) g_string_append (s, ",PATH"); +#ifdef O_TMPFILE if (flags & O_TMPFILE) g_string_append (s, ",TMPFILE"); +#endif return g_string_free (s, FALSE); } @@ -1965,7 +1987,11 @@ xdp_fuse_fallocate (fuse_req_t req, g_debug ("FALLOCATE %lx", ino); +#ifdef __linux__ res = fallocate (file->fd, mode, offset, length); +#else + res = posix_fallocate (file->fd, offset, length); +#endif if (res == 0) xdp_reply_err (op, req, 0); @@ -2856,7 +2882,13 @@ xdp_fuse_setxattr (fuse_req_t req, return; path = fd_to_path (inode->physical->fd); +#if defined(HAVE_SYS_XATTR_H) res = setxattr (path, name, value, size, flags); +#elif defined(HAVE_SYS_EXTATTR_H) + res = extattr_set_file (path, EXTATTR_NAMESPACE_USER, name, value, size); +#else +#error "Not implemented for your platform" +#endif if (res < 0) return xdp_reply_err (op, req, errno); @@ -2888,7 +2920,15 @@ xdp_fuse_getxattr (fuse_req_t req, if (path == NULL) res = ENODATA; else + { +#if defined(HAVE_SYS_XATTR_H) res = getxattr (path, name, buf, size); +#elif defined(HAVE_SYS_EXTATTR_H) + res = extattr_get_file (path, EXTATTR_NAMESPACE_USER, name, buf, size); +#else +#error "Not implemented for your platform" +#endif + } if (res < 0) return xdp_reply_err (op, req, errno); @@ -2919,7 +2959,15 @@ xdp_fuse_listxattr (fuse_req_t req, path = xdp_document_inode_get_self_as_path (inode); if (path) + { +#if defined(HAVE_SYS_XATTR_H) res = listxattr (path, buf, size); +#elif defined(HAVE_SYS_EXTATTR_H) + res = extattr_list_file (path, EXTATTR_NAMESPACE_USER, buf, size); +#else +#error "Not implemented for your platform" +#endif + } else res = 0; @@ -2951,7 +2999,13 @@ xdp_fuse_removexattr (fuse_req_t req, return; path = fd_to_path (inode->physical->fd); +#if defined(HAVE_SYS_XATTR_H) res = removexattr (path, name); +#elif defined(HAVE_SYS_EXTATTR_H) + res = extattr_delete_file (path, EXTATTR_NAMESPACE_USER, name); +#else +#error "Not implemented for your platform" +#endif if (res < 0) xdp_reply_err (op, req, errno); From 8a4e356eebe8d20a7e1844a3fabc0f9ca2009181 Mon Sep 17 00:00:00 2001 From: Gleb Popov <6yearold@gmail.com> Date: Mon, 9 Nov 2020 17:17:13 +0400 Subject: [PATCH 5/5] Remove unused header inclusion. --- document-portal/document-portal.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/document-portal/document-portal.c b/document-portal/document-portal.c index 04c4b8d14..7f2e00bb4 100644 --- a/document-portal/document-portal.c +++ b/document-portal/document-portal.c @@ -21,8 +21,6 @@ #include "file-transfer.h" #include "document-portal.h" -#include - #define TABLE_NAME "documents" typedef struct