summaryrefslogtreecommitdiffstats
path: root/contrib/amd/amd/amfs_nfsl.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/amd/amd/amfs_nfsl.c')
-rw-r--r--contrib/amd/amd/amfs_nfsl.c143
1 files changed, 72 insertions, 71 deletions
diff --git a/contrib/amd/amd/amfs_nfsl.c b/contrib/amd/amd/amfs_nfsl.c
index bed6f4d..bb48f0e 100644
--- a/contrib/amd/amd/amfs_nfsl.c
+++ b/contrib/amd/amd/amfs_nfsl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2004 Erez Zadok
+ * Copyright (c) 1997-2006 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 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_nfsl.c,v 1.4.2.4 2004/01/06 03:15:16 ezk Exp $
+ * File: am-utils/amd/amfs_nfsl.c
*
*/
@@ -60,9 +59,9 @@
/* forward declarations */
static char *amfs_nfsl_match(am_opts *fo);
static int amfs_nfsl_init(mntfs *mf);
-static int amfs_nfsl_fmount(mntfs *mf);
-static int amfs_nfsl_fumount(mntfs *mf);
-static void amfs_nfsl_umounted(am_node *mp);
+static int amfs_nfsl_mount(am_node *mp, mntfs *mf);
+static int amfs_nfsl_umount(am_node *mp, mntfs *mf);
+static void amfs_nfsl_umounted(mntfs *mf);
static fserver *amfs_nfsl_ffserver(mntfs *mf);
/*
@@ -70,20 +69,23 @@ static fserver *amfs_nfsl_ffserver(mntfs *mf);
*/
am_ops amfs_nfsl_ops =
{
- "nfsl", /* name of file system */
- amfs_nfsl_match, /* match */
- amfs_nfsl_init, /* initialize */
- amfs_auto_fmount, /* mount vnode */
- amfs_nfsl_fmount, /* mount vfs */
- amfs_auto_fumount, /* unmount vnode */
- amfs_nfsl_fumount, /* unmount VFS */
- amfs_error_lookuppn, /* lookup path-name */
- amfs_error_readdir, /* read directory */
- 0, /* read link */
- 0, /* after-mount extra actions */
- amfs_nfsl_umounted, /* after-umount extra actions */
- amfs_nfsl_ffserver, /* find a file server */
- FS_MKMNT | FS_BACKGROUND | FS_AMQINFO /* flags */
+ "nfsl",
+ amfs_nfsl_match,
+ amfs_nfsl_init,
+ amfs_nfsl_mount,
+ amfs_nfsl_umount,
+ amfs_error_lookup_child,
+ amfs_error_mount_child,
+ amfs_error_readdir,
+ 0, /* amfs_nfsl_readlink */
+ 0, /* amfs_nfsl_mounted */
+ amfs_nfsl_umounted,
+ amfs_nfsl_ffserver,
+ 0, /* amfs_nfsl_get_wchan */
+ FS_MKMNT | FS_BACKGROUND | FS_AMQINFO, /* nfs_fs_flags */
+#ifdef HAVE_FS_AUTOFS
+ AUTOFS_NFSL_FS_FLAGS,
+#endif /* HAVE_FS_AUTOFS */
};
@@ -94,10 +96,16 @@ am_ops amfs_nfsl_ops =
static char *
amfs_nfsl_match(am_opts *fo)
{
- char *cp = fo->opt_fs;
+ char *cp;
char *ho = fo->opt_rhost;
+ char *retval;
struct stat stb;
+ if (fo->opt_sublink)
+ cp = fo->opt_sublink;
+ else
+ cp = fo->opt_fs;
+
if (!cp || !ho) {
plog(XLOG_USER, "amfs_nfsl: host $fs and $rhost must be specified");
return NULL;
@@ -105,20 +113,20 @@ amfs_nfsl_match(am_opts *fo)
/*
* If this host is not the same as $rhost, or if link does not exist,
- * perform nfs_match(), same as for type:=nfs.
- * If link value exists (or same host), then perform amfs_link_match(),
- * same as for linkx.
+ * call nfs_ops.fs_match().
+ * If link value exists (or same host), call amfs_link_ops.fs_match().
*/
if (!STRCEQ(ho, am_get_hostname())) {
plog(XLOG_INFO, "amfs_nfsl: \"%s\" is not local host, using type:=nfs", ho);
- return nfs_match(fo);
+ retval = nfs_ops.fs_match(fo);
} else if (lstat(cp, &stb) < 0) {
plog(XLOG_INFO, "amfs_nfsl: \"%s\" does not exist, using type:=nfs", cp);
- return nfs_match(fo);
+ retval = nfs_ops.fs_match(fo);
} else {
plog(XLOG_INFO, "amfs_nfsl: \"%s\" exists, using type:=link", cp);
- return amfs_link_match(fo);
+ retval = amfs_link_ops.fs_match(fo);
}
+ return retval;
}
@@ -129,15 +137,15 @@ amfs_nfsl_match(am_opts *fo)
static int
amfs_nfsl_init(mntfs *mf)
{
- /*
- * If a link, do nothing (same as type:=link).
- * If non-link, do nfs_init (same as type:=nfs).
- */
+ int ret = 0;
if (mf->mf_flags & MFF_NFSLINK) {
- return 0;
+ if (amfs_link_ops.fs_init)
+ ret = amfs_link_ops.fs_init(mf);
} else {
- return nfs_init(mf);
+ if (nfs_ops.fs_init)
+ ret = nfs_ops.fs_init(mf);
}
+ return ret;
}
@@ -146,17 +154,17 @@ amfs_nfsl_init(mntfs *mf)
* Returns: 0 if OK, non-zero (errno) if failed.
*/
static int
-amfs_nfsl_fmount(mntfs *mf)
+amfs_nfsl_mount(am_node *mp, mntfs *mf)
{
- /*
- * If a link, do run amfs_link_fmount() (same as type:=link)
- * If non-link, do nfs_fmount (same as type:=nfs).
- */
+ int ret = 0;
if (mf->mf_flags & MFF_NFSLINK) {
- return amfs_link_fmount(mf);
+ if (amfs_link_ops.mount_fs)
+ ret = amfs_link_ops.mount_fs(mp, mf);
} else {
- return nfs_fmount(mf);
+ if (nfs_ops.mount_fs)
+ ret = nfs_ops.mount_fs(mp, mf);
}
+ return ret;
}
@@ -165,17 +173,17 @@ amfs_nfsl_fmount(mntfs *mf)
* Returns: 0 if OK, non-zero (errno) if failed.
*/
static int
-amfs_nfsl_fumount(mntfs *mf)
+amfs_nfsl_umount(am_node *mp, mntfs *mf)
{
- /*
- * If a link, do run amfs_link_fumount() (same as type:=link)
- * If non-link, do nfs_fumount (same as type:=nfs).
- */
+ int ret = 0;
if (mf->mf_flags & MFF_NFSLINK) {
- return amfs_link_fumount(mf);
+ if (amfs_link_ops.umount_fs)
+ ret = amfs_link_ops.umount_fs(mp, mf);
} else {
- return nfs_fumount(mf);
+ if (nfs_ops.umount_fs)
+ ret = nfs_ops.umount_fs(mp, mf);
}
+ return ret;
}
@@ -186,27 +194,14 @@ amfs_nfsl_fumount(mntfs *mf)
* See amfs_auto_umounted(), host_umounted(), nfs_umounted().
*/
static void
-amfs_nfsl_umounted(am_node *mp)
+amfs_nfsl_umounted(mntfs *mf)
{
- mntfs *mf = mp->am_mnt;
-
- /*
- * If a link, do nothing (same as type:=link)
- * If non-link, do nfs_fumount (same as type:=nfs).
- */
if (mf->mf_flags & MFF_NFSLINK) {
- return;
+ if (amfs_link_ops.umounted)
+ amfs_link_ops.umounted(mf);
} else {
- nfs_umounted(mp);
- /*
- * MUST remove mount point directories, because if they remain
- * behind, the next nfsl access will think they are a link
- * type file system, and not NFS! (when it performs link target
- * existence test)
- */
- if (mf->mf_flags & MFF_MKMNT)
- rmdirs(mf->mf_mount);
- return;
+ if (nfs_ops.umounted)
+ nfs_ops.umounted(mf);
}
}
@@ -218,20 +213,26 @@ amfs_nfsl_umounted(am_node *mp)
static fserver *
amfs_nfsl_ffserver(mntfs *mf)
{
- char *cp = mf->mf_fo->opt_fs;
+ char *cp;
char *ho = mf->mf_fo->opt_rhost;
struct stat stb;
+ if (mf->mf_fo->opt_sublink)
+ cp = mf->mf_fo->opt_sublink;
+ else
+ cp = mf->mf_fo->opt_fs;
+
/*
* If this host is not the same as $rhost, or if link does not exist,
- * perform find_nfs_srvr(), same as for type:=nfs.
- * If link value exists (or same host), then perform
- * find_amfs_auto_srvr(), same as for linkx.
+ * call amfs_link_ops.ffserver().
+ * If link value exists (or same host), then call ops_nfs.ffserver().
*/
if (!STRCEQ(ho, am_get_hostname()) || lstat(cp, &stb) < 0) {
- return find_nfs_srvr(mf);
+ return nfs_ops.ffserver(mf);
} else {
mf->mf_flags |= MFF_NFSLINK;
- return find_amfs_auto_srvr(mf);
+ /* remove the FS_MKMNT flag, we don't want amd touching the mountpoint */
+ mf->mf_fsflags &= ~FS_MKMNT;
+ return amfs_link_ops.ffserver(mf);
}
}
OpenPOWER on IntegriCloud