xref: /original-bsd/usr.sbin/amd/amd/sfs_ops.c (revision 92ab646d)
1 /*
2  * $Id: sfs_ops.c,v 5.2 90/06/23 22:19:59 jsp Rel $
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.1 (Berkeley) 06/29/90
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 int 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 		free(fo->opt_fs);
67 		fo->opt_fs = strdup(".");
68 	}
69 
70 	fo->fs_mtab = strealloc(fo->fs_mtab, fo->opt_fs);
71 
72 	return 1;
73 }
74 
75 /*ARGUSED*/
76 static int sfs_mount(mp)
77 am_node *mp;
78 {
79 	/*
80 	 * Wow - this is hard to implement!
81 	 */
82 
83 	return 0;
84 }
85 
86 /*ARGUSED*/
87 static int sfs_umount(mp)
88 am_node *mp;
89 {
90 	return 0;
91 }
92 
93 /*
94  * Ops structure
95  */
96 am_ops sfs_ops = {
97 	"link",
98 	sfs_match,
99 	0, /* sfs_init */
100 	sfs_mount,
101 	sfs_umount,
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