]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
f3: define F3_NS in cflags rather than C code
authorEric Wong <e@80x24.org>
Wed, 26 Jul 2023 12:45:15 +0000 (12:45 +0000)
committerEric Wong <e@80x24.org>
Wed, 2 Aug 2023 20:29:25 +0000 (20:29 +0000)
This enhances reusability in other projects which use the same C
shim.  The executable will also be `lei.fuse' rather than `leifs',
because `leifs' is likely confused as `leafs' which makes no
sense.

lib/PublicInbox/LeiF3.pm
lib/PublicInbox/f3.h

index 74ad135d138b6a59e812452803addcd89a7cc968..1121340abf10195eeed0f5bdbc2a1ffc493385c1 100644 (file)
@@ -13,11 +13,12 @@ use PublicInbox::Spawn;
 my $dir = ($ENV{PERL_INLINE_DIRECTORY} //
        die('BUG: PERL_INLINE_DIRECTORY unset')) . '/f3';
 my $F3_NS = 'lei';
-my $bin = "$dir/${F3_NS}fs.fuse";
+my $bin = "$dir/${F3_NS}.fuse";
 my ($srcpfx) = (__FILE__ =~ m!\A(.+/)[^/]+\z!);
 my @srcs = map { $srcpfx.$_ } qw(f3.h);
 my $xflags = ($ENV{CFLAGS} // '-Wall -ggdb3 -O0') . ' ' .
-       ($ENV{LDFLAGS} // '-Wl,-O1 -Wl,--compress-debug-sections=zlib');
+       ($ENV{LDFLAGS} // '-Wl,-O1 -Wl,--compress-debug-sections=zlib') .
+       qq{ -DF3_NS='"$F3_NS"'};
 
 sub xflags_chg () {
        open my $fh, '<', "$dir/XFLAGS" or return 1;
index 4494e61b7ef14c70309d17374542e6f3f11cf00e..4572f7f2e434ae63dbd49fccb440be575cd4eeb4 100644 (file)
@@ -8,7 +8,9 @@
  */
 
 /* another project may use this: */
-#define F3_NS "lei"
+#ifndef F3_NS
+#error F3_NS not defined
+#endif
 
 #define _GNU_SOURCE
 #define _FILE_OFFSET_BITS 64
@@ -126,7 +128,7 @@ static struct f3_data f3 = {
 };
 
 static const struct fuse_opt f3_opt[] = {
-       /* *-fd and root-vid are internal knobs */
+       /* *-fd and root-vid are internal knobs used by perl mount wrapper */
        { "reader-fd=%d", offsetof(struct f3_data, rfd) },
        { "worker-fd=%d", offsetof(struct f3_data, wfd) },
        { "root-vid=%"PRId64, offsetof(struct f3_data, vroot.vid) },