sdev_vnops.c revision b774fca88bff9e11d96e3b40f4d259d278048a3a
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * CDDL HEADER START
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * The contents of this file are subject to the terms of the
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * Common Development and Distribution License (the "License").
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * You may not use this file except in compliance with the License.
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * See the License for the specific language governing permissions
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * and limitations under the License.
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * When distributing Covered Code, include this CDDL HEADER in each
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * If applicable, add the following below this CDDL HEADER, with the
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * fields enclosed by brackets "[]" replaced with your own identifying
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * information: Portions Copyright [yyyy] [name of copyright owner]
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * CDDL HEADER END
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * Use is subject to license terms.
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt#pragma ident "%Z%%M% %I% %E% SMI"
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * vnode ops for the /dev filesystem
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * - VDIR, VCHR, CBLK, and VLNK are considered must supported files
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * - VREG and VDOOR are used for some internal implementations in
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * the global zone, e.g. devname and devfsadm communication
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * - other file types are unusual in this namespace and
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * not supported for now
f3ad877eb05befbc862b0233d985758c0caef29aEvan Huntsdev_open(struct vnode **vpp, int flag, struct cred *cred)
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt/*ARGSUSED1*/
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt return (VOP_CLOSE(dv->sdev_attrvp, flag, count, offset, cred));
f3ad877eb05befbc862b0233d985758c0caef29aEvan Huntsdev_read(struct vnode *vp, struct uio *uio, int ioflag, struct cred *cred,
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt struct sdev_node *dv = (struct sdev_node *)VTOSDEV(vp);
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt /* only supporting regular files in /dev */
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt ASSERT(RW_READ_HELD(&VTOSDEV(vp)->sdev_contents));
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt error = VOP_READ(dv->sdev_attrvp, uio, ioflag, cred, ct);
f3ad877eb05befbc862b0233d985758c0caef29aEvan Huntsdev_write(struct vnode *vp, struct uio *uio, int ioflag, struct cred *cred,
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt /* only supporting regular files in /dev */
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt error = VOP_WRITE(dv->sdev_attrvp, uio, ioflag, cred, ct);
f3ad877eb05befbc862b0233d985758c0caef29aEvan Huntsdev_ioctl(struct vnode *vp, int cmd, intptr_t arg, int flag,
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt return (VOP_IOCTL(dv->sdev_attrvp, cmd, arg, flag, cred, rvalp));
f3ad877eb05befbc862b0233d985758c0caef29aEvan Huntsdev_getattr(struct vnode *vp, struct vattr *vap, int flags, struct cred *cr)
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt int (*fn)(devname_handle_t *, struct vattr *, struct cred *);
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt if (SDEV_IS_GLOBAL(dv) && (dv->sdev_state != SDEV_ZOMBIE)) {
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * search order:
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * - for persistent nodes (SDEV_PERSIST): backstore
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt * - for non-persistent nodes: module ops if global, then memory
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt error = VOP_GETATTR(dv->sdev_attrvp, vap, flags, cr);
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt } else if (dirops && (fn = dirops->devnops_getattr)) {
f3ad877eb05befbc862b0233d985758c0caef29aEvan Huntsdev_setattr(struct vnode *vp, struct vattr *vap, int flags, struct cred *cred)
f3ad877eb05befbc862b0233d985758c0caef29aEvan Hunt return (devname_setattr_func(vp, vap, flags, cred, NULL, 0));
int error;
return (ENOSYS);
return (error);
int error;
return (fs_nosys());
if (error) {
return (fs_nosys());
return (error);
int shift = 0;
if (mode == 0)
int ret = 0;
if (ret)
return (ret);
int error = 0;
return (ENOTSUP);
return (ENOENT);
if (error == 0) {
if (error) {
return (error);
if (error) {
return (error);
return (error);
return (ENOTSUP);
if (error) {
if (self)
return (error);
return (error);
int error;
int len;
int bkstore = 0;
return (EINVAL);
return (EEXIST);
return (ENOTSUP);
return (ENOENT);
return (ENOENT);
if (error) {
return (error);
if (bkstore) {
error = 0;
error = 0;
return (error);
int len;
int error = 0;
int bkstore = 0;
return (EINVAL);
return (ENOENT);
return (ENOTSUP);
return (ENOENT);
if (error) {
onm));
return (error);
return (error);
return (EINVAL);
return (error);
return (error);
return (EXDEV);
if (error) {
return (error);
if (!samedir) {
if (error) {
return (error);
if (samedir) {
if (error) {
return (error);
if (nvp) {
case VDIR:
if (error) {
return (error);
return (error);
if (error) {
return (error);
if (error == 0) {
if (error == 0) {
if (bkstore) {
if (error) {
error = 0;
error = 0;
if (error) {
return (error);
int error;
return (ENOENT);
return (ENOTSUP);
if (error == 0) {
return (EEXIST);
return (error);
if (error) {
if (self)
return (error);
int error;
return (ENOENT);
if (error == 0) {
return (EEXIST);
return (error);
if (error) {
if (self)
return (error);
int error = 0;
return (EINVAL);
return (ENOTSUP);
return (ENOENT);
return (ENOENT);
return (EINVAL);
return (ENOTDIR);
return (EBUSY);
return (EBUSY);
return (ENOTEMPTY);
error = 0;
return (error);
int error = 0;
return (error);
return (ENOENT);
int clean;
int state;
if (clean) {
return (ENOSPC);
int error;
return (error);
switch (cmd) {
case _PC_ACL_ENABLED: