diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md index d6977310ba0..e4019e8c258 100644 --- a/Ports/AvailablePorts.md +++ b/Ports/AvailablePorts.md @@ -148,6 +148,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n | [`libfftw3`](libfftw3/) | Fastest Fourier Transform in the West (double precision) | 3.3.10 | https://www.fftw.org/ | | [`libfftw3f`](libfftw3f/) | Fastest Fourier Transform in the West (single precision) | 3.3.10 | https://www.fftw.org/ | | [`libfts`](libfts/) | libfts | 1.2.7 | https://github.com/void-linux/musl-fts | +| [`libfuse`](libfuse/) | libfuse | 3.16.2 | https://github.com/libfuse/libfuse | | [`libgcrypt`](libgcrypt/) | libgcrypt | 1.10.3 | https://gnupg.org/software/libgcrypt/index.html | | [`libgd`](libgd/) | libgd | 2.3.3 | https://libgd.github.io/ | | [`libgpg-error`](libgpg-error/) | libgpg-error | 1.48 | https://gnupg.org/software/libgpg-error/index.html | diff --git a/Ports/libfuse/package.sh b/Ports/libfuse/package.sh new file mode 100755 index 00000000000..b1a5a0df3ad --- /dev/null +++ b/Ports/libfuse/package.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env -S bash ../.port_include.sh +port='libfuse' +version='3.16.2' +files=( + "https://github.com/libfuse/libfuse/releases/download/fuse-${version}/fuse-${version}.tar.gz#f797055d9296b275e981f5f62d4e32e089614fc253d1ef2985851025b8a0ce87" +) +useconfigure='true' +configopts=( + "--cross-file=${SERENITY_BUILD_DIR}/meson-cross-file.txt" +) +workdir="fuse-${version}" + +configure() { + run meson _build "${configopts[@]}" +} + +build() { + run ninja -C _build +} + +install() { + export DESTDIR="${SERENITY_INSTALL_ROOT}" + run meson install -C _build +} diff --git a/Ports/libfuse/patches/0001-Disable-unsupported-functionality.patch b/Ports/libfuse/patches/0001-Disable-unsupported-functionality.patch new file mode 100644 index 00000000000..5935bda23f1 --- /dev/null +++ b/Ports/libfuse/patches/0001-Disable-unsupported-functionality.patch @@ -0,0 +1,239 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: implicitfield <114500360+implicitfield@users.noreply.github.com> +Date: Mon, 5 Feb 2024 00:55:02 +0400 +Subject: [PATCH] Disable unsupported functionality + +--- + example/meson.build | 11 +++++------ + include/fuse_mount_compat.h | 2 ++ + lib/fuse_loop_mt.c | 4 ++++ + lib/meson.build | 6 ++++-- + lib/mount_bsd.c | 19 +++++++++++++++++++ + lib/mount_util.c | 4 ++++ + meson.build | 2 +- + test/meson.build | 2 ++ + 8 files changed, 41 insertions(+), 9 deletions(-) + +diff --git a/example/meson.build b/example/meson.build +index e641543..3ee2630 100644 +--- a/example/meson.build ++++ b/example/meson.build +@@ -1,9 +1,8 @@ +-examples = [ 'passthrough', 'passthrough_fh', +- 'hello', 'hello_ll', 'hello_ll_uds', +- 'printcap', 'ioctl_client', 'poll_client', +- 'ioctl', 'cuse', 'cuse_client' ] ++examples = [ 'passthrough', ++ 'hello', 'hello_ll', ++ 'printcap', 'poll_client' ] + +-if not platform.endswith('bsd') and platform != 'dragonfly' ++if not platform.endswith('bsd') and platform != 'dragonfly' and platform != 'serenity' + examples += 'passthrough_ll' + + # According to Conrad Meyer , FreeBSD doesn't +@@ -31,7 +30,7 @@ foreach ex : threaded_examples + install: false) + endforeach + +-if not platform.endswith('bsd') and platform != 'dragonfly' and add_languages('cpp', required : false) ++if not platform.endswith('bsd') and platform != 'dragonfly' and platform != 'serenity' and add_languages('cpp', required : false) + executable('passthrough_hp', 'passthrough_hp.cc', + dependencies: [ thread_dep, libfuse_dep ], + install: false) +diff --git a/include/fuse_mount_compat.h b/include/fuse_mount_compat.h +index 0142b51..f52b8f5 100644 +--- a/include/fuse_mount_compat.h ++++ b/include/fuse_mount_compat.h +@@ -11,7 +11,9 @@ + #ifndef FUSE_MOUNT_COMPAT_H_ + #define FUSE_MOUNT_COMPAT_H_ + ++#ifndef __serenity__ + #include ++#endif + + /* Some libc don't define MS_*, so define them manually + * (values taken from https://elixir.bootlin.com/linux/v4.0.9/source/include/uapi/linux/fs.h#L68 on) +diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c +index 0200d73..edef914 100644 +--- a/lib/fuse_loop_mt.c ++++ b/lib/fuse_loop_mt.c +@@ -242,6 +242,7 @@ int fuse_start_thread(pthread_t *thread_id, void *(*func)(void *), void *arg) + return 0; + } + ++#ifndef __serenity__ + static struct fuse_chan *fuse_clone_chan(struct fuse_mt *mt) + { + int res; +@@ -275,6 +276,7 @@ static struct fuse_chan *fuse_clone_chan(struct fuse_mt *mt) + + return newch; + } ++#endif + + static int fuse_loop_start_thread(struct fuse_mt *mt) + { +@@ -290,6 +292,7 @@ static int fuse_loop_start_thread(struct fuse_mt *mt) + w->mt = mt; + + w->ch = NULL; ++#ifndef __serenity__ + if (mt->clone_fd) { + w->ch = fuse_clone_chan(mt); + if(!w->ch) { +@@ -299,6 +302,7 @@ static int fuse_loop_start_thread(struct fuse_mt *mt) + mt->clone_fd = 0; + } + } ++#endif + + res = fuse_start_thread(&w->thread_id, fuse_do_work, w); + if (res == -1) { +diff --git a/lib/meson.build b/lib/meson.build +index 9044630..93fecc8 100644 +--- a/lib/meson.build ++++ b/lib/meson.build +@@ -28,8 +28,10 @@ if host_machine.system().startswith('netbsd') + deps += [ cc.find_library('perfuse'), + cc.find_library('puffs') ] + else +- # Required for clock_gettime before glibc 2.17 +- deps += cc.find_library('rt') ++ if host_machine.system() != 'serenity' ++ # Required for clock_gettime before glibc 2.17 ++ deps += cc.find_library('rt') ++ endif + endif + + fusermount_path = join_paths(get_option('prefix'), get_option('bindir')) +diff --git a/lib/mount_bsd.c b/lib/mount_bsd.c +index 73abc67..666be7f 100644 +--- a/lib/mount_bsd.c ++++ b/lib/mount_bsd.c +@@ -8,7 +8,9 @@ + See the file COPYING.LIB. + */ + ++#ifndef __serenity__ + #include "config.h" ++#endif + #include "fuse_i.h" + #include "fuse_misc.h" + #include "fuse_opt.h" +@@ -18,8 +20,10 @@ + + #include + #include ++#ifndef __serenity__ + #include + #include ++#endif + #include + #include + #include +@@ -50,6 +54,10 @@ struct mount_opts { + static const struct fuse_opt fuse_mount_opts[] = { + { "allow_other", offsetof(struct mount_opts, allow_other), 1 }, + { "max_read=%u", offsetof(struct mount_opts, max_read), 1 }, ++#ifdef __serenity__ ++ FUSE_DUAL_OPT_KEY("allow_other", KEY_KERN), ++ FUSE_OPT_KEY("max_read=", KEY_KERN), ++#else + FUSE_OPT_KEY("-r", KEY_RO), + /* standard FreeBSD mount options */ + FUSE_DUAL_OPT_KEY("dev", KEY_KERN), +@@ -95,6 +103,7 @@ static const struct fuse_opt fuse_mount_opts[] = { + * handle them + */ + FUSE_OPT_KEY("fsname=", KEY_KERN), ++#endif + FUSE_OPT_END + }; + +@@ -115,10 +124,12 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key, + struct mount_opts *mo = data; + + switch (key) { ++#ifndef __serenity__ + case KEY_RO: + arg = "ro"; + /* fall through */ + ++#endif + case KEY_KERN: + return fuse_opt_add_opt(&mo->kernel_opts, arg); + } +@@ -130,12 +141,19 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key, + void fuse_kern_unmount(const char *mountpoint, int fd) + { + close(fd); ++#ifdef __serenity__ ++ umount(mountpoint); ++#else + unmount(mountpoint, MNT_FORCE); ++#endif + } + + /* Check if kernel is doing init in background */ + static int init_backgrounded(void) + { ++#ifdef __serenity__ ++ return 0; ++#else + unsigned ibg; + size_t len; + +@@ -145,6 +163,7 @@ static int init_backgrounded(void) + return 0; + + return ibg; ++#endif + } + + +diff --git a/lib/mount_util.c b/lib/mount_util.c +index 8027a2e..cb305da 100644 +--- a/lib/mount_util.c ++++ b/lib/mount_util.c +@@ -37,6 +37,10 @@ + #define umount2(mnt, flags) unmount(mnt, ((flags) == 2) ? MNT_FORCE : 0) + #endif + ++#if defined(__serenity__) ++#define umount2(mnt, flags) umount(mnt) ++#endif ++ + #ifdef IGNORE_MTAB + #define mtab_needs_update(mnt) 0 + #else +diff --git a/meson.build b/meson.build +index 042c19c..bfddbb7 100644 +--- a/meson.build ++++ b/meson.build +@@ -205,7 +205,7 @@ thread_dep = dependency('threads') + # Read build files from sub-directories + # + subdirs = [ 'lib', 'include'] +-if get_option('utils') and not platform.endswith('bsd') and platform != 'dragonfly' ++if get_option('utils') and not platform.endswith('bsd') and platform != 'dragonfly' and platform != 'serenity' + subdirs += [ 'util', 'doc' ] + endif + +diff --git a/test/meson.build b/test/meson.build +index 3d74b9a..cc09527 100644 +--- a/test/meson.build ++++ b/test/meson.build +@@ -7,9 +7,11 @@ foreach prog: [ 'test_write_cache', 'test_setattr' ] + dependencies: thread_dep, + install: false) + endforeach ++if platform != 'serenity' + td += executable('test_syscalls', 'test_syscalls.c', + include_directories: include_dirs, + install: false) ++endif + td += executable('readdir_inode', 'readdir_inode.c', + include_directories: include_dirs, + install: false) diff --git a/Ports/libfuse/patches/0002-Install-examples.patch b/Ports/libfuse/patches/0002-Install-examples.patch new file mode 100644 index 00000000000..c9d36b885db --- /dev/null +++ b/Ports/libfuse/patches/0002-Install-examples.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: implicitfield <114500360+implicitfield@users.noreply.github.com> +Date: Mon, 5 Feb 2024 01:05:50 +0400 +Subject: [PATCH] Install examples + +--- + example/meson.build | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/example/meson.build b/example/meson.build +index 3ee2630..4f39c68 100644 +--- a/example/meson.build ++++ b/example/meson.build +@@ -20,14 +20,14 @@ threaded_examples = [ 'notify_inval_inode', + foreach ex : examples + executable(ex, ex + '.c', + dependencies: [ libfuse_dep ], +- install: false) ++ install: true) + endforeach + + + foreach ex : threaded_examples + executable(ex, ex + '.c', + dependencies: [ thread_dep, libfuse_dep ], +- install: false) ++ install: true) + endforeach + + if not platform.endswith('bsd') and platform != 'dragonfly' and platform != 'serenity' and add_languages('cpp', required : false) diff --git a/Ports/libfuse/patches/0003-Teach-the-mount-helpers-about-serenity.patch b/Ports/libfuse/patches/0003-Teach-the-mount-helpers-about-serenity.patch new file mode 100644 index 00000000000..69b319782fe --- /dev/null +++ b/Ports/libfuse/patches/0003-Teach-the-mount-helpers-about-serenity.patch @@ -0,0 +1,48 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: implicitfield <114500360+implicitfield@users.noreply.github.com> +Date: Mon, 5 Feb 2024 19:34:40 +0400 +Subject: [PATCH] Teach the mount helpers about serenity + +--- + lib/helper.c | 4 ++++ + lib/mount_bsd.c | 4 ++++ + 2 files changed, 8 insertions(+) + +diff --git a/lib/helper.c b/lib/helper.c +index 14a0df3..133904b 100644 +--- a/lib/helper.c ++++ b/lib/helper.c +@@ -178,6 +178,9 @@ static int fuse_helper_opt_proc(void *data, const char *arg, int key, + function actually sets the fsname */ + static int add_default_subtype(const char *progname, struct fuse_args *args) + { ++#ifdef __serenity__ ++ return 0; ++#else + int res; + char *subtype_opt; + +@@ -200,6 +203,7 @@ static int add_default_subtype(const char *progname, struct fuse_args *args) + res = fuse_opt_add_arg(args, subtype_opt); + free(subtype_opt); + return res; ++#endif + } + + int fuse_parse_cmdline_312(struct fuse_args *args, +diff --git a/lib/mount_bsd.c b/lib/mount_bsd.c +index 666be7f..0dac299 100644 +--- a/lib/mount_bsd.c ++++ b/lib/mount_bsd.c +@@ -34,7 +34,11 @@ + #include + #include + ++#ifdef __serenity__ ++#define FUSERMOUNT_PROG "fusermount" ++#else + #define FUSERMOUNT_PROG "mount_fusefs" ++#endif + #define FUSE_DEV_TRUNK "/dev/fuse" + + enum { diff --git a/Ports/libfuse/patches/ReadMe.md b/Ports/libfuse/patches/ReadMe.md new file mode 100644 index 00000000000..d9d308e97e1 --- /dev/null +++ b/Ports/libfuse/patches/ReadMe.md @@ -0,0 +1,14 @@ +# Patches for libfuse on SerenityOS + +## `0001-Disable-unsupported-functionality.patch` + +Disable unsupported functionality + +## `0002-Install-examples.patch` + +Install examples + +## `0003-Teach-the-mount-helpers-about-serenity.patch` + +Teach the mount helpers about serenity +