xref: /original-bsd/usr.sbin/amd/amd/ifs_ops.c (revision 4092c5cc)
1398a5aebSmckusick /*
2398a5aebSmckusick  * Copyright (c) 1989 Jan-Simon Pendry
3398a5aebSmckusick  * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
4*4092c5ccSbostic  * Copyright (c) 1989, 1993
5*4092c5ccSbostic  *	The Regents of the University of California.  All rights reserved.
6398a5aebSmckusick  *
7398a5aebSmckusick  * This code is derived from software contributed to Berkeley by
8398a5aebSmckusick  * Jan-Simon Pendry at Imperial College, London.
9398a5aebSmckusick  *
10398a5aebSmckusick  * %sccs.include.redist.c%
11398a5aebSmckusick  *
12*4092c5ccSbostic  *	@(#)ifs_ops.c	8.1 (Berkeley) 06/06/93
13c626267eSpendry  *
14cc0207dcSpendry  * $Id: ifs_ops.c,v 5.2.2.1 1992/02/09 15:08:26 jsp beta $
15c626267eSpendry  *
16398a5aebSmckusick  */
17398a5aebSmckusick 
18398a5aebSmckusick #include "am.h"
19398a5aebSmckusick 
20398a5aebSmckusick #ifdef HAS_IFS
21398a5aebSmckusick 
22398a5aebSmckusick /*
23398a5aebSmckusick  * Inheritance file system.
24398a5aebSmckusick  * This implements a filesystem restart.
25398a5aebSmckusick  *
26398a5aebSmckusick  * This is a *gross* hack - it knows far too
27398a5aebSmckusick  * much about the way other parts of the
28398a5aebSmckusick  * sytem work.  See restart.c too.
29398a5aebSmckusick  */
30398a5aebSmckusick static char not_a_filesystem[] = "Attempting to inherit not-a-filesystem";
31398a5aebSmckusick /*
32398a5aebSmckusick  * This should never be called.
33398a5aebSmckusick  */
348a89c22cSpendry /*ARGSUSED*/
358a89c22cSpendry static char *ifs_match P((am_opts *fo));
ifs_match(fo)368a89c22cSpendry static char *ifs_match(fo)
378a89c22cSpendry am_opts *fo;
38398a5aebSmckusick {
39398a5aebSmckusick 	plog(XLOG_FATAL, "ifs_match called!");
408a89c22cSpendry 	return 0;
41398a5aebSmckusick }
42398a5aebSmckusick 
438a89c22cSpendry static int ifs_init P((mntfs *mf));
ifs_init(mf)44398a5aebSmckusick static int ifs_init(mf)
45398a5aebSmckusick mntfs *mf;
46398a5aebSmckusick {
47398a5aebSmckusick 	mntfs *mf_link = (mntfs *) mf->mf_private;
48398a5aebSmckusick 	if (mf_link == 0) {
49398a5aebSmckusick 		plog(XLOG_FATAL, not_a_filesystem);
50398a5aebSmckusick 		return EINVAL;
51398a5aebSmckusick 	}
528a89c22cSpendry #ifdef notdef
53398a5aebSmckusick 	/*
54398a5aebSmckusick 	 * Fill in attribute fields
55398a5aebSmckusick 	 */
56398a5aebSmckusick 	mf_link->mf_fattr.type = NFLNK;
57398a5aebSmckusick 	mf_link->mf_fattr.mode = NFSMODE_LNK | 0777;
58398a5aebSmckusick 	mf_link->mf_fattr.nlink = 1;
59398a5aebSmckusick 	mf_link->mf_fattr.size = MAXPATHLEN / 4;
608a89c22cSpendry #endif
61398a5aebSmckusick 	if (mf_link->mf_ops->fs_init)
62398a5aebSmckusick 		return (*mf_link->mf_ops->fs_init)(mf_link);
63398a5aebSmckusick 	return 0;
64398a5aebSmckusick }
65398a5aebSmckusick 
668a89c22cSpendry static mntfs *ifs_inherit P((mntfs *mf));
ifs_inherit(mf)678a89c22cSpendry static mntfs *ifs_inherit(mf)
688a89c22cSpendry mntfs *mf;
69398a5aebSmckusick {
70398a5aebSmckusick 	/*
71398a5aebSmckusick 	 * Take the linked mount point and
72398a5aebSmckusick 	 * propogate.
73398a5aebSmckusick 	 */
74398a5aebSmckusick 	mntfs *mf_link = (mntfs *) mf->mf_private;
75398a5aebSmckusick 	if (mf_link == 0) {
76398a5aebSmckusick 		plog(XLOG_FATAL, not_a_filesystem);
778a89c22cSpendry 		return 0;	/*XXX*/
78398a5aebSmckusick 	}
79398a5aebSmckusick 
80398a5aebSmckusick 	mf_link->mf_fo = mf->mf_fo;
818a89c22cSpendry #ifdef notdef
82398a5aebSmckusick 	mf_link->mf_fattr.fileid = mf->mf_fattr.fileid;
838a89c22cSpendry #endif /* notdef */
84398a5aebSmckusick 
85398a5aebSmckusick 	/*
86398a5aebSmckusick 	 * Discard the old map.
87398a5aebSmckusick 	 * Don't call am_unmounted since this
88398a5aebSmckusick 	 * node was never really mounted in the
89398a5aebSmckusick 	 * first place.
90398a5aebSmckusick 	 */
91398a5aebSmckusick 	mf->mf_private = 0;
92398a5aebSmckusick 	free_mntfs(mf);
93398a5aebSmckusick 	/*
94398a5aebSmckusick 	 * Free the dangling reference
95398a5aebSmckusick 	 * to the mount link.
96398a5aebSmckusick 	 */
97398a5aebSmckusick 	free_mntfs(mf_link);
98398a5aebSmckusick 	/*
99398a5aebSmckusick 	 * Get a hold of the other entry
100398a5aebSmckusick 	 */
1018a89c22cSpendry 	mf_link->mf_flags &= ~MFF_RESTART;
102398a5aebSmckusick 
103398a5aebSmckusick 	/* Say what happened */
1048a89c22cSpendry 	plog(XLOG_INFO, "restarting %s on %s", mf_link->mf_info, mf_link->mf_mount);
105398a5aebSmckusick 
1068a89c22cSpendry 	return mf_link;
1078a89c22cSpendry }
1088a89c22cSpendry 
1098a89c22cSpendry static int ifs_mount P((am_node *mp));
ifs_mount(mp)1108a89c22cSpendry static int ifs_mount(mp)
1118a89c22cSpendry am_node *mp;
1128a89c22cSpendry {
1138a89c22cSpendry 	mntfs *newmf = ifs_inherit(mp->am_mnt);
1148a89c22cSpendry 	if (newmf) {
1158a89c22cSpendry 		mp->am_mnt = newmf;
116398a5aebSmckusick 		/*
117398a5aebSmckusick 		 * XXX - must do the am_mounted call here
118398a5aebSmckusick 		 */
1198a89c22cSpendry 		if (newmf->mf_ops->fs_flags & FS_MBACKGROUND)
120398a5aebSmckusick 			am_mounted(mp);
121398a5aebSmckusick 
122398a5aebSmckusick 		new_ttl(mp);
123398a5aebSmckusick 		return 0;
124398a5aebSmckusick 	}
1258a89c22cSpendry 	return EINVAL;
1268a89c22cSpendry }
1278a89c22cSpendry 
1288a89c22cSpendry static int ifs_fmount P((mntfs *mf));
ifs_fmount(mf)1298a89c22cSpendry static int ifs_fmount(mf)
1308a89c22cSpendry mntfs *mf;
1318a89c22cSpendry {
1328a89c22cSpendry 	am_node *mp = find_mf(mf);
1338a89c22cSpendry 	if (mp)
1348a89c22cSpendry 		return ifs_mount(mp);
1358a89c22cSpendry 	return ifs_inherit(mf) ? 0 : EINVAL;
1368a89c22cSpendry }
137398a5aebSmckusick 
138398a5aebSmckusick /*ARGSUSED*/
1398a89c22cSpendry static int ifs_fumount P((mntfs *mf));
ifs_fumount(mf)1408a89c22cSpendry static int ifs_fumount(mf)
1418a89c22cSpendry mntfs *mf;
142398a5aebSmckusick {
143398a5aebSmckusick 	/*
144398a5aebSmckusick 	 * Always succeed
145398a5aebSmckusick 	 */
146398a5aebSmckusick 	return 0;
147398a5aebSmckusick }
148398a5aebSmckusick 
149398a5aebSmckusick /*
150398a5aebSmckusick  * Ops structure
151398a5aebSmckusick  */
152398a5aebSmckusick am_ops ifs_ops = {
153398a5aebSmckusick 	"inherit",
154398a5aebSmckusick 	ifs_match,
155398a5aebSmckusick 	ifs_init,
156398a5aebSmckusick 	ifs_mount,
1578a89c22cSpendry 	ifs_fmount,
1588a89c22cSpendry 	auto_fumount,
1598a89c22cSpendry 	ifs_fumount,
160398a5aebSmckusick 	efs_lookuppn,
161398a5aebSmckusick 	efs_readdir,
162398a5aebSmckusick 	0, /* ifs_readlink */
163398a5aebSmckusick 	0, /* ifs_mounted */
164398a5aebSmckusick 	0, /* ifs_umounted */
165398a5aebSmckusick 	find_afs_srvr,
166398a5aebSmckusick 	FS_DISCARD
167398a5aebSmckusick };
168398a5aebSmckusick 
169398a5aebSmckusick #endif /* HAS_IFS */
170