Skip to contentSkip to conversation

module development

DISCUSSION Jordi Prats 3 participants 7 messages Feb 27, 2007 – Mar 1, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,
I'm new to this list. I need to develop a module for autofs for a custom fs type, but I'm not really familiar with autofs. I'm supposing to do this I need to do a module like modules/mount_generic.c but with my custom stuff. For the mounting process it's all right, but to umount the fs I also need to do some operations.

There isn't any hook to do my custom operations before or after (in my cas doesn't matter) umounting it?

I'm sorry if this a simple or trivial question, but I didn't found how to do this as a module.

Thank you all,
Jordi

Signature · 11 lines
......................................................................
        __
       / /          Jordi Prats Català
 C E / S / C A      Departament de Sistemes
     /_/            Centre de Supercomputació de Catalunya

 Gran Capità, 2-4 (Edifici Nexus) · 08034 Barcelona
 T. 93 205 6464 · F.  93 205 6979 · [email protected]
......................................................................
pgp:0x5D0D1321
......................................................................
maintainer
#1 lore raw
Quoted 7 lines · Jordi Prats

Hi all,
I'm new to this list. I need to develop a module for autofs for a custom fs type, but I'm not really familiar with autofs. I'm supposing to do this I need to do a module like modules/mount_generic.c but with my custom stuff. For the mounting process it's all right, but to umount the fs I also need to do some operations.

Quoted 5 lines

There isn't any hook to do my custom operations before or after (in my cas doesn't matter) umounting it?

I'm sorry if this a simple or trivial question, but I didn't found how to do this as a module.

Your right, at this stage there isn't an entry point for the umount operation.

Ian

#2 lore raw

Hi all,
I have modified autofs's source code to create an entry point for the umount operation. Here I attach a patch for autofs-4.1.4

This patch will allow to create a custom umount operation. In my case I need to perform an operation before mounting the fs and after. So, I think this could help others.

What I need to do to contribute this code?

Thank you,

Signature · 9 lines
......................................................................
        __
       / /          Jordi Prats
 C E / S / C A      Dept. de Sistemes
     /_/            Centre de Supercomputació de Catalunya

 Gran Capità, 2-4 (Edifici Nexus) · 08034 Barcelona
 T. 93 205 6464 · F.  93 205 6979 · [email protected]
...................................................................... 
Quoted 12 lines · Ian Kent
Quoted 10 lines · Jordi Prats

Hi all,
I'm new to this list. I need to develop a module for autofs for a custom fs type, but I'm not really familiar with autofs. I'm supposing to do this I need to do a module like modules/mount_generic.c but with my custom stuff. For the mounting process it's all right, but to umount the fs I also need to do some operations.

There isn't any hook to do my custom operations before or after (in my cas doesn't matter) umounting it?

Quoted 13 lines
Quoted 3 lines

I'm sorry if this a simple or trivial question, but I didn't found how to do this as a module.

Your right, at this stage there isn't an entry point for the umount operation.

Ian

