1 /* 2 * $Id: ifs_ops.c,v 5.2 90/06/23 22:19:28 jsp Rel $ 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.1 (Berkeley) 06/29/90 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 static int ifs_match() 34 { 35 plog(XLOG_FATAL, "ifs_match called!"); 36 return FALSE; 37 } 38 39 static int ifs_init(mf) 40 mntfs *mf; 41 { 42 mntfs *mf_link = (mntfs *) mf->mf_private; 43 if (mf_link == 0) { 44 plog(XLOG_FATAL, not_a_filesystem); 45 return EINVAL; 46 } 47 /* 48 * Fill in attribute fields 49 */ 50 mf_link->mf_fattr.type = NFLNK; 51 mf_link->mf_fattr.mode = NFSMODE_LNK | 0777; 52 mf_link->mf_fattr.nlink = 1; 53 mf_link->mf_fattr.size = MAXPATHLEN / 4; 54 if (mf_link->mf_ops->fs_init) 55 return (*mf_link->mf_ops->fs_init)(mf_link); 56 return 0; 57 } 58 59 /*ARGSUSED*/ 60 static int ifs_mount(mp) 61 am_node *mp; 62 { 63 mntfs *mf = mp->am_mnt; 64 65 /* 66 * Take the linked mount point and 67 * propogate. 68 */ 69 mntfs *mf_link = (mntfs *) mf->mf_private; 70 if (mf_link == 0) { 71 plog(XLOG_FATAL, not_a_filesystem); 72 return EINVAL; /*XXX*/ 73 } 74 75 mf_link->mf_fo = mf->mf_fo; 76 mf_link->mf_fattr.fileid = mf->mf_fattr.fileid; 77 78 /* 79 * Discard the old map. 80 * Don't call am_unmounted since this 81 * node was never really mounted in the 82 * first place. 83 */ 84 mf->mf_private = 0; 85 free_mntfs(mf); 86 /* 87 * Free the dangling reference 88 * to the mount link. 89 */ 90 free_mntfs(mf_link); 91 /* 92 * Get a hold of the other entry 93 */ 94 mp->am_mnt = mf = mf_link; 95 mf->mf_flags &= ~MFF_RESTART; 96 97 /* Say what happened */ 98 plog(XLOG_INFO, "restarting %s on %s", mf->mf_info, mf->mf_mount); 99 100 /* 101 * XXX - must do the am_mounted call here 102 */ 103 if (mf->mf_ops->fs_flags & FS_MBACKGROUND) 104 am_mounted(mp); 105 106 new_ttl(mp); 107 108 return 0; 109 } 110 111 /*ARGSUSED*/ 112 static int ifs_umount(mp) 113 am_node *mp; 114 { 115 /* 116 * Always succeed 117 */ 118 return 0; 119 } 120 121 /* 122 * Ops structure 123 */ 124 am_ops ifs_ops = { 125 "inherit", 126 ifs_match, 127 ifs_init, 128 ifs_mount, 129 ifs_umount, 130 efs_lookuppn, 131 efs_readdir, 132 0, /* ifs_readlink */ 133 0, /* ifs_mounted */ 134 0, /* ifs_umounted */ 135 find_afs_srvr, 136 FS_DISCARD 137 }; 138 139 #endif /* HAS_IFS */ 140