144626Smckusick /*
244626Smckusick * Copyright (c) 1989 Jan-Simon Pendry
344626Smckusick * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
4*61776Sbostic * Copyright (c) 1989, 1993
5*61776Sbostic * The Regents of the University of California. All rights reserved.
644626Smckusick *
744626Smckusick * This code is derived from software contributed to Berkeley by
844626Smckusick * Jan-Simon Pendry at Imperial College, London.
944626Smckusick *
1044626Smckusick * %sccs.include.redist.c%
1144626Smckusick *
12*61776Sbostic * @(#)ifs_ops.c 8.1 (Berkeley) 06/06/93
1349683Spendry *
1452460Spendry * $Id: ifs_ops.c,v 5.2.2.1 1992/02/09 15:08:26 jsp beta $
1549683Spendry *
1644626Smckusick */
1744626Smckusick
1844626Smckusick #include "am.h"
1944626Smckusick
2044626Smckusick #ifdef HAS_IFS
2144626Smckusick
2244626Smckusick /*
2344626Smckusick * Inheritance file system.
2444626Smckusick * This implements a filesystem restart.
2544626Smckusick *
2644626Smckusick * This is a *gross* hack - it knows far too
2744626Smckusick * much about the way other parts of the
2844626Smckusick * sytem work. See restart.c too.
2944626Smckusick */
3044626Smckusick static char not_a_filesystem[] = "Attempting to inherit not-a-filesystem";
3144626Smckusick /*
3244626Smckusick * This should never be called.
3344626Smckusick */
3447526Spendry /*ARGSUSED*/
3547526Spendry static char *ifs_match P((am_opts *fo));
ifs_match(fo)3647526Spendry static char *ifs_match(fo)
3747526Spendry am_opts *fo;
3844626Smckusick {
3944626Smckusick plog(XLOG_FATAL, "ifs_match called!");
4047526Spendry return 0;
4144626Smckusick }
4244626Smckusick
4347526Spendry static int ifs_init P((mntfs *mf));
ifs_init(mf)4444626Smckusick static int ifs_init(mf)
4544626Smckusick mntfs *mf;
4644626Smckusick {
4744626Smckusick mntfs *mf_link = (mntfs *) mf->mf_private;
4844626Smckusick if (mf_link == 0) {
4944626Smckusick plog(XLOG_FATAL, not_a_filesystem);
5044626Smckusick return EINVAL;
5144626Smckusick }
5247526Spendry #ifdef notdef
5344626Smckusick /*
5444626Smckusick * Fill in attribute fields
5544626Smckusick */
5644626Smckusick mf_link->mf_fattr.type = NFLNK;
5744626Smckusick mf_link->mf_fattr.mode = NFSMODE_LNK | 0777;
5844626Smckusick mf_link->mf_fattr.nlink = 1;
5944626Smckusick mf_link->mf_fattr.size = MAXPATHLEN / 4;
6047526Spendry #endif
6144626Smckusick if (mf_link->mf_ops->fs_init)
6244626Smckusick return (*mf_link->mf_ops->fs_init)(mf_link);
6344626Smckusick return 0;
6444626Smckusick }
6544626Smckusick
6647526Spendry static mntfs *ifs_inherit P((mntfs *mf));
ifs_inherit(mf)6747526Spendry static mntfs *ifs_inherit(mf)
6847526Spendry mntfs *mf;
6944626Smckusick {
7044626Smckusick /*
7144626Smckusick * Take the linked mount point and
7244626Smckusick * propogate.
7344626Smckusick */
7444626Smckusick mntfs *mf_link = (mntfs *) mf->mf_private;
7544626Smckusick if (mf_link == 0) {
7644626Smckusick plog(XLOG_FATAL, not_a_filesystem);
7747526Spendry return 0; /*XXX*/
7844626Smckusick }
7944626Smckusick
8044626Smckusick mf_link->mf_fo = mf->mf_fo;
8147526Spendry #ifdef notdef
8244626Smckusick mf_link->mf_fattr.fileid = mf->mf_fattr.fileid;
8347526Spendry #endif /* notdef */
8444626Smckusick
8544626Smckusick /*
8644626Smckusick * Discard the old map.
8744626Smckusick * Don't call am_unmounted since this
8844626Smckusick * node was never really mounted in the
8944626Smckusick * first place.
9044626Smckusick */
9144626Smckusick mf->mf_private = 0;
9244626Smckusick free_mntfs(mf);
9344626Smckusick /*
9444626Smckusick * Free the dangling reference
9544626Smckusick * to the mount link.
9644626Smckusick */
9744626Smckusick free_mntfs(mf_link);
9844626Smckusick /*
9944626Smckusick * Get a hold of the other entry
10044626Smckusick */
10147526Spendry mf_link->mf_flags &= ~MFF_RESTART;
10244626Smckusick
10344626Smckusick /* Say what happened */
10447526Spendry plog(XLOG_INFO, "restarting %s on %s", mf_link->mf_info, mf_link->mf_mount);
10544626Smckusick
10647526Spendry return mf_link;
10747526Spendry }
10844626Smckusick
10947526Spendry static int ifs_mount P((am_node *mp));
ifs_mount(mp)11047526Spendry static int ifs_mount(mp)
11147526Spendry am_node *mp;
11247526Spendry {
11347526Spendry mntfs *newmf = ifs_inherit(mp->am_mnt);
11447526Spendry if (newmf) {
11547526Spendry mp->am_mnt = newmf;
11647526Spendry /*
11747526Spendry * XXX - must do the am_mounted call here
11847526Spendry */
11947526Spendry if (newmf->mf_ops->fs_flags & FS_MBACKGROUND)
12047526Spendry am_mounted(mp);
12144626Smckusick
12247526Spendry new_ttl(mp);
12347526Spendry return 0;
12447526Spendry }
12547526Spendry return EINVAL;
12644626Smckusick }
12744626Smckusick
12847526Spendry static int ifs_fmount P((mntfs *mf));
ifs_fmount(mf)12947526Spendry static int ifs_fmount(mf)
13047526Spendry mntfs *mf;
13147526Spendry {
13247526Spendry am_node *mp = find_mf(mf);
13347526Spendry if (mp)
13447526Spendry return ifs_mount(mp);
13547526Spendry return ifs_inherit(mf) ? 0 : EINVAL;
13647526Spendry }
13747526Spendry
13844626Smckusick /*ARGSUSED*/
13947526Spendry static int ifs_fumount P((mntfs *mf));
ifs_fumount(mf)14047526Spendry static int ifs_fumount(mf)
14147526Spendry mntfs *mf;
14244626Smckusick {
14344626Smckusick /*
14444626Smckusick * Always succeed
14544626Smckusick */
14644626Smckusick return 0;
14744626Smckusick }
14844626Smckusick
14944626Smckusick /*
15044626Smckusick * Ops structure
15144626Smckusick */
15244626Smckusick am_ops ifs_ops = {
15344626Smckusick "inherit",
15444626Smckusick ifs_match,
15544626Smckusick ifs_init,
15644626Smckusick ifs_mount,
15747526Spendry ifs_fmount,
15847526Spendry auto_fumount,
15947526Spendry ifs_fumount,
16044626Smckusick efs_lookuppn,
16144626Smckusick efs_readdir,
16244626Smckusick 0, /* ifs_readlink */
16344626Smckusick 0, /* ifs_mounted */
16444626Smckusick 0, /* ifs_umounted */
16544626Smckusick find_afs_srvr,
16644626Smckusick FS_DISCARD
16744626Smckusick };
16844626Smckusick
16944626Smckusick #endif /* HAS_IFS */
170