xref: /original-bsd/usr.sbin/amd/amd/ifs_ops.c (revision a94793f7)
1 /*
2  * $Id: ifs_ops.c,v 5.2.1.3 91/03/17 17:47:48 jsp Alpha $
3  *
4  * Copyright (c) 1989 Jan-Simon Pendry
5  * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
6  * Copyright (c) 1989 The Regents of the University of California.
7  * All rights reserved.
8  *
9  * This code is derived from software contributed to Berkeley by
10  * Jan-Simon Pendry at Imperial College, London.
11  *
12  * %sccs.include.redist.c%
13  *
14  *	@(#)ifs_ops.c	5.2 (Berkeley) 03/17/91
15  */
16 
17 #include "am.h"
18 
19 #ifdef HAS_IFS
20 
21 /*
22  * Inheritance file system.
23  * This implements a filesystem restart.
24  *
25  * This is a *gross* hack - it knows far too
26  * much about the way other parts of the
27  * sytem work.  See restart.c too.
28  */
29 static char not_a_filesystem[] = "Attempting to inherit not-a-filesystem";
30 /*
31  * This should never be called.
32  */
33 /*ARGSUSED*/
34 static char *ifs_match P((am_opts *fo));
35 static char *ifs_match(fo)
36 am_opts *fo;
37 {
38 	plog(XLOG_FATAL, "ifs_match called!");
39 	return 0;
40 }
41 
42 static int ifs_init P((mntfs *mf));
43 static int ifs_init(mf)
44 mntfs *mf;
45 {
46 	mntfs *mf_link = (mntfs *) mf->mf_private;
47 	if (mf_link == 0) {
48 		plog(XLOG_FATAL, not_a_filesystem);
49 		return EINVAL;
50 	}
51 #ifdef notdef
52 	/*
53 	 * Fill in attribute fields
54 	 */
55 	mf_link->mf_fattr.type = NFLNK;
56 	mf_link->mf_fattr.mode = NFSMODE_LNK | 0777;
57 	mf_link->mf_fattr.nlink = 1;
58 	mf_link->mf_fattr.size = MAXPATHLEN / 4;
59 #endif
60 	if (mf_link->mf_ops->fs_init)
61 		return (*mf_link->mf_ops->fs_init)(mf_link);
62 	return 0;
63 }
64 
65 static mntfs *ifs_inherit P((mntfs *mf));
66 static mntfs *ifs_inherit(mf)
67 mntfs *mf;
68 {
69 	/*
70 	 * Take the linked mount point and
71 	 * propogate.
72 	 */
73 	mntfs *mf_link = (mntfs *) mf->mf_private;
74 	if (mf_link == 0) {
75 		plog(XLOG_FATAL, not_a_filesystem);
76 		return 0;	/*XXX*/
77 	}
78 
79 	mf_link->mf_fo = mf->mf_fo;
80 #ifdef notdef
81 	mf_link->mf_fattr.fileid = mf->mf_fattr.fileid;
82 #endif /* notdef */
83 
84 	/*
85 	 * Discard the old map.
86 	 * Don't call am_unmounted since this
87 	 * node was never really mounted in the
88 	 * first place.
89 	 */
90 	mf->mf_private = 0;
91 	free_mntfs(mf);
92 	/*
93 	 * Free the dangling reference
94 	 * to the mount link.
95 	 */
96 	free_mntfs(mf_link);
97 	/*
98 	 * Get a hold of the other entry
99 	 */
100 	mf_link->mf_flags &= ~MFF_RESTART;
101 
102 	/* Say what happened */
103 	plog(XLOG_INFO, "restarting %s on %s", mf_link->mf_info, mf_link->mf_mount);
104 
105 	return mf_link;
106 }
107 
108 static int ifs_mount P((am_node *mp));
109 static int ifs_mount(mp)
110 am_node *mp;
111 {
112 	mntfs *newmf = ifs_inherit(mp->am_mnt);
113 	if (newmf) {
114 		mp->am_mnt = newmf;
115 		/*
116 		 * XXX - must do the am_mounted call here
117 		 */
118 		if (newmf->mf_ops->fs_flags & FS_MBACKGROUND)
119 			am_mounted(mp);
120 
121 		new_ttl(mp);
122 		return 0;
123 	}
124 	return EINVAL;
125 }
126 
127 static int ifs_fmount P((mntfs *mf));
128 static int ifs_fmount(mf)
129 mntfs *mf;
130 {
131 	am_node *mp = find_mf(mf);
132 	if (mp)
133 		return ifs_mount(mp);
134 	return ifs_inherit(mf) ? 0 : EINVAL;
135 }
136 
137 /*ARGSUSED*/
138 static int ifs_fumount P((mntfs *mf));
139 static int ifs_fumount(mf)
140 mntfs *mf;
141 {
142 	/*
143 	 * Always succeed
144 	 */
145 	return 0;
146 }
147 
148 /*
149  * Ops structure
150  */
151 am_ops ifs_ops = {
152 	"inherit",
153 	ifs_match,
154 	ifs_init,
155 	ifs_mount,
156 	ifs_fmount,
157 	auto_fumount,
158 	ifs_fumount,
159 	efs_lookuppn,
160 	efs_readdir,
161 	0, /* ifs_readlink */
162 	0, /* ifs_mounted */
163 	0, /* ifs_umounted */
164 	find_afs_srvr,
165 	FS_DISCARD
166 };
167 
168 #endif /* HAS_IFS */
169