config.log +537 -0
diff -Naur autofs-4.1.4/config.log autofs-modificat/config.log
@@ -0,0 +1,537 @@
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by configure, which was
+generated by GNU Autoconf 2.59.  Invocation command line was
+
+  $ ./configure 
+
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = inf12
+uname -m = i686
+uname -r = 2.6.19-1.2911.fc6xen
+uname -s = Linux
+uname -v = #1 SMP Sat Feb 10 16:09:50 EST 2007
+
+/usr/bin/uname -p = unknown
+/bin/uname -X     = unknown
+
+/bin/arch              = i686
+/usr/bin/arch -k       = unknown
+/usr/convex/getsysinfo = unknown
+hostinfo               = unknown
+/bin/machine           = unknown
+/usr/bin/oslevel       = unknown
+/bin/universe          = unknown
+
+PATH: /usr/kerberos/sbin
+PATH: /usr/kerberos/bin
+PATH: /usr/local/sbin
+PATH: /usr/local/bin
+PATH: /sbin
+PATH: /bin
+PATH: /usr/sbin
+PATH: /usr/bin
+PATH: /root/bin
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+configure:1307: checking for binaries in
+configure:1309: result: /usr/bin:/bin:/usr/sbin:/sbin
+configure:1319: checking for mount
+configure:1337: found /bin/mount
+configure:1349: result: /bin/mount
+configure:1378: checking for umount
+configure:1396: found /bin/umount
+configure:1408: result: /bin/umount
+configure:1437: checking for fsck.ext2
+configure:1455: found /sbin/fsck.ext2
+configure:1467: result: /sbin/fsck.ext2
+configure:1495: checking for fsck.ext3
+configure:1513: found /sbin/fsck.ext3
+configure:1525: result: /sbin/fsck.ext3
+configure:1555: checking if mount accepts the -s option
+configure:1562: result: yes
+configure:1619: checking for gcc
+configure:1635: found /usr/bin/gcc
+configure:1645: result: gcc
+configure:1889: checking for C compiler version
+configure:1892: gcc --version </dev/null >&5
+gcc (GCC) 4.1.1 20070105 (Red Hat 4.1.1-51)
+Copyright (C) 2006 Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+configure:1895: $? = 0
+configure:1897: gcc -v </dev/null >&5
+Using built-in specs.
+Target: i386-redhat-linux
+Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
+Thread model: posix
+gcc version 4.1.1 20070105 (Red Hat 4.1.1-51)
+configure:1900: $? = 0
+configure:1902: gcc -V </dev/null >&5
+gcc: '-V' option must have argument
+configure:1905: $? = 1
+configure:1928: checking for C compiler default output file name
+configure:1931: gcc    conftest.c  >&5
+configure:1934: $? = 0
+configure:1980: result: a.out
+configure:1985: checking whether the C compiler works
+configure:1991: ./a.out
+configure:1994: $? = 0
+configure:2011: result: yes
+configure:2018: checking whether we are cross compiling
+configure:2020: result: no
+configure:2023: checking for suffix of executables
+configure:2025: gcc -o conftest    conftest.c  >&5
+configure:2028: $? = 0
+configure:2053: result: 
+configure:2059: checking for suffix of object files
+configure:2080: gcc -c   conftest.c >&5
+configure:2083: $? = 0
+configure:2105: result: o
+configure:2109: checking whether we are using the GNU C compiler
+configure:2133: gcc -c   conftest.c >&5
+configure:2139: $? = 0
+configure:2143: test -z 
+			 || test ! -s conftest.err
+configure:2146: $? = 0
+configure:2149: test -s conftest.o
+configure:2152: $? = 0
+configure:2165: result: yes
+configure:2171: checking whether gcc accepts -g
+configure:2192: gcc -c -g  conftest.c >&5
+configure:2198: $? = 0
+configure:2202: test -z 
+			 || test ! -s conftest.err
+configure:2205: $? = 0
+configure:2208: test -s conftest.o
+configure:2211: $? = 0
+configure:2222: result: yes
+configure:2239: checking for gcc option to accept ANSI C
+configure:2309: gcc  -c -g -O2  conftest.c >&5
+configure:2315: $? = 0
+configure:2319: test -z 
+			 || test ! -s conftest.err
+configure:2322: $? = 0
+configure:2325: test -s conftest.o
+configure:2328: $? = 0
+configure:2346: result: none needed
+configure:2364: gcc -c -g -O2  conftest.c >&5
+conftest.c:2: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'me'
+configure:2370: $? = 1
+configure: failed program was:
+| #ifndef __cplusplus
+|   choke me
+| #endif
+configure:2504: checking for yp_match in -lnsl
+configure:2534: gcc -o conftest -g -O2   conftest.c -lnsl   >&5
+configure:2540: $? = 0
+configure:2544: test -z 
+			 || test ! -s conftest.err
+configure:2547: $? = 0
+configure:2550: test -s conftest
+configure:2553: $? = 0
+configure:2566: result: yes
+configure:2574: checking for res_query in -lresolv
+configure:2604: gcc -o conftest -g -O2   conftest.c -lresolv   >&5
+configure:2610: $? = 0
+configure:2614: test -z 
+			 || test ! -s conftest.err
+configure:2617: $? = 0
+configure:2620: test -s conftest
+configure:2623: $? = 0
+configure:2636: result: yes
+configure:2672: checking for hes_resolve in -lhesiod
+configure:2702: gcc -o conftest -g -O2   conftest.c -lhesiod -lresolv  >&5
+configure:2708: $? = 0
+configure:2712: test -z 
+			 || test ! -s conftest.err
+configure:2715: $? = 0
+configure:2718: test -s conftest
+configure:2721: $? = 0
+configure:2734: result: yes
+configure:2753: checking how to run the C preprocessor
+configure:2788: gcc -E  conftest.c
+configure:2794: $? = 0
+configure:2826: gcc -E  conftest.c
+conftest.c:18:28: error: ac_nonexistent.h: No such file or directory
+configure:2832: $? = 1
+configure: failed program was:
+| /* confdefs.h.  */
+| 
+| #define PACKAGE_NAME ""
+| #define PACKAGE_TARNAME ""
+| #define PACKAGE_VERSION ""
+| #define PACKAGE_STRING ""
+| #define PACKAGE_BUGREPORT ""
+| #define HAVE_MOUNT 1
+| #define PATH_MOUNT "/bin/mount"
+| #define HAVE_UMOUNT 1
+| #define PATH_UMOUNT "/bin/umount"
+| #define HAVE_E2FSCK 1
+| #define PATH_E2FSCK "/sbin/fsck.ext2"
+| #define HAVE_E3FSCK 1
+| #define PATH_E3FSCK "/sbin/fsck.ext3"
+| #define HAVE_SLOPPY_MOUNT 1
+| /* end confdefs.h.  */
+| #include <ac_nonexistent.h>
+configure:2871: result: gcc -E
+configure:2895: gcc -E  conftest.c
+configure:2901: $? = 0
+configure:2933: gcc -E  conftest.c
+conftest.c:18:28: error: ac_nonexistent.h: No such file or directory
+configure:2939: $? = 1
+configure: failed program was:
+| /* confdefs.h.  */
+| 
+| #define PACKAGE_NAME ""
+| #define PACKAGE_TARNAME ""
+| #define PACKAGE_VERSION ""
+| #define PACKAGE_STRING ""
+| #define PACKAGE_BUGREPORT ""
+| #define HAVE_MOUNT 1
+| #define PATH_MOUNT "/bin/mount"
+| #define HAVE_UMOUNT 1
+| #define PATH_UMOUNT "/bin/umount"
+| #define HAVE_E2FSCK 1
+| #define PATH_E2FSCK "/sbin/fsck.ext2"
+| #define HAVE_E3FSCK 1
+| #define PATH_E3FSCK "/sbin/fsck.ext3"
+| #define HAVE_SLOPPY_MOUNT 1
+| /* end confdefs.h.  */
+| #include <ac_nonexistent.h>
+configure:2983: checking for egrep
+configure:2993: result: grep -E
+configure:2998: checking for ANSI C header files
+configure:3023: gcc -c -g -O2  conftest.c >&5
+configure:3029: $? = 0
+configure:3033: test -z 
+			 || test ! -s conftest.err
+configure:3036: $? = 0
+configure:3039: test -s conftest.o
+configure:3042: $? = 0
+configure:3131: gcc -o conftest -g -O2   conftest.c  >&5
+conftest.c: In function 'main':
+conftest.c:35: warning: incompatible implicit declaration of built-in function 'exit'
+configure:3134: $? = 0
+configure:3136: ./conftest
+configure:3139: $? = 0
+configure:3154: result: yes
+configure:3178: checking for sys/types.h
+configure:3194: gcc -c -g -O2  conftest.c >&5
+configure:3200: $? = 0
+configure:3204: test -z 
+			 || test ! -s conftest.err
+configure:3207: $? = 0
+configure:3210: test -s conftest.o
+configure:3213: $? = 0
+configure:3224: result: yes
+configure:3178: checking for sys/stat.h
+configure:3194: gcc -c -g -O2  conftest.c >&5
+configure:3200: $? = 0
+configure:3204: test -z 
+			 || test ! -s conftest.err
+configure:3207: $? = 0
+configure:3210: test -s conftest.o
+configure:3213: $? = 0
+configure:3224: result: yes
+configure:3178: checking for stdlib.h
+configure:3194: gcc -c -g -O2  conftest.c >&5
+configure:3200: $? = 0
+configure:3204: test -z 
+			 || test ! -s conftest.err
+configure:3207: $? = 0
+configure:3210: test -s conftest.o
+configure:3213: $? = 0
+configure:3224: result: yes
+configure:3178: checking for string.h
+configure:3194: gcc -c -g -O2  conftest.c >&5
+configure:3200: $? = 0
+configure:3204: test -z 
+			 || test ! -s conftest.err
+configure:3207: $? = 0
+configure:3210: test -s conftest.o
+configure:3213: $? = 0
+configure:3224: result: yes
+configure:3178: checking for memory.h
+configure:3194: gcc -c -g -O2  conftest.c >&5
+configure:3200: $? = 0
+configure:3204: test -z 
+			 || test ! -s conftest.err
+configure:3207: $? = 0
+configure:3210: test -s conftest.o
+configure:3213: $? = 0
+configure:3224: result: yes
+configure:3178: checking for strings.h
+configure:3194: gcc -c -g -O2  conftest.c >&5
+configure:3200: $? = 0
+configure:3204: test -z 
+			 || test ! -s conftest.err
+configure:3207: $? = 0
+configure:3210: test -s conftest.o
+configure:3213: $? = 0
+configure:3224: result: yes
+configure:3178: checking for inttypes.h
+configure:3194: gcc -c -g -O2  conftest.c >&5
+configure:3200: $? = 0
+configure:3204: test -z 
+			 || test ! -s conftest.err
+configure:3207: $? = 0
+configure:3210: test -s conftest.o
+configure:3213: $? = 0
+configure:3224: result: yes
+configure:3178: checking for stdint.h
+configure:3194: gcc -c -g -O2  conftest.c >&5
+configure:3200: $? = 0
+configure:3204: test -z 
+			 || test ! -s conftest.err
+configure:3207: $? = 0
+configure:3210: test -s conftest.o
+configure:3213: $? = 0
+configure:3224: result: yes
+configure:3178: checking for unistd.h
+configure:3194: gcc -c -g -O2  conftest.c >&5
+configure:3200: $? = 0
+configure:3204: test -z 
+			 || test ! -s conftest.err
+configure:3207: $? = 0
+configure:3210: test -s conftest.o
+configure:3213: $? = 0
+configure:3224: result: yes
+configure:3246: checking rpcsvc/nis.h usability
+configure:3258: gcc -c -g -O2  conftest.c >&5
+configure:3264: $? = 0
+configure:3268: test -z 
+			 || test ! -s conftest.err
+configure:3271: $? = 0
+configure:3274: test -s conftest.o
+configure:3277: $? = 0
+configure:3287: result: yes
+configure:3291: checking rpcsvc/nis.h presence
+configure:3301: gcc -E  conftest.c
+configure:3307: $? = 0
+configure:3327: result: yes
+configure:3362: checking for rpcsvc/nis.h
+configure:3369: result: yes
+configure:3405: checking for ldap_init in -lldap
+configure:3435: gcc -o conftest -g -O2   conftest.c -lldap -llber -lresolv   >&5
+configure:3441: $? = 0
+configure:3445: test -z 
+			 || test ! -s conftest.err
+configure:3448: $? = 0
+configure:3451: test -s conftest
+configure:3454: $? = 0
+configure:3467: result: yes
+configure:3529: checking for gcc
+configure:3555: result: gcc
+configure:3799: checking for C compiler version
+configure:3802: gcc --version </dev/null >&5
+gcc (GCC) 4.1.1 20070105 (Red Hat 4.1.1-51)
+Copyright (C) 2006 Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+configure:3805: $? = 0
+configure:3807: gcc -v </dev/null >&5
+Using built-in specs.
+Target: i386-redhat-linux
+Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
+Thread model: posix
+gcc version 4.1.1 20070105 (Red Hat 4.1.1-51)
+configure:3810: $? = 0
+configure:3812: gcc -V </dev/null >&5
+gcc: '-V' option must have argument
+configure:3815: $? = 1
+configure:3818: checking whether we are using the GNU C compiler
+configure:3874: result: yes
+configure:3880: checking whether gcc accepts -g
+configure:3931: result: yes
+configure:3948: checking for gcc option to accept ANSI C
+configure:4055: result: none needed
+configure:4073: gcc -c -g -O2  conftest.c >&5
+conftest.c:2: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'me'
+configure:4079: $? = 1
+configure: failed program was:
+| #ifndef __cplusplus
+|   choke me
+| #endif
+configure:4219: checking whether gcc -fPIE works
+configure:4244: gcc -o conftest -fPIE  -pie conftest.c  >&5
+configure:4247: $? = 0
+configure:4249: ./conftest
+configure:4252: $? = 0
+configure:4265: result: yes
+configure:4279: checking location of the init.d directory
+configure:4285: result: /etc/init.d
+configure:4358: creating ./config.status
+
+## ---------------------- ##
+## Running config.status. ##
+## ---------------------- ##
+
+This file was extended by config.status, which was
+generated by GNU Autoconf 2.59.  Invocation command line was
+
+  CONFIG_FILES    = 
+  CONFIG_HEADERS  = 
+  CONFIG_LINKS    = 
+  CONFIG_COMMANDS = 
+  $ ./config.status 
+
+on inf12
+
+config.status:661: creating Makefile.conf
+config.status:764: creating include/config.h
+
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+
+ac_cv_c_compiler_gnu=yes
+ac_cv_env_CC_set=
+ac_cv_env_CC_value=
+ac_cv_env_CFLAGS_set=
+ac_cv_env_CFLAGS_value=
+ac_cv_env_CPPFLAGS_set=
+ac_cv_env_CPPFLAGS_value=
+ac_cv_env_CPP_set=
+ac_cv_env_CPP_value=
+ac_cv_env_LDFLAGS_set=
+ac_cv_env_LDFLAGS_value=
+ac_cv_env_build_alias_set=
+ac_cv_env_build_alias_value=
+ac_cv_env_host_alias_set=
+ac_cv_env_host_alias_value=
+ac_cv_env_target_alias_set=
+ac_cv_env_target_alias_value=
+ac_cv_exeext=
+ac_cv_header_inttypes_h=yes
+ac_cv_header_memory_h=yes
+ac_cv_header_rpcsvc_nis_h=yes
+ac_cv_header_stdc=yes
+ac_cv_header_stdint_h=yes
+ac_cv_header_stdlib_h=yes
+ac_cv_header_string_h=yes
+ac_cv_header_strings_h=yes
+ac_cv_header_sys_stat_h=yes
+ac_cv_header_sys_types_h=yes
+ac_cv_header_unistd_h=yes
+ac_cv_lib_hesiod_hes_resolve=yes
+ac_cv_lib_ldap_ldap_init=yes
+ac_cv_lib_nsl_yp_match=yes
+ac_cv_lib_resolv_res_query=yes
+ac_cv_objext=o
+ac_cv_path_E2FSCK=/sbin/fsck.ext2
+ac_cv_path_E3FSCK=/sbin/fsck.ext3
+ac_cv_path_MOUNT=/bin/mount
+ac_cv_path_UMOUNT=/bin/umount
+ac_cv_prog_CPP='gcc -E'
+ac_cv_prog_ac_ct_CC=gcc
+ac_cv_prog_cc_g=yes
+ac_cv_prog_cc_stdc=
+ac_cv_prog_egrep='grep -E'
+
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+
+CC='gcc'
+CFLAGS='-fPIE'
+CPP='gcc -E'
+CPPFLAGS=''
+DAEMON_CFLAGS='-fPIE'
+DAEMON_LDFLAGS='-pie'
+DEFS='-DHAVE_CONFIG_H'
+E2FSCK='/sbin/fsck.ext2'
+E3FSCK='/sbin/fsck.ext3'
+ECHO_C=''
+ECHO_N='-n'
+ECHO_T=''
+EGREP='grep -E'
+EXEEXT=''
+HAVE_E2FSCK='1'
+HAVE_E3FSCK='1'
+HAVE_HESIOD='1'
+HAVE_LDAP='1'
+HAVE_MOUNT='1'
+HAVE_NISPLUS='1'
+HAVE_UMOUNT='1'
+HESIOD_FLAGS=''
+LDAP_FLAGS=''
+LDFLAGS='-pie'
+LIBHESIOD=' -lhesiod'
+LIBLDAP=' -lldap -llber -lresolv'
+LIBNSL='-lnsl'
+LIBOBJS=''
+LIBRESOLV='-lresolv'
+LIBS=''
+LTLIBOBJS=''
+MOUNT='/bin/mount'
+OBJEXT='o'
+PACKAGE_BUGREPORT=''
+PACKAGE_NAME=''
+PACKAGE_STRING=''
+PACKAGE_TARNAME=''
+PACKAGE_VERSION=''
+PATH_SEPARATOR=':'
+SHELL='/bin/sh'
+UMOUNT='/bin/umount'
+ac_ct_CC='gcc'
+bindir='${exec_prefix}/bin'
+build_alias=''
+datadir='${prefix}/share'
+exec_prefix='${prefix}'
+host_alias=''
+includedir='${prefix}/include'
+infodir='${prefix}/info'
+initdir='/etc/init.d'
+libdir='${exec_prefix}/lib'
+libexecdir='${exec_prefix}/libexec'
+localstatedir='${prefix}/var'
+mandir='${prefix}/man'
+oldincludedir='/usr/include'
+prefix='/usr'
+program_transform_name='s,x,x,'
+sbindir='${exec_prefix}/sbin'
+sharedstatedir='${prefix}/com'
+sysconfdir='${prefix}/etc'
+target_alias=''
+
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+
+#define HAVE_E2FSCK 1
+#define HAVE_E3FSCK 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_MOUNT 1
+#define HAVE_SLOPPY_MOUNT 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_UMOUNT 1
+#define HAVE_UNISTD_H 1
+#define PACKAGE_BUGREPORT ""
+#define PACKAGE_NAME ""
+#define PACKAGE_STRING ""
+#define PACKAGE_TARNAME ""
+#define PACKAGE_VERSION ""
+#define PATH_E2FSCK "/sbin/fsck.ext2"
+#define PATH_E3FSCK "/sbin/fsck.ext3"
+#define PATH_MOUNT "/bin/mount"
+#define PATH_UMOUNT "/bin/umount"
+#define STDC_HEADERS 1
+
+configure: exit 0
config.status +933 -0

