1 /* 2 * Copyright (c) 1990 Jan-Simon Pendry 3 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 4 * Copyright (c) 1990 The Regents of the University of California. 5 * 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 * @(#)sfs_ops.c 5.3 (Berkeley) 05/12/91 13 * 14 * $Id: sfs_ops.c,v 5.2.1.3 91/05/07 22:18:33 jsp Alpha $ 15 * 16 */ 17 18 #include "am.h" 19 20 #ifdef HAS_SFS 21 22 /* 23 * Symbol-link file system 24 */ 25 26 /* 27 * SFS needs a link. 28 */ 29 static char *sfs_match(fo) 30 am_opts *fo; 31 { 32 if (!fo->opt_fs) { 33 plog(XLOG_USER, "link: no fs specified"); 34 return 0; 35 } 36 37 /* 38 * Bug report (14/12/89) from Jay Plett <jay@princeton.edu> 39 * If an automount point has the same name as an existing 40 * link type mount Amd hits a race condition and either hangs 41 * or causes a symlink loop. 42 * 43 * If fs begins with a '/' change the opt_fs & opt_sublink 44 * fields so that the fs option doesn't end up pointing at 45 * an existing symlink. 46 * 47 * If sublink is nil then set sublink to fs 48 * else set sublink to fs / sublink 49 * 50 * Finally set fs to ".". 51 */ 52 if (*fo->opt_fs == '/') { 53 char *fullpath; 54 char *link = fo->opt_sublink; 55 if (link) { 56 if (*link == '/') 57 fullpath = strdup(link); 58 else 59 fullpath = str3cat((char *)0, fo->opt_fs, "/", link); 60 } else { 61 fullpath = strdup(fo->opt_fs); 62 } 63 64 if (fo->opt_sublink) 65 free(fo->opt_sublink); 66 fo->opt_sublink = fullpath; 67 fo->opt_fs = str3cat(fo->opt_fs, ".", fullpath, ""); 68 } 69 70 return strdup(fo->opt_fs); 71 } 72 73 /*ARGUSED*/ 74 static int sfs_fmount(mf) 75 mntfs *mf; 76 { 77 /* 78 * Wow - this is hard to implement! 79 */ 80 81 return 0; 82 } 83 84 /*ARGUSED*/ 85 static int sfs_fumount(mf) 86 mntfs *mf; 87 { 88 return 0; 89 } 90 91 /* 92 * Ops structure 93 */ 94 am_ops sfs_ops = { 95 "link", 96 sfs_match, 97 0, /* sfs_init */ 98 auto_fmount, 99 sfs_fmount, 100 auto_fumount, 101 sfs_fumount, 102 efs_lookuppn, 103 efs_readdir, 104 0, /* sfs_readlink */ 105 0, /* sfs_mounted */ 106 0, /* sfs_umounted */ 107 find_afs_srvr, 108 #ifdef FLUSH_KERNEL_NAME_CACHE 109 FS_UBACKGROUND 110 #else /* FLUSH_KERNEL_NAME_CACHE */ 111 0 112 #endif /* FLUSH_KERNEL_NAME_CACHE */ 113 }; 114 115 #endif /* HAS_SFS */ 116