aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>1998-03-27 04:59:29 +0000
committerH. Peter Anvin <hpa@zytor.com>1998-03-27 04:59:29 +0000
commit416c8a6915ad2e45c98fd8a72a0deeb8adb5d1c1 (patch)
treec42f72b7c6d36b99b02a117e800a10fc3309706c
parentd1a392948f14d1faa62271472ef6fecf1e80972f (diff)
downloadautofs3-416c8a6915ad2e45c98fd8a72a0deeb8adb5d1c1.tar.gz
autofs3-416c8a6915ad2e45c98fd8a72a0deeb8adb5d1c1.tar.xz
autofs3-416c8a6915ad2e45c98fd8a72a0deeb8adb5d1c1.zip
Added mount_ext2 module.
-rw-r--r--NEWS1
-rw-r--r--include/automount.h8
-rw-r--r--modules/Makefile4
-rw-r--r--modules/mount_ext2.c94
4 files changed, 103 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 374df4a..bca7527 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Since autofs-0.3.14:
practical; also cleaned up comment preambles.
* AFS/Hesiod support by Nalin Dahyabhai.
* NIS+ support by Thorsten Kukuk.
+* mount_ext2 module that runs e2fsck -p on the filesystem first.
Since autofs-0.3.13:
--------------------
diff --git a/include/automount.h b/include/automount.h
index 8054269..a590525 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -14,13 +14,17 @@
#ifndef _PATH_MOUNT
#define _PATH_MOUNT "/bin/mount"
#endif
+
#ifndef _PATH_UMOUNT
#define _PATH_UMOUNT "/bin/umount"
#endif
-/* If smbmount is unavailable, remote the mount_smbfs module from
- modules/Makefile */
+#ifndef _PATH_E2FSCK
+#define _PATH_E2FSCK "/sbin/fsck.ext2"
+#endif
+/* If smbmount is unavailable, remove the mount_smbfs module from
+ modules/Makefile */
#ifndef _PATH_SMBMOUNT
#define _PATH_SMBMOUNT "/usr/bin/smbmount"
#endif
diff --git a/modules/Makefile b/modules/Makefile
index 4e81be0..3b5d849 100644
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -7,11 +7,11 @@ include ../Makefile.rules
SRCS = lookup_yp.c lookup_file.c lookup_program.c \
parse_sun.c \
- mount_generic.c mount_nfs.c mount_smbfs.c mount_afs.c
+ mount_generic.c mount_ext2.c mount_nfs.c mount_smbfs.c mount_afs.c
MODS = lookup_yp.so lookup_file.so lookup_program.so \
parse_sun.so \
- mount_generic.so mount_nfs.so mount_smbfs.so mount_afs.so
+ mount_generic.so mount_ext2.so mount_nfs.so mount_smbfs.so mount_afs.so
ifdef HESIOD
SRCS += lookup_hesiod.c parse_hesiod.c
diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
new file mode 100644
index 0000000..dec22d5
--- /dev/null
+++ b/modules/mount_ext2.c
@@ -0,0 +1,94 @@
+#ident "$Id$"
+/* ----------------------------------------------------------------------- *
+ *
+ * mount_ext2.c - module for Linux automountd to mount ext2 filesystems
+ * after running fsck on them.
+ *
+ * Copyright 1998 Transmeta Corporation - 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 <sys/param.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define MODULE_MOUNT
+#include "automount.h"
+
+#define MODPREFIX "mount(ext2): "
+int mount_version = AUTOFS_MOUNT_VERSION; /* Required by protocol */
+
+
+int mount_init(void **context)
+{
+ return 0;
+}
+
+int mount_mount(const char *root, const char *name, int name_len,
+ const char *what, const char *fstype, const char *options,
+ void *context)
+{
+ char *fullpath;
+ int err;
+
+ fullpath = alloca(strlen(root)+name_len+2);
+ if ( !fullpath ) {
+ syslog(LOG_ERR, MODPREFIX "alloca: %m");
+ return 1;
+ }
+ sprintf(fullpath, "%s/%s", root, name);
+
+ syslog(LOG_DEBUG, MODPREFIX "calling mkdir %s", fullpath);
+ if ( mkdir(fullpath, 0555) && errno != EEXIST ) {
+ syslog(LOG_NOTICE, MODPREFIX "mkdir %s failed: %m", name);
+ return 1;
+ }
+
+ syslog(LOG_DEBUG, MODPREFIX "calling fsck.ext2 -p %s", what);
+ err = spawnl(LOG_DEBUG, _PATH_E2FSCK, _PATH_E2FSCK, "-p", what, NULL);
+ if ( err & ~7 ) {
+ syslog(LOG_ERR, MODPREFIX "%s: filesystem needs repair, won't mount",
+ what);
+ return 1;
+ }
+
+ if ( options ) {
+ syslog(LOG_DEBUG, MODPREFIX "calling mount -t %s -o %s %s %s",
+ fstype, options, what, fullpath);
+ err = spawnl(LOG_NOTICE, _PATH_MOUNT, _PATH_MOUNT, "-t", fstype,
+ "-o", options, what, fullpath, NULL);
+ } else {
+ syslog(LOG_DEBUG, MODPREFIX "calling mount -t %s %s %s",
+ fstype, what, fullpath);
+ err = spawnl(LOG_NOTICE, _PATH_MOUNT, _PATH_MOUNT, "-t", fstype,
+ what, fullpath, NULL);
+ }
+ if ( err ) {
+ rmdir(fullpath);
+ syslog(LOG_NOTICE, MODPREFIX "failed to mount %s (type %s) on %s",
+ what, fstype, fullpath);
+ return 1;
+ } else {
+ syslog(LOG_DEBUG, MODPREFIX "mounted %s type %s on %s",
+ what, fstype, fullpath);
+ return 0;
+ }
+}
+
+int mount_done(void *context)
+{
+ return 0;
+}