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