933 lines not on this page · raw message

daemon/automount.c +1 -25
diff -Naur autofs-4.1.4/daemon/automount.c autofs-modificat/daemon/automount.c
@@ -139,31 +139,7 @@
 
 static int umount_ent(const char *root, const char *name, const char *type)
 {
-	char path_buf[PATH_MAX];
-	struct stat st;
-	int sav_errno;
-	int is_smbfs = (strcmp(type, "smbfs") == 0);
-	int status;
-	int rv = 0;
-
-	sprintf(path_buf, "%s/%s", root, name);
-	status =  lstat(path_buf, &st);
-	sav_errno = errno;
-
-	/* EIO appears to correspond to an smb mount that has gone away */
-	if (!status ||
-	    (is_smbfs && (sav_errno == EIO || sav_errno == EBADSLT))) {
-		int umount_ok = 0;
-
-		if (!status && (S_ISDIR(st.st_mode) && (st.st_dev != ap.dev)))
-			umount_ok = 1;
-
-		if (umount_ok || is_smbfs) {
-			rv = spawnll(LOG_DEBUG, 
-				    PATH_UMOUNT, PATH_UMOUNT, path_buf, NULL);
-		}
-	}
-	return rv;
+  return do_umount(root, name, type);
 }
 
 /* Like ftw, except fn gets called twice: before a directory is
daemon/Makefile +2 -2
diff -Naur autofs-4.1.4/daemon/Makefile autofs-modificat/daemon/Makefile
@@ -6,8 +6,8 @@
 -include ../Makefile.conf
 include ../Makefile.rules
 
-SRCS = automount.c spawn.c module.c mount.c
-OBJS = automount.o spawn.o module.o mount.o
+SRCS = automount.c spawn.c module.c mount.c umount.c
+OBJS = automount.o spawn.o module.o mount.o umount.o
 
 version := $(shell cat ../.version)
 
daemon/module.c +69 -0

75 lines not on this page · raw message

daemon/umount.c +63 -0

63 lines not on this page · raw message

daemon/umount.c~ +64 -0

64 lines not on this page · raw message

include/automount.h +13 -0
diff -Naur autofs-4.1.4/include/automount.h autofs-modificat/include/automount.h
@@ -130,6 +130,9 @@
 int signal_children(int sig);
 int do_mount(const char *root, const char *name, int name_len,
 	     const char *what, const char *fstype, const char *options);
+
+int do_umount(const char *root, const char *name, const char *type);
+
 int mkdir_path(const char *path, mode_t mode);
 int rmdir_path(const char *path);
 
@@ -200,22 +203,32 @@
 int mount_init(void **context);
 int mount_mount(const char *root, const char *name, int name_len,
 		const char *what, const char *fstype, const char *options, void *context);
+
+int mount_umount(const char *root, const char *name, int name_len,
+		 const char *fstype, void *context);
+
 int mount_done(void *context);
 #endif
 typedef int (*mount_init_t) (void **);
 typedef int (*mount_mount_t) (const char *, const char *, int, const char *, const char *,
 			      const char *, void *);
+
+typedef int (*mount_umount_t) (const char *, const char *, int, const char *,
+			      void *);
+
 typedef int (*mount_done_t) (void *);
 
 struct mount_mod {
 	mount_init_t mount_init;
 	mount_mount_t mount_mount;
+	mount_umount_t mount_umount;
 	mount_done_t mount_done;
 	void *dlhandle;
 	void *context;
 };
 
 struct mount_mod *open_mount(const char *name, const char *err_prefix);
+struct mount_mod *open_umount(const char *name, const char *err_prefix);
 int close_mount(struct mount_mod *);
 
 /* mapent cache definition */
