summaryrefslogtreecommitdiffstats
path: root/contrib/amd/amd/amfs_link.c
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2007-12-05 15:48:03 +0000
committerobrien <obrien@FreeBSD.org>2007-12-05 15:48:03 +0000
commitea691ecd980d2860f0b39e9e504de4da404806fd (patch)
treefa83b3bb0660890a21b550fa1f334b151bf098f9 /contrib/amd/amd/amfs_link.c
parentc06a2e613662fc6ce10145b41762be8f8ab22ba4 (diff)
downloadFreeBSD-src-ea691ecd980d2860f0b39e9e504de4da404806fd.zip
FreeBSD-src-ea691ecd980d2860f0b39e9e504de4da404806fd.tar.gz
Virgin import of AMD (am-utils) v6.1.5
Sponsored by: Juniper Networks
Diffstat (limited to 'contrib/amd/amd/amfs_link.c')
-rw-r--r--contrib/amd/amd/amfs_link.c78
1 files changed, 35 insertions, 43 deletions
diff --git a/contrib/amd/amd/amfs_link.c b/contrib/amd/amd/amfs_link.c
index 55552ae..e75ab86 100644
--- a/contrib/amd/amd/amfs_link.c
+++ b/contrib/amd/amd/amfs_link.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_link.c,v 1.3.2.4 2004/01/06 03:15:16 ezk Exp $
+ * File: am-utils/amd/amfs_link.c
*
*/
@@ -52,6 +51,9 @@
#include <am_defs.h>
#include <amd.h>
+/* forward declarations */
+static int amfs_link_mount(am_node *mp, mntfs *mf);
+static int amfs_link_umount(am_node *mp, mntfs *mf);
/*
* Ops structures
@@ -61,17 +63,20 @@ am_ops amfs_link_ops =
"link",
amfs_link_match,
0, /* amfs_link_init */
- amfs_auto_fmount,
- amfs_link_fmount,
- amfs_auto_fumount,
- amfs_link_fumount,
- amfs_error_lookuppn,
+ amfs_link_mount,
+ amfs_link_umount,
+ amfs_error_lookup_child,
+ amfs_error_mount_child,
amfs_error_readdir,
0, /* amfs_link_readlink */
0, /* amfs_link_mounted */
0, /* amfs_link_umounted */
- find_amfs_auto_srvr,
- 0
+ amfs_generic_find_srvr,
+ 0, /* nfs_fs_flags */
+ 0, /* amfs_link_get_wchan */
+#ifdef HAVE_FS_AUTOFS
+ AUTOFS_LINK_FS_FLAGS,
+#endif /* HAVE_FS_AUTOFS */
};
@@ -88,54 +93,41 @@ amfs_link_match(am_opts *fo)
}
/*
- * Bug report (14/12/89) from Jay Plett <jay@princeton.edu>
- * If an automount point has the same name as an existing
- * link type mount Amd hits a race condition and either hangs
- * or causes a symlink loop.
+ * If the link target points to another mount point, then we could
+ * end up with an unpleasant situation, where the link f/s simply
+ * "assumes" the mntfs of that mount point.
*
- * If fs begins with a '/' change the opt_fs & opt_sublink
- * fields so that the fs option doesn't end up pointing at
- * an existing symlink.
+ * For example, if the link points to /usr, and /usr is a real ufs
+ * filesystem, then the link f/s will use the inherited ufs mntfs,
+ * and the end result will be that it will become unmountable.
*
- * If sublink is nil then set sublink to fs
- * else set sublink to fs / sublink
+ * To prevent this, we use a hack: we prepend a dot ('.') to opt_fs if
+ * its original value was an absolute path, so that it will never match
+ * any other mntfs.
*
- * Finally set fs to ".".
+ * XXX: a less hacky solution should be used...
*/
- if (*fo->opt_fs == '/') {
- char *fullpath;
- char *link = fo->opt_sublink;
- if (link) {
- if (*link == '/')
- fullpath = strdup(link);
- else
- fullpath = str3cat((char *) 0, fo->opt_fs, "/", link);
- } else {
- fullpath = strdup(fo->opt_fs);
- }
-
- if (fo->opt_sublink)
- XFREE(fo->opt_sublink);
- fo->opt_sublink = fullpath;
- fo->opt_fs = str3cat(fo->opt_fs, ".", fullpath, "");
+ if (fo->opt_fs[0] == '/') {
+ char *link_hack = str3cat(NULL, ".", fo->opt_fs, "");
+ if (!fo->opt_sublink)
+ fo->opt_sublink = strdup(fo->opt_fs);
+ XFREE(fo->opt_fs);
+ fo->opt_fs = link_hack;
}
return strdup(fo->opt_fs);
}
-int
-amfs_link_fmount(mntfs *mf)
+static int
+amfs_link_mount(am_node *mp, mntfs *mf)
{
- /*
- * Wow - this is hard to implement! :-)
- */
return 0;
}
-int
-amfs_link_fumount(mntfs *mf)
+static int
+amfs_link_umount(am_node *mp, mntfs *mf)
{
return 0;
}
OpenPOWER on IntegriCloud