2 * Copyright (c) 1997-1999 Erez Zadok
3 * Copyright (c) 1989 Jan-Simon Pendry
4 * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
5 * Copyright (c) 1989 The Regents of the University of California.
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry at Imperial College, London.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgment:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 * $Id: amfs_inherit.c,v 1.2 1999/01/10 21:53:41 ezk Exp $
46 * Inheritance file system.
51 #endif /* HAVE_CONFIG_H */
56 * This implements a filesystem restart.
58 * This is a *gross* hack - it knows far too
59 * much about the way other parts of the
60 * system work. See restart.c too.
63 static char *amfs_inherit_match(am_opts
*fo
);
64 static int amfs_inherit_fmount(mntfs
*mf
);
65 static int amfs_inherit_fumount(mntfs
*mf
);
66 static int amfs_inherit_init(mntfs
*mf
);
67 static int amfs_inherit_mount(am_node
*mp
);
73 am_ops amfs_inherit_ops
=
84 0, /* amfs_inherit_readlink */
85 0, /* amfs_inherit_mounted */
86 0, /* amfs_inherit_umounted */
93 * This should never be called.
96 amfs_inherit_match(am_opts
*fo
)
98 plog(XLOG_FATAL
, "amfs_inherit_match called!");
104 amfs_inherit_init(mntfs
*mf
)
106 mntfs
*mf_link
= (mntfs
*) mf
->mf_private
;
109 plog(XLOG_ERROR
, "Remount collision on %s?", mf
->mf_mount
);
110 plog(XLOG_FATAL
, "Attempting to init not-a-filesystem");
114 if (mf_link
->mf_ops
->fs_init
)
115 return (*mf_link
->mf_ops
->fs_init
) (mf_link
);
121 * Take the linked mount point and
125 amfs_inherit_inherit(mntfs
*mf
)
127 mntfs
*mf_link
= (mntfs
*) mf
->mf_private
;
130 plog(XLOG_FATAL
, "Attempting to inherit not-a-filesystem");
133 mf_link
->mf_fo
= mf
->mf_fo
;
136 * Discard the old map.
137 * Don't call am_unmounted since this
138 * node was never really mounted in the
145 * Free the dangling reference
151 * Get a hold of the other entry
153 mf_link
->mf_flags
&= ~MFF_RESTART
;
155 /* Say what happened */
156 plog(XLOG_INFO
, "restarting %s on %s", mf_link
->mf_info
, mf_link
->mf_mount
);
163 amfs_inherit_mount(am_node
*mp
)
165 mntfs
*newmf
= amfs_inherit_inherit(mp
->am_mnt
);
170 * XXX - must do the am_mounted call here
172 if (newmf
->mf_ops
->fs_flags
& FS_MBACKGROUND
)
183 amfs_inherit_fmount(mntfs
*mf
)
185 am_node
*mp
= find_mf(mf
);
188 return amfs_inherit_mount(mp
);
189 return amfs_inherit_inherit(mf
) ? 0 : EINVAL
;
194 amfs_inherit_fumount(mntfs
*mf
)