ops_pcfs.c revision 42629
138494Sobrien/* 238494Sobrien * Copyright (c) 1997-1998 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 * %W% (Berkeley) %G% 4038494Sobrien * 4142629Sobrien * $Id: ops_pcfs.c,v 1.1.1.1 1998/11/05 02:04:50 ezk Exp $ 4238494Sobrien * 4338494Sobrien */ 4438494Sobrien 4538494Sobrien/* 4638494Sobrien * PC (MS-DOS) file system 4738494Sobrien */ 4838494Sobrien 4938494Sobrien#ifdef HAVE_CONFIG_H 5038494Sobrien# include <config.h> 5138494Sobrien#endif /* HAVE_CONFIG_H */ 5238494Sobrien#include <am_defs.h> 5338494Sobrien#include <amd.h> 5438494Sobrien 5538494Sobrien/* forward definitions */ 5638494Sobrienstatic char *pcfs_match(am_opts *fo); 5738494Sobrienstatic int pcfs_fmount(mntfs *mf); 5838494Sobrienstatic int pcfs_fumount(mntfs *mf); 5938494Sobrien 6038494Sobrien/* 6138494Sobrien * Ops structure 6238494Sobrien */ 6338494Sobrienam_ops pcfs_ops = 6438494Sobrien{ 6538494Sobrien "pcfs", 6638494Sobrien pcfs_match, 6738494Sobrien 0, /* pcfs_init */ 6838494Sobrien amfs_auto_fmount, 6938494Sobrien pcfs_fmount, 7038494Sobrien amfs_auto_fumount, 7138494Sobrien pcfs_fumount, 7238494Sobrien amfs_error_lookuppn, 7338494Sobrien amfs_error_readdir, 7438494Sobrien 0, /* pcfs_readlink */ 7538494Sobrien 0, /* pcfs_mounted */ 7638494Sobrien 0, /* pcfs_umounted */ 7738494Sobrien find_amfs_auto_srvr, 7838494Sobrien FS_MKMNT | FS_UBACKGROUND | FS_AMQINFO 7938494Sobrien}; 8038494Sobrien 8138494Sobrien 8238494Sobrien 8338494Sobrien/* 8438494Sobrien * PCFS needs remote filesystem. 8538494Sobrien */ 8638494Sobrienstatic char * 8738494Sobrienpcfs_match(am_opts *fo) 8838494Sobrien{ 8938494Sobrien if (!fo->opt_dev) { 9038494Sobrien plog(XLOG_USER, "pcfs: no source device specified"); 9138494Sobrien return 0; 9238494Sobrien } 9338494Sobrien#ifdef DEBUG 9438494Sobrien dlog("PCFS: mounting device \"%s\" on \"%s\"", fo->opt_dev, fo->opt_fs); 9538494Sobrien#endif /* DEBUG */ 9638494Sobrien 9738494Sobrien /* 9838494Sobrien * Determine magic cookie to put in mtab 9938494Sobrien */ 10038494Sobrien return strdup(fo->opt_dev); 10138494Sobrien} 10238494Sobrien 10338494Sobrien 10438494Sobrienstatic int 10538494Sobrienmount_pcfs(char *dir, char *fs_name, char *opts) 10638494Sobrien{ 10738494Sobrien pcfs_args_t pcfs_args; 10838494Sobrien mntent_t mnt; 10938494Sobrien int flags; 11038494Sobrien 11138494Sobrien /* 11238494Sobrien * Figure out the name of the file system type. 11338494Sobrien */ 11438494Sobrien MTYPE_TYPE type = MOUNT_TYPE_PCFS; 11538494Sobrien 11638494Sobrien memset((voidp) &pcfs_args, 0, sizeof(pcfs_args)); /* Paranoid */ 11738494Sobrien 11838494Sobrien /* 11938494Sobrien * Fill in the mount structure 12038494Sobrien */ 12138494Sobrien memset((voidp) &mnt, 0, sizeof(mnt)); 12238494Sobrien mnt.mnt_dir = dir; 12338494Sobrien mnt.mnt_fsname = fs_name; 12438494Sobrien mnt.mnt_type = MNTTAB_TYPE_PCFS; 12538494Sobrien mnt.mnt_opts = opts; 12638494Sobrien 12738494Sobrien flags = compute_mount_flags(&mnt); 12838494Sobrien 12938494Sobrien#ifdef HAVE_FIELD_PCFS_ARGS_T_FSPEC 13038494Sobrien pcfs_args.fspec = fs_name; 13138494Sobrien#endif /* HAVE_FIELD_PCFS_ARGS_T_FSPEC */ 13238494Sobrien 13338494Sobrien#ifdef HAVE_FIELD_PCFS_ARGS_T_MASK 13438494Sobrien pcfs_args.mask = 0777; /* this may be the msdos file modes */ 13538494Sobrien#endif /* HAVE_FIELD_PCFS_ARGS_T_MASK */ 13638494Sobrien 13738494Sobrien#ifdef HAVE_FIELD_PCFS_ARGS_T_UID 13838494Sobrien pcfs_args.uid = 0; /* root */ 13938494Sobrien#endif /* HAVE_FIELD_PCFS_ARGS_T_UID */ 14038494Sobrien 14138494Sobrien#ifdef HAVE_FIELD_PCFS_ARGS_T_GID 14238494Sobrien pcfs_args.gid = 0; /* wheel */ 14338494Sobrien#endif /* HAVE_FIELD_PCFS_ARGS_T_GID */ 14438494Sobrien 14538494Sobrien#ifdef HAVE_FIELD_PCFS_ARGS_T_SECONDSWEST 14638494Sobrien pcfs_args.secondswest = 0; /* XXX: fill in correct values */ 14738494Sobrien#endif /* HAVE_FIELD_PCFS_ARGS_T_SECONDSWEST */ 14838494Sobrien#ifdef HAVE_FIELD_PCFS_ARGS_T_DSTTIME 14938494Sobrien pcfs_args.dsttime = 0; /* XXX: fill in correct values */ 15038494Sobrien#endif /* HAVE_FIELD_PCFS_ARGS_T_DSTTIME */ 15138494Sobrien 15238494Sobrien /* 15338494Sobrien * Call generic mount routine 15438494Sobrien */ 15538494Sobrien return mount_fs(&mnt, flags, (caddr_t) & pcfs_args, 0, type, 0, NULL, mnttab_file_name); 15638494Sobrien} 15738494Sobrien 15838494Sobrien 15938494Sobrienstatic int 16038494Sobrienpcfs_fmount(mntfs *mf) 16138494Sobrien{ 16238494Sobrien int error; 16338494Sobrien 16438494Sobrien error = mount_pcfs(mf->mf_mount, mf->mf_info, mf->mf_mopts); 16538494Sobrien if (error) { 16638494Sobrien errno = error; 16738494Sobrien plog(XLOG_ERROR, "mount_pcfs: %m"); 16838494Sobrien return error; 16938494Sobrien } 17038494Sobrien 17138494Sobrien return 0; 17238494Sobrien} 17338494Sobrien 17438494Sobrien 17538494Sobrienstatic int 17638494Sobrienpcfs_fumount(mntfs *mf) 17738494Sobrien{ 17838494Sobrien return UMOUNT_FS(mf->mf_mount, mnttab_file_name); 17938494Sobrien} 180