ops_TEMPLATE.c revision 82794
1/*
2 * Copyright (c) 1997-2001 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.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry at Imperial College, London.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
26 *
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
37 * SUCH DAMAGE.
38 *
39 *      %W% (Berkeley) %G%
40 *
41 * $Id: ops_TEMPLATE.c,v 1.3.2.2 2001/01/12 23:28:57 ro Exp $
42 *
43 */
44
45/*
46 * An empty template for an amd pseudo filesystem "foofs".
47 */
48
49/*
50 * NOTE: if this is an Amd file system, prepend "amfs_" to all foofs symbols
51 * and renamed the file name to amfs_foofs.c.  If it is a native file system
52 * (such as pcfs, isofs, or ffs), then you can keep the names as is, and
53 * just rename the file to ops_foofs.c.
54 */
55
56#ifdef HAVE_CONFIG_H
57# include <config.h>
58#endif /* HAVE_CONFIG_H */
59#include <am_defs.h>
60#include <amd.h>
61
62/* forward declarations */
63static char *foofs_match(am_opts *fo);
64static int foofs_init(mntfs *mf);
65static int foofs_mount(am_node *mp);
66static int foofs_fmount(mntfs *mf);
67static int foofs_umount(am_node *mp);
68static int foofs_fumount(mntfs *mf);
69static am_node *foofs_lookuppn(am_node *mp, char *fname, int *error_return, int op);
70static int foofs_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, int count);
71static am_node *foofs_readlink(am_node *mp, int *error_return);
72static void foofs_mounted(mntfs *mf);
73static void foofs_umounted(am_node *mp);
74fserver *foofs_ffserver(mntfs *mf);
75
76
77/*
78 * Foofs operations.
79 * Define only those you need, others set to 0 (NULL)
80 */
81am_ops foofs_ops =
82{
83  "foofs",			/* name of file system */
84  foofs_match,			/* match */
85  foofs_init,			/* initialize */
86  foofs_mount,			/* mount vnode */
87  foofs_fmount,			/* mount vfs */
88  foofs_umount,			/* unmount vnode */
89  foofs_fumount,		/* unmount VFS */
90  foofs_lookuppn,		/* lookup path-name */
91  foofs_readdir,		/* read directory */
92  foofs_readlink,		/* read link */
93  foofs_mounted,		/* after-mount extra actions */
94  foofs_umounted,		/* after-umount extra actions */
95  foofs_ffserver,		/* find a file server */
96  FS_MKMNT | FS_BACKGROUND | FS_AMQINFO	/* flags */
97};
98
99
100/*
101 * Check that f/s has all needed fields.
102 * Returns: matched string if found, NULL otherwise.
103 */
104static char *
105foofs_match(am_opts *fo)
106{
107  char *cp = "fill this with a way to find the match";
108
109  plog(XLOG_INFO, "entering foofs_match...");
110
111  if (cp)
112    return cp;			/* OK */
113
114  return NULL;			/* not OK */
115}
116
117
118/*
119 * Initialize.
120 * Returns: 0 if OK, non-zero (errno) if failed.
121 */
122static int
123foofs_init(mntfs *mf)
124{
125  int error = 0;
126
127  plog(XLOG_INFO, "entering foofs_init...");
128
129  error = EPERM;		/* XXX: fixme */
130  return error;
131}
132
133
134/*
135 * Mount vnode.
136 * Returns: 0 if OK, non-zero (errno) if failed.
137 */
138static int
139foofs_mount(am_node *mp)
140{
141  int error = 0;
142
143  plog(XLOG_INFO, "entering foofs_mount...");
144
145  error = EPERM;		/* XXX: fixme */
146  return error;
147}
148
149
150/*
151 * Mount vfs.
152 * Returns: 0 if OK, non-zero (errno) if failed.
153 */
154static int
155foofs_fmount(mntfs *mf)
156{
157  int error = 0;
158
159  plog(XLOG_INFO, "entering foofs_fmount...");
160
161  error = EPERM;		/* XXX: fixme */
162  return error;
163}
164
165
166/*
167 * Unmount vnode.
168 * Returns: 0 if OK, non-zero (errno) if failed.
169 */
170static int
171foofs_umount(am_node *mp)
172{
173  int error = 0;
174
175  plog(XLOG_INFO, "entering foofs_umount...");
176
177  error = EPERM;		/* XXX: fixme */
178  return error;
179}
180
181
182/*
183 * Unmount VFS.
184 * Returns: 0 if OK, non-zero (errno) if failed.
185 */
186static int
187foofs_fumount(mntfs *mf)
188{
189  int error = 0;
190
191  plog(XLOG_INFO, "entering foofs_fumount...");
192
193  error = EPERM;		/* XXX: fixme */
194  return error;
195}
196
197
198/*
199 * Lookup path-name.
200 * Returns: the am_node that was found, or NULL if failed.
201 * If failed, also fills in errno in error_return.
202 */
203static am_node *
204foofs_lookuppn(am_node *mp, char *fname, int *error_return, int op)
205{
206  int error = 0;
207
208  plog(XLOG_INFO, "entering foofs_lookuppn...");
209
210  error = EPERM;			/* XXX: fixme */
211
212  *error_return = error;
213  return NULL;
214}
215
216
217/*
218 * Read directory.
219 * Returns: 0 if OK, non-zero (errno) if failed.
220 * If OK, fills in ep with chain of directory entries.
221 */
222static int
223foofs_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, int count)
224{
225  int error = 0;
226
227  plog(XLOG_INFO, "entering foofs_readdir...");
228
229  error = EPERM;		/* XXX: fixme */
230  return error;
231}
232
233
234/*
235 * Read link.
236 * Returns: am_node found, or NULL if not found.
237 * If failed, fills in errno in error_return.
238 */
239static am_node *
240foofs_readlink(am_node *mp, int *error_return)
241{
242  int error = 0;
243
244  plog(XLOG_INFO, "entering foofs_readlink...");
245
246  error = EPERM;			/* XXX: fixme */
247
248  *error_return = error;
249  return NULL;
250}
251
252
253/*
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
257 * toplvl_mounted().
258 */
259static void
260foofs_mounted(mntfs *mf)
261{
262  plog(XLOG_INFO, "entering foofs_mounted...");
263
264  return;
265}
266
267
268/*
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().
273 */
274static void
275foofs_umounted(am_node *mp)
276{
277  plog(XLOG_INFO, "entering foofs_umounted...");
278
279  return;
280}
281
282
283/*
284 * Find a file server.
285 * Returns: fserver of found server, or NULL if not found.
286 */
287fserver *
288foofs_ffserver(mntfs *mf)
289{
290  plog(XLOG_INFO, "entering foofs_ffserver...");
291
292  return NULL;
293}
294