1 /* 2 * $Id: ufs_ops.c,v 5.2.1.1 90/10/21 22:29:47 jsp Exp $ 3 * 4 * Copyright (c) 1990 Jan-Simon Pendry 5 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 6 * Copyright (c) 1990 The Regents of the University of California. 7 * All rights reserved. 8 * 9 * This code is derived from software contributed to Berkeley by 10 * Jan-Simon Pendry at Imperial College, London. 11 * 12 * %sccs.include.redist.c% 13 * 14 * @(#)ufs_ops.c 5.2 (Berkeley) 03/17/91 15 */ 16 17 #include "am.h" 18 19 #ifdef HAS_UFS 20 21 #include <sys/stat.h> 22 #ifdef NFS_3 23 typedef nfs_fh fhandle_t; 24 #endif /* NFS_3 */ 25 26 #ifdef UFS_HDR 27 #include UFS_HDR 28 #endif /* UFS_HDR */ 29 30 #include <sys/mount.h> 31 32 /* 33 * UN*X file system 34 */ 35 36 /* 37 * UFS needs local filesystem and device. 38 */ 39 static char *ufs_match P((am_opts *fo)); 40 static char *ufs_match(fo) 41 am_opts *fo; 42 { 43 if (!fo->opt_dev) { 44 plog(XLOG_USER, "ufs: no device specified"); 45 return 0; 46 } 47 48 #ifdef DEBUG 49 dlog("UFS: mounting device \"%s\" on \"%s\"", 50 fo->opt_dev, fo->opt_fs); 51 #endif /* DEBUG */ 52 53 /* 54 * Determine magic cookie to put in mtab 55 */ 56 return strdup(fo->opt_dev); 57 } 58 59 static mount_ufs(dir, fs_name, opts) 60 char *dir; 61 char *fs_name; 62 char *opts; 63 { 64 struct ufs_args ufs_args; 65 struct mntent mnt; 66 int flags; 67 68 /* 69 * Figure out the name of the file system type. 70 */ 71 #ifdef M_NEWTYPE 72 char *type = MOUNT_TYPE_UFS; 73 #else 74 int type = MOUNT_TYPE_UFS; 75 #endif /* M_NEWTYPE */ 76 77 bzero((voidp) &ufs_args, sizeof(ufs_args)); /* Paranoid */ 78 79 /* 80 * Fill in the mount structure 81 */ 82 mnt.mnt_dir = dir; 83 mnt.mnt_fsname = fs_name; 84 mnt.mnt_type = MTAB_TYPE_UFS; 85 mnt.mnt_opts = opts; 86 mnt.mnt_freq = 1; 87 mnt.mnt_passno = 2; 88 89 flags = compute_mount_flags(&mnt); 90 91 #ifdef ULTRIX_HACK 92 ufs_args.ufs_flags = flags; 93 ufs_args.ufs_pgthresh = 64; /* 64K - XXX */ 94 flags &= M_RDONLY; 95 #else 96 ufs_args.fspec = fs_name; 97 #endif /* ULTRIX_HACK */ 98 99 /* 100 * Call generic mount routine 101 */ 102 return mount_fs(&mnt, flags, (caddr_t) &ufs_args, 0, type); 103 } 104 105 /*ARGSUSED*/ 106 static int ufs_fmount(mf) 107 mntfs *mf; 108 { 109 int error; 110 111 error = mount_ufs(mf->mf_mount, mf->mf_info, mf->mf_mopts); 112 if (error) { 113 errno = error; 114 plog(XLOG_ERROR, "mount_ufs: %m"); 115 return error; 116 } 117 118 return 0; 119 } 120 121 static int ufs_fumount(mf) 122 mntfs *mf; 123 { 124 return UMOUNT_FS(mf->mf_mount); 125 } 126 127 /* 128 * Ops structure 129 */ 130 am_ops ufs_ops = { 131 "ufs", 132 ufs_match, 133 0, /* ufs_init */ 134 auto_fmount, 135 ufs_fmount, 136 auto_fumount, 137 ufs_fumount, 138 efs_lookuppn, 139 efs_readdir, 140 0, /* ufs_readlink */ 141 0, /* ufs_mounted */ 142 0, /* ufs_umounted */ 143 find_afs_srvr, 144 #ifdef FLUSH_KERNEL_NAME_CACHE 145 FS_MKMNT|FS_NOTIMEOUT|FS_UBACKGROUND|FS_AMQINFO 146 #else /* FLUSH_KERNEL_NAME_CACHE */ 147 FS_MKMNT|FS_NOTIMEOUT|FS_UBACKGROUND|FS_AMQINFO 148 #endif /* FLUSH_KERNEL_NAME_CACHE */ 149 }; 150 151 #endif /* HAS_UFS */ 152