summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2000-01-22 22:17:31 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2000-01-22 22:17:31 (GMT)
commit58ce3bea37f11479b1bfbc7b77eab37dc1b621f7 (patch)
treefff8de24aebc67baa4a86152572e6798f7559d88
parentc9c952121b53417f53a5487b85e5a067cdf2b235 (diff)
downloadautofs3-58ce3bea37f11479b1bfbc7b77eab37dc1b621f7.zip
autofs3-58ce3bea37f11479b1bfbc7b77eab37dc1b621f7.tar.gz
autofs3-58ce3bea37f11479b1bfbc7b77eab37dc1b621f7.tar.bz2
autofs3-58ce3bea37f11479b1bfbc7b77eab37dc1b621f7.tar.xz
Commit changes as of 3.1.4 release
-rw-r--r--.lastrel2
-rw-r--r--COPYRIGHT5
-rw-r--r--NEWS7
-rw-r--r--README.changer32
-rw-r--r--configure.in2
-rw-r--r--daemon/mount.c4
-rw-r--r--modules/Makefile6
-rw-r--r--modules/mount_changer.c149
-rw-r--r--samples/rc.autofs.in21
9 files changed, 210 insertions, 18 deletions
diff --git a/.lastrel b/.lastrel
index ff365e0..0aec50e 100644
--- a/.lastrel
+++ b/.lastrel
@@ -1 +1 @@
-3.1.3
+3.1.4
diff --git a/COPYRIGHT b/COPYRIGHT
index e49c9b8..23e3fcf 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,6 +1,6 @@
-For all software in this distribution:
+For all software in this distribution unless otherwise indicated:
- Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
+ Copyright 1997-2000 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
@@ -12,4 +12,3 @@ For all software in this distribution:
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.
-
diff --git a/NEWS b/NEWS
index 2388f03..5c83bd7 100644
--- a/NEWS
+++ b/NEWS
@@ -3,12 +3,17 @@ Since autofs-3.1.3:
* Merge in documentation changes from RedHat RPM.
* Support installing the samples stuff (make install_samples).
* Make samples/rc.autofs appropriate for both RedHat and Debian.
-* Include spec file to make RedHat RPM.
+ Thanks to Jeremy Fitzhardinge for a patch here.
* Added fixes to mount_autofs with options, from Rainer Clasen.
* Removed the now-obsolete mount_smbfs. MAKE SURE YOU READ
"README.smbfs" before trying to mount an smbfs filesystem using autofs!!
* Created a new lookup_multi module. Sample usage:
automount /path multi file /etc/auto.path -- yp auto.path
+* New mount_changer module from Toby Jaffery (for selecting slots out
+ of a media changer automatically.) See README.changer.
+* Include spec file that can make a RedHat RPM. Note that this may
+ not be appropriate for actual RedHat systems; the way RedHat does
+ autofs seems to change with every release.
Since autofs-3.1.2:
-------------------
diff --git a/README.changer b/README.changer
new file mode 100644
index 0000000..9325299
--- /dev/null
+++ b/README.changer
@@ -0,0 +1,32 @@
+Fri Jan 21 17:31:43 GMT 2000
+Toby Jaffey <toby@earth.li>
+Added modules/mount_changer.c
+
+I have an NEC CD-ROM DRIVE:251, 4X CD-ROM changer w/4 slots, 128kB
+Cache. The drive can only mount one CD at a time. To change the CD in
+use you must unmount, swap slots (lots of ioctl() calls) and
+remount. Using autofs, this module allows the illusion that all CDs
+are mounted at any given time. Only when data is requested does the
+drive need to swap. Clearly, this is awful for simultaneous reads
+across many disks, but I use it to create mp3 playlists spanning
+multiple CDs.
+
+The code is mostly clean, but rather than adding a new "mediatype" to
+the config file, I set my drive up as fstype=changer. The assumption
+is made that all of the disks are of type iso9660. This is a bad
+thing, but it works for me.
+
+[hpa: I believe these problems are due to a design error. The changer
+should be a lookup type, rather than a filesystem (mount) type.]
+
+My /etc/auto.master says:
+/mnt/changer /etc/auto.misc
+
+My /etc/auto.misc says:
+1 -fstype=changer :/dev/hdb
+2 -fstype=changer :/dev/hdb
+3 -fstype=changer :/dev/hdb
+4 -fstype=changer :/dev/hdb
+
+
+
diff --git a/configure.in b/configure.in
index fcd2ff7..1d4688e 100644
--- a/configure.in
+++ b/configure.in
@@ -7,7 +7,7 @@
#
define([AC_CACHE_LOAD], )dnl
define([AC_CACHE_SAVE], )dnl
-AC_INIT(.autofs-3.1.0)
+AC_INIT(.autofs-3.1.4)
#
# autofs installs by default in /usr
diff --git a/daemon/mount.c b/daemon/mount.c
index 14c718a..1978463 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -4,7 +4,7 @@
* mount.c - Abstract mount code used by modules for an unexpected
* filesystem type
*
- * Copyright 1997-1999 Transmeta Corporation - All Rights Reserved
+ * Copyright 1997-2000 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
@@ -26,7 +26,7 @@
/* These filesystems are known not to work with the "generic" module */
/* Note: starting with Samba 2.0.6, smbfs is handled generically. */
static char *not_generic[] = { "nfs", "ncpfs", "userfs", "afs",
- "autofs", NULL };
+ "autofs", "changer", NULL };
int do_mount(const char *root, const char *name, int name_len,
const char *what, const char *fstype, const char *options)
diff --git a/modules/Makefile b/modules/Makefile
index b1db26a..20980f8 100644
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -9,12 +9,14 @@ include ../Makefile.rules
SRCS := lookup_yp.c lookup_file.c lookup_program.c lookup_userhome.c \
lookup_multi.c \
parse_sun.c \
- mount_generic.c mount_nfs.c mount_afs.c mount_autofs.c
+ mount_generic.c mount_nfs.c mount_afs.c mount_autofs.c \
+ mount_changer.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_generic.so mount_nfs.so mount_afs.so mount_autofs.so \
+ mount_changer.so
ifeq ($(EXT2FS), 1)
SRCS += mount_ext2.c
diff --git a/modules/mount_changer.c b/modules/mount_changer.c
new file mode 100644
index 0000000..275e3a6
--- /dev/null
+++ b/modules/mount_changer.c
@@ -0,0 +1,149 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * mount_changer.c - module for Linux automountd to mount filesystems
+ * from cd changers
+ *
+ * Copyright 1999 Toby Jaffey - All Rights Reserved
+ * CD swapping code from linux kernel in Documentation/cdrom/ide-cd
+ * Based on code originally from Gerhard Zuber <zuber@berlin.snafu.de>.
+ * Changer status information, and rewrite for the new Uniform CDROM driver
+ * interface by Erik Andersen <andersee@debian.org>.
+ *
+ * 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>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <linux/cdrom.h>
+
+#define MODULE_MOUNT
+#include "automount.h"
+
+#define MODPREFIX "mount(changer): "
+int mount_version = AUTOFS_MOUNT_VERSION; /* Required by protocol */
+
+int swapCD(const char *device, const char *slotName);
+
+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;
+
+ fstype = "iso9660";
+
+ 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 umount %s", what);
+ err = spawnl(LOG_DEBUG, "/bin/umount", "/bin/umount", what, NULL);
+ if ( err ) {
+ syslog(LOG_DEBUG, MODPREFIX "umount of %s failed (all may be unmounted)", what);
+ }
+
+ 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_NOTICE, MODPREFIX "Swapping CD to slot %s", name);
+ err = swapCD(what, name);
+ if ( err ) {
+ syslog(LOG_NOTICE, MODPREFIX "failed to swap CD to slot %s", name);
+ return 1;
+ }
+ if ( options ) {
+ syslog(LOG_DEBUG, MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
+ fstype, options, what, fullpath);
+ err = spawnl(LOG_DEBUG, PATH_MOUNT, PATH_MOUNT, "-t", fstype, what, SLOPPYOPT "-o", options, what, fullpath, NULL);
+ } else {
+ syslog(LOG_DEBUG, MODPREFIX "calling mount -t %s %s %s",
+ fstype, what, fullpath);
+ err = spawnl(LOG_DEBUG, 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;
+}
+
+int swapCD(const char *device, const char *slotName)
+{
+int fd; /* file descriptor for CD-ROM device */
+int status; /* return status for system calls */
+int slot=-1;
+int total_slots_available;
+
+slot = atoi (slotName) - 1;
+
+/* open device */
+fd = open(device, O_RDONLY | O_NONBLOCK);
+if (fd < 0)
+ {
+ syslog(LOG_NOTICE, MODPREFIX "Opening device %s failed : %s", device, strerror(errno));
+ return 1;
+ }
+
+/* Check CD player status */
+total_slots_available = ioctl (fd, CDROM_CHANGER_NSLOTS);
+if (total_slots_available <= 1 )
+ {
+ syslog(LOG_NOTICE, MODPREFIX, "Device %s is not an ATAPI compliant CD changer.\n", device);
+ return 1;
+ }
+
+/* load */
+slot=ioctl (fd, CDROM_SELECT_DISC, slot);
+if (slot<0)
+ {
+ syslog(LOG_NOTICE, MODPREFIX, "CDROM_SELECT_DISC failed");
+ return 1;
+ }
+
+/* close device */
+status = close (fd);
+if (status != 0)
+ {
+ syslog(LOG_NOTICE, MODPREFIX, "close failed for `%s': %s\n", device, strerror(errno));
+ return 1;
+ }
+return 0;
+}
+
diff --git a/samples/rc.autofs.in b/samples/rc.autofs.in
index 86aa26a..cdf638b 100644
--- a/samples/rc.autofs.in
+++ b/samples/rc.autofs.in
@@ -10,6 +10,11 @@
# /etc/rc.d/init.d/autofs or /etc/init.d/autofs
#
+# For Redhat-ish systems
+#
+# chkconfig: 345 15 85
+# description: Automounts filesystems on demand
+
# This is used in the Debian distribution to determine the proper
# location for the S- and K-links to this init file.
# The following value is extracted by debstd to figure out how to
@@ -44,7 +49,7 @@ fi
test -e $DAEMON || exit 0
thisscript="$0"
-if [ ! test -f $thisscript ]; then
+if [ ! -f "$thisscript" ]; then
echo "$0: Cannot find myself" 1>&2
exit 1
fi
@@ -145,18 +150,18 @@ function redhat()
case "$1" in
start)
# Check if the automounter is already running?
- if [ ! -f /var/lock/subsys/automount ]; then
+ if [ ! -f /var/lock/subsys/autofs ]; then
echo 'Starting automounter: '
getmounts | sh
- touch /var/lock/subsys/automount
+ touch /var/lock/subsys/autofs
fi
;;
stop)
kill -TERM $(/sbin/pidof /usr/sbin/automount)
- rm -f /var/lock/subsys/automount
+ rm -f /var/lock/subsys/autofs
;;
reload|restart)
- if [ ! -f /var/lock/subsys/automount ]; then
+ if [ ! -f /var/lock/subsys/autofs ]; then
echo "Automounter not running"
exit 1
fi
@@ -204,7 +209,7 @@ case "$1" in
getmounts | while read cmd mnt rest
do
echo -n " $mnt"
- pidfile=/var/run/automount`echo $mnt | sed 's/\//./'`.pid
+ pidfile=/var/run/autofs`echo $mnt | sed 's/\//./'`.pid
start-stop-daemon --start --pidfile $pidfile --quiet \
--exec $DAEMON -- $mnt $rest
#
@@ -225,9 +230,9 @@ case "$1" in
;;
reload|restart)
echo "Reloading automounter: checking for changes ... "
- TMP=/var/run/automount.tmp
+ TMP=/var/run/autofs.tmp
getmounts >$TMP
- for i in /var/run/automount.*.pid
+ for i in /var/run/autofs.*.pid
do
pid=`head -n 1 $i 2>/dev/null`
[ "$pid" = "" ] && continue