specvnops.c revision 25e8c5aa2b496d9026e958ac731a610167574f59
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan/* All Rights Reserved */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * University Copyright- Copyright (c) 1982, 1986, 1988
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * The Regents of the University of California
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * All Rights Reserved
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * University Acknowledgment- Portions of this document are derived from
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * software developed by the University of California, Berkeley, and its
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * contributors.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan#pragma ident "%Z%%M% %I% %E% SMI"
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_open(struct vnode **, int, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_close(struct vnode *, int, int, offset_t, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_read(struct vnode *, struct uio *, int, struct cred *,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_write(struct vnode *, struct uio *, int, struct cred *,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_ioctl(struct vnode *, int, intptr_t, int, struct cred *, int *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_getattr(struct vnode *, struct vattr *, int, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_setattr(struct vnode *, struct vattr *, int, struct cred *,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_access(struct vnode *, int, int, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_create(struct vnode *, char *, vattr_t *, enum vcexcl,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int, struct vnode **, struct cred *, int);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_fsync(struct vnode *, int, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic void spec_inactive(struct vnode *, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_fid(struct vnode *, struct fid *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_seek(struct vnode *, offset_t, offset_t *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_frlock(struct vnode *, int, struct flock64 *, int, offset_t,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_realvp(struct vnode *, struct vnode **);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_getpage(struct vnode *, offset_t, size_t, uint_t *, page_t **,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan size_t, struct seg *, caddr_t, enum seg_rw, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_putapage(struct vnode *, page_t *, u_offset_t *, size_t *, int,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic struct buf *spec_startio(struct vnode *, page_t *, u_offset_t, size_t,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_getapage(struct vnode *, u_offset_t, size_t, uint_t *,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan page_t **, size_t, struct seg *, caddr_t, enum seg_rw, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_map(struct vnode *, offset_t, struct as *, caddr_t *, size_t,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uchar_t, uchar_t, uint_t, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_addmap(struct vnode *, offset_t, struct as *, caddr_t, size_t,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uchar_t, uchar_t, uint_t, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_delmap(struct vnode *, offset_t, struct as *, caddr_t, size_t,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_poll(struct vnode *, short, int, short *, struct pollhead **);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_dump(struct vnode *, caddr_t, int, int);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_pageio(struct vnode *, page_t *, u_offset_t, size_t, int,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_getsecattr(struct vnode *, vsecattr_t *, int, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_setsecattr(struct vnode *, vsecattr_t *, int, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic int spec_pathconf(struct vnode *, int, ulong_t *, struct cred *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ASSERT((csp->s_count > 0) || (csp->s_vnode->v_stream == NULL)); \
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan#define S_ISFENCED(sp) ((VTOS((sp)->s_commonvp))->s_flag & SFENCED)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * *PLEASE NOTE*: If you add new entry points to specfs, do
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * not forget to add support for fencing. A fenced snode
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * is indicated by the SFENCED flag in the common snode.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If a snode is fenced, determine if your entry point is
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * a configuration operation (Example: open), a detection
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * operation (Example: gettattr), an I/O operation (Example: ioctl())
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * or an unconfiguration operation (Example: close). If it is
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * a configuration or detection operation, fail the operation
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * for a fenced snode with an ENXIO or EIO as appropriate. If
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * it is any other operation, let it through.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanconst fs_operation_def_t spec_vnodeops_template[] = {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_OPEN, { .vop_open = spec_open },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_CLOSE, { .vop_close = spec_close },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_READ, { .vop_read = spec_read },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_WRITE, { .vop_write = spec_write },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_IOCTL, { .vop_ioctl = spec_ioctl },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_GETATTR, { .vop_getattr = spec_getattr },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_SETATTR, { .vop_setattr = spec_setattr },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_ACCESS, { .vop_access = spec_access },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_CREATE, { .vop_create = spec_create },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_FSYNC, { .vop_fsync = spec_fsync },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_INACTIVE, { .vop_inactive = spec_inactive },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_SEEK, { .vop_seek = spec_seek },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_PATHCONF, { .vop_pathconf = spec_pathconf },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_FRLOCK, { .vop_frlock = spec_frlock },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_REALVP, { .vop_realvp = spec_realvp },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_GETPAGE, { .vop_getpage = spec_getpage },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_PUTPAGE, { .vop_putpage = spec_putpage },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_ADDMAP, { .vop_addmap = spec_addmap },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_DELMAP, { .vop_delmap = spec_delmap },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_POLL, { .vop_poll = spec_poll },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_DUMP, { .vop_dump = spec_dump },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_PAGEIO, { .vop_pageio = spec_pageio },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_SETSECATTR, { .vop_setsecattr = spec_setsecattr },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan VOPNAME_GETSECATTR, { .vop_getsecattr = spec_getsecattr },
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Return address of spec_vnodeops
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Acquire the serial lock on the common snode.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan#define LOCK_CSP(csp) (void) spec_lockcsp(csp, 0, 1, 0)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan#define LOCKHOLD_CSP_SIG(csp) spec_lockcsp(csp, 1, 1, 1)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan#define SYNCHOLD_CSP_SIG(csp, intr) spec_lockcsp(csp, intr, 0, 1)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Synchronize with active SLOCKED, optionally checking for a signal and
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * optionally returning with SLOCKED set and SN_HOLD done. The 'intr'
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * argument determines if the thread is interruptible by a signal while
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * waiting, the function returns 0 if interrupted. When 1 is returned
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * the 'hold' argument determines if the open count (SN_HOLD) has been
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * incremented and the 'setlock' argument determines if the function
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * returns with SLOCKED set.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanspec_lockcsp(struct snode *csp, int intr, int setlock, int hold)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!cv_wait_sig(&csp->s_cv, &csp->s_lock)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return (0); /* interrupted */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan csp->s_count++; /* one more open reference : SN_HOLD */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Unlock the serial lock on the common snode
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * compute/return the size of the device
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (((csp)->s_flag & SSIZEVALID) ? (csp)->s_size : spec_size(csp))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Compute and return the size. If the size in the common snode is valid then
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * return it. If not valid then get the size from the driver and set size in
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * the common snode. If the device has not been attached then we don't ask for
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * an update from the driver- for non-streams SSIZEVALID stays unset until the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * device is attached. A stat of a mknod outside /devices (non-devfs) may
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * report UNKNOWN_SIZE because the device may not be attached yet (SDIPSET not
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * established in mknod until open time). An stat in /devices will report the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * size correctly. Specfs should always call SPEC_SIZE instead of referring
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * directly to s_size to initialize/retrieve the size of a device.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * XXX There is an inconsistency between block and raw - "unknown" is
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * UNKNOWN_SIZE for VBLK and 0 for VCHR(raw).
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ASSERT((csp)->s_commonvp == cvp); /* must be common node */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* return cached value */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* VOP_GETATTR of mknod has not had devcnt restriction applied */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* return non-cached UNKNOWN_SIZE */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return ((cvp->v_type == VCHR) ? 0 : UNKNOWN_SIZE);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* establish cached zero size for streams */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Return non-cached UNKNOWN_SIZE if not open.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * NB: This check is bogus, calling prop_op(9E) should be gated by
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * attach, not open. Not having this check however opens up a new
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * context under which a driver's prop_op(9E) could be called. Calling
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * prop_op(9E) in this new context has been shown to expose latent
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * driver bugs (insufficient NULL pointer checks that lead to panic).
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * We are keeping this open check for now to avoid these panics.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return ((cvp->v_type == VCHR) ? 0 : UNKNOWN_SIZE);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Return non-cached UNKNOWN_SIZE if not attached. */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (((csp->s_flag & SDIPSET) == 0) || (csp->s_dip == NULL) ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return ((cvp->v_type == VCHR) ? 0 : UNKNOWN_SIZE);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Established cached size obtained from the attached driver. Since we
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * know the devinfo node, for efficiency we use cdev_prop_op directly
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * instead of [cb]dev_[Ss]size.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cdev_prop_op(dev, devi, PROP_LEN_AND_VAL_BUF,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan DDI_PROP_CONSUMER_TYPED, "Size", (caddr_t)&size,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cdev_prop_op(dev, devi, PROP_LEN_AND_VAL_BUF,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cdev_prop_op(dev, devi, PROP_LEN_AND_VAL_BUF,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan DDI_PROP_CONSUMER_TYPED, "Nblocks", (caddr_t)&size,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cdev_prop_op(dev, devi, PROP_LEN_AND_VAL_BUF,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* try to get dev_t specific "blksize" */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cdev_prop_op(dev, devi, PROP_LEN_AND_VAL_BUF,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Try for dev_info node "device-blksize".
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If this fails then blksize will still be
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * DEV_BSIZE default value.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) cdev_prop_op(DDI_DEV_T_ANY, devi,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "device-blksize", (caddr_t)&blksize, &plen);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* blksize must be a power of two */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* convert from block size to byte size */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * This function deal with vnode substitution in the case of
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * device cloning.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanspec_clone(struct vnode **vpp, dev_t newdev, int vtype, struct stdata *stp)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Check for cloning across different drivers.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * We only support this under the system provided clone driver
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "unsupported clone open maj = %u, newmaj = %u",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Clones inherit fsid, realvp, and dip.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * XXX realvp inherit is not occurring, does fstat of clone work?
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If we cloned to an opened newdev that already has called
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * spec_assoc_vp_with_devi (SDIPSET set) then the association is
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * already established.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Establish s_dip association for newdev.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If we trusted the getinfo(9E) DDI_INFO_DEVT2INSTANCE
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * implementation of all cloning drivers (SCLONE and SELFCLONE)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * we would always use e_ddi_hold_devi_by_dev(). We know that
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * many drivers have had (still have?) problems with
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * DDI_INFO_DEVT2INSTANCE, so we try to minimize reliance by
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * detecting drivers that use QASSOCIATE (by looking down the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * stream) and setting their s_dip association to NULL.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (dq = stp->sd_wrq; dq; dq = dq->q_next) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* derive association from newdev */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan dip = e_ddi_hold_devi_by_dev(newdev, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* deal with stream stuff */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan LOCK_CSP(newcsp); /* synchronize stream open/close */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan newcvp->v_stream = newvp->v_stream = stp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* substitute the vnode */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanspec_open(struct vnode **vpp, int flag, struct cred *cr)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ASSERT((vp->v_type == VCHR) || (vp->v_type == VBLK));
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((vp->v_type != VCHR) && (vp->v_type != VBLK))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If the VFS_NODEVICES bit was set for the mount,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * do not allow opens of special devices.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sp->s_realvp && (sp->s_realvp->v_vfsp->vfs_flag & VFS_NODEVICES))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If we are opening a node that has not had spec_assoc_vp_with_devi
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * called against it (mknod outside /devices or a non-dacf makespecvp
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * node) then SDIPSET will not be set. In this case we call an
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * interface which will reconstruct the path and lookup (drive attach)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * through devfs (e_ddi_hold_devi_by_dev -> e_ddi_hold_devi_by_path ->
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * devfs_lookupname). For support of broken drivers that don't call
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * ddi_create_minor_node for all minor nodes in their instance space,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * we call interfaces that operates at the directory/devinfo
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * (major/instance) level instead of to the leaf/minor node level.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * After finding and attaching the dip we associate it with the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * common specfs vnode (s_dip), which sets SDIPSET. A DL_DETACH_REQ
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * to style-2 stream driver may set s_dip to NULL with SDIPSET set.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * NOTE: Although e_ddi_hold_devi_by_dev takes a dev_t argument, its
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * implementation operates at the major/instance level since it only
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * need to return a dip.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* try to attach, return error if we fail */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((dip = e_ddi_hold_devi_by_dev(dev, 0)) == NULL)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* associate dip with the common snode s_dip */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ddi_release_devi(dip); /* from e_ddi_hold_devi_by_dev */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* check if device fenced off */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* verify attach/open exclusion guarantee */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ASSERT((dip == NULL) || i_ddi_devi_attached(dip));
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan#endif /* DEBUG */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((error = secpolicy_spec_open(cr, vp, flag)) != 0)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Wait for in progress last close to complete. This guarantees
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * to the driver writer that we will never be in the drivers
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * open and close on the same (dev_t, otype) at the same time.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Open count already incremented (SN_HOLD) on non-zero return.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * The wait is interruptible by a signal if the driver sets the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * D_OPEN_RETURNS_EINTR cb_ops(9S) cb_flag or sets the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * ddi-open-returns-eintr(9P) property in its driver.conf.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((devopsp[maj]->devo_cb_ops->cb_flag & D_OPEN_RETURNS_EINTR) ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (devnamesp[maj].dn_flags & DN_OPEN_RETURNS_EINTR))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan while (SYNCHOLD_CSP_SIG(csp, open_returns_eintr) == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* non streams open */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan type = (vp->v_type == VBLK ? OTYP_BLK : OTYP_CHR);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = dev_open(&newdev, flag, type, cr);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* deal with clone case */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = spec_clone(vpp, newdev, vp->v_type, NULL);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * bail on clone failure, further processing
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * results in undefined behaviors.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * create contracts only for userland opens
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Successful open and cloning is done at this point.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan spec_type = (STOV(csp)->v_type == VCHR) ? S_IFCHR : S_IFBLK;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (contract_device_open(newdev, spec_type, NULL) != 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* successful open needs a close later */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Invalidate possible cached "unknown" size
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * established by a VOP_GETATTR while open was in
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * progress, and the driver might fail prop_op(9E).
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (((cvp->v_type == VCHR) && (csp->s_size == 0)) ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (devopsp[nmaj]->devo_cb_ops->cb_flag & D_64BIT)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (devopsp[nmaj]->devo_cb_ops->cb_flag & D_U64BIT)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Open failed. If we missed a close operation because
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * we were trying to get the device open and it is the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * last in progress open that is failing then call close.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * NOTE: Only non-streams open has this race condition.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan csp->s_count--; /* decrement open count : SN_RELE */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((csp->s_count == 0) && /* no outstanding open */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (csp->s_mapcnt == 0) && /* no mapping */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (csp->s_flag & SNEEDCLOSE)) { /* need a close */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan csp->s_flag &= ~(SNEEDCLOSE | SSIZEVALID);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* See comment in spec_close() */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (csp->s_flag & (SCLONE | SSELFCLONE))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Lock common snode to prevent any new clone opens on this
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * stream while one is in progress. This is necessary since
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * the stream currently associated with the clone device will
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * not be part of it after the clone open completes. Unfortunately
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * we don't know in advance if this is a clone
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * device so we have to lock all opens.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If we fail, it's because of an interrupt - EINTR return is an
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * expected aspect of opening a stream so we don't need to check
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * D_OPEN_RETURNS_EINTR. Open count already incremented (SN_HOLD)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * on non-zero return.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = stropen(cvp, &newdev, flag, cr);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* deal with the clone case */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = spec_clone(vpp, newdev, vp->v_type, stp);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * bail on clone failure, further processing
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * results in undefined behaviors.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else if (error == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * create contracts only for userland opens
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Successful open and cloning is done at this point.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* STREAM is of type S_IFCHR */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (contract_device_open(newdev, S_IFCHR, &ct) != 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* STREAMS devices don't have a size */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!(stp->sd_flag & STRISTTY) || (flag & FNOCTTY))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* try to allocate it as a controlling terminal */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* strctty() was interrupted by a signal */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* we only create contracts for userland opens */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) contract_abandon(ct, ttoproc(curthread), 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Deal with stropen failure.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * sd_flag in the stream head cannot change since the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * common snode is locked before the call to stropen().
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((stp != NULL) && (stp->sd_flag & STREOPENFAIL)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Open failed part way through.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* this only applies to closes of devices from userland */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cleanlocks(vp, ttoproc(curthread)->p_pid, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cleanshares(vp, ttoproc(curthread)->p_pid);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* we allow close to succeed even if device is fenced off */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Prevent close/close and close/open races by serializing closes
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * on this common snode. Clone opens are held up until after
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * we have closed this device so the streams linkage is maintained
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan csp->s_count--; /* one fewer open reference : SN_RELE */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Invalidate size on each close.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * XXX We do this on each close because we don't have interfaces that
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * allow a driver to invalidate the size. Since clearing this on each
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * close this causes property overhead we skip /dev/null and
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * /dev/zero to avoid degrading kenbus performance.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Only call the close routine when the last open reference through
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * any [s, v]node goes away. This can be checked by looking at
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * s_count on the common vnode.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((csp->s_count == 0) && (csp->s_mapcnt == 0)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* we don't need a close */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan csp->s_flag &= ~(SNEEDCLOSE | SSIZEVALID);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * A cloning driver may open-clone to the same dev_t that we
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * are closing before spec_inactive destroys the common snode.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If this occurs the s_dip association needs to be reevaluated.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * We clear SDIPSET to force reevaluation in this case. When
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * reevaluation occurs (by spec_clone after open), if the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * devinfo association has changed then the old association
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * will be released as the new association is established by
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * spec_assoc_vp_with_devi().
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (csp->s_flag & (SCLONE | SSELFCLONE))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Decrement the devops held in clnopen()
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ASSERT(vp->v_type == VCHR || vp->v_type == VBLK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (STREAMSTAB(getmajor(dev))) { /* stream */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Plain old character devices that set D_U64BIT can have
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * unrestricted offsets.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ASSERT(maxoff != -1 || vp->v_type == VCHR);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (maxoff != -1 && (uiop->uio_loffset < 0 ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uiop->uio_loffset + uiop->uio_resid > maxoff))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Block device.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan off = uiop->uio_loffset & (offset_t)MAXBMASK;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan on = (size_t)(uiop->uio_loffset & MAXBOFFSET);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan n = (size_t)MIN(MAXBSIZE - on, uiop->uio_resid);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = vpm_data_copy(blkvp, (u_offset_t)(off + on),
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = uiomove(base + on, n, UIO_READ, uiop);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If we read a whole block, we won't need this
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * buffer again soon.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = vpm_sync_pages(blkvp, off, n, flags);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = segmap_release(segkmap, base, flags);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) vpm_sync_pages(blkvp, off, n, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) segmap_release(segkmap, base, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } while (error == 0 && uiop->uio_resid > 0 && n != 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ASSERT(vp->v_type == VCHR || vp->v_type == VBLK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Plain old character devices that set D_U64BIT can have
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * unrestricted offsets.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ASSERT(maxoff != -1 || vp->v_type == VCHR);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (maxoff != -1 && (uiop->uio_loffset < 0 ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uiop->uio_loffset + uiop->uio_resid > maxoff))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan off = uiop->uio_loffset & (offset_t)MAXBMASK;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan on = (ulong_t)(uiop->uio_loffset & MAXBOFFSET);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan n = (size_t)MIN(MAXBSIZE - on, uiop->uio_resid);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Check to see if we can skip reading in the page
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * and just allocate the memory. We can do this
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * if we are going to rewrite the entire mapping
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * or if we are going to write to end of the device
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * from the beginning of the mapping.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (n == MAXBSIZE || (on == 0 && (off + n) == bdevsize))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = vpm_data_copy(blkvp, (u_offset_t)(off + on),
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan n, uiop, !pagecreate, NULL, 0, S_WRITE);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (u_offset_t)(off + on), n, !pagecreate, S_WRITE);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * segmap_pagecreate() returns 1 if it calls
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * page_create_va() to allocate any pages.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan newpage = segmap_pagecreate(segkmap, base + on,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = uiomove(base + on, n, UIO_WRITE, uiop);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan P2ROUNDUP_TYPED(off + on + n, PAGESIZE, offset_t)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * We created pages w/o initializing them completely,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * thus we need to zero the part that wasn't set up.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * This can happen if we write to the end of the device
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * or if we had some sort of error during the uiomove.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nmoved = (uiop->uio_loffset - (off + on));
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /*NOTREACHED*/
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (nzero < 0 || (on + nmoved + nzero > MAXBSIZE)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /*NOTREACHED*/
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) kzero(base + on + nmoved, (size_t)nzero);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Unlock the pages which have been allocated by
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * page_create_va() in segmap_pagecreate().
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Force write back for synchronous write cases.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan else if (n + on == MAXBSIZE || IS_SWAPVP(vp)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Have written a whole block.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Start an asynchronous write and
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * mark the buffer to indicate that
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * it won't be needed again soon.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Push swap files here, since it
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * won't happen anywhere else.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan flags = SM_WRITE | SM_ASYNC | SM_DONTNEED;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = vpm_sync_pages(blkvp, off, n, flags);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = segmap_release(segkmap, base, flags);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) vpm_sync_pages(blkvp, off, n, SM_INVAL);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) segmap_release(segkmap, base, SM_INVAL);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } while (error == 0 && uiop->uio_resid > 0 && n != 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanspec_ioctl(struct vnode *vp, int cmd, intptr_t arg, int mode, struct cred *cr,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * allow ioctls() to go through even for fenced snodes, as they
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * may include unconfiguration operation - for example popping of
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * streams modules.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = strioctl(vp, cmd, arg, mode, U_TO_K, cr, rvalp);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = cdev_ioctl(dev, cmd, arg, mode, cr, rvalp);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanspec_getattr(struct vnode *vp, struct vattr *vap, int flags, struct cred *cr)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* With ATTR_COMM we will not get attributes from realvp */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* we want stat() to fail with ENXIO if the device is fenced off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static int snode_shift = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Calculate the amount of bitshift to a snode pointer which
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will still keep it unique. See below.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * No real vnode behind this one. Fill in the fields
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * from the snode.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This code should be refined to return only the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * attributes asked for instead of all of them.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If the va_nodeid is > MAX_USHORT, then i386 stats might
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * fail. So we shift down the snode pointer to try and get
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the most uniqueness into 16-bits.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vap->va_nodeid = ((ino64_t)(uintptr_t)sp >> snode_shift) &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * va_nblocks is the number of 512 byte blocks used to store
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the mknod for the device, not the number of blocks on the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * device itself. This is typically zero since the mknod is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * represented directly in the inode itself.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = VOP_GETATTR(realvp, vap, flags, cr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the size from the snode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fail with ENXIO if the device is fenced off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vp->v_type == VCHR && vp->v_stream && (vap->va_mask & AT_SIZE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1135080: O_TRUNC should have no effect on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * named pipes and terminal devices.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = VOP_SETATTR(realvp, vap, flags, cr, ctp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If times were changed, update snode.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortespec_access(struct vnode *vp, int mode, int flags, struct cred *cr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fail with ENXIO if the device is fenced off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0); /* Allow all access. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This can be called if creat or an open with O_CREAT is done on the root
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of a lofs mount where the mounted entity is a special file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortespec_create(struct vnode *dvp, char *name, vattr_t *vap, enum vcexcl excl,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int mode, struct vnode **vpp, struct cred *cr, int flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fail with ENXIO if the device is fenced off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(dvp && (dvp->v_flag & VROOT) && *name == '\0');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mode && (error = spec_access(dvp, mode, 0, cr)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * In order to sync out the snode times without multi-client problems,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * make sure the times written out are never earlier than the times
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * already set in the vnode.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortespec_fsync(struct vnode *vp, int syncflag, struct cred *cr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allow syncing even if device is fenced off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If times didn't change, don't flush anything. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((sp->s_flag & (SACC|SUPD|SCHG)) == 0 && vp->v_type != VBLK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vp->v_type == VBLK && cvp != vp && vn_has_cached_data(cvp) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For devices that support it, force write cache to stable storage.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We don't need the lock to check s_flags since we can treat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SNOFLUSH as a hint.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((vp->v_type == VBLK || vp->v_type == VCHR) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = cdev_ioctl(vp->v_rdev, DKIOCFLUSHWRITECACHE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If no real vnode to update, don't flush anything.
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (vatmp.va_atime.tv_sec > sp->s_atime)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) VOP_SETATTR(realvp, &va, 0, cr, NULL);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanspec_inactive(struct vnode *vp, struct cred *cr)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If no one has reclaimed the vnode, remove from the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /*NOTREACHED*/
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Drop the temporary hold by vn_rele now
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* We are the sole owner of sp now */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If the snode times changed, then update the times
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * associated with the "realvp".
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((sp->s_flag & (SACC|SUPD|SCHG)) != 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * The user may not own the device, but we
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * want to update the attributes anyway.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (VOP_GETATTR(rvp, &vatmp, 0, kcred) == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (vatmp.va_atime.tv_sec > sp->s_atime)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (vatmp.va_mtime.tv_sec > sp->s_mtime)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) VOP_SETATTR(rvp, &va, 0, kcred, NULL);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* if we are sharing another file systems vfs, release it */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (vp->v_vfsp && (vp->v_vfsp != &spec_vfs))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* if we have a realvp, release the realvp */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* if we have a common, release the common */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * if this is the last reference to a common vnode, any
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * associated stream had better have been closed
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan#endif /* DEBUG */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * if we have a hold on a devinfo node (established by
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * spec_assoc_vp_with_devi), release the hold
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If we have an associated device policy, release it.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If all holds on the devinfo node are through specfs/devfs
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * and we just destroyed the last specfs node associated with the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * device, then the devinfo node reference count should now be
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * zero. We can't check this because there may be other holds
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * on the node from non file system sources: ddi_hold_devi_by_instance
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * for example.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanspec_fid(struct vnode *vp, struct fid *fidp)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanspec_seek(struct vnode *vp, offset_t ooff, offset_t *noffp)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If file is being mapped, disallow frlock.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return (fs_frlock(vp, cmd, bfp, flag, offset, flk_cbp, cr));
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanspec_realvp(struct vnode *vp, struct vnode **vpp)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((rvp = VTOS(vp)->s_realvp) != NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Return all the pages from [off..off + len] in block
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * or character device.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * XXX Given the above assertion, this might not do
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * what is wanted here.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan TRACE_4(TR_FAC_SPECFS, TR_SPECFS_GETPAGE,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "specfs getpage:vp %p off %llx len %ld snode %p",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (((u_offset_t)off + len) > (SPEC_SIZE(sp) + PAGEOFFSET))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan err = spec_getapage(vp, (u_offset_t)off, len, protp, pl,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan err = pvn_getpages(spec_getapage, vp, (u_offset_t)off,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan len, protp, pl, plsz, seg, addr, rw, cr);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cmn_err(CE_NOTE, "spec_getpage called for character device. "
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "Check any non-ON consolidation drivers");
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan panic("spec_getpage: bad v_type 0x%x", vp->v_type);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /*NOTREACHED*/
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanextern int klustsize; /* set in machdep.c */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanint spec_lostpage; /* number of times we lost original page */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan TRACE_3(TR_FAC_SPECFS, TR_SPECFS_GETAPAGE,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "specfs getapage:vp %p off %llx snode %p", vp, off, sp);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan adj_klustsize = dora ? klustsize : PAGESIZE;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((pagefound = page_exists(vp, off)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We're allocating a swap slot and it's
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * associated page was not found, so allocate
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * and return it.
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan PAGESIZE, PG_WAIT, seg, addr)) == NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /*NOTREACHED*/
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Need to really do disk I/O to get the page(s).
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan blkoff = (off / adj_klustsize) * adj_klustsize;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan pp = pvn_read_kluster(vp, off, seg, addr, &tmpoff,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Make sure the page didn't sneek into the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * cache while we blocked in pvn_read_kluster.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Zero part of page which we are not
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * going to be reading from disk now.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan pagezero(pp->p_prev, xlen, PAGESIZE - xlen);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bp = spec_startio(vp, pp, io_off1, io_len1,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan pl == NULL ? (B_ASYNC | B_READ) : B_READ);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan off2 = ((off / adj_klustsize) + 1) * adj_klustsize;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If we are past EOF then don't bother trying
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * with read-ahead.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan blksz = MIN(size - off2, adj_klustsize);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan pp2 = pvn_read_kluster(vp, off2, seg, addr2, &tmpoff,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Zero part of page which we are not
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * going to be reading from disk now.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan pagezero(pp2->p_prev, xlen, PAGESIZE - xlen);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) spec_startio(vp, pp2, io_off2, io_len2,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan se_t se = (rw == S_CREATE ? SE_EXCL : SE_SHARED);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Page exists in the cache, acquire the appropriate
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * lock. If this fails, start all over again.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((pp = page_lookup(vp, off, se)) == NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan pvn_plist_init(pp, pl, plsz, off, io_len1, rw);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Flags are composed of {B_INVAL, B_DIRTY B_FREE, B_DONTNEED, B_FORCE}.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If len == 0, do from off to EOF.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * The normal cases should be len == 0 & off == 0 (entire vp list),
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * len == MAXBSIZE (from segmap_release actions), and len == PAGESIZE
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * (from pageout).
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!vn_has_cached_data(vp) || off >= size)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ASSERT(vp->v_type == VBLK && cvp == vp);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan TRACE_4(TR_FAC_SPECFS, TR_SPECFS_PUTPAGE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "specfs putpage:vp %p off %llx len %ld snode %p",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Search the entire vp list for pages >= off.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan err = pvn_vplist_dirty(vp, off, spec_putapage,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Loop over all offsets in the range [off...off + len]
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * looking for pages to deal with. We set limits so
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that we kluster to klustsize boundaries.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (io_off = off; io_off < eoff && io_off < size;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If we are not invalidating, synchronously
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * freeing or writing pages use the routine
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * page_lookup_nowait() to prevent reclaiming
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * them from the free list.
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if ((flags & B_INVAL) || ((flags & B_ASYNC) == 0)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (flags & B_FREE) ? SE_EXCL : SE_SHARED);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * "io_off" and "io_len" are returned as
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * the range of pages we actually wrote.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * This allows us to skip ahead more quickly
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * since several pages may've been dealt
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * with by this iteration of the loop.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Write out a single page, possibly klustering adjacent
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * dirty pages.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Destroy read ahead value since we are really going to write.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan blkoff = (pp->p_offset / adj_klustsize) * adj_klustsize;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Find a kluster that fits in one contiguous chunk.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan pp = pvn_write_kluster(vp, pp, &tmpoff, &io_len, blkoff,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Check for page length rounding problems
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * XXX - Is this necessary?
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ASSERT((io_off + io_len) - size < PAGESIZE);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan bp = spec_startio(vp, pp, io_off, io_len, B_WRITE | flags);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Wait for i/o to complete if the request is not B_ASYNC.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan pvn_write_done(pp, ((err) ? B_ERROR : 0) | B_WRITE | flags);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan TRACE_4(TR_FAC_SPECFS, TR_SPECFS_PUTAPAGE,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "specfs putapage:vp %p offp %p snode %p err %d",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Flags are composed of {B_ASYNC, B_INVAL, B_FREE, B_DONTNEED}
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic struct buf *
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan bp = pageio_setup(pp, io_len, vp, flags);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan error = fs_poll(vp, events, anyyet, reventsp, phpp);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = strpoll(vp->v_stream, events, anyyet,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan } else if (devopsp[getmajor(dev)]->devo_cb_ops->cb_chpoll) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = cdev_poll(dev, events, anyyet, reventsp, phpp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = fs_poll(vp, events, anyyet, reventsp, phpp);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * This routine is called through the cdevsw[] table to handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * traditional mmap'able devices that support a d_mmap function.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED8*/
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((mapfunc = devopsp[getmajor(dev)]->devo_cb_ops->cb_mmap) == nodev)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan TRACE_4(TR_FAC_SPECFS, TR_SPECFS_SEGMAP,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "specfs segmap:dev %x as %p len %lx prot %x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Character devices that support the d_mmap
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * interface can only be mmap'ed shared.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to ensure that the entire range is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * legal and we are not trying to map in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * more than the device will let us.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cdev_mmap(mapfunc, dev, off + i, maxprot) == -1)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Pick an address w/o worrying about
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * any vac alignment constraints.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * User-specified address; blow away any previous mappings.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = as_map(as, *addrp, len, segdev_create, &dev_a);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan caddr_t *, off_t, uint_t, uint_t, uint_t, cred_t *);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int (*devmap)(dev_t, devmap_cookie_t, offset_t,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int (*mmap)(dev_t dev, off_t off, int prot);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Character device: let the device driver
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * pick the appropriate segment driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 4.x compat.: allow 'NULL' cb_segmap => spec_segmap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Kindness: allow 'nulldev' cb_segmap => spec_segmap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (segmap == NULL || segmap == nulldev || segmap == nodev) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use old mmap framework if the driver has both mmap
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * and devmap entry points. This is to prevent the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * system from calling invalid devmap entry point
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for some drivers that might have put garbage in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * devmap entry point.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If driver provides devmap entry point in
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * cb_ops but not xx_segmap(9E), call
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * devmap_setup with default settings
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * (NULL) for callback_ops and driver
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * callback private data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((*segmap)(dev, (off_t)off, as, addrp, len, prot,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* fail map with ENXIO if the device is fenced off */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If file is locked, fail mapping attempt.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return (spec_char_map(vp->v_rdev, off, as, addrp, len, prot,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Block device, use segvn mapping to the underlying commonvp
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (off < 0 || ((offset_t)(off + len) < 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * User-specified address; blow away any
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * previous mappings.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = as_map(as, *addrp, len, segvn_create, &vn_a);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED1*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(vp != NULL && VTOS(vp)->s_commonvp == vp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * XXX Given the above assertion, this might not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be a particularly sensible thing to test.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fail with EIO if the device is fenced off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED1*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* segdev passes us the common vp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(vp != NULL && VTOS(vp)->s_commonvp == vp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allow delmap to succeed even if device fenced off */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * XXX Given the above assertion, this might not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be a particularly sensible thing to test..
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Call the close routine when the last reference of any
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * kind through any [s, v]node goes away. The s_dip hold
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on the devinfo node is released when the vnode is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * destroyed.
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan csp->s_flag &= ~(SNEEDCLOSE | SSIZEVALID);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* See comment in spec_close() */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanspec_dump(struct vnode *vp, caddr_t addr, int bn, int count)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* allow dump to succeed even if device fenced off */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return (bdev_dump(vp->v_rdev, addr, bn, count));
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Do i/o on the given page list from/to vp, io_off for io_len.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Flags are composed of:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * {B_ASYNC, B_INVAL, B_FREE, B_DONTNEED, B_READ, B_WRITE}
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If B_ASYNC is not set i/o is waited for.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan bp = spec_startio(vp, pp, io_off, io_len, flags);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Wait for i/o to complete if the request is not B_ASYNC.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Set ACL on underlying vnode if one exists, or return ENOSYS otherwise.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanspec_setsecattr(struct vnode *vp, vsecattr_t *vsap, int flag, struct cred *cr)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* fail with ENXIO if the device is fenced off */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * The acl(2) system calls VOP_RWLOCK on the file before setting an
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * ACL, but since specfs does not serialize reads and writes, this
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * VOP does not do anything. However, some backing file systems may
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * expect the lock to be held before setting an ACL, so it is taken
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * here privately to avoid serializing specfs reads and writes.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) VOP_RWLOCK(realvp, V_WRITELOCK_TRUE, NULL);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan error = VOP_SETSECATTR(realvp, vsap, flag, cr);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) VOP_RWUNLOCK(realvp, V_WRITELOCK_TRUE, NULL);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Get ACL from underlying vnode if one exists, or fabricate it from
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * the permissions returned by spec_getattr() otherwise.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanspec_getsecattr(struct vnode *vp, vsecattr_t *vsap, int flag, struct cred *cr)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* fail with ENXIO if the device is fenced off */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return (VOP_GETSECATTR(realvp, vsap, flag, cr));
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return (fs_fab_acl(vp, vsap, flag, cr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortespec_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fail with ENXIO if the device is fenced off */