138494Sobrien/* 2174294Sobrien * Copyright (c) 1997-2006 Erez Zadok 338494Sobrien * Copyright (c) 1990 Jan-Simon Pendry 438494Sobrien * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 538494Sobrien * Copyright (c) 1990 The Regents of the University of California. 638494Sobrien * All rights reserved. 738494Sobrien * 838494Sobrien * This code is derived from software contributed to Berkeley by 938494Sobrien * Jan-Simon Pendry at Imperial College, London. 1038494Sobrien * 1138494Sobrien * Redistribution and use in source and binary forms, with or without 1238494Sobrien * modification, are permitted provided that the following conditions 1338494Sobrien * are met: 1438494Sobrien * 1. Redistributions of source code must retain the above copyright 1538494Sobrien * notice, this list of conditions and the following disclaimer. 1638494Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1738494Sobrien * notice, this list of conditions and the following disclaimer in the 1838494Sobrien * documentation and/or other materials provided with the distribution. 1938494Sobrien * 3. All advertising materials mentioning features or use of this software 2042629Sobrien * must display the following acknowledgment: 2138494Sobrien * This product includes software developed by the University of 2238494Sobrien * California, Berkeley and its contributors. 2338494Sobrien * 4. Neither the name of the University nor the names of its contributors 2438494Sobrien * may be used to endorse or promote products derived from this software 2538494Sobrien * without specific prior written permission. 2638494Sobrien * 2738494Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2838494Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2938494Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 3038494Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3138494Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3238494Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3338494Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3438494Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3538494Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3638494Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3738494Sobrien * SUCH DAMAGE. 3838494Sobrien * 3938494Sobrien * 40174294Sobrien * File: am-utils/amd/ops_TEMPLATE.c 4138494Sobrien * 4238494Sobrien */ 4338494Sobrien 4438494Sobrien/* 4538494Sobrien * An empty template for an amd pseudo filesystem "foofs". 4638494Sobrien */ 4738494Sobrien 4838494Sobrien/* 4938494Sobrien * NOTE: if this is an Amd file system, prepend "amfs_" to all foofs symbols 5038494Sobrien * and renamed the file name to amfs_foofs.c. If it is a native file system 5138494Sobrien * (such as pcfs, isofs, or ffs), then you can keep the names as is, and 5238494Sobrien * just rename the file to ops_foofs.c. 5338494Sobrien */ 5438494Sobrien 5538494Sobrien#ifdef HAVE_CONFIG_H 5638494Sobrien# include <config.h> 5738494Sobrien#endif /* HAVE_CONFIG_H */ 5838494Sobrien#include <am_defs.h> 5938494Sobrien#include <amd.h> 6038494Sobrien 6138494Sobrien/* forward declarations */ 6282794Sobrienstatic char *foofs_match(am_opts *fo); 6338494Sobrienstatic int foofs_init(mntfs *mf); 64174294Sobrienstatic int foofs_mount(am_node *mp, mntfs *mf); 65174294Sobrienstatic int foofs_umount(am_node *mp, mntfs *mf); 6682794Sobrienstatic am_node *foofs_lookuppn(am_node *mp, char *fname, int *error_return, int op); 67174294Sobrienstatic int foofs_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int count); 6882794Sobrienstatic am_node *foofs_readlink(am_node *mp, int *error_return); 69174294Sobrienstatic void foofs_mounted(am_node *am, mntfs *mf); 70174294Sobrienstatic void foofs_umounted(am_node *mp, mntfs *mf); 71174294Sobrienstatic fserver *foofs_ffserver(mntfs *mf); 7238494Sobrien 7338494Sobrien 7438494Sobrien/* 7538494Sobrien * Foofs operations. 7638494Sobrien * Define only those you need, others set to 0 (NULL) 7738494Sobrien */ 7838494Sobrienam_ops foofs_ops = 7938494Sobrien{ 8038494Sobrien "foofs", /* name of file system */ 8138494Sobrien foofs_match, /* match */ 8238494Sobrien foofs_init, /* initialize */ 8338494Sobrien foofs_mount, /* mount vnode */ 8438494Sobrien foofs_umount, /* unmount vnode */ 85174294Sobrien foofs_lookup_child, /* lookup path-name */ 86174294Sobrien foofs_mount_child, /* mount path-name */ 8738494Sobrien foofs_readdir, /* read directory */ 8838494Sobrien foofs_readlink, /* read link */ 8938494Sobrien foofs_mounted, /* after-mount extra actions */ 9038494Sobrien foofs_umounted, /* after-umount extra actions */ 9138494Sobrien foofs_ffserver, /* find a file server */ 92174294Sobrien foofs_get_wchan, /* return the waiting channel */ 93174294Sobrien FS_MKMNT | FS_BACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ 94174294Sobrien#ifdef HAVE_FS_AUTOFS 95174294Sobrien AUTOFS_TEMPLATE_FS_FLAGS, 96174294Sobrien#endif /* HAVE_FS_AUTOFS */ 9738494Sobrien}; 9838494Sobrien 9938494Sobrien 10038494Sobrien/* 10138494Sobrien * Check that f/s has all needed fields. 10238494Sobrien * Returns: matched string if found, NULL otherwise. 10338494Sobrien */ 10438494Sobrienstatic char * 10538494Sobrienfoofs_match(am_opts *fo) 10638494Sobrien{ 10738494Sobrien char *cp = "fill this with a way to find the match"; 10838494Sobrien 10938494Sobrien plog(XLOG_INFO, "entering foofs_match..."); 11038494Sobrien 11138494Sobrien if (cp) 11238494Sobrien return cp; /* OK */ 11338494Sobrien 11438494Sobrien return NULL; /* not OK */ 11538494Sobrien} 11638494Sobrien 11738494Sobrien 11838494Sobrien/* 11938494Sobrien * Initialize. 12038494Sobrien * Returns: 0 if OK, non-zero (errno) if failed. 12138494Sobrien */ 12238494Sobrienstatic int 12338494Sobrienfoofs_init(mntfs *mf) 12438494Sobrien{ 12538494Sobrien int error = 0; 12638494Sobrien 12738494Sobrien plog(XLOG_INFO, "entering foofs_init..."); 12838494Sobrien 12938494Sobrien error = EPERM; /* XXX: fixme */ 13038494Sobrien return error; 13138494Sobrien} 13238494Sobrien 13338494Sobrien 13438494Sobrien/* 13538494Sobrien * Mount vnode. 13638494Sobrien * Returns: 0 if OK, non-zero (errno) if failed. 13738494Sobrien */ 13838494Sobrienstatic int 13938494Sobrienfoofs_mount(am_node *mp) 14038494Sobrien{ 14138494Sobrien int error = 0; 14238494Sobrien 14338494Sobrien plog(XLOG_INFO, "entering foofs_mount..."); 14438494Sobrien 14538494Sobrien error = EPERM; /* XXX: fixme */ 14638494Sobrien return error; 14738494Sobrien} 14838494Sobrien 14938494Sobrien 15038494Sobrien/* 15138494Sobrien * Mount vfs. 15238494Sobrien * Returns: 0 if OK, non-zero (errno) if failed. 15338494Sobrien */ 15438494Sobrienstatic int 15538494Sobrienfoofs_fmount(mntfs *mf) 15638494Sobrien{ 15738494Sobrien int error = 0; 15838494Sobrien 15938494Sobrien plog(XLOG_INFO, "entering foofs_fmount..."); 16038494Sobrien 16138494Sobrien error = EPERM; /* XXX: fixme */ 16238494Sobrien return error; 16338494Sobrien} 16438494Sobrien 16538494Sobrien 16638494Sobrien/* 16738494Sobrien * Unmount vnode. 16838494Sobrien * Returns: 0 if OK, non-zero (errno) if failed. 16938494Sobrien */ 17038494Sobrienstatic int 17138494Sobrienfoofs_umount(am_node *mp) 17238494Sobrien{ 17338494Sobrien int error = 0; 17438494Sobrien 17538494Sobrien plog(XLOG_INFO, "entering foofs_umount..."); 17638494Sobrien 17738494Sobrien error = EPERM; /* XXX: fixme */ 17838494Sobrien return error; 17938494Sobrien} 18038494Sobrien 18138494Sobrien 18238494Sobrien/* 18338494Sobrien * Unmount VFS. 18438494Sobrien * Returns: 0 if OK, non-zero (errno) if failed. 18538494Sobrien */ 18638494Sobrienstatic int 18738494Sobrienfoofs_fumount(mntfs *mf) 18838494Sobrien{ 18938494Sobrien int error = 0; 19038494Sobrien 19138494Sobrien plog(XLOG_INFO, "entering foofs_fumount..."); 19238494Sobrien 19338494Sobrien error = EPERM; /* XXX: fixme */ 19438494Sobrien return error; 19538494Sobrien} 19638494Sobrien 19738494Sobrien 19838494Sobrien/* 19938494Sobrien * Lookup path-name. 20038494Sobrien * Returns: the am_node that was found, or NULL if failed. 20138494Sobrien * If failed, also fills in errno in error_return. 20238494Sobrien */ 20338494Sobrienstatic am_node * 20438494Sobrienfoofs_lookuppn(am_node *mp, char *fname, int *error_return, int op) 20538494Sobrien{ 20638494Sobrien int error = 0; 20738494Sobrien 20838494Sobrien plog(XLOG_INFO, "entering foofs_lookuppn..."); 20938494Sobrien 21038494Sobrien error = EPERM; /* XXX: fixme */ 21138494Sobrien 21238494Sobrien *error_return = error; 21338494Sobrien return NULL; 21438494Sobrien} 21538494Sobrien 21638494Sobrien 21738494Sobrien/* 21838494Sobrien * Read directory. 21938494Sobrien * Returns: 0 if OK, non-zero (errno) if failed. 22038494Sobrien * If OK, fills in ep with chain of directory entries. 22138494Sobrien */ 22238494Sobrienstatic int 223174294Sobrienfoofs_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int count) 22438494Sobrien{ 22538494Sobrien int error = 0; 22638494Sobrien 22738494Sobrien plog(XLOG_INFO, "entering foofs_readdir..."); 22838494Sobrien 22938494Sobrien error = EPERM; /* XXX: fixme */ 23038494Sobrien return error; 23138494Sobrien} 23238494Sobrien 23338494Sobrien 23438494Sobrien/* 23538494Sobrien * Read link. 23638494Sobrien * Returns: am_node found, or NULL if not found. 23738494Sobrien * If failed, fills in errno in error_return. 23838494Sobrien */ 23938494Sobrienstatic am_node * 24038494Sobrienfoofs_readlink(am_node *mp, int *error_return) 24138494Sobrien{ 24238494Sobrien int error = 0; 24338494Sobrien 24438494Sobrien plog(XLOG_INFO, "entering foofs_readlink..."); 24538494Sobrien 24638494Sobrien error = EPERM; /* XXX: fixme */ 24738494Sobrien 24838494Sobrien *error_return = error; 24938494Sobrien return NULL; 25038494Sobrien} 25138494Sobrien 25238494Sobrien 25338494Sobrien/* 25438494Sobrien * Async mount callback function. 25538494Sobrien * After the base mount went OK, sometimes 25638494Sobrien * there are additional actions that are needed. See union_mounted() and 25738494Sobrien * toplvl_mounted(). 25838494Sobrien */ 25938494Sobrienstatic void 26038494Sobrienfoofs_mounted(mntfs *mf) 26138494Sobrien{ 26238494Sobrien plog(XLOG_INFO, "entering foofs_mounted..."); 26338494Sobrien 26438494Sobrien return; 26538494Sobrien} 26638494Sobrien 26738494Sobrien 26838494Sobrien/* 26938494Sobrien * Async unmount callback function. 27038494Sobrien * After the base umount() succeeds, we may want to take extra actions, 27138494Sobrien * such as informing remote mount daemons that we've unmounted them. 27238494Sobrien * See amfs_auto_umounted(), host_umounted(), nfs_umounted(). 27338494Sobrien */ 27438494Sobrienstatic void 27538494Sobrienfoofs_umounted(am_node *mp) 27638494Sobrien{ 27738494Sobrien plog(XLOG_INFO, "entering foofs_umounted..."); 27838494Sobrien 27938494Sobrien return; 28038494Sobrien} 28138494Sobrien 28238494Sobrien 28338494Sobrien/* 28438494Sobrien * Find a file server. 28538494Sobrien * Returns: fserver of found server, or NULL if not found. 28638494Sobrien */ 287174294Sobrienstatic fserver * 28838494Sobrienfoofs_ffserver(mntfs *mf) 28938494Sobrien{ 29038494Sobrien plog(XLOG_INFO, "entering foofs_ffserver..."); 29138494Sobrien 29238494Sobrien return NULL; 29338494Sobrien} 294174294Sobrien 295174294Sobrien 296174294Sobrien/* 297174294Sobrien * Normally just return mf. Only inherit needs to do special tricks. 298174294Sobrien */ 299174294Sobrienstatic wchan_t * 300174294Sobrienfoofs_get_wchan(mntfs *mf) 301174294Sobrien{ 302174294Sobrien plog(XLOG_INFO, "entering foofs_get_wchan..."); 303174294Sobrien 304174294Sobrien return mf; 305174294Sobrien} 306