10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51025Sfrankho * Common Development and Distribution License (the "License"). 61025Sfrankho * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 226734Sjohnlev * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * VFS operations for High Sierra filesystem 300Sstevel@tonic-gate */ 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <sys/types.h> 330Sstevel@tonic-gate #include <sys/isa_defs.h> 340Sstevel@tonic-gate #include <sys/t_lock.h> 350Sstevel@tonic-gate #include <sys/param.h> 360Sstevel@tonic-gate #include <sys/systm.h> 370Sstevel@tonic-gate #include <sys/sysmacros.h> 380Sstevel@tonic-gate #include <sys/kmem.h> 390Sstevel@tonic-gate #include <sys/signal.h> 400Sstevel@tonic-gate #include <sys/user.h> 410Sstevel@tonic-gate #include <sys/proc.h> 420Sstevel@tonic-gate #include <sys/disp.h> 430Sstevel@tonic-gate #include <sys/buf.h> 440Sstevel@tonic-gate #include <sys/pathname.h> 450Sstevel@tonic-gate #include <sys/vfs.h> 463898Srsb #include <sys/vfs_opreg.h> 470Sstevel@tonic-gate #include <sys/vnode.h> 480Sstevel@tonic-gate #include <sys/file.h> 490Sstevel@tonic-gate #include <sys/uio.h> 500Sstevel@tonic-gate #include <sys/conf.h> 510Sstevel@tonic-gate #include <sys/policy.h> 520Sstevel@tonic-gate 530Sstevel@tonic-gate #include <vm/page.h> 540Sstevel@tonic-gate 550Sstevel@tonic-gate #include <sys/fs/snode.h> 560Sstevel@tonic-gate #include <sys/fs/hsfs_spec.h> 570Sstevel@tonic-gate #include <sys/fs/hsfs_isospec.h> 580Sstevel@tonic-gate #include <sys/fs/hsfs_node.h> 590Sstevel@tonic-gate #include <sys/fs/hsfs_impl.h> 600Sstevel@tonic-gate #include <sys/fs/hsfs_susp.h> 610Sstevel@tonic-gate #include <sys/fs/hsfs_rrip.h> 620Sstevel@tonic-gate 630Sstevel@tonic-gate #include <sys/statvfs.h> 640Sstevel@tonic-gate #include <sys/mount.h> 650Sstevel@tonic-gate #include <sys/mntent.h> 660Sstevel@tonic-gate #include <sys/swap.h> 670Sstevel@tonic-gate #include <sys/errno.h> 680Sstevel@tonic-gate #include <sys/debug.h> 690Sstevel@tonic-gate #include "fs/fs_subr.h" 700Sstevel@tonic-gate #include <sys/cmn_err.h> 710Sstevel@tonic-gate #include <sys/bootconf.h> 720Sstevel@tonic-gate 732900Sfrankho #include <sys/sdt.h> 742900Sfrankho 750Sstevel@tonic-gate /* 760Sstevel@tonic-gate * These are needed for the CDROMREADOFFSET Code 770Sstevel@tonic-gate */ 780Sstevel@tonic-gate #include <sys/cdio.h> 790Sstevel@tonic-gate #include <sys/sunddi.h> 800Sstevel@tonic-gate 810Sstevel@tonic-gate #define HSFS_CLKSET 820Sstevel@tonic-gate 830Sstevel@tonic-gate #include <sys/modctl.h> 840Sstevel@tonic-gate 850Sstevel@tonic-gate /* 860Sstevel@tonic-gate * Options for mount. 870Sstevel@tonic-gate */ 880Sstevel@tonic-gate #define HOPT_GLOBAL MNTOPT_GLOBAL 890Sstevel@tonic-gate #define HOPT_NOGLOBAL MNTOPT_NOGLOBAL 900Sstevel@tonic-gate #define HOPT_MAPLCASE "maplcase" 910Sstevel@tonic-gate #define HOPT_NOMAPLCASE "nomaplcase" 920Sstevel@tonic-gate #define HOPT_NOTRAILDOT "notraildot" 930Sstevel@tonic-gate #define HOPT_TRAILDOT "traildot" 940Sstevel@tonic-gate #define HOPT_NRR "nrr" 950Sstevel@tonic-gate #define HOPT_RR "rr" 962900Sfrankho #define HOPT_JOLIET "joliet" 972900Sfrankho #define HOPT_NOJOLIET "nojoliet" 982900Sfrankho #define HOPT_JOLIETLONG "jolietlong" 992900Sfrankho #define HOPT_VERS2 "vers2" 1002900Sfrankho #define HOPT_NOVERS2 "novers2" 1010Sstevel@tonic-gate #define HOPT_RO MNTOPT_RO 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate static char *global_cancel[] = { HOPT_NOGLOBAL, NULL }; 1040Sstevel@tonic-gate static char *noglobal_cancel[] = { HOPT_GLOBAL, NULL }; 1050Sstevel@tonic-gate static char *mapl_cancel[] = { HOPT_NOMAPLCASE, NULL }; 1060Sstevel@tonic-gate static char *nomapl_cancel[] = { HOPT_MAPLCASE, NULL }; 1070Sstevel@tonic-gate static char *ro_cancel[] = { MNTOPT_RW, NULL }; 1080Sstevel@tonic-gate static char *rr_cancel[] = { HOPT_NRR, NULL }; 1090Sstevel@tonic-gate static char *nrr_cancel[] = { HOPT_RR, NULL }; 1102900Sfrankho static char *joliet_cancel[] = { HOPT_NOJOLIET, NULL }; 1112900Sfrankho static char *nojoliet_cancel[] = { HOPT_JOLIET, NULL }; 1122900Sfrankho static char *vers2_cancel[] = { HOPT_NOVERS2, NULL }; 1132900Sfrankho static char *novers2_cancel[] = { HOPT_VERS2, NULL }; 1140Sstevel@tonic-gate static char *trail_cancel[] = { HOPT_NOTRAILDOT, NULL }; 1150Sstevel@tonic-gate static char *notrail_cancel[] = { HOPT_TRAILDOT, NULL }; 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate static mntopt_t hsfs_options[] = { 1180Sstevel@tonic-gate { HOPT_GLOBAL, global_cancel, NULL, 0, NULL }, 1190Sstevel@tonic-gate { HOPT_NOGLOBAL, noglobal_cancel, NULL, MO_DEFAULT, NULL }, 1200Sstevel@tonic-gate { HOPT_MAPLCASE, mapl_cancel, NULL, MO_DEFAULT, NULL }, 1210Sstevel@tonic-gate { HOPT_NOMAPLCASE, nomapl_cancel, NULL, 0, NULL }, 1220Sstevel@tonic-gate { HOPT_RO, ro_cancel, NULL, MO_DEFAULT, NULL }, 1230Sstevel@tonic-gate { HOPT_RR, rr_cancel, NULL, MO_DEFAULT, NULL }, 1240Sstevel@tonic-gate { HOPT_NRR, nrr_cancel, NULL, 0, NULL }, 1252900Sfrankho { HOPT_JOLIET, joliet_cancel, NULL, 0, NULL }, 1262900Sfrankho { HOPT_NOJOLIET, nojoliet_cancel, NULL, 0, NULL }, 1272900Sfrankho { HOPT_JOLIETLONG, NULL, NULL, 0, NULL }, 1282900Sfrankho { HOPT_VERS2, vers2_cancel, NULL, 0, NULL }, 1292900Sfrankho { HOPT_NOVERS2, novers2_cancel, NULL, 0, NULL }, 1300Sstevel@tonic-gate { HOPT_TRAILDOT, trail_cancel, NULL, MO_DEFAULT, NULL }, 1310Sstevel@tonic-gate { HOPT_NOTRAILDOT, notrail_cancel, NULL, 0, NULL }, 1322900Sfrankho { "sector", NULL, "0", MO_HASVALUE, NULL}, 1330Sstevel@tonic-gate }; 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate static mntopts_t hsfs_proto_opttbl = { 1360Sstevel@tonic-gate sizeof (hsfs_options) / sizeof (mntopt_t), 1370Sstevel@tonic-gate hsfs_options 1380Sstevel@tonic-gate }; 1390Sstevel@tonic-gate 1405312Smg147109 /* 1415312Smg147109 * Indicates whether to enable the I/O scheduling and readahead logic 1425312Smg147109 * 1 - Enable, 0 - Do not Enable. 1435312Smg147109 * Debugging purposes. 1445312Smg147109 */ 1455312Smg147109 int do_schedio = 1; 1462900Sfrankho static int hsfsfstype; 1470Sstevel@tonic-gate static int hsfsinit(int, char *); 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate static vfsdef_t vfw = { 1500Sstevel@tonic-gate VFSDEF_VERSION, 1510Sstevel@tonic-gate "hsfs", 1520Sstevel@tonic-gate hsfsinit, 153*6855Sjohnlev /* We don't suppport remounting */ 154*6855Sjohnlev VSW_HASPROTO|VSW_STATS|VSW_CANLOFI, 1550Sstevel@tonic-gate &hsfs_proto_opttbl 1560Sstevel@tonic-gate }; 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate static struct modlfs modlfs = { 1590Sstevel@tonic-gate &mod_fsops, "filesystem for HSFS", &vfw 1600Sstevel@tonic-gate }; 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate static struct modlinkage modlinkage = { 1630Sstevel@tonic-gate MODREV_1, (void *)&modlfs, NULL 1640Sstevel@tonic-gate }; 1650Sstevel@tonic-gate 1660Sstevel@tonic-gate char _depends_on[] = "fs/specfs"; 1670Sstevel@tonic-gate 1685312Smg147109 extern void hsched_init_caches(void); 1695312Smg147109 extern void hsched_fini_caches(void); 1705312Smg147109 1715312Smg147109 1720Sstevel@tonic-gate int 1732900Sfrankho _init(void) 1740Sstevel@tonic-gate { 1750Sstevel@tonic-gate return (mod_install(&modlinkage)); 1760Sstevel@tonic-gate } 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate int 1792900Sfrankho _fini(void) 1800Sstevel@tonic-gate { 1812900Sfrankho int error; 1822900Sfrankho 1832900Sfrankho error = mod_remove(&modlinkage); 1842900Sfrankho 1852900Sfrankho DTRACE_PROBE1(mod_remove, int, error); 1862900Sfrankho 1872900Sfrankho if (error) 1882900Sfrankho return (error); 1892900Sfrankho 1902900Sfrankho mutex_destroy(&hs_mounttab_lock); 1912900Sfrankho 1922900Sfrankho /* 1932900Sfrankho * Tear down the operations vectors 1942900Sfrankho */ 1952900Sfrankho (void) vfs_freevfsops_by_type(hsfsfstype); 1962900Sfrankho vn_freevnodeops(hsfs_vnodeops); 1972900Sfrankho 1982900Sfrankho hs_fini_hsnode_cache(); 1995312Smg147109 hsched_fini_caches(); 2002900Sfrankho return (0); 2010Sstevel@tonic-gate } 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate int 2040Sstevel@tonic-gate _info(struct modinfo *modinfop) 2050Sstevel@tonic-gate { 2060Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 2070Sstevel@tonic-gate } 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate #define BDEVFLAG(dev) ((devopsp[getmajor(dev)])->devo_cb_ops->cb_flag) 2100Sstevel@tonic-gate 2110Sstevel@tonic-gate kmutex_t hs_mounttab_lock; 2120Sstevel@tonic-gate struct hsfs *hs_mounttab = NULL; 2130Sstevel@tonic-gate 2140Sstevel@tonic-gate /* default mode, uid, gid */ 2150Sstevel@tonic-gate mode_t hsfs_default_mode = 0555; 2160Sstevel@tonic-gate uid_t hsfs_default_uid = 0; 2170Sstevel@tonic-gate gid_t hsfs_default_gid = 3; 2180Sstevel@tonic-gate 2195312Smg147109 extern void hsched_init(struct hsfs *fsp, int fsid, 2205312Smg147109 struct modlinkage *modlinkage); 2215312Smg147109 extern void hsched_fini(struct hsfs_queue *hqueue); 2225312Smg147109 extern void hsfs_init_kstats(struct hsfs *fsp, int fsid); 2235312Smg147109 extern void hsfs_fini_kstats(struct hsfs *fsp); 2245312Smg147109 2250Sstevel@tonic-gate static int hsfs_mount(struct vfs *vfsp, struct vnode *mvp, 2260Sstevel@tonic-gate struct mounta *uap, struct cred *cr); 2270Sstevel@tonic-gate static int hsfs_unmount(struct vfs *vfsp, int, struct cred *cr); 2280Sstevel@tonic-gate static int hsfs_root(struct vfs *vfsp, struct vnode **vpp); 2290Sstevel@tonic-gate static int hsfs_statvfs(struct vfs *vfsp, struct statvfs64 *sbp); 2300Sstevel@tonic-gate static int hsfs_vget(struct vfs *vfsp, struct vnode **vpp, struct fid *fidp); 2310Sstevel@tonic-gate static int hsfs_mountroot(struct vfs *, enum whymountroot); 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate static int hs_mountfs(struct vfs *vfsp, dev_t dev, char *path, 2340Sstevel@tonic-gate mode_t mode, int flags, struct cred *cr, int isroot); 2352900Sfrankho static int hs_getrootvp(struct vfs *vfsp, struct hsfs *fsp, size_t pathsize); 2360Sstevel@tonic-gate static int hs_findhsvol(struct hsfs *fsp, struct vnode *vp, 2370Sstevel@tonic-gate struct hs_volume *hvp); 2380Sstevel@tonic-gate static int hs_parsehsvol(struct hsfs *fsp, uchar_t *volp, 2390Sstevel@tonic-gate struct hs_volume *hvp); 2400Sstevel@tonic-gate static int hs_findisovol(struct hsfs *fsp, struct vnode *vp, 2412900Sfrankho struct hs_volume *hvp, 2422900Sfrankho struct hs_volume *svp, 2432900Sfrankho struct hs_volume *jvp); 2442900Sfrankho static int hs_joliet_level(uchar_t *volp); 2450Sstevel@tonic-gate static int hs_parseisovol(struct hsfs *fsp, uchar_t *volp, 2460Sstevel@tonic-gate struct hs_volume *hvp); 2472900Sfrankho static void hs_copylabel(struct hs_volume *, unsigned char *, int); 2480Sstevel@tonic-gate static int hs_getmdev(struct vfs *, char *fspec, int flags, dev_t *pdev, 2490Sstevel@tonic-gate mode_t *mode, cred_t *cr); 2500Sstevel@tonic-gate static int hs_findvoldesc(dev_t rdev, int desc_sec); 2510Sstevel@tonic-gate 2520Sstevel@tonic-gate static int 2530Sstevel@tonic-gate hsfsinit(int fstype, char *name) 2540Sstevel@tonic-gate { 2550Sstevel@tonic-gate static const fs_operation_def_t hsfs_vfsops_template[] = { 2563898Srsb VFSNAME_MOUNT, { .vfs_mount = hsfs_mount }, 2573898Srsb VFSNAME_UNMOUNT, { .vfs_unmount = hsfs_unmount }, 2583898Srsb VFSNAME_ROOT, { .vfs_root = hsfs_root }, 2593898Srsb VFSNAME_STATVFS, { .vfs_statvfs = hsfs_statvfs }, 2603898Srsb VFSNAME_VGET, { .vfs_vget = hsfs_vget }, 2613898Srsb VFSNAME_MOUNTROOT, { .vfs_mountroot = hsfs_mountroot }, 2623898Srsb NULL, NULL 2630Sstevel@tonic-gate }; 2640Sstevel@tonic-gate int error; 2650Sstevel@tonic-gate 2660Sstevel@tonic-gate error = vfs_setfsops(fstype, hsfs_vfsops_template, NULL); 2670Sstevel@tonic-gate if (error != 0) { 2680Sstevel@tonic-gate cmn_err(CE_WARN, "hsfsinit: bad vfs ops template"); 2690Sstevel@tonic-gate return (error); 2700Sstevel@tonic-gate } 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate error = vn_make_ops(name, hsfs_vnodeops_template, &hsfs_vnodeops); 2730Sstevel@tonic-gate if (error != 0) { 2740Sstevel@tonic-gate (void) vfs_freevfsops_by_type(fstype); 2750Sstevel@tonic-gate cmn_err(CE_WARN, "hsfsinit: bad vnode ops template"); 2760Sstevel@tonic-gate return (error); 2770Sstevel@tonic-gate } 2780Sstevel@tonic-gate 2790Sstevel@tonic-gate hsfsfstype = fstype; 2800Sstevel@tonic-gate mutex_init(&hs_mounttab_lock, NULL, MUTEX_DEFAULT, NULL); 2810Sstevel@tonic-gate hs_init_hsnode_cache(); 2825312Smg147109 hsched_init_caches(); 2830Sstevel@tonic-gate return (0); 2840Sstevel@tonic-gate } 2850Sstevel@tonic-gate 2860Sstevel@tonic-gate /*ARGSUSED*/ 2870Sstevel@tonic-gate static int 2880Sstevel@tonic-gate hsfs_mount(struct vfs *vfsp, struct vnode *mvp, 2890Sstevel@tonic-gate struct mounta *uap, struct cred *cr) 2900Sstevel@tonic-gate { 2910Sstevel@tonic-gate int vnode_busy; 2920Sstevel@tonic-gate dev_t dev; 2930Sstevel@tonic-gate struct pathname dpn; 2940Sstevel@tonic-gate int error; 2950Sstevel@tonic-gate mode_t mode; 2960Sstevel@tonic-gate int flags; /* this will hold the mount specific data */ 2970Sstevel@tonic-gate 2980Sstevel@tonic-gate if ((error = secpolicy_fs_mount(cr, mvp, vfsp)) != 0) 2990Sstevel@tonic-gate return (error); 3000Sstevel@tonic-gate 3010Sstevel@tonic-gate if (mvp->v_type != VDIR) 3020Sstevel@tonic-gate return (ENOTDIR); 3030Sstevel@tonic-gate 3040Sstevel@tonic-gate /* mount option must be read only, else mount will be rejected */ 3050Sstevel@tonic-gate if (!(uap->flags & MS_RDONLY)) 3060Sstevel@tonic-gate return (EROFS); 3070Sstevel@tonic-gate 3080Sstevel@tonic-gate /* 3090Sstevel@tonic-gate * We already told the framework that we don't support remounting. 3100Sstevel@tonic-gate */ 3110Sstevel@tonic-gate ASSERT(!(uap->flags & MS_REMOUNT)); 3120Sstevel@tonic-gate 3130Sstevel@tonic-gate mutex_enter(&mvp->v_lock); 3140Sstevel@tonic-gate vnode_busy = (mvp->v_count != 1) || (mvp->v_flag & VROOT); 3150Sstevel@tonic-gate mutex_exit(&mvp->v_lock); 3160Sstevel@tonic-gate 3170Sstevel@tonic-gate if ((uap->flags & MS_OVERLAY) == 0 && vnode_busy) { 3180Sstevel@tonic-gate return (EBUSY); 3190Sstevel@tonic-gate } 3200Sstevel@tonic-gate 3210Sstevel@tonic-gate /* 3220Sstevel@tonic-gate * Check for the options that actually affect things 3230Sstevel@tonic-gate * at our level. 3240Sstevel@tonic-gate */ 3250Sstevel@tonic-gate flags = 0; 3260Sstevel@tonic-gate if (vfs_optionisset(vfsp, HOPT_NOMAPLCASE, NULL)) 3274866Sfrankho flags |= HSFSMNT_NOMAPLCASE; 3280Sstevel@tonic-gate if (vfs_optionisset(vfsp, HOPT_NOTRAILDOT, NULL)) 3294866Sfrankho flags |= HSFSMNT_NOTRAILDOT; 3300Sstevel@tonic-gate if (vfs_optionisset(vfsp, HOPT_NRR, NULL)) 3314866Sfrankho flags |= HSFSMNT_NORRIP; 3322900Sfrankho if (vfs_optionisset(vfsp, HOPT_NOJOLIET, NULL)) 3334866Sfrankho flags |= HSFSMNT_NOJOLIET; 3342900Sfrankho if (vfs_optionisset(vfsp, HOPT_JOLIETLONG, NULL)) 3354866Sfrankho flags |= HSFSMNT_JOLIETLONG; 3362900Sfrankho if (vfs_optionisset(vfsp, HOPT_NOVERS2, NULL)) 3374866Sfrankho flags |= HSFSMNT_NOVERS2; 3380Sstevel@tonic-gate 3390Sstevel@tonic-gate error = pn_get(uap->dir, (uap->flags & MS_SYSSPACE) ? 3400Sstevel@tonic-gate UIO_SYSSPACE : UIO_USERSPACE, &dpn); 3410Sstevel@tonic-gate if (error) 3420Sstevel@tonic-gate return (error); 3430Sstevel@tonic-gate 3444866Sfrankho error = hs_getmdev(vfsp, uap->spec, uap->flags, &dev, &mode, cr); 3454866Sfrankho if (error != 0) { 3460Sstevel@tonic-gate pn_free(&dpn); 3470Sstevel@tonic-gate return (error); 3480Sstevel@tonic-gate } 3490Sstevel@tonic-gate 3500Sstevel@tonic-gate /* 3510Sstevel@tonic-gate * If the device is a tape, return error 3520Sstevel@tonic-gate */ 3530Sstevel@tonic-gate if ((BDEVFLAG(dev) & D_TAPE) == D_TAPE) { 3540Sstevel@tonic-gate pn_free(&dpn); 3550Sstevel@tonic-gate return (ENOTBLK); 3560Sstevel@tonic-gate } 3570Sstevel@tonic-gate 3580Sstevel@tonic-gate /* 3590Sstevel@tonic-gate * Mount the filesystem. 3600Sstevel@tonic-gate */ 3610Sstevel@tonic-gate error = hs_mountfs(vfsp, dev, dpn.pn_path, mode, flags, cr, 0); 3620Sstevel@tonic-gate pn_free(&dpn); 3630Sstevel@tonic-gate return (error); 3640Sstevel@tonic-gate } 3650Sstevel@tonic-gate 3660Sstevel@tonic-gate /*ARGSUSED*/ 3670Sstevel@tonic-gate static int 3680Sstevel@tonic-gate hsfs_unmount( 3690Sstevel@tonic-gate struct vfs *vfsp, 3700Sstevel@tonic-gate int flag, 3710Sstevel@tonic-gate struct cred *cr) 3720Sstevel@tonic-gate { 3730Sstevel@tonic-gate struct hsfs **tspp; 3740Sstevel@tonic-gate struct hsfs *fsp; 3750Sstevel@tonic-gate 3760Sstevel@tonic-gate if (secpolicy_fs_unmount(cr, vfsp) != 0) 3770Sstevel@tonic-gate return (EPERM); 3780Sstevel@tonic-gate 3790Sstevel@tonic-gate /* 3800Sstevel@tonic-gate * forced unmount is not supported by this file system 3810Sstevel@tonic-gate * and thus, ENOTSUP is being returned. 3820Sstevel@tonic-gate */ 3830Sstevel@tonic-gate if (flag & MS_FORCE) 3840Sstevel@tonic-gate return (ENOTSUP); 3850Sstevel@tonic-gate 3860Sstevel@tonic-gate fsp = VFS_TO_HSFS(vfsp); 3870Sstevel@tonic-gate 3880Sstevel@tonic-gate if (fsp->hsfs_rootvp->v_count != 1) 3890Sstevel@tonic-gate return (EBUSY); 3900Sstevel@tonic-gate 3910Sstevel@tonic-gate /* destroy all old pages and hsnodes for this vfs */ 3920Sstevel@tonic-gate if (hs_synchash(vfsp)) 3930Sstevel@tonic-gate return (EBUSY); 3940Sstevel@tonic-gate 3950Sstevel@tonic-gate mutex_enter(&hs_mounttab_lock); 3960Sstevel@tonic-gate for (tspp = &hs_mounttab; *tspp != NULL; tspp = &(*tspp)->hsfs_next) { 3970Sstevel@tonic-gate if (*tspp == fsp) 3980Sstevel@tonic-gate break; 3990Sstevel@tonic-gate } 4000Sstevel@tonic-gate if (*tspp == NULL) { 4010Sstevel@tonic-gate mutex_exit(&hs_mounttab_lock); 4020Sstevel@tonic-gate panic("hsfs_unmount: vfs not mounted?"); 4030Sstevel@tonic-gate /*NOTREACHED*/ 4040Sstevel@tonic-gate } 4050Sstevel@tonic-gate 4060Sstevel@tonic-gate *tspp = fsp->hsfs_next; 4070Sstevel@tonic-gate 4080Sstevel@tonic-gate mutex_exit(&hs_mounttab_lock); 4090Sstevel@tonic-gate 4105312Smg147109 hsfs_fini_kstats(fsp); 4115331Samw (void) VOP_CLOSE(fsp->hsfs_devvp, FREAD, 1, (offset_t)0, cr, NULL); 4120Sstevel@tonic-gate VN_RELE(fsp->hsfs_devvp); 4130Sstevel@tonic-gate /* free path table space */ 4140Sstevel@tonic-gate if (fsp->hsfs_ptbl != NULL) 4154866Sfrankho kmem_free(fsp->hsfs_ptbl, (size_t)fsp->hsfs_vol.ptbl_len); 4160Sstevel@tonic-gate /* free path table index table */ 4170Sstevel@tonic-gate if (fsp->hsfs_ptbl_idx != NULL) 4180Sstevel@tonic-gate kmem_free(fsp->hsfs_ptbl_idx, (size_t) 4194866Sfrankho (fsp->hsfs_ptbl_idx_size * sizeof (struct ptable_idx))); 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate /* free "mounted on" pathame */ 4220Sstevel@tonic-gate if (fsp->hsfs_fsmnt != NULL) 4230Sstevel@tonic-gate kmem_free(fsp->hsfs_fsmnt, strlen(fsp->hsfs_fsmnt) + 1); 4240Sstevel@tonic-gate 4255312Smg147109 hsched_fini(fsp->hqueue); 4265312Smg147109 kmem_free(fsp->hqueue, sizeof (struct hsfs_queue)); 4275312Smg147109 4280Sstevel@tonic-gate mutex_destroy(&fsp->hsfs_free_lock); 4290Sstevel@tonic-gate rw_destroy(&fsp->hsfs_hash_lock); 4300Sstevel@tonic-gate 4310Sstevel@tonic-gate kmem_free(fsp, sizeof (*fsp)); 4320Sstevel@tonic-gate return (0); 4330Sstevel@tonic-gate } 4340Sstevel@tonic-gate 4350Sstevel@tonic-gate /*ARGSUSED*/ 4360Sstevel@tonic-gate static int 4370Sstevel@tonic-gate hsfs_root(struct vfs *vfsp, struct vnode **vpp) 4380Sstevel@tonic-gate { 4390Sstevel@tonic-gate *vpp = (VFS_TO_HSFS(vfsp))->hsfs_rootvp; 4400Sstevel@tonic-gate VN_HOLD(*vpp); 4410Sstevel@tonic-gate return (0); 4420Sstevel@tonic-gate } 4430Sstevel@tonic-gate 4440Sstevel@tonic-gate /*ARGSUSED*/ 4450Sstevel@tonic-gate static int 4460Sstevel@tonic-gate hsfs_statvfs(struct vfs *vfsp, struct statvfs64 *sbp) 4470Sstevel@tonic-gate { 4480Sstevel@tonic-gate struct hsfs *fsp; 4490Sstevel@tonic-gate dev32_t d32; 4500Sstevel@tonic-gate 4510Sstevel@tonic-gate fsp = VFS_TO_HSFS(vfsp); 4520Sstevel@tonic-gate if (fsp->hsfs_magic != HSFS_MAGIC) 4530Sstevel@tonic-gate return (EINVAL); 4540Sstevel@tonic-gate bzero(sbp, sizeof (*sbp)); 4550Sstevel@tonic-gate sbp->f_bsize = vfsp->vfs_bsize; 4560Sstevel@tonic-gate sbp->f_frsize = sbp->f_bsize; /* no fragment, same as block size */ 4570Sstevel@tonic-gate sbp->f_blocks = (fsblkcnt64_t)fsp->hsfs_vol.vol_size; 4580Sstevel@tonic-gate 4590Sstevel@tonic-gate sbp->f_bfree = (fsblkcnt64_t)0; 4600Sstevel@tonic-gate sbp->f_bavail = (fsblkcnt64_t)0; 4610Sstevel@tonic-gate sbp->f_files = (fsfilcnt64_t)-1; 4620Sstevel@tonic-gate sbp->f_ffree = (fsfilcnt64_t)0; 4630Sstevel@tonic-gate sbp->f_favail = (fsfilcnt64_t)0; 4640Sstevel@tonic-gate (void) cmpldev(&d32, vfsp->vfs_dev); 4650Sstevel@tonic-gate sbp->f_fsid = d32; 4660Sstevel@tonic-gate (void) strcpy(sbp->f_basetype, vfssw[vfsp->vfs_fstype].vsw_name); 4670Sstevel@tonic-gate sbp->f_flag = vf_to_stf(vfsp->vfs_flag); 4680Sstevel@tonic-gate sbp->f_namemax = fsp->hsfs_namemax; 4690Sstevel@tonic-gate (void) strcpy(sbp->f_fstr, fsp->hsfs_vol.vol_id); 4700Sstevel@tonic-gate 4710Sstevel@tonic-gate return (0); 4720Sstevel@tonic-gate } 4730Sstevel@tonic-gate 4740Sstevel@tonic-gate /* 4750Sstevel@tonic-gate * Previously nodeid was declared as uint32_t. This has been changed 4760Sstevel@tonic-gate * to conform better with the ISO9660 standard. The standard states that 4770Sstevel@tonic-gate * a LBN can be a 32 bit number, as the MAKE_NODEID macro shifts this 4780Sstevel@tonic-gate * LBN 11 places left (LBN_TO_BYTE) and then shifts the result 5 right 4790Sstevel@tonic-gate * (divide by 32) we are left with the potential of an overflow if 4800Sstevel@tonic-gate * confined to a 32 bit value. 4810Sstevel@tonic-gate */ 4820Sstevel@tonic-gate 4830Sstevel@tonic-gate static int 4840Sstevel@tonic-gate hsfs_vget(struct vfs *vfsp, struct vnode **vpp, struct fid *fidp) 4850Sstevel@tonic-gate { 4860Sstevel@tonic-gate struct hsfid *fid; 4870Sstevel@tonic-gate struct hsfs *fsp; 4880Sstevel@tonic-gate ino64_t nodeid; 4890Sstevel@tonic-gate int error; 4900Sstevel@tonic-gate 4910Sstevel@tonic-gate fsp = (struct hsfs *)VFS_TO_HSFS(vfsp); 4920Sstevel@tonic-gate fid = (struct hsfid *)fidp; 4930Sstevel@tonic-gate 4940Sstevel@tonic-gate /* 4950Sstevel@tonic-gate * Look for vnode on hashlist. 4960Sstevel@tonic-gate * If found, it's now active and the refcnt was incremented. 4970Sstevel@tonic-gate */ 4980Sstevel@tonic-gate 4990Sstevel@tonic-gate rw_enter(&fsp->hsfs_hash_lock, RW_READER); 5000Sstevel@tonic-gate 5014866Sfrankho nodeid = fid->hf_ino; 5020Sstevel@tonic-gate 5034866Sfrankho if ((*vpp = hs_findhash(nodeid, fid->hf_dir_lbn, 5044866Sfrankho (uint_t)fid->hf_dir_off, vfsp)) == NULL) { 5050Sstevel@tonic-gate /* 5060Sstevel@tonic-gate * Not in cache, so we need to remake it. 5070Sstevel@tonic-gate * hs_remakenode() will read the directory entry 5080Sstevel@tonic-gate * and then check again to see if anyone else has 5090Sstevel@tonic-gate * put it in the cache. 5100Sstevel@tonic-gate */ 5110Sstevel@tonic-gate rw_exit(&fsp->hsfs_hash_lock); 5120Sstevel@tonic-gate error = hs_remakenode(fid->hf_dir_lbn, (uint_t)fid->hf_dir_off, 5130Sstevel@tonic-gate vfsp, vpp); 5140Sstevel@tonic-gate return (error); 5150Sstevel@tonic-gate } 5160Sstevel@tonic-gate rw_exit(&fsp->hsfs_hash_lock); 5170Sstevel@tonic-gate return (0); 5180Sstevel@tonic-gate } 5190Sstevel@tonic-gate 5200Sstevel@tonic-gate 5210Sstevel@tonic-gate #define CHECKSUM_SIZE (64 * 1024) 5220Sstevel@tonic-gate 5230Sstevel@tonic-gate /* 5240Sstevel@tonic-gate * Compute a CD-ROM fsid by checksumming the first 64K of data on the CD 5250Sstevel@tonic-gate * We use the 'fsp' argument to determine the location of the root 5260Sstevel@tonic-gate * directory entry, and we start reading from there. 5270Sstevel@tonic-gate */ 5280Sstevel@tonic-gate static int 5290Sstevel@tonic-gate compute_cdrom_id(struct hsfs *fsp, vnode_t *devvp) 5300Sstevel@tonic-gate { 5310Sstevel@tonic-gate uint_t secno; 5320Sstevel@tonic-gate struct hs_volume *hsvp = &fsp->hsfs_vol; 5330Sstevel@tonic-gate struct buf *bp; 5340Sstevel@tonic-gate int error; 5350Sstevel@tonic-gate int fsid; 5360Sstevel@tonic-gate 5370Sstevel@tonic-gate secno = hsvp->root_dir.ext_lbn >> hsvp->lbn_secshift; 538494Sfrankho bp = bread(devvp->v_rdev, secno * 4, CHECKSUM_SIZE); 5390Sstevel@tonic-gate error = geterror(bp); 540494Sfrankho 541494Sfrankho /* 542494Sfrankho * An error on read or a partial read means we asked 543494Sfrankho * for a nonexistant/corrupted piece of the device 544494Sfrankho * (including past-the-end of the media). Don't 545494Sfrankho * try to use the checksumming method then. 546494Sfrankho */ 547494Sfrankho if (!error && bp->b_bcount == CHECKSUM_SIZE) { 5480Sstevel@tonic-gate int *ibuf = (int *)bp->b_un.b_addr; 5490Sstevel@tonic-gate int i; 5500Sstevel@tonic-gate 5510Sstevel@tonic-gate fsid = 0; 5520Sstevel@tonic-gate 553494Sfrankho for (i = 0; i < CHECKSUM_SIZE / sizeof (int); i++) 5540Sstevel@tonic-gate fsid ^= ibuf[ i ]; 555494Sfrankho } else { 556494Sfrankho /* 557494Sfrankho * Fallback - use creation date 558494Sfrankho */ 5590Sstevel@tonic-gate fsid = hsvp->cre_date.tv_sec; 560494Sfrankho } 5610Sstevel@tonic-gate 5620Sstevel@tonic-gate brelse(bp); 5630Sstevel@tonic-gate 5640Sstevel@tonic-gate return (fsid); 5650Sstevel@tonic-gate } 5660Sstevel@tonic-gate 5670Sstevel@tonic-gate 5680Sstevel@tonic-gate /*ARGSUSED*/ 5690Sstevel@tonic-gate static int 5700Sstevel@tonic-gate hs_mountfs( 5710Sstevel@tonic-gate struct vfs *vfsp, 5720Sstevel@tonic-gate dev_t dev, 5730Sstevel@tonic-gate char *path, 5740Sstevel@tonic-gate mode_t mode, 5750Sstevel@tonic-gate int mount_flags, 5760Sstevel@tonic-gate struct cred *cr, 5770Sstevel@tonic-gate int isroot) 5780Sstevel@tonic-gate { 5790Sstevel@tonic-gate struct vnode *devvp; 5800Sstevel@tonic-gate struct hsfs *tsp; 5810Sstevel@tonic-gate struct hsfs *fsp = NULL; 5820Sstevel@tonic-gate struct vattr vap; 5830Sstevel@tonic-gate struct hsnode *hp; 5840Sstevel@tonic-gate int error; 5850Sstevel@tonic-gate struct timeval tv; 5860Sstevel@tonic-gate int fsid; 5872900Sfrankho int use_rrip; 5882900Sfrankho int use_vers2; 5892900Sfrankho int use_joliet; 5902900Sfrankho int has_rrip = 0; 5912900Sfrankho int has_vers2 = 0; 5922900Sfrankho int has_joliet = 0; 5932900Sfrankho int force_rrip_off; 5942900Sfrankho int force_vers2_off; 5952900Sfrankho int force_joliet_off; 5962900Sfrankho size_t pathbufsz = strlen(path) + 1; 5972900Sfrankho int redo_rootvp; 5982900Sfrankho 5992900Sfrankho struct hs_volume *svp; /* Supplemental VD for ISO-9660:1999 */ 6002900Sfrankho struct hs_volume *jvp; /* Joliet VD */ 6012900Sfrankho 6022900Sfrankho /* 6032900Sfrankho * The rules for which extension will be used are: 6042900Sfrankho * 1. No specific mount options given: 6052900Sfrankho * - use rrip if available 6062900Sfrankho * - use ISO9660:1999 if available 6072900Sfrankho * - use joliet if available. 6082900Sfrankho * 2. rrip/ISO9660:1999/joliet explicitly disabled via mount option: 6092900Sfrankho * - use next "lower" extension 6102900Sfrankho * 3. joliet/ISO9660:1999/rrip explicitly requested via mount option: 6112900Sfrankho * - disable rrip support even if available 6122900Sfrankho * - disable IOS9660:1999 support even if available 6132900Sfrankho * 6142900Sfrankho * We need to adjust these flags as we discover the extensions 6152900Sfrankho * present. See below. These are just the starting values. 6162900Sfrankho */ 6172900Sfrankho use_rrip = (mount_flags & HSFSMNT_NORRIP) == 0; 6182900Sfrankho use_vers2 = (mount_flags & HSFSMNT_NOVERS2) == 0; 6192900Sfrankho use_joliet = (mount_flags & HSFSMNT_NOJOLIET) == 0; 6200Sstevel@tonic-gate 6210Sstevel@tonic-gate /* 6220Sstevel@tonic-gate * Open the device 6230Sstevel@tonic-gate */ 6240Sstevel@tonic-gate devvp = makespecvp(dev, VBLK); 6250Sstevel@tonic-gate ASSERT(devvp != 0); 6260Sstevel@tonic-gate 6270Sstevel@tonic-gate /* 6280Sstevel@tonic-gate * Open the target device (file) for read only. 6290Sstevel@tonic-gate */ 6305331Samw if (error = VOP_OPEN(&devvp, FREAD, cr, NULL)) { 6310Sstevel@tonic-gate VN_RELE(devvp); 6320Sstevel@tonic-gate return (error); 6330Sstevel@tonic-gate } 6340Sstevel@tonic-gate 6350Sstevel@tonic-gate /* 6360Sstevel@tonic-gate * Refuse to go any further if this 6370Sstevel@tonic-gate * device is being used for swapping 6380Sstevel@tonic-gate */ 6390Sstevel@tonic-gate if (IS_SWAPVP(common_specvp(devvp))) { 6400Sstevel@tonic-gate error = EBUSY; 6410Sstevel@tonic-gate goto cleanup; 6420Sstevel@tonic-gate } 6430Sstevel@tonic-gate 6440Sstevel@tonic-gate vap.va_mask = AT_SIZE; 6455331Samw if ((error = VOP_GETATTR(devvp, &vap, ATTR_COMM, cr, NULL)) != 0) { 6460Sstevel@tonic-gate cmn_err(CE_NOTE, "Cannot get attributes of the CD-ROM driver"); 6470Sstevel@tonic-gate goto cleanup; 6480Sstevel@tonic-gate } 6490Sstevel@tonic-gate 6500Sstevel@tonic-gate /* 6510Sstevel@tonic-gate * Make sure we have a nonzero size partition. 6520Sstevel@tonic-gate * The current version of the SD driver will *not* fail the open 6530Sstevel@tonic-gate * of such a partition so we have to check for it here. 6540Sstevel@tonic-gate */ 6550Sstevel@tonic-gate if (vap.va_size == 0) { 6560Sstevel@tonic-gate error = ENXIO; 6570Sstevel@tonic-gate goto cleanup; 6580Sstevel@tonic-gate } 6590Sstevel@tonic-gate 6600Sstevel@tonic-gate /* 6610Sstevel@tonic-gate * Init a new hsfs structure. 6620Sstevel@tonic-gate */ 6630Sstevel@tonic-gate fsp = kmem_zalloc(sizeof (*fsp), KM_SLEEP); 6642900Sfrankho svp = kmem_zalloc(sizeof (*svp), KM_SLEEP); 6652900Sfrankho jvp = kmem_zalloc(sizeof (*jvp), KM_SLEEP); 6660Sstevel@tonic-gate 6670Sstevel@tonic-gate /* hardwire perms, uid, gid */ 6680Sstevel@tonic-gate fsp->hsfs_vol.vol_uid = hsfs_default_uid; 6690Sstevel@tonic-gate fsp->hsfs_vol.vol_gid = hsfs_default_gid; 6700Sstevel@tonic-gate fsp->hsfs_vol.vol_prot = hsfs_default_mode; 6712900Sfrankho svp->vol_uid = hsfs_default_uid; 6722900Sfrankho svp->vol_gid = hsfs_default_gid; 6732900Sfrankho svp->vol_prot = hsfs_default_mode; 6742900Sfrankho jvp->vol_uid = hsfs_default_uid; 6752900Sfrankho jvp->vol_gid = hsfs_default_gid; 6762900Sfrankho jvp->vol_prot = hsfs_default_mode; 6770Sstevel@tonic-gate 6780Sstevel@tonic-gate /* 6790Sstevel@tonic-gate * Look for a Standard File Structure Volume Descriptor, 6800Sstevel@tonic-gate * of which there must be at least one. 6810Sstevel@tonic-gate * If found, check for volume size consistency. 6822900Sfrankho * 6832900Sfrankho * If svp->lbn_size is != 0, we did find a ISO-9660:1999 SVD 6842900Sfrankho * If jvp->lbn_size is != 0, we did find a Joliet SVD. 6850Sstevel@tonic-gate */ 6862900Sfrankho fsp->hsfs_namemax = ISO_FILE_NAMELEN; 6872900Sfrankho fsp->hsfs_namelen = ISO_FILE_NAMELEN; 6882900Sfrankho error = hs_findisovol(fsp, devvp, &fsp->hsfs_vol, svp, jvp); 6891025Sfrankho if (error == EINVAL) /* no iso 9660 - try high sierra ... */ 6901025Sfrankho error = hs_findhsvol(fsp, devvp, &fsp->hsfs_vol); 6910Sstevel@tonic-gate 6920Sstevel@tonic-gate if (error) 6930Sstevel@tonic-gate goto cleanup; 6940Sstevel@tonic-gate 6952900Sfrankho DTRACE_PROBE4(findvol, 6962900Sfrankho struct hsfs *, fsp, 6972900Sfrankho struct hs_volume *, &fsp->hsfs_vol, 6982900Sfrankho struct hs_volume *, svp, 6992900Sfrankho struct hs_volume *, jvp); 7002900Sfrankho 7010Sstevel@tonic-gate /* 7020Sstevel@tonic-gate * Generate a file system ID from the CD-ROM, 7030Sstevel@tonic-gate * and check it for uniqueness. 7040Sstevel@tonic-gate * 7050Sstevel@tonic-gate * What we are aiming for is some chance of integrity 7060Sstevel@tonic-gate * across disk change. That is, if a client has an fhandle, 7070Sstevel@tonic-gate * it will be valid as long as the same disk is mounted. 7080Sstevel@tonic-gate */ 7090Sstevel@tonic-gate fsid = compute_cdrom_id(fsp, devvp); 7100Sstevel@tonic-gate 7110Sstevel@tonic-gate mutex_enter(&hs_mounttab_lock); 7120Sstevel@tonic-gate 7130Sstevel@tonic-gate if (fsid == 0 || fsid == -1) { 7140Sstevel@tonic-gate uniqtime(&tv); 7150Sstevel@tonic-gate fsid = tv.tv_sec; 7160Sstevel@tonic-gate } else /* make sure that the fsid is unique */ 7170Sstevel@tonic-gate for (tsp = hs_mounttab; tsp != NULL; tsp = tsp->hsfs_next) { 7180Sstevel@tonic-gate if (fsid == tsp->hsfs_vfs->vfs_fsid.val[0]) { 7190Sstevel@tonic-gate uniqtime(&tv); 7200Sstevel@tonic-gate fsid = tv.tv_sec; 7210Sstevel@tonic-gate break; 7220Sstevel@tonic-gate } 7230Sstevel@tonic-gate } 7240Sstevel@tonic-gate 7250Sstevel@tonic-gate fsp->hsfs_next = hs_mounttab; 7260Sstevel@tonic-gate hs_mounttab = fsp; 7270Sstevel@tonic-gate 7280Sstevel@tonic-gate fsp->hsfs_devvp = devvp; 7290Sstevel@tonic-gate fsp->hsfs_vfs = vfsp; 7302900Sfrankho fsp->hsfs_fsmnt = kmem_alloc(pathbufsz, KM_SLEEP); 7312900Sfrankho (void) strlcpy(fsp->hsfs_fsmnt, path, pathbufsz); 7320Sstevel@tonic-gate 7330Sstevel@tonic-gate mutex_init(&fsp->hsfs_free_lock, NULL, MUTEX_DEFAULT, NULL); 7340Sstevel@tonic-gate rw_init(&fsp->hsfs_hash_lock, NULL, RW_DEFAULT, NULL); 7350Sstevel@tonic-gate 7360Sstevel@tonic-gate vfsp->vfs_data = (caddr_t)fsp; 7370Sstevel@tonic-gate vfsp->vfs_dev = dev; 7380Sstevel@tonic-gate vfsp->vfs_fstype = hsfsfstype; 7390Sstevel@tonic-gate vfsp->vfs_bsize = fsp->hsfs_vol.lbn_size; /* %% */ 7400Sstevel@tonic-gate vfsp->vfs_fsid.val[0] = fsid; 7410Sstevel@tonic-gate vfsp->vfs_fsid.val[1] = hsfsfstype; 7420Sstevel@tonic-gate 7432900Sfrankho if (!hs_getrootvp(vfsp, fsp, pathbufsz)) { 7442900Sfrankho DTRACE_PROBE1(rootvp__failed, struct hsfs *, fsp); 7452900Sfrankho error = EINVAL; 7462900Sfrankho goto cleanup; 7472900Sfrankho } 7482900Sfrankho DTRACE_PROBE1(rootvp, struct hsfs *, fsp); 7492900Sfrankho 7502900Sfrankho /* 7512900Sfrankho * Attempt to discover a RR extension. 7522900Sfrankho */ 7532900Sfrankho if (use_rrip) { 7542900Sfrankho hp = VTOH(fsp->hsfs_rootvp); 7552900Sfrankho hs_check_root_dirent(fsp->hsfs_rootvp, &(hp->hs_dirent)); 7562900Sfrankho } 7572900Sfrankho 7582900Sfrankho has_rrip = IS_RRIP_IMPLEMENTED(fsp); 7592900Sfrankho has_vers2 = (svp->lbn_size != 0); 7602900Sfrankho has_joliet = (jvp->lbn_size != 0); 7612900Sfrankho 7622900Sfrankho DTRACE_PROBE4(voltype__suggested, struct hsfs *, fsp, 7632900Sfrankho int, use_rrip, int, use_vers2, int, use_joliet); 7642900Sfrankho 7652900Sfrankho DTRACE_PROBE4(voltype__actual, struct hsfs *, fsp, 7662900Sfrankho int, has_rrip, int, has_vers2, int, has_joliet); 7672900Sfrankho 7682900Sfrankho DTRACE_PROBE4(findvol, 7692900Sfrankho struct hsfs *, fsp, 7702900Sfrankho struct hs_volume *, &fsp->hsfs_vol, 7712900Sfrankho struct hs_volume *, svp, 7722900Sfrankho struct hs_volume *, jvp); 7732900Sfrankho 7742900Sfrankho force_rrip_off = !use_rrip || 7752900Sfrankho (vfs_optionisset(vfsp, HOPT_JOLIET, NULL) && has_joliet) || 7762900Sfrankho (vfs_optionisset(vfsp, HOPT_VERS2, NULL) && has_vers2); 7772900Sfrankho 7782900Sfrankho force_vers2_off = !use_vers2 || 7792900Sfrankho (vfs_optionisset(vfsp, HOPT_JOLIET, NULL) && has_joliet); 7802900Sfrankho 7812900Sfrankho force_joliet_off = !use_joliet; 7822900Sfrankho 7832900Sfrankho DTRACE_PROBE4(voltype__force_off, struct hsfs *, fsp, 7842900Sfrankho int, force_rrip_off, int, force_vers2_off, int, force_joliet_off); 7852900Sfrankho 7862900Sfrankho /* 7872900Sfrankho * At the moment, we have references of all three possible 7882900Sfrankho * extensions (RR, ISO9660:1999/v2 and Joliet) if present. 7892900Sfrankho * 7902900Sfrankho * The "active" volume descriptor is RRIP (or ISO9660:1988). 7912900Sfrankho * We now switch to the user-requested one. 7922900Sfrankho */ 7932900Sfrankho redo_rootvp = 0; 7942900Sfrankho 7952900Sfrankho if (force_rrip_off || !has_rrip) { 7962900Sfrankho if (has_vers2 && !force_vers2_off) { 7972900Sfrankho VN_RELE(fsp->hsfs_rootvp); 7982900Sfrankho bcopy(svp, &fsp->hsfs_vol, sizeof (struct hs_volume)); 7992900Sfrankho fsp->hsfs_vol_type = HS_VOL_TYPE_ISO_V2; 8002900Sfrankho vfsp->vfs_bsize = fsp->hsfs_vol.lbn_size; 8012900Sfrankho redo_rootvp = 1; 8022900Sfrankho has_joliet = 0; 8032900Sfrankho } else if (has_joliet && !force_joliet_off) { 8042900Sfrankho VN_RELE(fsp->hsfs_rootvp); 8052900Sfrankho bcopy(jvp, &fsp->hsfs_vol, sizeof (struct hs_volume)); 8062900Sfrankho fsp->hsfs_vol_type = HS_VOL_TYPE_JOLIET; 8072900Sfrankho vfsp->vfs_bsize = fsp->hsfs_vol.lbn_size; 8082900Sfrankho redo_rootvp = 1; 8092900Sfrankho has_vers2 = 0; 8102900Sfrankho } 8112900Sfrankho } 8122900Sfrankho 8132900Sfrankho if (redo_rootvp) { 8142900Sfrankho /* 8152900Sfrankho * Make sure not to use Rock Ridge. 8162900Sfrankho */ 8172900Sfrankho UNSET_IMPL_BIT(fsp, RRIP_BIT); 8182900Sfrankho UNSET_SUSP_BIT(fsp); 8192900Sfrankho has_rrip = 0; 8202900Sfrankho 8212900Sfrankho if (!hs_getrootvp(vfsp, fsp, pathbufsz)) { 8222900Sfrankho DTRACE_PROBE1(rootvp__failed, struct hsfs *, fsp); 8232900Sfrankho error = EINVAL; 8242900Sfrankho goto cleanup; 8252900Sfrankho } 8262900Sfrankho DTRACE_PROBE1(rootvp, struct hsfs *, fsp); 8272900Sfrankho } 8282900Sfrankho if (IS_RRIP_IMPLEMENTED(fsp)) { 8292900Sfrankho has_vers2 = 0; 8302900Sfrankho has_joliet = 0; 8312900Sfrankho } 8322900Sfrankho if (force_vers2_off) 8332900Sfrankho has_vers2 = 0; 8342900Sfrankho if (force_joliet_off) 8352900Sfrankho has_joliet = 0; 8362900Sfrankho DTRACE_PROBE4(voltype__taken, struct hsfs *, fsp, 8372900Sfrankho int, has_rrip, int, has_vers2, int, has_joliet); 8382900Sfrankho 8392900Sfrankho /* 8402900Sfrankho * mark root node as VROOT 8412900Sfrankho */ 8422900Sfrankho fsp->hsfs_rootvp->v_flag |= VROOT; 8432900Sfrankho 8442900Sfrankho /* Here we take care of some special case stuff for mountroot */ 8452900Sfrankho if (isroot) { 8462900Sfrankho fsp->hsfs_rootvp->v_rdev = devvp->v_rdev; 8472900Sfrankho rootvp = fsp->hsfs_rootvp; 8482900Sfrankho } 8492900Sfrankho 8502900Sfrankho if (IS_RRIP_IMPLEMENTED(fsp)) { 8512900Sfrankho /* 8522900Sfrankho * if RRIP, don't copy NOMAPLCASE or NOTRAILDOT to hsfs_flags 8532900Sfrankho */ 8542900Sfrankho mount_flags &= ~(HSFSMNT_NOMAPLCASE | HSFSMNT_NOTRAILDOT); 8552900Sfrankho 8562900Sfrankho fsp->hsfs_namemax = RRIP_FILE_NAMELEN; 8572900Sfrankho fsp->hsfs_namelen = RRIP_FILE_NAMELEN; 8582900Sfrankho 8592900Sfrankho ASSERT(vfs_optionisset(vfsp, HOPT_RR, NULL)); 8602900Sfrankho vfs_clearmntopt(vfsp, HOPT_VERS2); 8612900Sfrankho vfs_clearmntopt(vfsp, HOPT_JOLIET); 8622900Sfrankho 8632900Sfrankho } else switch (fsp->hsfs_vol_type) { 8642900Sfrankho 8652900Sfrankho case HS_VOL_TYPE_HS: 8662900Sfrankho case HS_VOL_TYPE_ISO: 8672900Sfrankho default: 8682900Sfrankho /* 8692900Sfrankho * if iso v1, don't allow trailing spaces in iso file names 8702900Sfrankho */ 8712900Sfrankho mount_flags |= HSFSMNT_NOTRAILSPACE; 8722900Sfrankho fsp->hsfs_namemax = ISO_NAMELEN_V2_MAX; 8732900Sfrankho fsp->hsfs_namelen = ISO_FILE_NAMELEN; 8742900Sfrankho vfs_clearmntopt(vfsp, HOPT_RR); 8752900Sfrankho vfs_clearmntopt(vfsp, HOPT_VERS2); 8762900Sfrankho vfs_clearmntopt(vfsp, HOPT_JOLIET); 8772900Sfrankho break; 8782900Sfrankho 8792900Sfrankho case HS_VOL_TYPE_ISO_V2: 8802900Sfrankho /* 8812900Sfrankho * if iso v2, don't copy NOTRAILDOT to hsfs_flags 8822900Sfrankho */ 8832900Sfrankho mount_flags &= ~HSFSMNT_NOTRAILDOT; 8842900Sfrankho mount_flags |= HSFSMNT_NOMAPLCASE | HSFSMNT_NOVERSION; 8852900Sfrankho fsp->hsfs_namemax = ISO_NAMELEN_V2_MAX; 8862900Sfrankho fsp->hsfs_namelen = ISO_NAMELEN_V2; 8872900Sfrankho vfs_setmntopt(vfsp, HOPT_VERS2, NULL, 0); 8882900Sfrankho vfs_clearmntopt(vfsp, HOPT_RR); 8892900Sfrankho vfs_clearmntopt(vfsp, HOPT_JOLIET); 8902900Sfrankho break; 8912900Sfrankho 8922900Sfrankho case HS_VOL_TYPE_JOLIET: 8932900Sfrankho /* 8942900Sfrankho * if Joliet, don't copy NOMAPLCASE or NOTRAILDOT to hsfs_flags 8952900Sfrankho */ 8962900Sfrankho mount_flags &= ~(HSFSMNT_NOMAPLCASE | HSFSMNT_NOTRAILDOT); 8972900Sfrankho mount_flags |= HSFSMNT_NOMAPLCASE; 8982900Sfrankho if (mount_flags & HSFSMNT_JOLIETLONG) 8992900Sfrankho fsp->hsfs_namemax = JOLIET_NAMELEN_MAX*3; /* UTF-8 */ 9002900Sfrankho else 9012900Sfrankho fsp->hsfs_namemax = MAXNAMELEN-1; 9022900Sfrankho fsp->hsfs_namelen = JOLIET_NAMELEN*2; 9032900Sfrankho vfs_setmntopt(vfsp, HOPT_JOLIET, NULL, 0); 9042900Sfrankho vfs_clearmntopt(vfsp, HOPT_RR); 9052900Sfrankho vfs_clearmntopt(vfsp, HOPT_VERS2); 9062900Sfrankho break; 9072900Sfrankho } 9082900Sfrankho 9094866Sfrankho /* 9104866Sfrankho * Add the HSFSMNT_INODE pseudo mount flag to the current mount flags. 9114866Sfrankho */ 9124866Sfrankho fsp->hsfs_flags = mount_flags | (fsp->hsfs_flags & HSFSMNT_INODE); 9132900Sfrankho 9145312Smg147109 /* 9155312Smg147109 * Setup I/O Scheduling structures 9165312Smg147109 */ 9175312Smg147109 if (do_schedio) { 9185312Smg147109 fsp->hqueue = kmem_alloc(sizeof (struct hsfs_queue), KM_SLEEP); 9195312Smg147109 hsched_init(fsp, fsid, &modlinkage); 9205312Smg147109 } 9215312Smg147109 9225312Smg147109 /* 9235312Smg147109 * Setup kstats 9245312Smg147109 */ 9255312Smg147109 hsfs_init_kstats(fsp, fsid); 9265312Smg147109 9272900Sfrankho DTRACE_PROBE1(mount__done, struct hsfs *, fsp); 9282900Sfrankho 9292900Sfrankho /* 9302900Sfrankho * set the magic word 9312900Sfrankho */ 9322900Sfrankho fsp->hsfs_magic = HSFS_MAGIC; 9332900Sfrankho mutex_exit(&hs_mounttab_lock); 9342900Sfrankho 9354866Sfrankho kmem_free(svp, sizeof (*svp)); 9364866Sfrankho kmem_free(jvp, sizeof (*jvp)); 9374866Sfrankho 9382900Sfrankho return (0); 9392900Sfrankho 9402900Sfrankho cleanup: 9415331Samw (void) VOP_CLOSE(devvp, FREAD, 1, (offset_t)0, cr, NULL); 9422900Sfrankho VN_RELE(devvp); 9432900Sfrankho if (fsp) 9442900Sfrankho kmem_free(fsp, sizeof (*fsp)); 9452900Sfrankho if (svp) 9462900Sfrankho kmem_free(svp, sizeof (*svp)); 9472900Sfrankho if (jvp) 9482900Sfrankho kmem_free(jvp, sizeof (*jvp)); 9492900Sfrankho return (error); 9502900Sfrankho } 9512900Sfrankho 9522900Sfrankho /* 9532900Sfrankho * Get the rootvp associated with fsp->hsfs_vol 9542900Sfrankho */ 9552900Sfrankho static int 9562900Sfrankho hs_getrootvp( 9572900Sfrankho struct vfs *vfsp, 9582900Sfrankho struct hsfs *fsp, 9592900Sfrankho size_t pathsize) 9602900Sfrankho { 9612900Sfrankho struct hsnode *hp; 9622900Sfrankho 9632900Sfrankho ASSERT(pathsize == strlen(fsp->hsfs_fsmnt) + 1); 9642900Sfrankho 9650Sstevel@tonic-gate /* 9660Sstevel@tonic-gate * If the root directory does not appear to be 9670Sstevel@tonic-gate * valid, use what it points to as "." instead. 9680Sstevel@tonic-gate * Some Defense Mapping Agency disks are non-conformant 9690Sstevel@tonic-gate * in this way. 9700Sstevel@tonic-gate */ 9710Sstevel@tonic-gate if (!hsfs_valid_dir(&fsp->hsfs_vol.root_dir)) { 9720Sstevel@tonic-gate hs_log_bogus_disk_warning(fsp, HSFS_ERR_BAD_ROOT_DIR, 0); 9730Sstevel@tonic-gate if (hs_remakenode(fsp->hsfs_vol.root_dir.ext_lbn, 9744866Sfrankho (uint_t)0, vfsp, &fsp->hsfs_rootvp)) { 9751025Sfrankho hs_mounttab = hs_mounttab->hsfs_next; 9761025Sfrankho mutex_destroy(&fsp->hsfs_free_lock); 9771025Sfrankho rw_destroy(&fsp->hsfs_hash_lock); 9782900Sfrankho kmem_free(fsp->hsfs_fsmnt, pathsize); 979494Sfrankho mutex_exit(&hs_mounttab_lock); 9802900Sfrankho return (0); 9810Sstevel@tonic-gate } 9820Sstevel@tonic-gate } else { 9830Sstevel@tonic-gate fsp->hsfs_rootvp = hs_makenode(&fsp->hsfs_vol.root_dir, 9844866Sfrankho fsp->hsfs_vol.root_dir.ext_lbn, 0, vfsp); 9850Sstevel@tonic-gate } 9860Sstevel@tonic-gate 9870Sstevel@tonic-gate /* XXX - ignore the path table for now */ 9880Sstevel@tonic-gate fsp->hsfs_ptbl = NULL; 9890Sstevel@tonic-gate hp = VTOH(fsp->hsfs_rootvp); 9900Sstevel@tonic-gate hp->hs_ptbl_idx = NULL; 9910Sstevel@tonic-gate 9922900Sfrankho return (1); 9930Sstevel@tonic-gate } 9940Sstevel@tonic-gate 9950Sstevel@tonic-gate /* 9960Sstevel@tonic-gate * hs_findhsvol() 9970Sstevel@tonic-gate * 9980Sstevel@tonic-gate * Locate the Standard File Structure Volume Descriptor and 9990Sstevel@tonic-gate * parse it into an hs_volume structure. 10000Sstevel@tonic-gate * 10010Sstevel@tonic-gate * XXX - May someday want to look for Coded Character Set FSVD, too. 10020Sstevel@tonic-gate */ 10030Sstevel@tonic-gate static int 10040Sstevel@tonic-gate hs_findhsvol(struct hsfs *fsp, struct vnode *vp, struct hs_volume *hvp) 10050Sstevel@tonic-gate { 10060Sstevel@tonic-gate struct buf *secbp; 10070Sstevel@tonic-gate int i; 10084866Sfrankho int n; 10090Sstevel@tonic-gate uchar_t *volp; 10100Sstevel@tonic-gate int error; 10110Sstevel@tonic-gate uint_t secno; 10120Sstevel@tonic-gate 10130Sstevel@tonic-gate secno = hs_findvoldesc(vp->v_rdev, HS_VOLDESC_SEC); 10140Sstevel@tonic-gate secbp = bread(vp->v_rdev, secno * 4, HS_SECTOR_SIZE); 10150Sstevel@tonic-gate error = geterror(secbp); 10160Sstevel@tonic-gate 10170Sstevel@tonic-gate if (error != 0) { 10180Sstevel@tonic-gate cmn_err(CE_NOTE, "hs_findhsvol: bread: error=(%d)", error); 10190Sstevel@tonic-gate brelse(secbp); 10200Sstevel@tonic-gate return (error); 10210Sstevel@tonic-gate } 10220Sstevel@tonic-gate 10230Sstevel@tonic-gate volp = (uchar_t *)secbp->b_un.b_addr; 10240Sstevel@tonic-gate 10254866Sfrankho /* 10264866Sfrankho * To avoid that we read the whole medium in case that someone prepares 10274866Sfrankho * a malicious "fs image", we read at most 32 blocks. 10284866Sfrankho */ 10294866Sfrankho for (n = 0; n < 32 && 10304866Sfrankho HSV_DESC_TYPE(volp) != VD_EOV; n++) { 10310Sstevel@tonic-gate for (i = 0; i < HSV_ID_STRLEN; i++) 10320Sstevel@tonic-gate if (HSV_STD_ID(volp)[i] != HSV_ID_STRING[i]) 10330Sstevel@tonic-gate goto cantfind; 10340Sstevel@tonic-gate if (HSV_STD_VER(volp) != HSV_ID_VER) 10350Sstevel@tonic-gate goto cantfind; 10360Sstevel@tonic-gate switch (HSV_DESC_TYPE(volp)) { 10370Sstevel@tonic-gate case VD_SFS: 10380Sstevel@tonic-gate /* Standard File Structure */ 10390Sstevel@tonic-gate fsp->hsfs_vol_type = HS_VOL_TYPE_HS; 10400Sstevel@tonic-gate error = hs_parsehsvol(fsp, volp, hvp); 10410Sstevel@tonic-gate brelse(secbp); 10420Sstevel@tonic-gate return (error); 10430Sstevel@tonic-gate 10440Sstevel@tonic-gate case VD_CCFS: 10450Sstevel@tonic-gate /* Coded Character File Structure */ 10460Sstevel@tonic-gate case VD_BOOT: 10470Sstevel@tonic-gate case VD_UNSPEC: 10480Sstevel@tonic-gate case VD_EOV: 10490Sstevel@tonic-gate break; 10500Sstevel@tonic-gate } 10510Sstevel@tonic-gate brelse(secbp); 10520Sstevel@tonic-gate ++secno; 10530Sstevel@tonic-gate secbp = bread(vp->v_rdev, secno * 4, HS_SECTOR_SIZE); 10540Sstevel@tonic-gate 10550Sstevel@tonic-gate error = geterror(secbp); 10560Sstevel@tonic-gate 10570Sstevel@tonic-gate if (error != 0) { 10580Sstevel@tonic-gate cmn_err(CE_NOTE, "hs_findhsvol: bread: error=(%d)", 10594866Sfrankho error); 10600Sstevel@tonic-gate brelse(secbp); 10610Sstevel@tonic-gate return (error); 10620Sstevel@tonic-gate } 10630Sstevel@tonic-gate 10640Sstevel@tonic-gate volp = (uchar_t *)secbp->b_un.b_addr; 10650Sstevel@tonic-gate } 10660Sstevel@tonic-gate cantfind: 10670Sstevel@tonic-gate brelse(secbp); 10680Sstevel@tonic-gate return (EINVAL); 10690Sstevel@tonic-gate } 10700Sstevel@tonic-gate 10710Sstevel@tonic-gate /* 10720Sstevel@tonic-gate * hs_parsehsvol 10730Sstevel@tonic-gate * 10740Sstevel@tonic-gate * Parse the Standard File Structure Volume Descriptor into 10750Sstevel@tonic-gate * an hs_volume structure. We can't just bcopy it into the 10760Sstevel@tonic-gate * structure because of byte-ordering problems. 10770Sstevel@tonic-gate * 10780Sstevel@tonic-gate */ 10790Sstevel@tonic-gate static int 10800Sstevel@tonic-gate hs_parsehsvol(struct hsfs *fsp, uchar_t *volp, struct hs_volume *hvp) 10810Sstevel@tonic-gate { 10820Sstevel@tonic-gate hvp->vol_size = HSV_VOL_SIZE(volp); 10830Sstevel@tonic-gate hvp->lbn_size = HSV_BLK_SIZE(volp); 10840Sstevel@tonic-gate if (hvp->lbn_size == 0) { 10850Sstevel@tonic-gate cmn_err(CE_NOTE, "hs_parsehsvol: logical block size in the " 10864866Sfrankho "SFSVD is zero"); 10870Sstevel@tonic-gate return (EINVAL); 10880Sstevel@tonic-gate } 10890Sstevel@tonic-gate hvp->lbn_shift = ffs((long)hvp->lbn_size) - 1; 10904866Sfrankho hvp->lbn_secshift = 10914866Sfrankho ffs((long)howmany(HS_SECTOR_SIZE, (int)hvp->lbn_size)) - 1; 10920Sstevel@tonic-gate hvp->lbn_maxoffset = hvp->lbn_size - 1; 10930Sstevel@tonic-gate hs_parse_longdate(HSV_cre_date(volp), &hvp->cre_date); 10940Sstevel@tonic-gate hs_parse_longdate(HSV_mod_date(volp), &hvp->mod_date); 10950Sstevel@tonic-gate hvp->file_struct_ver = HSV_FILE_STRUCT_VER(volp); 10960Sstevel@tonic-gate hvp->ptbl_len = HSV_PTBL_SIZE(volp); 10970Sstevel@tonic-gate hvp->vol_set_size = (ushort_t)HSV_SET_SIZE(volp); 10980Sstevel@tonic-gate hvp->vol_set_seq = (ushort_t)HSV_SET_SEQ(volp); 10990Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN) 11000Sstevel@tonic-gate hvp->ptbl_lbn = HSV_PTBL_MAN_LS(volp); 11010Sstevel@tonic-gate #else 11020Sstevel@tonic-gate hvp->ptbl_lbn = HSV_PTBL_MAN_MS(volp); 11030Sstevel@tonic-gate #endif 11042900Sfrankho hs_copylabel(hvp, HSV_VOL_ID(volp), 0); 11050Sstevel@tonic-gate 11060Sstevel@tonic-gate /* 11070Sstevel@tonic-gate * Make sure that lbn_size is a power of two and otherwise valid. 11080Sstevel@tonic-gate */ 11090Sstevel@tonic-gate if (hvp->lbn_size & ~(1 << hvp->lbn_shift)) { 11100Sstevel@tonic-gate cmn_err(CE_NOTE, 11114866Sfrankho "hsfs: %d-byte logical block size not supported", 11124866Sfrankho hvp->lbn_size); 11130Sstevel@tonic-gate return (EINVAL); 11140Sstevel@tonic-gate } 11150Sstevel@tonic-gate return (hs_parsedir(fsp, HSV_ROOT_DIR(volp), &hvp->root_dir, 11164866Sfrankho (char *)NULL, (int *)NULL, HDE_ROOT_DIR_REC_SIZE)); 11170Sstevel@tonic-gate } 11180Sstevel@tonic-gate 11190Sstevel@tonic-gate /* 11200Sstevel@tonic-gate * hs_findisovol() 11210Sstevel@tonic-gate * 11220Sstevel@tonic-gate * Locate the Primary Volume Descriptor 11230Sstevel@tonic-gate * parse it into an hs_volume structure. 11240Sstevel@tonic-gate * 11252900Sfrankho * XXX - Partition not yet done 11262900Sfrankho * 11272900Sfrankho * Except for fsp->hsfs_vol_type, no fsp member may be modified. 11282900Sfrankho * fsp->hsfs_vol is modified indirectly via the *hvp argument. 11290Sstevel@tonic-gate */ 11300Sstevel@tonic-gate static int 11310Sstevel@tonic-gate hs_findisovol(struct hsfs *fsp, struct vnode *vp, 11322900Sfrankho struct hs_volume *hvp, 11332900Sfrankho struct hs_volume *svp, 11342900Sfrankho struct hs_volume *jvp) 11350Sstevel@tonic-gate { 11360Sstevel@tonic-gate struct buf *secbp; 11370Sstevel@tonic-gate int i; 11384866Sfrankho int n; 11390Sstevel@tonic-gate uchar_t *volp; 11400Sstevel@tonic-gate int error; 11410Sstevel@tonic-gate uint_t secno; 11420Sstevel@tonic-gate int foundpvd = 0; 11432900Sfrankho int foundsvd = 0; 11442900Sfrankho int foundjvd = 0; 11454866Sfrankho int pvd_sum = 0; 11460Sstevel@tonic-gate 11470Sstevel@tonic-gate secno = hs_findvoldesc(vp->v_rdev, ISO_VOLDESC_SEC); 11480Sstevel@tonic-gate secbp = bread(vp->v_rdev, secno * 4, ISO_SECTOR_SIZE); 11490Sstevel@tonic-gate error = geterror(secbp); 11500Sstevel@tonic-gate 11510Sstevel@tonic-gate if (error != 0) { 11520Sstevel@tonic-gate cmn_err(CE_NOTE, "hs_findisovol: bread: error=(%d)", error); 11530Sstevel@tonic-gate brelse(secbp); 11540Sstevel@tonic-gate return (error); 11550Sstevel@tonic-gate } 11560Sstevel@tonic-gate 11570Sstevel@tonic-gate volp = (uchar_t *)secbp->b_un.b_addr; 11580Sstevel@tonic-gate 11594866Sfrankho /* 11604866Sfrankho * To avoid that we read the whole medium in case that someone prepares 11614866Sfrankho * a malicious "fs image", we read at most 32 blocks. 11624866Sfrankho */ 11634866Sfrankho for (n = 0; n < 32 && 11644866Sfrankho (enum iso_voldesc_type) ISO_DESC_TYPE(volp) != ISO_VD_EOV; n++) { 11650Sstevel@tonic-gate for (i = 0; i < ISO_ID_STRLEN; i++) 11660Sstevel@tonic-gate if (ISO_STD_ID(volp)[i] != ISO_ID_STRING[i]) 11670Sstevel@tonic-gate goto cantfind; 11680Sstevel@tonic-gate switch (ISO_DESC_TYPE(volp)) { 11690Sstevel@tonic-gate case ISO_VD_PVD: 11700Sstevel@tonic-gate /* Standard File Structure */ 11712900Sfrankho if (ISO_STD_VER(volp) != ISO_ID_VER) 11722900Sfrankho goto cantfind; 11730Sstevel@tonic-gate if (foundpvd != 1) { 11740Sstevel@tonic-gate fsp->hsfs_vol_type = HS_VOL_TYPE_ISO; 11750Sstevel@tonic-gate if (error = hs_parseisovol(fsp, volp, hvp)) { 11760Sstevel@tonic-gate brelse(secbp); 11770Sstevel@tonic-gate return (error); 11780Sstevel@tonic-gate } 11790Sstevel@tonic-gate foundpvd = 1; 11804866Sfrankho for (i = 0; i < ISO_SECTOR_SIZE; i++) 11814866Sfrankho pvd_sum += volp[i]; 11820Sstevel@tonic-gate } 11830Sstevel@tonic-gate break; 11840Sstevel@tonic-gate case ISO_VD_SVD: 11850Sstevel@tonic-gate /* Supplementary Volume Descriptor */ 11862900Sfrankho if (ISO_STD_VER(volp) == ISO_ID_VER2 && 11872900Sfrankho foundsvd != 1) { 11882900Sfrankho fsp->hsfs_vol_type = HS_VOL_TYPE_ISO; 11892900Sfrankho if (error = hs_parseisovol(fsp, volp, svp)) { 11902900Sfrankho brelse(secbp); 11912900Sfrankho return (error); 11922900Sfrankho } 11932900Sfrankho foundsvd = 1; 11942900Sfrankho } 11952900Sfrankho if (hs_joliet_level(volp) >= 1 && foundjvd != 1) { 11962900Sfrankho fsp->hsfs_vol_type = HS_VOL_TYPE_ISO; 11972900Sfrankho if (error = hs_parseisovol(fsp, volp, jvp)) { 11982900Sfrankho brelse(secbp); 11992900Sfrankho return (error); 12002900Sfrankho } 12012900Sfrankho foundjvd = 1; 12022900Sfrankho } 12030Sstevel@tonic-gate break; 12040Sstevel@tonic-gate case ISO_VD_BOOT: 12050Sstevel@tonic-gate break; 12060Sstevel@tonic-gate case ISO_VD_VPD: 12070Sstevel@tonic-gate /* currently cannot handle partition */ 12080Sstevel@tonic-gate break; 12090Sstevel@tonic-gate case VD_EOV: 12100Sstevel@tonic-gate break; 12110Sstevel@tonic-gate } 12120Sstevel@tonic-gate brelse(secbp); 12130Sstevel@tonic-gate ++secno; 12140Sstevel@tonic-gate secbp = bread(vp->v_rdev, secno * 4, HS_SECTOR_SIZE); 12150Sstevel@tonic-gate error = geterror(secbp); 12160Sstevel@tonic-gate 12170Sstevel@tonic-gate if (error != 0) { 12180Sstevel@tonic-gate cmn_err(CE_NOTE, "hs_findisovol: bread: error=(%d)", 12194866Sfrankho error); 12200Sstevel@tonic-gate brelse(secbp); 12210Sstevel@tonic-gate return (error); 12220Sstevel@tonic-gate } 12230Sstevel@tonic-gate 12240Sstevel@tonic-gate volp = (uchar_t *)secbp->b_un.b_addr; 12250Sstevel@tonic-gate } 12264866Sfrankho for (n = 0; n < 16; n++) { 12274866Sfrankho brelse(secbp); 12284866Sfrankho ++secno; 12294866Sfrankho secbp = bread(vp->v_rdev, secno * 4, HS_SECTOR_SIZE); 12304866Sfrankho error = geterror(secbp); 12314866Sfrankho 12324866Sfrankho if (error != 0) { 12334866Sfrankho cmn_err(CE_NOTE, "hs_findisovol: bread: error=(%d)", 12344866Sfrankho error); 12354866Sfrankho brelse(secbp); 12364866Sfrankho return (error); 12374866Sfrankho } 12384866Sfrankho 12394866Sfrankho /* 12404866Sfrankho * Check for the signature from mkisofs that grants that 12414866Sfrankho * the current filesystem allows to use the extent lbn as 12424866Sfrankho * inode number even in pure ISO9660 mode. 12434866Sfrankho */ 12444866Sfrankho volp = (uchar_t *)secbp->b_un.b_addr; 12454866Sfrankho if (strncmp((char *)volp, "MKI ", 4) == 0) { 12464866Sfrankho int sum; 12474866Sfrankho 12484866Sfrankho sum = volp[2045]; 12494866Sfrankho sum *= 256; 12504866Sfrankho sum += volp[2046]; 12514866Sfrankho sum *= 256; 12524866Sfrankho sum += volp[2047]; 12534866Sfrankho if (sum == pvd_sum) 12544866Sfrankho fsp->hsfs_flags |= HSFSMNT_INODE; 12554866Sfrankho break; 12564866Sfrankho } 12574866Sfrankho } 12580Sstevel@tonic-gate if (foundpvd) { 12590Sstevel@tonic-gate brelse(secbp); 12600Sstevel@tonic-gate return (0); 12610Sstevel@tonic-gate } 12620Sstevel@tonic-gate cantfind: 12630Sstevel@tonic-gate brelse(secbp); 12640Sstevel@tonic-gate return (EINVAL); 12650Sstevel@tonic-gate } 12662900Sfrankho 12672900Sfrankho /* 12682900Sfrankho * Return 0 if no Joliet is found 12692900Sfrankho * else return Joliet Level 1..3 12702900Sfrankho */ 12712900Sfrankho static int 12722900Sfrankho hs_joliet_level(uchar_t *volp) 12732900Sfrankho { 12742900Sfrankho if (ISO_std_ver(volp)[0] == ISO_ID_VER && 12752900Sfrankho ISO_svd_esc(volp)[0] == '%' && 12762900Sfrankho ISO_svd_esc(volp)[1] == '/') { 12772900Sfrankho 12782900Sfrankho switch (ISO_svd_esc(volp)[2]) { 12792900Sfrankho 12802900Sfrankho case '@': 12812900Sfrankho return (1); 12822900Sfrankho case 'C': 12832900Sfrankho return (2); 12842900Sfrankho case 'E': 12852900Sfrankho return (3); 12862900Sfrankho } 12872900Sfrankho } 12882900Sfrankho return (0); 12892900Sfrankho } 12902900Sfrankho 12910Sstevel@tonic-gate /* 12920Sstevel@tonic-gate * hs_parseisovol 12930Sstevel@tonic-gate * 12940Sstevel@tonic-gate * Parse the Primary Volume Descriptor into an hs_volume structure. 12950Sstevel@tonic-gate * 12960Sstevel@tonic-gate */ 12970Sstevel@tonic-gate static int 12980Sstevel@tonic-gate hs_parseisovol(struct hsfs *fsp, uchar_t *volp, struct hs_volume *hvp) 12990Sstevel@tonic-gate { 13000Sstevel@tonic-gate hvp->vol_size = ISO_VOL_SIZE(volp); 13010Sstevel@tonic-gate hvp->lbn_size = ISO_BLK_SIZE(volp); 13020Sstevel@tonic-gate if (hvp->lbn_size == 0) { 13030Sstevel@tonic-gate cmn_err(CE_NOTE, "hs_parseisovol: logical block size in the " 13044866Sfrankho "PVD is zero"); 13050Sstevel@tonic-gate return (EINVAL); 13060Sstevel@tonic-gate } 13070Sstevel@tonic-gate hvp->lbn_shift = ffs((long)hvp->lbn_size) - 1; 13084866Sfrankho hvp->lbn_secshift = 13094866Sfrankho ffs((long)howmany(ISO_SECTOR_SIZE, (int)hvp->lbn_size)) - 1; 13100Sstevel@tonic-gate hvp->lbn_maxoffset = hvp->lbn_size - 1; 13110Sstevel@tonic-gate hs_parse_longdate(ISO_cre_date(volp), &hvp->cre_date); 13120Sstevel@tonic-gate hs_parse_longdate(ISO_mod_date(volp), &hvp->mod_date); 13130Sstevel@tonic-gate hvp->file_struct_ver = ISO_FILE_STRUCT_VER(volp); 13140Sstevel@tonic-gate hvp->ptbl_len = ISO_PTBL_SIZE(volp); 13150Sstevel@tonic-gate hvp->vol_set_size = (ushort_t)ISO_SET_SIZE(volp); 13160Sstevel@tonic-gate hvp->vol_set_seq = (ushort_t)ISO_SET_SEQ(volp); 13170Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN) 13180Sstevel@tonic-gate hvp->ptbl_lbn = ISO_PTBL_MAN_LS(volp); 13190Sstevel@tonic-gate #else 13200Sstevel@tonic-gate hvp->ptbl_lbn = ISO_PTBL_MAN_MS(volp); 13210Sstevel@tonic-gate #endif 13222900Sfrankho hs_copylabel(hvp, ISO_VOL_ID(volp), hs_joliet_level(volp) >= 1); 13230Sstevel@tonic-gate 13240Sstevel@tonic-gate /* 13250Sstevel@tonic-gate * Make sure that lbn_size is a power of two and otherwise valid. 13260Sstevel@tonic-gate */ 13270Sstevel@tonic-gate if (hvp->lbn_size & ~(1 << hvp->lbn_shift)) { 13280Sstevel@tonic-gate cmn_err(CE_NOTE, 13294866Sfrankho "hsfs: %d-byte logical block size not supported", 13304866Sfrankho hvp->lbn_size); 13310Sstevel@tonic-gate return (EINVAL); 13320Sstevel@tonic-gate } 13330Sstevel@tonic-gate return (hs_parsedir(fsp, ISO_ROOT_DIR(volp), &hvp->root_dir, 13344866Sfrankho (char *)NULL, (int *)NULL, IDE_ROOT_DIR_REC_SIZE)); 13350Sstevel@tonic-gate } 13360Sstevel@tonic-gate 13370Sstevel@tonic-gate /* 13380Sstevel@tonic-gate * Common code for mount and umount. 13390Sstevel@tonic-gate * Check that the user's argument is a reasonable 13400Sstevel@tonic-gate * thing on which to mount, and return the device number if so. 13410Sstevel@tonic-gate */ 13420Sstevel@tonic-gate static int 13430Sstevel@tonic-gate hs_getmdev(struct vfs *vfsp, char *fspec, int flags, dev_t *pdev, mode_t *mode, 13440Sstevel@tonic-gate cred_t *cr) 13450Sstevel@tonic-gate { 13460Sstevel@tonic-gate int error; 13476734Sjohnlev struct vnode *svp = NULL; 13486734Sjohnlev struct vnode *lvp = NULL; 13496734Sjohnlev struct vnode *bvp; 13500Sstevel@tonic-gate struct vattr vap; 13510Sstevel@tonic-gate dev_t dev; 13526734Sjohnlev enum uio_seg fromspace = (flags & MS_SYSSPACE) ? 13536734Sjohnlev UIO_SYSSPACE : UIO_USERSPACE; 13540Sstevel@tonic-gate 13550Sstevel@tonic-gate /* 13566734Sjohnlev * Look up the device/file to be mounted. 13570Sstevel@tonic-gate */ 13586734Sjohnlev error = lookupname(fspec, fromspace, FOLLOW, NULLVPP, &svp); 13590Sstevel@tonic-gate if (error) { 13606734Sjohnlev if (error == ENOENT) 13616734Sjohnlev error = ENODEV; 13626734Sjohnlev goto out; 13630Sstevel@tonic-gate } 13640Sstevel@tonic-gate 13656734Sjohnlev error = vfs_get_lofi(vfsp, &lvp); 13666734Sjohnlev 13676734Sjohnlev if (error > 0) { 13686734Sjohnlev if (error == ENOENT) 13696734Sjohnlev error = ENODEV; 13706734Sjohnlev goto out; 13716734Sjohnlev } else if (error == 0) { 13726734Sjohnlev bvp = lvp; 13736734Sjohnlev } else { 13746734Sjohnlev bvp = svp; 13756734Sjohnlev 13766734Sjohnlev if (bvp->v_type != VBLK) { 13776734Sjohnlev error = ENOTBLK; 13786734Sjohnlev goto out; 13796734Sjohnlev } 13806734Sjohnlev 13816734Sjohnlev if ((error = secpolicy_spec_open(cr, bvp, FREAD)) != 0) 13826734Sjohnlev goto out; 13836734Sjohnlev } 13846734Sjohnlev 13856734Sjohnlev /* 13866734Sjohnlev * Can we read from the device/file ? 13876734Sjohnlev */ 13886734Sjohnlev if ((error = VOP_ACCESS(svp, VREAD, 0, cr, NULL)) != 0) 13896734Sjohnlev goto out; 13906734Sjohnlev 13910Sstevel@tonic-gate vap.va_mask = AT_MODE; /* get protection mode */ 13926734Sjohnlev (void) VOP_GETATTR(bvp, &vap, 0, CRED(), NULL); 13930Sstevel@tonic-gate *mode = vap.va_mode; 13940Sstevel@tonic-gate 13956734Sjohnlev dev = *pdev = bvp->v_rdev; 13966734Sjohnlev 13976734Sjohnlev error = EBUSY; 13980Sstevel@tonic-gate 13990Sstevel@tonic-gate /* 14000Sstevel@tonic-gate * Ensure that this device isn't already mounted, 14010Sstevel@tonic-gate * unless this is a REMOUNT request or we are told to suppress 14020Sstevel@tonic-gate * mount checks. 14030Sstevel@tonic-gate */ 14040Sstevel@tonic-gate if ((flags & MS_NOCHECK) == 0) { 14050Sstevel@tonic-gate if (vfs_devmounting(dev, vfsp)) 14066734Sjohnlev goto out; 14070Sstevel@tonic-gate if (vfs_devismounted(dev) && !(flags & MS_REMOUNT)) 14086734Sjohnlev goto out; 14090Sstevel@tonic-gate } 14100Sstevel@tonic-gate 14116734Sjohnlev if (getmajor(*pdev) >= devcnt) { 14126734Sjohnlev error = ENXIO; 14136734Sjohnlev goto out; 14146734Sjohnlev } 14156734Sjohnlev 14166734Sjohnlev error = 0; 14176734Sjohnlev out: 14186734Sjohnlev if (svp != NULL) 14196734Sjohnlev VN_RELE(svp); 14206734Sjohnlev if (lvp != NULL) 14216734Sjohnlev VN_RELE(lvp); 14226734Sjohnlev return (error); 14230Sstevel@tonic-gate } 14240Sstevel@tonic-gate 14250Sstevel@tonic-gate static void 14262900Sfrankho hs_copylabel(struct hs_volume *hvp, unsigned char *label, int isjoliet) 14270Sstevel@tonic-gate { 14282900Sfrankho char lbuf[64]; /* hs_joliet_cp() creates 48 bytes at most */ 14292900Sfrankho 14302900Sfrankho if (isjoliet) { 14312900Sfrankho /* 14322900Sfrankho * hs_joliet_cp() will output 16..48 bytes. 14332900Sfrankho * We need to clear 'lbuf' to avoid junk chars past byte 15. 14342900Sfrankho */ 14352900Sfrankho bzero(lbuf, sizeof (lbuf)); 14362904Sfrankho (void) hs_joliet_cp((char *)label, lbuf, 32); 14372900Sfrankho label = (unsigned char *)lbuf; 14382900Sfrankho } 14390Sstevel@tonic-gate /* cdrom volid is at most 32 bytes */ 14400Sstevel@tonic-gate bcopy(label, hvp->vol_id, 32); 14410Sstevel@tonic-gate hvp->vol_id[31] = NULL; 14420Sstevel@tonic-gate } 14430Sstevel@tonic-gate 14440Sstevel@tonic-gate /* 14450Sstevel@tonic-gate * Mount root file system. 14460Sstevel@tonic-gate * "why" is ROOT_INIT on initial call, ROOT_REMOUNT if called to 14470Sstevel@tonic-gate * remount the root file system, and ROOT_UNMOUNT if called to 14480Sstevel@tonic-gate * unmount the root (e.g., as part of a system shutdown). 14490Sstevel@tonic-gate * 14500Sstevel@tonic-gate * XXX - this may be partially machine-dependent; it, along with the VFS_SWAPVP 14510Sstevel@tonic-gate * operation, goes along with auto-configuration. A mechanism should be 14520Sstevel@tonic-gate * provided by which machine-INdependent code in the kernel can say "get me the 14530Sstevel@tonic-gate * right root file system" and "get me the right initial swap area", and have 14540Sstevel@tonic-gate * that done in what may well be a machine-dependent fashion. 14550Sstevel@tonic-gate * Unfortunately, it is also file-system-type dependent (NFS gets it via 14560Sstevel@tonic-gate * bootparams calls, UFS gets it from various and sundry machine-dependent 14570Sstevel@tonic-gate * mechanisms, as SPECFS does for swap). 14580Sstevel@tonic-gate */ 14590Sstevel@tonic-gate static int 14600Sstevel@tonic-gate hsfs_mountroot(struct vfs *vfsp, enum whymountroot why) 14610Sstevel@tonic-gate { 14620Sstevel@tonic-gate int error; 14630Sstevel@tonic-gate struct hsfs *fsp; 14640Sstevel@tonic-gate struct hs_volume *fvolp; 14650Sstevel@tonic-gate static int hsfsrootdone = 0; 14660Sstevel@tonic-gate dev_t rootdev; 14670Sstevel@tonic-gate mode_t mode = 0; 14680Sstevel@tonic-gate 14690Sstevel@tonic-gate if (why == ROOT_INIT) { 14700Sstevel@tonic-gate if (hsfsrootdone++) 14710Sstevel@tonic-gate return (EBUSY); 14720Sstevel@tonic-gate rootdev = getrootdev(); 14730Sstevel@tonic-gate if (rootdev == (dev_t)NODEV) 14740Sstevel@tonic-gate return (ENODEV); 14750Sstevel@tonic-gate vfsp->vfs_dev = rootdev; 14760Sstevel@tonic-gate vfsp->vfs_flag |= VFS_RDONLY; 14770Sstevel@tonic-gate } else if (why == ROOT_REMOUNT) { 14780Sstevel@tonic-gate cmn_err(CE_NOTE, "hsfs_mountroot: ROOT_REMOUNT"); 14790Sstevel@tonic-gate return (0); 14800Sstevel@tonic-gate } else if (why == ROOT_UNMOUNT) { 14810Sstevel@tonic-gate return (0); 14820Sstevel@tonic-gate } 14830Sstevel@tonic-gate error = vfs_lock(vfsp); 14840Sstevel@tonic-gate if (error) { 14850Sstevel@tonic-gate cmn_err(CE_NOTE, "hsfs_mountroot: couldn't get vfs_lock"); 14860Sstevel@tonic-gate return (error); 14870Sstevel@tonic-gate } 14880Sstevel@tonic-gate 14890Sstevel@tonic-gate error = hs_mountfs(vfsp, rootdev, "/", mode, 1, CRED(), 1); 14900Sstevel@tonic-gate /* 14910Sstevel@tonic-gate * XXX - assumes root device is not indirect, because we don't set 14920Sstevel@tonic-gate * rootvp. Is rootvp used for anything? If so, make another arg 14930Sstevel@tonic-gate * to mountfs. 14940Sstevel@tonic-gate */ 14950Sstevel@tonic-gate if (error) { 14960Sstevel@tonic-gate vfs_unlock(vfsp); 14970Sstevel@tonic-gate if (rootvp) { 14980Sstevel@tonic-gate VN_RELE(rootvp); 14990Sstevel@tonic-gate rootvp = (struct vnode *)0; 15000Sstevel@tonic-gate } 15010Sstevel@tonic-gate return (error); 15020Sstevel@tonic-gate } 15030Sstevel@tonic-gate if (why == ROOT_INIT) 15040Sstevel@tonic-gate vfs_add((struct vnode *)0, vfsp, 15050Sstevel@tonic-gate (vfsp->vfs_flag & VFS_RDONLY) ? MS_RDONLY : 0); 15060Sstevel@tonic-gate vfs_unlock(vfsp); 15070Sstevel@tonic-gate fsp = VFS_TO_HSFS(vfsp); 15080Sstevel@tonic-gate fvolp = &fsp->hsfs_vol; 15090Sstevel@tonic-gate #ifdef HSFS_CLKSET 15100Sstevel@tonic-gate if (fvolp->cre_date.tv_sec == 0) { 15114866Sfrankho cmn_err(CE_NOTE, "hsfs_mountroot: cre_date.tv_sec == 0"); 15124866Sfrankho if (fvolp->mod_date.tv_sec == 0) { 15134866Sfrankho cmn_err(CE_NOTE, 15144866Sfrankho "hsfs_mountroot: mod_date.tv_sec == 0"); 15154866Sfrankho cmn_err(CE_NOTE, "hsfs_mountroot: clkset(-1L)"); 15164866Sfrankho clkset(-1L); 15174866Sfrankho } else { 15184866Sfrankho clkset(fvolp->mod_date.tv_sec); 15194866Sfrankho } 15204866Sfrankho } else { 15210Sstevel@tonic-gate clkset(fvolp->mod_date.tv_sec); 15224866Sfrankho } 15230Sstevel@tonic-gate #else /* HSFS_CLKSET */ 15240Sstevel@tonic-gate clkset(-1L); 15250Sstevel@tonic-gate #endif /* HSFS_CLKSET */ 15260Sstevel@tonic-gate return (0); 15270Sstevel@tonic-gate } 15280Sstevel@tonic-gate 15290Sstevel@tonic-gate /* 15300Sstevel@tonic-gate * hs_findvoldesc() 15310Sstevel@tonic-gate * 15320Sstevel@tonic-gate * Return the sector where the volume descriptor lives. This is 15330Sstevel@tonic-gate * a fixed value for "normal" cd-rom's, but can change for 15340Sstevel@tonic-gate * multisession cd's. 15350Sstevel@tonic-gate * 15360Sstevel@tonic-gate * desc_sec is the same for high-sierra and iso 9660 formats, why 15375331Samw * there are two different #defines used in the code for this is 15380Sstevel@tonic-gate * beyond me. These are standards, cast in concrete, right? 15390Sstevel@tonic-gate * To be general, however, this function supports passing in different 15400Sstevel@tonic-gate * values. 15410Sstevel@tonic-gate */ 15420Sstevel@tonic-gate static int 15430Sstevel@tonic-gate hs_findvoldesc(dev_t rdev, int desc_sec) 15440Sstevel@tonic-gate { 15450Sstevel@tonic-gate int secno; 15460Sstevel@tonic-gate int error; 15470Sstevel@tonic-gate int rval; /* ignored */ 15480Sstevel@tonic-gate 15490Sstevel@tonic-gate #ifdef CDROMREADOFFSET 15500Sstevel@tonic-gate /* 15510Sstevel@tonic-gate * Issue the Read Offset ioctl directly to the 15520Sstevel@tonic-gate * device. Ignore any errors and set starting 15530Sstevel@tonic-gate * secno to the default, otherwise add the 15540Sstevel@tonic-gate * VOLDESC sector number to the offset. 15550Sstevel@tonic-gate */ 15560Sstevel@tonic-gate error = cdev_ioctl(rdev, CDROMREADOFFSET, (intptr_t)&secno, 15570Sstevel@tonic-gate FNATIVE|FKIOCTL|FREAD, CRED(), &rval); 15580Sstevel@tonic-gate if (error) { 15590Sstevel@tonic-gate secno = desc_sec; 15600Sstevel@tonic-gate } else { 15610Sstevel@tonic-gate secno += desc_sec; 15620Sstevel@tonic-gate } 15630Sstevel@tonic-gate #else 15640Sstevel@tonic-gate secno = desc_sec; 15650Sstevel@tonic-gate #endif 15660Sstevel@tonic-gate 15670Sstevel@tonic-gate return (secno); 15680Sstevel@tonic-gate } 1569