summaryrefslogtreecommitdiffstats
path: root/contrib/amd/amd/amfs_program.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/amd/amd/amfs_program.c')
-rw-r--r--contrib/amd/amd/amfs_program.c64
1 files changed, 38 insertions, 26 deletions
diff --git a/contrib/amd/amd/amfs_program.c b/contrib/amd/amd/amfs_program.c
index 795c596..843e805 100644
--- a/contrib/amd/amd/amfs_program.c
+++ b/contrib/amd/amd/amfs_program.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2004 Erez Zadok
+ * Copyright (c) 1997-2006 Erez Zadok
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
@@ -36,9 +36,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: amfs_program.c,v 1.6.2.4 2004/01/06 03:15:16 ezk Exp $
+ * File: am-utils/amd/amfs_program.c
*
*/
@@ -54,8 +53,8 @@
/* forward definitions */
static char *amfs_program_match(am_opts *fo);
-static int amfs_program_fmount(mntfs *mf);
-static int amfs_program_fumount(mntfs *mf);
+static int amfs_program_mount(am_node *am, mntfs *mf);
+static int amfs_program_umount(am_node *am, mntfs *mf);
static int amfs_program_init(mntfs *mf);
/*
@@ -66,17 +65,20 @@ am_ops amfs_program_ops =
"program",
amfs_program_match,
amfs_program_init,
- amfs_auto_fmount,
- amfs_program_fmount,
- amfs_auto_fumount,
- amfs_program_fumount,
- amfs_error_lookuppn,
+ amfs_program_mount,
+ amfs_program_umount,
+ amfs_error_lookup_child,
+ amfs_error_mount_child,
amfs_error_readdir,
0, /* amfs_program_readlink */
0, /* amfs_program_mounted */
0, /* amfs_program_umounted */
- find_amfs_auto_srvr,
- FS_BACKGROUND | FS_AMQINFO
+ amfs_generic_find_srvr,
+ 0, /* amfs_program_get_wchan */
+ FS_MKMNT | FS_BACKGROUND | FS_AMQINFO, /* nfs_fs_flags */
+#ifdef HAVE_FS_AUTOFS
+ AUTOFS_PROGRAM_FS_FLAGS,
+#endif /* HAVE_FS_AUTOFS */
};
@@ -88,10 +90,19 @@ amfs_program_match(am_opts *fo)
{
char *prog;
- if (!fo->opt_mount || !fo->opt_unmount) {
- plog(XLOG_ERROR, "program: both mount and unmount must be specified");
+ if (fo->opt_unmount && fo->opt_umount) {
+ plog(XLOG_ERROR, "program: cannot specify both unmount and umount options");
return 0;
}
+ if (!fo->opt_mount) {
+ plog(XLOG_ERROR, "program: must specify mount command");
+ return 0;
+ }
+ if (!fo->opt_unmount && !fo->opt_umount) {
+ fo->opt_unmount = str3cat(NULL, UNMOUNT_PROGRAM, " umount ", fo->opt_fs);
+ plog(XLOG_INFO, "program: un/umount not specified; using default \"%s\"",
+ fo->opt_unmount);
+ }
prog = strchr(fo->opt_mount, ' ');
return strdup(prog ? prog + 1 : fo->opt_mount);
@@ -101,13 +112,16 @@ amfs_program_match(am_opts *fo)
static int
amfs_program_init(mntfs *mf)
{
- /*
- * Save unmount command
- */
- if (mf->mf_refc == 1) {
- mf->mf_private = (voidp) strdup(mf->mf_fo->opt_unmount);
- mf->mf_prfree = (void (*)(voidp)) free;
- }
+ /* check if already saved value */
+ if (mf->mf_private != NULL)
+ return 0;
+
+ /* save unmount (or umount) command */
+ if (mf->mf_fo->opt_unmount != NULL)
+ mf->mf_private = (opaque_t) strdup(mf->mf_fo->opt_unmount);
+ else
+ mf->mf_private = (opaque_t) strdup(mf->mf_fo->opt_umount);
+ mf->mf_prfree = (void (*)(opaque_t)) free;
return 0;
}
@@ -142,8 +156,7 @@ amfs_program_exec(char *info)
/*
* Try the exec
*/
-#ifdef DEBUG
- amuDebug(D_FULL) {
+ if (amuDebug(D_FULL)) {
char **cp = xivec;
plog(XLOG_DEBUG, "executing (un)mount command...");
while (*cp) {
@@ -151,7 +164,6 @@ amfs_program_exec(char *info)
cp++;
}
}
-#endif /* DEBUG */
if (xivec[0] == 0 || xivec[1] == 0) {
errno = EINVAL;
@@ -180,14 +192,14 @@ amfs_program_exec(char *info)
static int
-amfs_program_fmount(mntfs *mf)
+amfs_program_mount(am_node *am, mntfs *mf)
{
return amfs_program_exec(mf->mf_fo->opt_mount);
}
static int
-amfs_program_fumount(mntfs *mf)
+amfs_program_umount(am_node *am, mntfs *mf)
{
return amfs_program_exec((char *) mf->mf_private);
}
OpenPOWER on IntegriCloud