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