diff --git a/Makefile b/Makefile index a221e66d..51add2aa 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ PREFIX?=/usr/local PKG_CONFIG?=pkg-config INSTALL=install +LN=ln ifeq ("$(origin V)", "command line") BUILD_VERBOSE = $(V) @@ -152,15 +153,15 @@ install: INITRAMFS_HOOK=$(INITRAMFS_DIR)/hooks/bcachefs install: INITRAMFS_SCRIPT=$(INITRAMFS_DIR)/scripts/local-premount/bcachefs install: bcachefs $(INSTALL) -m0755 -D bcachefs -t $(DESTDIR)$(ROOT_SBINDIR) - $(INSTALL) -m0755 fsck.bcachefs $(DESTDIR)$(ROOT_SBINDIR) - $(INSTALL) -m0755 mkfs.bcachefs $(DESTDIR)$(ROOT_SBINDIR) - $(INSTALL) -m0755 mount.bcachefs $(DESTDIR)$(ROOT_SBINDIR) - $(INSTALL) -m0755 fsck.bcachefs $(DESTDIR)$(ROOT_SBINDIR)/fsck.fuse.bcachefs - $(INSTALL) -m0755 mkfs.bcachefs $(DESTDIR)$(ROOT_SBINDIR)/mkfs.fuse.bcachefs - $(INSTALL) -m0755 mount.fuse.bcachefs $(DESTDIR)$(ROOT_SBINDIR) $(INSTALL) -m0644 -D bcachefs.8 -t $(DESTDIR)$(PREFIX)/share/man/man8/ $(INSTALL) -m0755 -D initramfs/script $(DESTDIR)$(INITRAMFS_SCRIPT) $(INSTALL) -m0755 -D initramfs/hook $(DESTDIR)$(INITRAMFS_HOOK) + $(LN) -sr $(DESTDIR)$(ROOT_SBINDIR)/bcachefs $(DESTDIR)$(ROOT_SBINDIR)/mkfs.bcachefs + $(LN) -sr $(DESTDIR)$(ROOT_SBINDIR)/bcachefs $(DESTDIR)$(ROOT_SBINDIR)/fsck.bcachefs + $(LN) -sr $(DESTDIR)$(ROOT_SBINDIR)/bcachefs $(DESTDIR)$(ROOT_SBINDIR)/mount.bcachefs + $(LN) -sr $(DESTDIR)$(ROOT_SBINDIR)/bcachefs $(DESTDIR)$(ROOT_SBINDIR)/mkfs.fuse.bcachefs + $(LN) -sr $(DESTDIR)$(ROOT_SBINDIR)/bcachefs $(DESTDIR)$(ROOT_SBINDIR)/fsck.fuse.bcachefs + $(LN) -sr $(DESTDIR)$(ROOT_SBINDIR)/bcachefs $(DESTDIR)$(ROOT_SBINDIR)/mount.fuse.bcachefs sed -i '/^# Note: make install replaces/,$$d' $(DESTDIR)$(INITRAMFS_HOOK) echo "copy_exec $(ROOT_SBINDIR)/bcachefs /sbin/bcachefs" >> $(DESTDIR)$(INITRAMFS_HOOK) diff --git a/bcachefs.c b/bcachefs.c index e0e20458..827996f8 100644 --- a/bcachefs.c +++ b/bcachefs.c @@ -188,6 +188,24 @@ int main(int argc, char *argv[]) full_cmd = argv[0]; + /* Are we being called via a symlink? */ + + if (strstr(full_cmd, "mkfs")) + return cmd_format(argc, argv); + + if (strstr(full_cmd, "fsck")) + return cmd_fsck(argc, argv); + +#ifdef BCACHEFS_FUSE + if (strstr(full_cmd, "mount.fuse")) + return cmd_fusemount(argc, argv); +#endif + +#ifndef BCACHEFS_NO_RUST + if (strstr(full_cmd, "mount")) + return cmd_mount(argc, argv); +#endif + setvbuf(stdout, NULL, _IOLBF, 0); char *cmd = pop_cmd(&argc, argv); @@ -253,9 +271,8 @@ int main(int argc, char *argv[]) if (!strcmp(cmd, "setattr")) return cmd_setattr(argc, argv); #ifndef BCACHEFS_NO_RUST - if (!strcmp(cmd, "mount")) { + if (!strcmp(cmd, "mount")) return cmd_mount(argc, argv); - } #endif #ifdef BCACHEFS_FUSE diff --git a/fsck.bcachefs b/fsck.bcachefs deleted file mode 100755 index f8de4a8c..00000000 --- a/fsck.bcachefs +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -SDIR="$(readlink -f "$0")" -exec "${SDIR%/*}/bcachefs" fsck "$@" diff --git a/mkfs.bcachefs b/mkfs.bcachefs deleted file mode 100755 index b3631bad..00000000 --- a/mkfs.bcachefs +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -SDIR="$(readlink -f "$0")" -exec "${SDIR%/*}/bcachefs" format "$@" diff --git a/mount.bcachefs b/mount.bcachefs deleted file mode 100755 index 59002328..00000000 --- a/mount.bcachefs +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -SDIR="$(readlink -f "$0")" -exec "${SDIR%/*}/bcachefs" mount "$@" diff --git a/mount.fuse.bcachefs b/mount.fuse.bcachefs deleted file mode 100755 index 115b3d02..00000000 --- a/mount.fuse.bcachefs +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec bcachefs fusemount "$@"