From 4003dfa31341e5584375c1423d223f099a6049c7 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Sun, 1 Oct 2006 13:46:02 +0000 Subject: [PATCH] Add init script --- ChangeLog | 10 +++++++++ NEWS | 2 ++ configure.in | 7 ++++-- example/Makefile.am | 2 +- example/fusexmp.c | 4 ++++ example/fusexmp_fh.c | 4 ++++ example/hello.c | 4 ++++ example/hello_ll.c | 4 ++++ example/null.c | 4 ++++ kernel/configure.ac | 2 +- lib/Makefile.am | 4 +++- util/Makefile.am | 14 +++++++++++- util/init_script | 53 ++++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 108 insertions(+), 6 deletions(-) create mode 100755 util/init_script diff --git a/ChangeLog b/ChangeLog index c5858a0..0478639 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-10-01 Miklos Szeredi + + * Add init script to insert fuse module and mount the control + filesystem. The script is installed as /etc/init.d/fuse and on + debian based systems (where update-rc.d is available) symlinks + from /etc/rc*.d/ are also installed. + + * Include '#define FUSE_USE_VERSION=XX' into examples so they + become more self contained. + 2006-09-30 Miklos Szeredi * API changes: diff --git a/NEWS b/NEWS index 70503db..a41c92f 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ What is new in 2.6 - Building module for Linux kernels earlier than 2.6.9 not supported + - Allow block device based filesystems to support swap files + What is new in 2.5 - Merge library part of FreeBSD port diff --git a/configure.in b/configure.in index a20f2b7..ec02ea4 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -AC_INIT(fuse, 2.6.0-rc1) +AC_INIT(fuse, 2.6.0-rc2) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE AM_CONFIG_HEADER(include/config.h) @@ -21,7 +21,6 @@ esac if test "$ac_env_CFLAGS_set" != set; then CFLAGS="-Wall -W -g -O2" fi -CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DFUSE_USE_VERSION=26" AC_ARG_ENABLE(kernel-module, [ --enable-kernel-module Compile kernel module ]) @@ -77,6 +76,10 @@ if test -z "$UDEV_RULES_PATH"; then UDEV_RULES_PATH=/etc/udev/rules.d fi AC_SUBST(UDEV_RULES_PATH) +if test -z "$INIT_D_PATH"; then + INIT_D_PATH=/etc/init.d +fi +AC_SUBST(INIT_D_PATH) AC_SUBST(subdirs2) diff --git a/example/Makefile.am b/example/Makefile.am index 9fe35e8..469dcb4 100644 --- a/example/Makefile.am +++ b/example/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include -D_FILE_OFFSET_BITS=64 -D_REENTRANT noinst_PROGRAMS = fusexmp fusexmp_fh null hello hello_ll LDADD = ../lib/libfuse.la -lpthread diff --git a/example/fusexmp.c b/example/fusexmp.c index b32e236..b086235 100644 --- a/example/fusexmp.c +++ b/example/fusexmp.c @@ -4,8 +4,12 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. + + gcc -Wall `pkg-config fuse --cflags --libs` fusexmp.c -o fusexmp */ +#define FUSE_USE_VERSION 26 + #include #ifdef linux diff --git a/example/fusexmp_fh.c b/example/fusexmp_fh.c index 2ad1a50..c10044c 100644 --- a/example/fusexmp_fh.c +++ b/example/fusexmp_fh.c @@ -4,8 +4,12 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. + + gcc -Wall `pkg-config fuse --cflags --libs` fusexmp_fh.c -o fusexmp_fh */ +#define FUSE_USE_VERSION 26 + #include #define _GNU_SOURCE diff --git a/example/hello.c b/example/hello.c index f717c34..7a1cdb5 100644 --- a/example/hello.c +++ b/example/hello.c @@ -4,8 +4,12 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. + + gcc -Wall `pkg-config fuse --cflags --libs` hello.c -o hello */ +#define FUSE_USE_VERSION 26 + #include #include #include diff --git a/example/hello_ll.c b/example/hello_ll.c index dbe141c..934e9a7 100644 --- a/example/hello_ll.c +++ b/example/hello_ll.c @@ -4,8 +4,12 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. + + gcc -Wall `pkg-config fuse --cflags --libs` hello_ll.c -o hello_ll */ +#define FUSE_USE_VERSION 26 + #include #include #include diff --git a/example/null.c b/example/null.c index eda843a..1ab6573 100644 --- a/example/null.c +++ b/example/null.c @@ -4,8 +4,12 @@ This program can be distributed under the terms of the GNU GPL. See the file COPYING. + + gcc -Wall `pkg-config fuse --cflags --libs` null.c -o null */ +#define FUSE_USE_VERSION 26 + #include #include #include diff --git a/kernel/configure.ac b/kernel/configure.ac index 67049b5..d0ebcc8 100644 --- a/kernel/configure.ac +++ b/kernel/configure.ac @@ -1,4 +1,4 @@ -AC_INIT(fuse-kernel, 2.6.0-rc1) +AC_INIT(fuse-kernel, 2.6.0-rc2) AC_CONFIG_HEADERS([config.h]) AC_PROG_INSTALL diff --git a/lib/Makefile.am b/lib/Makefile.am index 87e323a..1ffe330 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,8 @@ ## Process this file with automake to produce Makefile.in -AM_CPPFLAGS = -I$(top_srcdir)/include -DFUSERMOUNT_DIR=\"$(bindir)\" +AM_CPPFLAGS = -I$(top_srcdir)/include -DFUSERMOUNT_DIR=\"$(bindir)\" \ + -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DFUSE_USE_VERSION=26 + lib_LTLIBRARIES = libfuse.la libulockmgr.la if BSD diff --git a/util/Makefile.am b/util/Makefile.am index 8e8db2a..d963e81 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -16,14 +16,21 @@ install-exec-hook: mknod $(DESTDIR)/dev/fuse -m 0666 c 10 229; \ fi -EXTRA_DIST = mount.fuse udev.rules +EXTRA_DIST = mount.fuse udev.rules init_script MOUNT_FUSE_PATH = @MOUNT_FUSE_PATH@ UDEV_RULES_PATH = @UDEV_RULES_PATH@ +INIT_D_PATH = @INIT_D_PATH@ install-exec-local: $(mkdir_p) $(DESTDIR)$(MOUNT_FUSE_PATH) $(INSTALL_PROGRAM) $(srcdir)/mount.fuse $(DESTDIR)$(MOUNT_FUSE_PATH)/mount.fuse + $(mkdir_p) $(DESTDIR)$(INIT_D_PATH) + $(INSTALL_PROGRAM) $(srcdir)/init_script $(DESTDIR)$(INIT_D_PATH)/fuse + @if test -x /usr/sbin/update-rc.d; then \ + echo "/usr/sbin/update-rc.d fuse start 34 S . start 41 0 6 ."; \ + /usr/sbin/update-rc.d fuse start 34 S . start 41 0 6 .; \ + fi install-data-local: $(mkdir_p) $(DESTDIR)$(UDEV_RULES_PATH) @@ -32,3 +39,8 @@ install-data-local: uninstall-local: rm -f $(DESTDIR)$(MOUNT_FUSE_PATH)/mount.fuse rm -f $(DESTDIR)$(UDEV_RULES_PATH)/60-fuse.rules + rm -f $(DESTDIR)$(INIT_D_PATH)/fuse + @if test -x /usr/sbin/update-rc.d; then \ + echo "/usr/sbin/update-rc.d fuse remove"; \ + /usr/sbin/update-rc.d fuse remove; \ + fi diff --git a/util/init_script b/util/init_script new file mode 100755 index 0000000..ed964cb --- /dev/null +++ b/util/init_script @@ -0,0 +1,53 @@ +#! /bin/sh +# +# fuse Init script for Filesystem in Userspace +# +# Author: Miklos Szeredi + +set -e + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +SCRIPTNAME=/etc/init.d/fuse +DESC="FUSE" +MOUNTPOINT=/sys/fs/fuse/connections + +# Gracefully exit if the package has been removed. +test -x `which fusermount` || exit 0 + +error() +{ + echo "Error $1" >&2 + exit 1 +} + +case "$1" in + start) + echo -n "Starting $DESC: " + if ! grep -qw fuse /proc/filesystems; then + modprobe fuse >/dev/null 2>&1 || error "loading fuse module" + fi + if grep -qw fusectl /proc/filesystems && \ + ! grep -qw $MOUNTPOINT /proc/mounts; then + mount -t fusectl none $MOUNTPOINT >/dev/null 2>&1 || \ + error "mounting control filesystem" + fi + echo "done." + ;; + stop) + echo -n "Stopping $DESC: " + if grep -qw $MOUNTPOINT /proc/mounts; then + umount $MOUNTPOINT >/dev/null 2>&1 || \ + error "unmounting control filesystem" + fi + if grep -qw "^fuse" /proc/modules; then + rmmod fuse >/dev/null 2>&1 || error "unloading fuse module" + fi + echo "done." + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop}" >&2 + exit 1 + ;; +esac + +exit 0 -- 2.30.2