summaryrefslogtreecommitdiffstats
path: root/contrib/amd/amd/ops_cachefs.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/amd/amd/ops_cachefs.c')
-rw-r--r--contrib/amd/amd/ops_cachefs.c67
1 files changed, 40 insertions, 27 deletions
diff --git a/contrib/amd/amd/ops_cachefs.c b/contrib/amd/amd/ops_cachefs.c
index 08c4875..d3e303b 100644
--- a/contrib/amd/amd/ops_cachefs.c
+++ b/contrib/amd/amd/ops_cachefs.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: ops_cachefs.c,v 1.3.2.4 2004/01/06 03:15:16 ezk Exp $
+ * File: am-utils/amd/ops_cachefs.c
*
*/
@@ -55,8 +54,8 @@
/* forward declarations */
static char *cachefs_match(am_opts *fo);
static int cachefs_init(mntfs *mf);
-static int cachefs_fmount(mntfs *mf);
-static int cachefs_fumount(mntfs *mf);
+static int cachefs_mount(am_node *am, mntfs *mf);
+static int cachefs_umount(am_node *am, mntfs *mf);
/*
@@ -67,17 +66,20 @@ am_ops cachefs_ops =
"cachefs",
cachefs_match,
cachefs_init,
- amfs_auto_fmount,
- cachefs_fmount,
- amfs_auto_fumount,
- cachefs_fumount,
- amfs_error_lookuppn,
+ cachefs_mount,
+ cachefs_umount,
+ amfs_error_lookup_child,
+ amfs_error_mount_child,
amfs_error_readdir,
0, /* cachefs_readlink */
- 0, /* post-mount actions */
- 0, /* post-umount actions */
- find_amfs_auto_srvr,
- FS_MKMNT | FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO
+ 0, /* cachefs_mounted */
+ 0, /* cachefs_umounted */
+ amfs_generic_find_srvr,
+ 0, /* cachefs_get_wchan */
+ FS_MKMNT | FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO, /* nfs_fs_flags */
+#ifdef HAVE_FS_AUTOFS
+ AUTOFS_CACHEFS_FS_FLAGS,
+#endif /* HAVE_FS_AUTOFS */
};
@@ -94,9 +96,7 @@ cachefs_match(am_opts *fo)
return NULL;
}
-#ifdef DEBUG
dlog("CACHEFS: using cache directory \"%s\"", fo->opt_cachedir);
-#endif /* DEBUG */
/* determine magic cookie to put in mtab */
return strdup(fo->opt_cachedir);
@@ -113,7 +113,7 @@ cachefs_init(mntfs *mf)
/*
* Save cache directory name
*/
- if (mf->mf_refc == 1) {
+ if (!mf->mf_private) {
mf->mf_private = (voidp) strdup(mf->mf_fo->opt_cachedir);
mf->mf_prfree = (void (*)(voidp)) free;
}
@@ -128,7 +128,8 @@ cachefs_init(mntfs *mf)
* cachedir is the cache directory ($cachedir)
*/
static int
-mount_cachefs(char *mntpt, char *backdir, char *cachedir, char *opts)
+mount_cachefs(char *mntdir, char *backdir, char *cachedir,
+ char *opts, int on_autofs)
{
cachefs_args_t ca;
mntent_t mnt;
@@ -142,12 +143,16 @@ mount_cachefs(char *mntpt, char *backdir, char *cachedir, char *opts)
* Fill in the mount structure
*/
memset((voidp) &mnt, 0, sizeof(mnt));
- mnt.mnt_dir = mntpt;
+ mnt.mnt_dir = mntdir;
mnt.mnt_fsname = backdir;
mnt.mnt_type = MNTTAB_TYPE_CACHEFS;
mnt.mnt_opts = opts;
flags = compute_mount_flags(&mnt);
+#ifdef HAVE_FS_AUTOFS
+ if (on_autofs)
+ flags |= autofs_compute_mount_flags(&mnt);
+#endif /* HAVE_FS_AUTOFS */
/* Fill in cachefs mount arguments */
@@ -170,8 +175,13 @@ mount_cachefs(char *mntpt, char *backdir, char *cachedir, char *opts)
/* CFS fscdir name */
memset(ca.cfs_cacheid, 0, sizeof(ca.cfs_cacheid));
- /* append cacheid and mountpoint */
- sprintf(ca.cfs_cacheid, "%s:%s", ca.cfs_fsid, mntpt);
+ /*
+ * Append cacheid and mountpoint.
+ * sizeof(cfs_cacheid) should be C_MAX_MOUNT_FSCDIRNAME as per
+ * <sys/fs/cachefs_fs.h> (checked on Solaris 8).
+ */
+ xsnprintf(ca.cfs_cacheid, sizeof(ca.cfs_cacheid),
+ "%s:%s", ca.cfs_fsid, mntdir);
/* convert '/' to '_' (Solaris does that...) */
cp = ca.cfs_cacheid;
while ((cp = strpbrk(cp, "/")) != NULL)
@@ -192,19 +202,21 @@ mount_cachefs(char *mntpt, char *backdir, char *cachedir, char *opts)
/*
* Call generic mount routine
*/
- return mount_fs(&mnt, flags, (caddr_t) &ca, 0, type, 0, NULL, mnttab_file_name);
+ return mount_fs(&mnt, flags, (caddr_t) &ca, 0, type, 0, NULL, mnttab_file_name, on_autofs);
}
static int
-cachefs_fmount(mntfs *mf)
+cachefs_mount(am_node *am, mntfs *mf)
{
+ int on_autofs = mf->mf_flags & MFF_ON_AUTOFS;
int error;
error = mount_cachefs(mf->mf_mount,
mf->mf_fo->opt_rfs,
mf->mf_fo->opt_cachedir,
- mf->mf_mopts);
+ mf->mf_mopts,
+ on_autofs);
if (error) {
errno = error;
/* according to Solaris, if errno==ESRCH, "options to not match" */
@@ -220,11 +232,12 @@ cachefs_fmount(mntfs *mf)
static int
-cachefs_fumount(mntfs *mf)
+cachefs_umount(am_node *am, mntfs *mf)
{
+ int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0;
int error;
- error = UMOUNT_FS(mf->mf_mount, mnttab_file_name);
+ error = UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags);
/*
* In the case of cachefs, we must fsck the cache directory. Otherwise,
@@ -239,7 +252,7 @@ cachefs_fumount(mntfs *mf)
cachedir = (char *) mf->mf_private;
plog(XLOG_INFO, "running fsck on cache directory \"%s\"", cachedir);
- sprintf(cmd, "fsck -F cachefs %s", cachedir);
+ xsnprintf(cmd, sizeof(cmd), "fsck -F cachefs %s", cachedir);
system(cmd);
}
OpenPOWER on IntegriCloud