include/config.h +28 -0
diff -Naur autofs-4.1.4/include/config.h autofs-modificat/include/config.h
@@ -0,0 +1,28 @@
+/* include/config.h.  Generated by configure.  */
+#ident "$Id: config.h.in,v 1.4 2004/02/03 15:23:21 raven Exp $"
+/* -*- c -*-
+ *
+ * config.h.in: Pattern file for autofs to be filled in by configure
+ *
+ */
+
+/* Program paths */
+#define HAVE_MOUNT 1
+#define PATH_MOUNT "/bin/mount"
+
+#define HAVE_UMOUNT 1
+#define PATH_UMOUNT "/bin/umount"
+
+/* #undef HAVE_SMBMOUNT */
+/* #undef PATH_SMBMOUNT */
+
+#define HAVE_E2FSCK 1
+#define PATH_E2FSCK "/sbin/fsck.ext2"
+
+#define HAVE_E3FSCK 1
+#define PATH_E3FSCK "/sbin/fsck.ext3"
+
+/* Define this option if mount(8) supports the -s (sloppy) option */
+#define HAVE_SLOPPY_MOUNT 1
+
+/* #undef ENABLE_EXT_ENV */
Makefile.conf +60 -0

60 lines not on this page · raw message

modules/Makefile +2 -2
diff -Naur autofs-4.1.4/modules/Makefile autofs-modificat/modules/Makefile
@@ -10,13 +10,13 @@
 	lookup_multi.c \
 	parse_sun.c    \
 	mount_generic.c  mount_nfs.c  mount_afs.c  mount_autofs.c \
-	mount_changer.c  mount_bind.c
+	mount_changer.c  mount_bind.c umount_generic.c
 
 MODS :=	lookup_yp.so lookup_file.so lookup_program.so lookup_userhome.so \
 	lookup_multi.so \
 	parse_sun.so \
 	mount_generic.so mount_nfs.so mount_afs.so mount_autofs.so \
-	mount_changer.so mount_bind.so
+	mount_changer.so mount_bind.so umount_generic.so
 
 ifeq ($(EXT2FS), 1)
   SRCS += mount_ext2.c
modules/#umount_generic.# +1 -0
diff -Naur autofs-4.1.4/modules/#umount_generic.# autofs-modificat/modules/#umount_generic.#
@@ -0,0 +1 @@
+-cn
\ No newline at end of file
modules/umount_generic.c +73 -0

73 lines not on this page · raw message

modules/umount_generic.c~ +74 -0

74 lines not on this page · raw message

