ops_xfs.c revision 131702
1314564Sdim/* 2314564Sdim * Copyright (c) 1997-2004 Erez Zadok 3293116Semaste * Copyright (c) 1990 Jan-Simon Pendry 4293116Semaste * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 5293116Semaste * Copyright (c) 1990 The Regents of the University of California. 6293116Semaste * All rights reserved. 7293116Semaste * 8293116Semaste * This code is derived from software contributed to Berkeley by 9293116Semaste * Jan-Simon Pendry at Imperial College, London. 10293116Semaste * 11293116Semaste * Redistribution and use in source and binary forms, with or without 12293116Semaste * modification, are permitted provided that the following conditions 13293116Semaste * are met: 14293116Semaste * 1. Redistributions of source code must retain the above copyright 15293116Semaste * notice, this list of conditions and the following disclaimer. 16293116Semaste * 2. Redistributions in binary form must reproduce the above copyright 17293116Semaste * notice, this list of conditions and the following disclaimer in the 18293116Semaste * documentation and/or other materials provided with the distribution. 19293116Semaste * 3. All advertising materials mentioning features or use of this software 20293116Semaste * must display the following acknowledgment: 21293116Semaste * This product includes software developed by the University of 22293116Semaste * California, Berkeley and its contributors. 23293116Semaste * 4. Neither the name of the University nor the names of its contributors 24293116Semaste * may be used to endorse or promote products derived from this software 25293116Semaste * without specific prior written permission. 26309124Sdim * 27309124Sdim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28293116Semaste * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29293116Semaste * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30293116Semaste * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31293116Semaste * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32293116Semaste * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33293116Semaste * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34309124Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35293116Semaste * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36293116Semaste * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37293116Semaste * SUCH DAMAGE. 38293116Semaste * 39293116Semaste * %W% (Berkeley) %G% 40293116Semaste * 41293116Semaste * $Id: ops_xfs.c,v 1.3.2.6 2004/01/06 03:15:16 ezk Exp $ 42293116Semaste * 43293116Semaste */ 44293116Semaste 45293116Semaste/* 46293116Semaste * Irix UN*X file system: XFS (Extended File System) 47314564Sdim */ 48314564Sdim 49314564Sdim#ifdef HAVE_CONFIG_H 50314564Sdim# include <config.h> 51314564Sdim#endif /* HAVE_CONFIG_H */ 52293116Semaste#include <am_defs.h> 53293116Semaste#include <amd.h> 54293116Semaste 55293116Semaste/* forward declarations */ 56293116Semastestatic char *xfs_match(am_opts *fo); 57293116Semastestatic int xfs_fmount(mntfs *mf); 58293116Semastestatic int xfs_fumount(mntfs *mf); 59293116Semaste 60293116Semaste/* 61293116Semaste * Ops structure 62293116Semaste */ 63293116Semasteam_ops xfs_ops = 64293116Semaste{ 65293116Semaste "xfs", 66293116Semaste xfs_match, 67293116Semaste 0, /* xfs_init */ 68293116Semaste amfs_auto_fmount, 69293116Semaste xfs_fmount, 70293116Semaste amfs_auto_fumount, 71293116Semaste xfs_fumount, 72293116Semaste amfs_error_lookuppn, 73293116Semaste amfs_error_readdir, 74293116Semaste 0, /* xfs_readlink */ 75293116Semaste 0, /* xfs_mounted */ 76293116Semaste 0, /* xfs_umounted */ 77293116Semaste find_amfs_auto_srvr, 78293116Semaste FS_MKMNT | FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO 79293116Semaste}; 80293116Semaste 81293116Semaste 82293116Semaste/* 83293116Semaste * XFS needs local filesystem and device. 84293116Semaste */ 85293116Semastestatic char * 86293116Semastexfs_match(am_opts *fo) 87293116Semaste{ 88293116Semaste 89293116Semaste if (!fo->opt_dev) { 90293116Semaste plog(XLOG_USER, "xfs: no device specified"); 91293116Semaste return 0; 92293116Semaste } 93293116Semaste 94293116Semaste#ifdef DEBUG 95293116Semaste dlog("XFS: mounting device \"%s\" on \"%s\"", fo->opt_dev, fo->opt_fs); 96293116Semaste#endif /* DEBUG */ 97293116Semaste 98293116Semaste /* 99293116Semaste * Determine magic cookie to put in mtab 100293116Semaste */ 101293116Semaste return strdup(fo->opt_dev); 102293116Semaste} 103293116Semaste 104293116Semaste 105293116Semastestatic int 106293116Semastemount_xfs(char *dir, char *fs_name, char *opts) 107293116Semaste{ 108293116Semaste xfs_args_t xfs_args; 109293116Semaste mntent_t mnt; 110293116Semaste int flags; 111293116Semaste 112293116Semaste /* 113293116Semaste * Figure out the name of the file system type. 114293116Semaste */ 115293116Semaste MTYPE_TYPE type = MOUNT_TYPE_XFS; 116293116Semaste 117293116Semaste memset((voidp) &xfs_args, 0, sizeof(xfs_args)); /* Paranoid */ 118293116Semaste 119293116Semaste /* 120293116Semaste * Fill in the mount structure 121293116Semaste */ 122293116Semaste memset((voidp) &mnt, 0, sizeof(mnt)); 123293116Semaste mnt.mnt_dir = dir; 124293116Semaste mnt.mnt_fsname = fs_name; 125293116Semaste mnt.mnt_type = MNTTAB_TYPE_XFS; 126293116Semaste mnt.mnt_opts = opts; 127293116Semaste 128293116Semaste flags = compute_mount_flags(&mnt); 129293116Semaste 130293116Semaste#ifdef HAVE_XFS_ARGS_T_FLAGS 131293116Semaste xfs_args.flags = 0; /* XXX: fix this to correct flags */ 132293116Semaste#endif /* HAVE_XFS_ARGS_T_FLAGS */ 133293116Semaste#ifdef HAVE_XFS_ARGS_T_FSPEC 134293116Semaste xfs_args.fspec = fs_name; 135293116Semaste#endif /* HAVE_XFS_ARGS_T_FSPEC */ 136293116Semaste 137293116Semaste /* 138293116Semaste * Call generic mount routine 139293116Semaste */ 140293116Semaste return mount_fs(&mnt, flags, (caddr_t) &xfs_args, 0, type, 0, NULL, mnttab_file_name); 141293116Semaste} 142293116Semaste 143293116Semaste 144293116Semastestatic int 145293116Semastexfs_fmount(mntfs *mf) 146293116Semaste{ 147293116Semaste int error; 148293116Semaste 149293116Semaste error = mount_xfs(mf->mf_mount, mf->mf_info, mf->mf_mopts); 150293116Semaste if (error) { 151293116Semaste errno = error; 152293116Semaste plog(XLOG_ERROR, "mount_xfs: %m"); 153293116Semaste return error; 154293116Semaste } 155293116Semaste 156293116Semaste return 0; 157293116Semaste} 158293116Semaste 159293116Semaste 160293116Semastestatic int 161293116Semastexfs_fumount(mntfs *mf) 162293116Semaste{ 163293116Semaste return UMOUNT_FS(mf->mf_mount, mnttab_file_name); 164293116Semaste} 165293116Semaste