xref: /csrg-svn/usr.sbin/amd/amd/ifs_ops.c (revision 47526)
144626Smckusick /*
2*47526Spendry  * $Id: ifs_ops.c,v 5.2.1.3 91/03/17 17:47:48 jsp Alpha $
344626Smckusick  *
444626Smckusick  * Copyright (c) 1989 Jan-Simon Pendry
544626Smckusick  * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
644626Smckusick  * Copyright (c) 1989 The Regents of the University of California.
744626Smckusick  * All rights reserved.
844626Smckusick  *
944626Smckusick  * This code is derived from software contributed to Berkeley by
1044626Smckusick  * Jan-Simon Pendry at Imperial College, London.
1144626Smckusick  *
1244626Smckusick  * %sccs.include.redist.c%
1344626Smckusick  *
14*47526Spendry  *	@(#)ifs_ops.c	5.2 (Berkeley) 03/17/91
1544626Smckusick  */
1644626Smckusick 
1744626Smckusick #include "am.h"
1844626Smckusick 
1944626Smckusick #ifdef HAS_IFS
2044626Smckusick 
2144626Smckusick /*
2244626Smckusick  * Inheritance file system.
2344626Smckusick  * This implements a filesystem restart.
2444626Smckusick  *
2544626Smckusick  * This is a *gross* hack - it knows far too
2644626Smckusick  * much about the way other parts of the
2744626Smckusick  * sytem work.  See restart.c too.
2844626Smckusick  */
2944626Smckusick static char not_a_filesystem[] = "Attempting to inherit not-a-filesystem";
3044626Smckusick /*
3144626Smckusick  * This should never be called.
3244626Smckusick  */
33*47526Spendry /*ARGSUSED*/
34*47526Spendry static char *ifs_match P((am_opts *fo));
35*47526Spendry static char *ifs_match(fo)
36*47526Spendry am_opts *fo;
3744626Smckusick {
3844626Smckusick 	plog(XLOG_FATAL, "ifs_match called!");
39*47526Spendry 	return 0;
4044626Smckusick }
4144626Smckusick 
42*47526Spendry static int ifs_init P((mntfs *mf));
4344626Smckusick static int ifs_init(mf)
4444626Smckusick mntfs *mf;
4544626Smckusick {
4644626Smckusick 	mntfs *mf_link = (mntfs *) mf->mf_private;
4744626Smckusick 	if (mf_link == 0) {
4844626Smckusick 		plog(XLOG_FATAL, not_a_filesystem);
4944626Smckusick 		return EINVAL;
5044626Smckusick 	}
51*47526Spendry #ifdef notdef
5244626Smckusick 	/*
5344626Smckusick 	 * Fill in attribute fields
5444626Smckusick 	 */
5544626Smckusick 	mf_link->mf_fattr.type = NFLNK;
5644626Smckusick 	mf_link->mf_fattr.mode = NFSMODE_LNK | 0777;
5744626Smckusick 	mf_link->mf_fattr.nlink = 1;
5844626Smckusick 	mf_link->mf_fattr.size = MAXPATHLEN / 4;
59*47526Spendry #endif
6044626Smckusick 	if (mf_link->mf_ops->fs_init)
6144626Smckusick 		return (*mf_link->mf_ops->fs_init)(mf_link);
6244626Smckusick 	return 0;
6344626Smckusick }
6444626Smckusick 
65*47526Spendry static mntfs *ifs_inherit P((mntfs *mf));
66*47526Spendry static mntfs *ifs_inherit(mf)
67*47526Spendry mntfs *mf;
6844626Smckusick {
6944626Smckusick 	/*
7044626Smckusick 	 * Take the linked mount point and
7144626Smckusick 	 * propogate.
7244626Smckusick 	 */
7344626Smckusick 	mntfs *mf_link = (mntfs *) mf->mf_private;
7444626Smckusick 	if (mf_link == 0) {
7544626Smckusick 		plog(XLOG_FATAL, not_a_filesystem);
76*47526Spendry 		return 0;	/*XXX*/
7744626Smckusick 	}
7844626Smckusick 
7944626Smckusick 	mf_link->mf_fo = mf->mf_fo;
80*47526Spendry #ifdef notdef
8144626Smckusick 	mf_link->mf_fattr.fileid = mf->mf_fattr.fileid;
82*47526Spendry #endif /* notdef */
8344626Smckusick 
8444626Smckusick 	/*
8544626Smckusick 	 * Discard the old map.
8644626Smckusick 	 * Don't call am_unmounted since this
8744626Smckusick 	 * node was never really mounted in the
8844626Smckusick 	 * first place.
8944626Smckusick 	 */
9044626Smckusick 	mf->mf_private = 0;
9144626Smckusick 	free_mntfs(mf);
9244626Smckusick 	/*
9344626Smckusick 	 * Free the dangling reference
9444626Smckusick 	 * to the mount link.
9544626Smckusick 	 */
9644626Smckusick 	free_mntfs(mf_link);
9744626Smckusick 	/*
9844626Smckusick 	 * Get a hold of the other entry
9944626Smckusick 	 */
100*47526Spendry 	mf_link->mf_flags &= ~MFF_RESTART;
10144626Smckusick 
10244626Smckusick 	/* Say what happened */
103*47526Spendry 	plog(XLOG_INFO, "restarting %s on %s", mf_link->mf_info, mf_link->mf_mount);
10444626Smckusick 
105*47526Spendry 	return mf_link;
106*47526Spendry }
10744626Smckusick 
108*47526Spendry static int ifs_mount P((am_node *mp));
109*47526Spendry static int ifs_mount(mp)
110*47526Spendry am_node *mp;
111*47526Spendry {
112*47526Spendry 	mntfs *newmf = ifs_inherit(mp->am_mnt);
113*47526Spendry 	if (newmf) {
114*47526Spendry 		mp->am_mnt = newmf;
115*47526Spendry 		/*
116*47526Spendry 		 * XXX - must do the am_mounted call here
117*47526Spendry 		 */
118*47526Spendry 		if (newmf->mf_ops->fs_flags & FS_MBACKGROUND)
119*47526Spendry 			am_mounted(mp);
12044626Smckusick 
121*47526Spendry 		new_ttl(mp);
122*47526Spendry 		return 0;
123*47526Spendry 	}
124*47526Spendry 	return EINVAL;
12544626Smckusick }
12644626Smckusick 
127*47526Spendry static int ifs_fmount P((mntfs *mf));
128*47526Spendry static int ifs_fmount(mf)
129*47526Spendry mntfs *mf;
130*47526Spendry {
131*47526Spendry 	am_node *mp = find_mf(mf);
132*47526Spendry 	if (mp)
133*47526Spendry 		return ifs_mount(mp);
134*47526Spendry 	return ifs_inherit(mf) ? 0 : EINVAL;
135*47526Spendry }
136*47526Spendry 
13744626Smckusick /*ARGSUSED*/
138*47526Spendry static int ifs_fumount P((mntfs *mf));
139*47526Spendry static int ifs_fumount(mf)
140*47526Spendry mntfs *mf;
14144626Smckusick {
14244626Smckusick 	/*
14344626Smckusick 	 * Always succeed
14444626Smckusick 	 */
14544626Smckusick 	return 0;
14644626Smckusick }
14744626Smckusick 
14844626Smckusick /*
14944626Smckusick  * Ops structure
15044626Smckusick  */
15144626Smckusick am_ops ifs_ops = {
15244626Smckusick 	"inherit",
15344626Smckusick 	ifs_match,
15444626Smckusick 	ifs_init,
15544626Smckusick 	ifs_mount,
156*47526Spendry 	ifs_fmount,
157*47526Spendry 	auto_fumount,
158*47526Spendry 	ifs_fumount,
15944626Smckusick 	efs_lookuppn,
16044626Smckusick 	efs_readdir,
16144626Smckusick 	0, /* ifs_readlink */
16244626Smckusick 	0, /* ifs_mounted */
16344626Smckusick 	0, /* ifs_umounted */
16444626Smckusick 	find_afs_srvr,
16544626Smckusick 	FS_DISCARD
16644626Smckusick };
16744626Smckusick 
16844626Smckusick #endif /* HAS_IFS */
169