2 * Copyright (c) 1997-2006 Erez Zadok
3 * Copyright (c) 1990 Jan-Simon Pendry
4 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
5 * Copyright (c) 1990 The Regents of the University of California.
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry at Imperial College, London.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgment:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * File: am-utils/amd/ops_TEMPLATE.c
45 * An empty template for an amd pseudo filesystem "foofs".
49 * NOTE: if this is an Amd file system, prepend "amfs_" to all foofs symbols
50 * and renamed the file name to amfs_foofs.c. If it is a native file system
51 * (such as pcfs, isofs, or ffs), then you can keep the names as is, and
52 * just rename the file to ops_foofs.c.
57 #endif /* HAVE_CONFIG_H */
61 /* forward declarations */
62 static char *foofs_match(am_opts *fo);
63 static int foofs_init(mntfs *mf);
64 static int foofs_mount(am_node *mp, mntfs *mf);
65 static int foofs_umount(am_node *mp, mntfs *mf);
66 static am_node *foofs_lookuppn(am_node *mp, char *fname, int *error_return, int op);
67 static int foofs_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int count);
68 static am_node *foofs_readlink(am_node *mp, int *error_return);
69 static void foofs_mounted(am_node *am, mntfs *mf);
70 static void foofs_umounted(am_node *mp, mntfs *mf);
71 static fserver *foofs_ffserver(mntfs *mf);
76 * Define only those you need, others set to 0 (NULL)
80 "foofs", /* name of file system */
81 foofs_match, /* match */
82 foofs_init, /* initialize */
83 foofs_mount, /* mount vnode */
84 foofs_umount, /* unmount vnode */
85 foofs_lookup_child, /* lookup path-name */
86 foofs_mount_child, /* mount path-name */
87 foofs_readdir, /* read directory */
88 foofs_readlink, /* read link */
89 foofs_mounted, /* after-mount extra actions */
90 foofs_umounted, /* after-umount extra actions */
91 foofs_ffserver, /* find a file server */
92 foofs_get_wchan, /* return the waiting channel */
93 FS_MKMNT | FS_BACKGROUND | FS_AMQINFO, /* nfs_fs_flags */
95 AUTOFS_TEMPLATE_FS_FLAGS,
96 #endif /* HAVE_FS_AUTOFS */
101 * Check that f/s has all needed fields.
102 * Returns: matched string if found, NULL otherwise.
105 foofs_match(am_opts *fo)
107 char *cp = "fill this with a way to find the match";
109 plog(XLOG_INFO, "entering foofs_match...");
114 return NULL; /* not OK */
120 * Returns: 0 if OK, non-zero (errno) if failed.
123 foofs_init(mntfs *mf)
127 plog(XLOG_INFO, "entering foofs_init...");
129 error = EPERM; /* XXX: fixme */
136 * Returns: 0 if OK, non-zero (errno) if failed.
139 foofs_mount(am_node *mp)
143 plog(XLOG_INFO, "entering foofs_mount...");
145 error = EPERM; /* XXX: fixme */
152 * Returns: 0 if OK, non-zero (errno) if failed.
155 foofs_fmount(mntfs *mf)
159 plog(XLOG_INFO, "entering foofs_fmount...");
161 error = EPERM; /* XXX: fixme */
168 * Returns: 0 if OK, non-zero (errno) if failed.
171 foofs_umount(am_node *mp)
175 plog(XLOG_INFO, "entering foofs_umount...");
177 error = EPERM; /* XXX: fixme */
184 * Returns: 0 if OK, non-zero (errno) if failed.
187 foofs_fumount(mntfs *mf)
191 plog(XLOG_INFO, "entering foofs_fumount...");
193 error = EPERM; /* XXX: fixme */
200 * Returns: the am_node that was found, or NULL if failed.
201 * If failed, also fills in errno in error_return.
204 foofs_lookuppn(am_node *mp, char *fname, int *error_return, int op)
208 plog(XLOG_INFO, "entering foofs_lookuppn...");
210 error = EPERM; /* XXX: fixme */
212 *error_return = error;
219 * Returns: 0 if OK, non-zero (errno) if failed.
220 * If OK, fills in ep with chain of directory entries.
223 foofs_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int count)
227 plog(XLOG_INFO, "entering foofs_readdir...");
229 error = EPERM; /* XXX: fixme */
236 * Returns: am_node found, or NULL if not found.
237 * If failed, fills in errno in error_return.
240 foofs_readlink(am_node *mp, int *error_return)
244 plog(XLOG_INFO, "entering foofs_readlink...");
246 error = EPERM; /* XXX: fixme */
248 *error_return = error;
254 * Async mount callback function.
255 * After the base mount went OK, sometimes
256 * there are additional actions that are needed. See union_mounted() and
260 foofs_mounted(mntfs *mf)
262 plog(XLOG_INFO, "entering foofs_mounted...");
269 * Async unmount callback function.
270 * After the base umount() succeeds, we may want to take extra actions,
271 * such as informing remote mount daemons that we've unmounted them.
272 * See amfs_auto_umounted(), host_umounted(), nfs_umounted().
275 foofs_umounted(am_node *mp)
277 plog(XLOG_INFO, "entering foofs_umounted...");
284 * Find a file server.
285 * Returns: fserver of found server, or NULL if not found.
288 foofs_ffserver(mntfs *mf)
290 plog(XLOG_INFO, "entering foofs_ffserver...");
297 * Normally just return mf. Only inherit needs to do special tricks.
300 foofs_get_wchan(mntfs *mf)
302 plog(XLOG_INFO, "entering foofs_get_wchan...");