1 /* 2 * $Id: ufs_ops.c,v 5.2 90/06/23 22:20:03 jsp Rel $ 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.1 (Berkeley) 06/29/90 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 #include <sys/mount.h> 26 27 #ifdef UFS_HDR 28 #include UFS_HDR 29 #endif /* UFS_HDR */ 30 31 /* 32 * UN*X file system 33 */ 34 35 /* 36 * UFS needs local filesystem and device. 37 */ 38 static int ufs_match(fo) 39 am_opts *fo; 40 { 41 if (!fo->opt_dev) { 42 plog(XLOG_USER, "ufs: no device specified"); 43 return 0; 44 } 45 /* 46 * Determine magic cookie to put in mtab 47 */ 48 fo->fs_mtab = strealloc(fo->fs_mtab, fo->opt_dev); 49 #ifdef DEBUG 50 dlog("UFS: mounting device \"%s\" on \"%s\"", 51 fo->opt_dev, fo->opt_fs); 52 #endif /* DEBUG */ 53 54 return 1; 55 } 56 57 static mount_ufs(dir, fs_name, opts) 58 char *dir; 59 char *fs_name; 60 char *opts; 61 { 62 struct ufs_args ufs_args; 63 struct mntent mnt; 64 int flags; 65 66 /* 67 * Figure out the name of the file system type. 68 */ 69 #ifdef M_NEWTYPE 70 char *type = MOUNT_TYPE_UFS; 71 #else 72 int type = MOUNT_TYPE_UFS; 73 #endif /* M_NEWTYPE */ 74 75 bzero((voidp) &ufs_args, sizeof(ufs_args)); /* Paranoid */ 76 77 /* 78 * Fill in the mount structure 79 */ 80 mnt.mnt_dir = dir; 81 mnt.mnt_fsname = fs_name; 82 mnt.mnt_type = MTAB_TYPE_UFS; 83 mnt.mnt_opts = opts; 84 mnt.mnt_freq = 1; 85 mnt.mnt_passno = 2; 86 87 flags = compute_mount_flags(&mnt); 88 89 #ifdef ULTRIX_HACK 90 ufs_args.ufs_flags = flags; 91 ufs_args.ufs_pgthresh = 64; /* 64K - XXX */ 92 flags &= M_RDONLY; 93 #else 94 ufs_args.fspec = fs_name; 95 #endif /* ULTRIX_HACK */ 96 97 /* 98 * Call generic mount routine 99 */ 100 return mount_fs(&mnt, flags, (caddr_t) &ufs_args, 0, type); 101 } 102 103 /*ARGSUSED*/ 104 static int ufs_mount(mp) 105 am_node *mp; 106 { 107 mntfs *mf = mp->am_mnt; 108 109 int error; 110 111 error = mount_ufs(mf->mf_mount, mf->mf_info, mf->mf_fo->opt_opts); 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_umount(mp) 122 am_node *mp; 123 { 124 mntfs *mf = mp->am_mnt; 125 126 return UMOUNT_FS(mf->mf_mount); 127 } 128 129 /* 130 * Ops structure 131 */ 132 am_ops ufs_ops = { 133 "ufs", 134 ufs_match, 135 0, /* ufs_init */ 136 ufs_mount, 137 ufs_umount, 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