samples/autofs-ldap-auto-master +17 -0
diff -Naur autofs-4.1.4/samples/autofs-ldap-auto-master autofs-modificat/samples/autofs-ldap-auto-master
@@ -0,0 +1,17 @@
+ELF�44 (44�4����������ȫȫp��ܫܫ��((�(�  Q�td/lib/ld-linux.so.2GNU	� �M#��|CE��K��8��qX������2�����N��+�� ! ~g�[C��J���s��uaebI��9^���95�w_�+�$��B}�b�;RW�H����8���*ȑp<��8���� �
+���
C8�i@�libldap-2.3.so.0__gmon_start___Jv_RegisterClassesldap_msgfreeldap_get_dnldap_simple_bind_sldap_control_freeldap_next_entryldap_value_freeldap_search_ext_sldap_err2stringldap_memfreeldap_first_entry_finildap_initldap_get_valuesldap_unbindldap_set_optionliblber-2.3.so.0libc.so.6_IO_stdin_usedsetlocaleoptindstrrchr__strdupmemsetgetoptoptargstderrfwritestrchrfprintf__libc_start_mainsnprintf_edata__bss_start_endGLIBC_2.0 ii
���8�$<� @�%ĬȬ̬ЬԬجܬ�	�
+���
�������������� �$�(�,�U������P�K
+���5���%���%Ĭh������%Ȭh������%̬h������%Ьh�����%Ԭh �����%جh(�����%ܬh0�����%�h8�p����%�h@�`����%�hH�P����%�hP�@����%�hX�0����%��h`� ����%��hh�����%��hp�����%�hx������%�h�������%�h�������%�h�������%�h������%�h������%�h������%�h������% �h��p����%$�h��`����%(�h��P����%,�h��@���1�^����PTRh�h�QVh���������U��S���[�È#��������t�2���X[�Ð�����U����=D�t����4��ҡ4����u��D��ÐU����ث��t���t	�$ث���Ð������������U��W��V��S��\�����$tDŽ$XDŽ$T�D$D�D$EDŽ$P�D$��D$�$�����$�������$D��$|�$�����\$�\$D�t$��$D�|$��$XDŽ$L�D$Б��$H�D$�$�c�����$P�D$(��$T�D$$�D$ �D$�|$�D$�t$�\$�D$�D$�,$������t�D$8�D$8��\[^_]Ë�$P�,$�D$�3�����t҉D$�,$�������D$4t��8t���$p�D$��D$�$�D$������$D�$������$H�$������$X��t�$����DŽ$X��$T��t�$����DŽ$T��$P��t�$�����DŽ$P��$x�$�,�����$D��$|�$����DŽ$L�D$$�D$ �|$�D$��$H��$P�D$(��$T�D$�D$4�t$�\$�D$�D$�,$�2������������$P�,$�D$������D$8����u��t$�,$�x�������t��$x�t$�,$�D$�;����t$�,$�Ë�$|�D$�"����ۉ�t4���t&��t"���t�D$�T$�$�������D$8�$������t��<$�����t&�o����D$4�$�W�����$D�$�������$H�$������$X��t�$�����DŽ$X��$T��t�$����DŽ$T��$P���i����$������\�������'�L$����q���\�l$X�$��L$H�\$L�t$P�|$T��q�D$]��$�y����D$(��D$,��D$0��D$$��D$:��t$�$�%�������D$D����e��w�$�����6�D$/�4$�f�����t�4$�D$/�����p�T$0�D$(�|$,�D$ .��T$�T$$�D$�|$�l$�T$�t$�D$ؚ�<��$����1��L$H�\$L�t$P�|$T�l$X��\�a�Ë-@��9����@��D$0�+����@��T$(�����@��D$$�����=@��|$,������8��D$4.�����t	�:���D$��$�7��������ÍD$D�D$D�D$�D$�$�]��������D$�D$�$����������$�=����D$��D$���D$�<��$�����$�f����������<��D$�D$�$E��D$����������T$4�)����$�����D$��$�X������L����T$(�D$,�|$0�L$$�T$�T$4�D$�؉|$�,$������t�$�����1���K����t$$�^��
����u^�k��
+���uN�T$(�u�:u?�v�:Bu3�w�:Bu'�|$,��:u��:Gu��:Gt4�T$4�^����D$x��D$��D$u��$k�������I����t$0�x����3���봐�����������U��]Ít&��'U��WVS�^�Ý�������������E������)E��}��U���t+1��ƍ��E���D$�E�D$�E�$���9}�u߃�[^_]Ë$Ð��U��S�ȫ���ȫ���t���Ћ���u��[]�U��S���[������Y[��(&(objectclass=%s)(%s=%s))(objectclass=%s)%s %s
+nisMapNamecnnisMapEntrynisMapnisObjectauto.masterm:e:n:k:v:error initializing LDAP
+automountMapautomountouautomountInformation�������ю�Î�����������syntax: %s
+	[-m %s] (map object class)
+	[-e %s] (entry object class)
+	[-n %s] (attribute used as map key)
+	[-k %s] (attribute used as entry key)
+	[-v %s] (attribute used as value)
+	[%s] (map name)
+%s: error binding to server: %s
+��������  �
�����oH�����
+����H�(� ���o����o���o��ܫN�^�n�~���������·އ�����.�>�N�^�n�~���������Έވ�ԫGCC: (GNU) 4.1.1 20061011 (Red Hat 4.1.1-30)GCC: (GNU) 4.1.1 20061011 (Red Hat 4.1.1-30)GCC: (GNU) 4.1.1 20070105 (Red Hat 4.1.1-51)GCC: (GNU) 4.1.1 20070105 (Red Hat 4.1.1-51)GCC: (GNU) 4.1.1 20070105 (Red Hat 4.1.1-51)GCC: (GNU) 4.1.1 20061011 (Red Hat 4.1.1-30).shstrtab.interp.note.ABI-tag.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rel.dyn.rel.plt.init.text.fini.rodata.eh_frame.ctors.dtors.jcr.dynamic.got.got.plt.data.bss.comment�(�( !���oH�HH+���`3����;���o���LH���o� W	(�( `	H�H�i � d8�8�o�	�u���{đ�
+�ě��ȫ��Ы��ث��ܫ����������x�0�0�8�8�8L�
\ No newline at end of file
samples/autofs-ldap-auto-master.o +15 -0
diff -Naur autofs-4.1.4/samples/autofs-ldap-auto-master.o autofs-modificat/samples/autofs-ldap-auto-master.o
@@ -0,0 +1,15 @@
+ELF4(U��W��V��S��\���$tDŽ$XDŽ$T�D$D�D$EDŽ$P�D$��D$�$������$�������$D��$|�$������\$�\$D�t$��$D�|$��$XDŽ$L�D$��$H�D$�$�������$P�D$(��$T�D$$�D$ �D$�|$�D$�t$�\$�D$�D$�,$�������t�D$8�D$8��\[^_]Ë�$P�,$�D$�������t҉D$�,$��������D$4t��8t���$p�D$�D$�$�D$�������$D�$�������$H�$�������$X��t�$�����DŽ$X��$T��t�$�����DŽ$T��$P��t�$�����DŽ$P��$x�$�������$D��$|�$�����DŽ$L�D$$�D$ �|$�D$��$H��$P�D$(��$T�D$�D$4�t$�\$�D$�D$�,$��������������$P�,$�D$������D$8����u��t$�,$���������t��$x�t$�,$�D$������t$�,$�Ë�$|�D$������ۉ�t4���t&��t"���t�D$�T$�$,������D$8�$�������t��<$������t&�o����D$4�$�������$D�$�������$H�$�������$X��t�$�����DŽ$X��$T��t�$�����DŽ$T��$P���i����$������\�������'�L$����q���\�l$X�U�L$H�\$L�t$P�|$T��q�D$3�$������D$(4�D$,?�D$0B�D$$N�D$k�t$�$���������D$D����e��w�$���6�D$/�4$�������t�4$�D$/������p�T$0�D$(�|$,�D$ _�T$�T$$�D$�|$�l$�T$�t$�D$��$�����1��L$H�\$L�t$P�|$T�l$X��\�a�Ë-�9�����D$0�+�����T$(������D$$�����=�|$,�������D$4_����t	�:���D$��$����������ÍD$D�D$D�D$�D$�$����������D$�D$�$����������$������D$��D$��D$��$������$�������������D$�D$�$v�D$�����������T$4�)����$������D$��$��������L����T$(�D$,�|$0�L$$�T$�T$4�D$�؉|$�,$������t�$�����1���K����t$$���
����u^���
+���uN�T$(��:u?�:Bu3�:Bu'�|$,�?:u�:Gu�:Gt4�T$4�����D$��D$?�D$��$�������I����t$0�����3����(&(objectclass=%s)(%s=%s))(objectclass=%s)%s %s
+nisMapNamecnnisMapEntrynisMapnisObjectauto.masterm:e:n:k:v:error initializing LDAP
+automountMapautomountouautomountInformation�`````!````````�syntax: %s
+	[-m %s] (map object class)
+	[-e %s] (entry object class)
+	[-n %s] (attribute used as map key)
+	[-k %s] (attribute used as entry key)
+	[-v %s] (attribute used as value)
+	[%s] (map name)
+%s: error binding to server: %s
+GCC: (GNU) 4.1.1 20070105 (Red Hat 4.1.1-51).symtab.strtab.shstrtab.rel.text.data.bss.rodata.str1.1.rel.rodata.rodata.str1.4.comment.note.GNU-stack@D	\�%�+�02��CDH?	��K2��Zu.c��sH�

	�q���
+$�*?	/6?HZkw|��������t����!+;N^jautofs-ldap-auto-master.cdump_map.LC17.LC6memset__strdupsnprintfldap_search_ext_sldap_first_entryldap_get_dnfreeldap_control_freeldap_msgfreeldap_next_entryldap_get_valuesprintfldap_value_freeldap_memfreemainsetlocalegetoptstrchrstrrchrstderrfprintfoptargoptindldap_initldap_set_optionldap_simple_bind_sldap_err2stringldap_unbindfwrite[
cy��AQm�����������,8M\k~����#+3?[n���� �!�"�"""#"1#9]$�%�&�'�� �!�(� 
)((<$y(����
+�
+����1 $(,048<@D
\ No newline at end of file
samples/Makefile +8 -8
diff -Naur autofs-4.1.4/samples/Makefile autofs-modificat/samples/Makefile
@@ -26,14 +26,14 @@
 
 install: all
 	install -d -m 755 $(INSTALLROOT)/etc
-	-mv -f $(INSTALLROOT)/etc/auto.master $(INSTALLROOT)/etc/auto.master.old
-	install -c auto.master -m 644 $(INSTALLROOT)/etc
-	-mv -f $(INSTALLROOT)/etc/auto.misc $(INSTALLROOT)/etc/auto.misc.old
-	install -c auto.misc   -m 644 $(INSTALLROOT)/etc
-	-mv -f $(INSTALLROOT)/etc/auto.net $(INSTALLROOT)/etc/auto.net.old
-	install -c auto.net    -m 755 $(INSTALLROOT)/etc
-	-mv -f $(INSTALLROOT)/etc/auto.smb $(INSTALLROOT)/etc/auto.smb.old
-	install -c auto.smb    -m 755 $(INSTALLROOT)/etc
+	#-mv -f $(INSTALLROOT)/etc/auto.master $(INSTALLROOT)/etc/auto.master.old
+	#install -c auto.master -m 644 $(INSTALLROOT)/etc
+	#-mv -f $(INSTALLROOT)/etc/auto.misc $(INSTALLROOT)/etc/auto.misc.old
+	#install -c auto.misc   -m 644 $(INSTALLROOT)/etc
+	#-mv -f $(INSTALLROOT)/etc/auto.net $(INSTALLROOT)/etc/auto.net.old
+	#install -c auto.net    -m 755 $(INSTALLROOT)/etc
+	#-mv -f $(INSTALLROOT)/etc/auto.smb $(INSTALLROOT)/etc/auto.smb.old
+	#install -c auto.smb    -m 755 $(INSTALLROOT)/etc
 	install -d -m 755 $(INSTALLROOT)$(initdir)
 	install -c rc.autofs   -m 755 $(INSTALLROOT)$(initdir)/autofs
 	install -d -m 755 $(INSTALLROOT)$(autofslibdir)
samples/rc.autofs +776 -0

776 lines not on this page · raw message

_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs

#6 lore raw
In reply to Jordi Prats
Quoted 5 lines · Jordi Prats

I'm new to this list. I need to develop a module for autofs for a custom fs type, but I'm not really familiar with autofs. I'm supposing to do this I need to do a module like modules/mount_generic.c but with my custom stuff. For the mounting process it's all right, but to umount the fs I also need to do some operations.

Special operations connected with mount or umount are a royal pain for the system administrator, not just for autofs but for boot-time mounting too, and hotplug mounting. I wonder if the custom filesystem could be modified to be easier to use? The ideal is if a submodule of mount can handle all the special operations and system call argument formatting, guided by the mount options. /sbin/mount.cifs is an example. Another possibility is if the filesystem driver, upon (un)mounting, starts a kernel thread that does whatever userspace activities and then exits.

But autofs does the mount system call itself because of the performance hit of forking mount(1) every time. Here's a modest proposal: autofs knows how to do NFS mounts and generic mounts (ext3, reiser, iso9660, etc. with only standard options). How about a mount option to be interpreted by autofs, -nonstandard, which gives control to a module that spawns mount(1) and accepts the performance hit?

In the interesting case of Samba/CIFS and NFSv4 mounts, a password or a user's Kerberos credential is needed for non-world-readable content. How could autofs (or better, mount(1) spawned by autofs) reach back to the user's context and figure out the credential cache (there could be several) or run a password requesting program using the correct .Xauthority file, e.g. /tmp/gdm.QwErTy?

James F. Carter Voice 310 825 2897 FAX 310 206 6673
UCLA-Mathnet; 6115 MSA; 405 Hilgard Ave.; Los Angeles, CA, USA 90095-1555
Email: [email protected] http://www.math.ucla.edu/~jimc (q.v. for PGP key)

maintainer
#3 lore raw
In reply to Jordi Prats
Quoted 9 lines · Jordi Prats

Hi all,
I have modified autofs's source code to create an entry point for the umount operation. Here I attach a patch for autofs-4.1.4

This patch will allow to create a custom umount operation. In my case I need to perform an operation before mounting the fs and after. So, I think this could help others.

What I need to do to contribute this code?

Sorry, you've got a bit of work to do on that patch.

When you make a patch please make the diff from a clean source tree. The reason for this is that the diff should contain only the changes that you're proposing so the possibility of mistakes getting through is minimized. As it is this patch contains a more unrelated stuff than the changes for the proposal itself. I can't really follow it well enough to know what you're trying to do.

Ian

#4 lore raw

Hi,
Ok, No problem! Here it is with the only changes of my proposal.

Jordi

Quoted 24 lines · Ian Kent
Quoted 7 lines · Jordi Prats

Hi all,
I have modified autofs's source code to create an entry point for the umount operation. Here I attach a patch for autofs-4.1.4

This patch will allow to create a custom umount operation. In my case I need to perform an operation before mounting the fs and after. So, I think this could help others.

What I need to do to contribute this code?

Sorry, you've got a bit of work to do on that patch.

When you make a patch please make the diff from a clean source tree. The reason for this is that the diff should contain only the changes that you're proposing so the possibility of mistakes getting through is minimized. As it is this patch contains a more unrelated stuff than the changes for the proposal itself. I can't really follow it well enough to know what you're trying to do.

Ian

Signature · 9 lines
......................................................................
        __
       / /          Jordi Prats
 C E / S / C A      Dept. de Sistemes
     /_/            Centre de Supercomputació de Catalunya

 Gran Capità, 2-4 (Edifici Nexus) · 08034 Barcelona
 T. 93 205 6464 · F.  93 205 6979 · [email protected]
...................................................................... 
daemon/automount.c +1 -25
diff -Naur autofs-4.1.4/daemon/automount.c autofs-modificat/daemon/automount.c
@@ -139,31 +139,7 @@
 
 static int umount_ent(const char *root, const char *name, const char *type)
 {
-	char path_buf[PATH_MAX];
-	struct stat st;
-	int sav_errno;
-	int is_smbfs = (strcmp(type, "smbfs") == 0);
-	int status;
-	int rv = 0;
-
-	sprintf(path_buf, "%s/%s", root, name);
-	status =  lstat(path_buf, &st);
-	sav_errno = errno;
-
-	/* EIO appears to correspond to an smb mount that has gone away */
-	if (!status ||
-	    (is_smbfs && (sav_errno == EIO || sav_errno == EBADSLT))) {
-		int umount_ok = 0;
-
-		if (!status && (S_ISDIR(st.st_mode) && (st.st_dev != ap.dev)))
-			umount_ok = 1;
-
-		if (umount_ok || is_smbfs) {
-			rv = spawnll(LOG_DEBUG, 
-				    PATH_UMOUNT, PATH_UMOUNT, path_buf, NULL);
-		}
-	}
-	return rv;
+  return do_umount(root, name, type);
 }
 
 /* Like ftw, except fn gets called twice: before a directory is
daemon/Makefile +2 -2
diff -Naur autofs-4.1.4/daemon/Makefile autofs-modificat/daemon/Makefile
@@ -6,8 +6,8 @@
 -include ../Makefile.conf
 include ../Makefile.rules
 
-SRCS = automount.c spawn.c module.c mount.c
-OBJS = automount.o spawn.o module.o mount.o
+SRCS = automount.c spawn.c module.c mount.c umount.c
+OBJS = automount.o spawn.o module.o mount.o umount.o
 
 version := $(shell cat ../.version)
 
daemon/module.c +69 -0

75 lines not on this page · raw message

daemon/umount.c +63 -0

63 lines not on this page · raw message

include/automount.h +13 -0
diff -Naur autofs-4.1.4/include/automount.h autofs-modificat/include/automount.h
@@ -130,6 +130,9 @@
 int signal_children(int sig);
 int do_mount(const char *root, const char *name, int name_len,
 	     const char *what, const char *fstype, const char *options);
+
+int do_umount(const char *root, const char *name, const char *type);
+
 int mkdir_path(const char *path, mode_t mode);
 int rmdir_path(const char *path);
 
@@ -200,22 +203,32 @@
 int mount_init(void **context);
 int mount_mount(const char *root, const char *name, int name_len,
 		const char *what, const char *fstype, const char *options, void *context);
+
+int mount_umount(const char *root, const char *name, int name_len,
+		 const char *fstype, void *context);
+
 int mount_done(void *context);
 #endif
 typedef int (*mount_init_t) (void **);
 typedef int (*mount_mount_t) (const char *, const char *, int, const char *, const char *,
 			      const char *, void *);
+
+typedef int (*mount_umount_t) (const char *, const char *, int, const char *,
+			      void *);
+
 typedef int (*mount_done_t) (void *);
 
 struct mount_mod {
 	mount_init_t mount_init;
 	mount_mount_t mount_mount;
+	mount_umount_t mount_umount;
 	mount_done_t mount_done;
 	void *dlhandle;
 	void *context;
 };
 
 struct mount_mod *open_mount(const char *name, const char *err_prefix);
+struct mount_mod *open_umount(const char *name, const char *err_prefix);
 int close_mount(struct mount_mod *);
 
 /* mapent cache definition */
include/config.h +28 -0
diff -Naur autofs-4.1.4/include/config.h autofs-modificat/include/config.h
@@ -0,0 +1,28 @@
+/* include/config.h.  Generated by configure.  */
+#ident "$Id: config.h.in,v 1.4 2004/02/03 15:23:21 raven Exp $"
+/* -*- c -*-
+ *
+ * config.h.in: Pattern file for autofs to be filled in by configure
+ *
+ */
+
+/* Program paths */
+#define HAVE_MOUNT 1
+#define PATH_MOUNT "/bin/mount"
+
+#define HAVE_UMOUNT 1
+#define PATH_UMOUNT "/bin/umount"
+
+/* #undef HAVE_SMBMOUNT */
+/* #undef PATH_SMBMOUNT */
+
+#define HAVE_E2FSCK 1
+#define PATH_E2FSCK "/sbin/fsck.ext2"
+
+#define HAVE_E3FSCK 1
+#define PATH_E3FSCK "/sbin/fsck.ext3"
+
+/* Define this option if mount(8) supports the -s (sloppy) option */
+#define HAVE_SLOPPY_MOUNT 1
+
+/* #undef ENABLE_EXT_ENV */
modules/Makefile +2 -2
diff -Naur autofs-4.1.4/modules/Makefile autofs-modificat/modules/Makefile
@@ -10,13 +10,13 @@
 	lookup_multi.c \
 	parse_sun.c    \
 	mount_generic.c  mount_nfs.c  mount_afs.c  mount_autofs.c \
-	mount_changer.c  mount_bind.c
+	mount_changer.c  mount_bind.c umount_generic.c
 
 MODS :=	lookup_yp.so lookup_file.so lookup_program.so lookup_userhome.so \
 	lookup_multi.so \
 	parse_sun.so \
 	mount_generic.so mount_nfs.so mount_afs.so mount_autofs.so \
-	mount_changer.so mount_bind.so
+	mount_changer.so mount_bind.so umount_generic.so
 
 ifeq ($(EXT2FS), 1)
   SRCS += mount_ext2.c
modules/umount_generic.c +73 -0

73 lines not on this page · raw message

_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs

maintainer
#5 lore raw
Quoted 2 lines · Jordi Prats

Hi,
Ok, No problem! Here it is with the only changes of my proposal.

The approach is good.

But there's something not quite right which I can't quite put my finger on. I'll have a closer look on the weekend.

btw, this is something that a couple of people have asked for which I haven't got to it yet.

Thanks
Ian

Quoted 404 lines

Jordi

Quoted 15 lines · Ian Kent
Quoted 10 lines · Jordi Prats

Hi all,
I have modified autofs's source code to create an entry point for the umount operation. Here I attach a patch for autofs-4.1.4

This patch will allow to create a custom umount operation. In my case I need to perform an operation before mounting the fs and after. So, I think this could help others.

What I need to do to contribute this code?

Sorry, you've got a bit of work to do on that patch.

Quoted 12 lines

When you make a patch please make the diff from a clean source tree. The reason for this is that the diff should contain only the changes that you're proposing so the possibility of mistakes getting through is minimized. As it is this patch contains a more unrelated stuff than the changes for the proposal itself. I can't really follow it well enough to know what you're trying to do.

Ian

plain text document attachment (patch-umount)
diff -Naur autofs-4.1.4/daemon/automount.c autofs-modificat/daemon/automount.c

daemon/automount.c +1 -25
@@ -139,31 +139,7 @@
 
 static int umount_ent(const char *root, const char *name, const char *type)
 {
-	char path_buf[PATH_MAX];
-	struct stat st;
-	int sav_errno;
-	int is_smbfs = (strcmp(type, "smbfs") == 0);
-	int status;
-	int rv = 0;
-
-	sprintf(path_buf, "%s/%s", root, name);
-	status =  lstat(path_buf, &st);
-	sav_errno = errno;
-
-	/* EIO appears to correspond to an smb mount that has gone away */
-	if (!status ||
-	    (is_smbfs && (sav_errno == EIO || sav_errno == EBADSLT))) {
-		int umount_ok = 0;
-
-		if (!status && (S_ISDIR(st.st_mode) && (st.st_dev != ap.dev)))
-			umount_ok = 1;
-
-		if (umount_ok || is_smbfs) {
-			rv = spawnll(LOG_DEBUG, 
-				    PATH_UMOUNT, PATH_UMOUNT, path_buf, NULL);
-		}
-	}
-	return rv;
+  return do_umount(root, name, type);
 }
 
 /* Like ftw, except fn gets called twice: before a directory is

diff -Naur autofs-4.1.4/daemon/Makefile autofs-modificat/daemon/Makefile

daemon/Makefile +2 -2
@@ -6,8 +6,8 @@
 -include ../Makefile.conf
 include ../Makefile.rules
 
-SRCS = automount.c spawn.c module.c mount.c
-OBJS = automount.o spawn.o module.o mount.o
+SRCS = automount.c spawn.c module.c mount.c umount.c
+OBJS = automount.o spawn.o module.o mount.o umount.o
 
 version := $(shell cat ../.version)
 

diff -Naur autofs-4.1.4/daemon/module.c autofs-modificat/daemon/module.c

daemon/module.c +69 -0
@@ -240,6 +240,75 @@
 	return mod;
 }
 
+
+struct mount_mod *open_umount(const char *name, const char *err_prefix)
+{
+	struct mount_mod *mod;
+	char *fnbuf;
+	size_t size_name;
+	size_t size_fnbuf;
+	void *dh;
+	int *ver;
+	
+	size_name = _strlen(name, PATH_MAX + 1);
+	if (!size_name)
+		return NULL;
+
+	mod = malloc(sizeof(struct mount_mod));
+	if (!mod) {
+		if (err_prefix)
+			crit("%s%m", err_prefix);
+		return NULL;
+	}
+
+	size_fnbuf = size_name + strlen(AUTOFS_LIB_DIR) + 13;
+	fnbuf = alloca(size_fnbuf);
+	if (!fnbuf) {
+		free(mod);
+		if (err_prefix)
+			crit("%s%m", err_prefix);
+		return NULL;
+	}
+	snprintf(fnbuf, size_fnbuf, "%s/umount_%s.so", AUTOFS_LIB_DIR, name);
+	
+	if (!(dh = dlopen(fnbuf, RTLD_NOW))) {
+		if (err_prefix)
+			crit("%scannot open umount module %s (%s)",
+			       err_prefix, name, dlerror());
+		free(mod);
+		return NULL;
+	}
+
+	if (!(ver = (int *) dlsym(dh, "mount_version"))
+	    || *ver != AUTOFS_MOUNT_VERSION) {
+		if (err_prefix)
+			crit("%smount module %s version mismatch",
+			     err_prefix, name);
+		dlclose(dh);
+		free(mod);
+		return NULL;
+	}
+
+	if (!(mod->mount_init = (mount_init_t) dlsym(dh, "mount_init")) ||
+	    !(mod->mount_umount = (mount_umount_t) dlsym(dh, "mount_umount")) ||
+	    !(mod->mount_done = (mount_done_t) dlsym(dh, "mount_done"))) {
+		if (err_prefix)
+			crit("%smount module %s corrupt", err_prefix, name);
+		dlclose(dh);
+		free(mod);
+		return NULL;
+	}
+
+	if (mod->mount_init(&mod->context)) {
+		dlclose(dh);
+		free(mod);
+		return NULL;
+	}
+	mod->dlhandle = dh;
+	return mod;
+}
+
+
 int close_mount(struct mount_mod *mod)
 {
 	int rv = mod->mount_done(mod->context);

diff -Naur autofs-4.1.4/daemon/umount.c autofs-modificat/daemon/umount.c

daemon/umount.c +63 -0
@@ -0,0 +1,63 @@
+/* ----------------------------------------------------------------------- *
+ *   
+ *   umount.c - Abstract umount code used by modules for an unexpected
+ *            filesystem type
+ *
+ *   Copyright 2007 Jordi Prats - CESCA - All Rights Reserved
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
+ *   USA; either version 2 of the License, or (at your option) any later
+ *   version.
+ *   
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include <syslog.h>
+#include <stdlib.h>
+#include <string.h>
+#include "automount.h"
+
+/* These filesystems are known not to work with the "generic" module */
+static char *not_generic[] = { "ext3lvm",
+			       NULL
+};
+
+// (const char *root, const char *name, int name_len,
+// const char *what, const char *fstype, const char *options)
+
+int do_umount(const char *root, const char *name, const char *type)
+{
+	struct mount_mod *mod;
+	const char *modstr;
+	char **ngp;
+	int rv;
+		
+	mod = open_umount(modstr = type, NULL);
+	if (!mod) {
+		for (ngp = not_generic; *ngp; ngp++) {
+			if (!strcmp(type, *ngp))
+				break;
+		}
+		if (!*ngp)
+			mod = open_umount(modstr = "generic", NULL);
+		if (!mod) {
+			error("cannot find umount method for filesystem %s",
+			       type);
+			return -1;
+		}
+	}
+
+	debug("do_umount root %s name type %s",
+		  root, name, type);
+
+	rv = mod->mount_umount(root, name, strlen(name), type, mod->context);
+	close_mount(mod);
+
+	return rv;
+}

diff -Naur autofs-4.1.4/include/automount.h autofs-modificat/include/automount.h

include/automount.h +13 -0
@@ -130,6 +130,9 @@
 int signal_children(int sig);
 int do_mount(const char *root, const char *name, int name_len,
 	     const char *what, const char *fstype, const char *options);
+
+int do_umount(const char *root, const char *name, const char *type);
+
 int mkdir_path(const char *path, mode_t mode);
 int rmdir_path(const char *path);
 
@@ -200,22 +203,32 @@
 int mount_init(void **context);
 int mount_mount(const char *root, const char *name, int name_len,
 		const char *what, const char *fstype, const char *options, void *context);
+
+int mount_umount(const char *root, const char *name, int name_len,
+		 const char *fstype, void *context);
+
 int mount_done(void *context);
 #endif
 typedef int (*mount_init_t) (void **);
 typedef int (*mount_mount_t) (const char *, const char *, int, const char *, const char *,
 			      const char *, void *);
+
+typedef int (*mount_umount_t) (const char *, const char *, int, const char *,
+			      void *);
+
 typedef int (*mount_done_t) (void *);
 
 struct mount_mod {
 	mount_init_t mount_init;
 	mount_mount_t mount_mount;
+	mount_umount_t mount_umount;
 	mount_done_t mount_done;
 	void *dlhandle;
 	void *context;
 };
 
 struct mount_mod *open_mount(const char *name, const char *err_prefix);
+struct mount_mod *open_umount(const char *name, const char *err_prefix);
 int close_mount(struct mount_mod *);
 
 /* mapent cache definition */

diff -Naur autofs-4.1.4/include/config.h autofs-modificat/include/config.h

include/config.h +28 -0
@@ -0,0 +1,28 @@
+/* include/config.h.  Generated by configure.  */
+#ident "$Id: config.h.in,v 1.4 2004/02/03 15:23:21 raven Exp $"
+/* -*- c -*-
+ *
+ * config.h.in: Pattern file for autofs to be filled in by configure
+ *
+ */
+
+/* Program paths */
+#define HAVE_MOUNT 1
+#define PATH_MOUNT "/bin/mount"
+
+#define HAVE_UMOUNT 1
+#define PATH_UMOUNT "/bin/umount"
+
+/* #undef HAVE_SMBMOUNT */
+/* #undef PATH_SMBMOUNT */
+
+#define HAVE_E2FSCK 1
+#define PATH_E2FSCK "/sbin/fsck.ext2"
+
+#define HAVE_E3FSCK 1
+#define PATH_E3FSCK "/sbin/fsck.ext3"
+
+/* Define this option if mount(8) supports the -s (sloppy) option */
+#define HAVE_SLOPPY_MOUNT 1
+
+/* #undef ENABLE_EXT_ENV */

diff -Naur autofs-4.1.4/modules/Makefile autofs-modificat/modules/Makefile

modules/Makefile +2 -2
@@ -10,13 +10,13 @@
 	lookup_multi.c \
 	parse_sun.c    \
 	mount_generic.c  mount_nfs.c  mount_afs.c  mount_autofs.c \
-	mount_changer.c  mount_bind.c
+	mount_changer.c  mount_bind.c umount_generic.c
 
 MODS :=	lookup_yp.so lookup_file.so lookup_program.so lookup_userhome.so \
 	lookup_multi.so \
 	parse_sun.so \
 	mount_generic.so mount_nfs.so mount_afs.so mount_autofs.so \
-	mount_changer.so mount_bind.so
+	mount_changer.so mount_bind.so umount_generic.so
 
 ifeq ($(EXT2FS), 1)
   SRCS += mount_ext2.c

diff -Naur autofs-4.1.4/modules/umount_generic.c autofs-modificat/modules/umount_generic.c

modules/umount_generic.c +73 -0
@@ -0,0 +1,73 @@
+/* ----------------------------------------------------------------------- *
+ *   
+ *  umount_generic.c - module for Linux automountd to umount filesystems
+ *                    for which no special magic is required
+ *
+ *   Copyright 2007 Jordi Prats - CESCA - All Rights Reserved
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
+ *   USA; either version 2 of the License, or (at your option) any later
+ *   version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include <stdio.h>
+#include <malloc.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define MODULE_MOUNT
+#include "automount.h"
+
+#define MODPREFIX "umount(generic): "
+
+int mount_version = AUTOFS_MOUNT_VERSION;	/* Required by protocol */
+
+int mount_init(void **context)
+{
+	return 0;
+}
+
+int mount_umount(const char *root, const char *name, int name_len,
+		 const char *fstype, void *context)
+{
+	char path_buf[PATH_MAX];
+	struct stat st;
+	int sav_errno;
+	int is_smbfs = (strcmp(fstype, "smbfs") == 0);
+	int status;
+	int rv = 0;
+	
+	sprintf(path_buf, "%s/%s", root, name);
+	status =  lstat(path_buf, &st);
+	sav_errno = errno;
+
+	/* EIO appears to correspond to an smb mount that has gone away */
+	if (!status ||
+	    (is_smbfs && (sav_errno == EIO || sav_errno == EBADSLT))) {
+		int umount_ok = 0;
+
+		if (!status && (S_ISDIR(st.st_mode) && (st.st_dev != ap.dev)))
+			umount_ok = 1;
+
+		if (umount_ok || is_smbfs) {
+			rv = spawnll(LOG_DEBUG, 
+				    PATH_UMOUNT, PATH_UMOUNT, path_buf, NULL);
+		}
+	}
+	return rv;
+}
+
+int mount_done(void *context)
+{
+	return 0;
+}