sdev_vnops.c revision 1c4bb543a73abbf7464757d5ba7d8b84899f2408
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* vnode ops for the /dev filesystem
*
* - VDIR, VCHR, CBLK, and VLNK are considered must supported files
* - VREG and VDOOR are used for some internal implementations in
* the global zone, e.g. devname and devfsadm communication
* - other file types are unusual in this namespace and
* not supported for now
*/
#include <sys/sysmacros.h>
#include <sys/vfs_opreg.h>
#include <sys/cred_impl.h>
#include <sys/pathname.h>
/*ARGSUSED*/
static int
{
int error = 0;
return (0);
if (!SDEV_IS_GLOBAL(dv))
return (ENOTSUP);
return (ENOTSUP);
return (ENOENT);
}
return (error);
}
/*ARGSUSED1*/
static int
{
return (0);
}
if (!SDEV_IS_GLOBAL(dv))
return (ENOTSUP);
return (ENOTSUP);
}
/*ARGSUSED*/
static int
struct caller_context *ct)
{
int error;
if (!SDEV_IS_GLOBAL(dv))
return (EINVAL);
return (EISDIR);
/* only supporting regular files in /dev */
return (EINVAL);
return (error);
}
/*ARGSUSED*/
static int
struct caller_context *ct)
{
int error = 0;
if (!SDEV_IS_GLOBAL(dv))
return (EINVAL);
return (EISDIR);
/* only supporting regular files in /dev */
return (EINVAL);
if (error == 0) {
AT_MTIME);
}
return (error);
}
/*ARGSUSED*/
static int
{
return (ENOTTY);
return (EINVAL);
}
static int
{
int error = 0;
}
/*
* search order:
* - for persistent nodes (SDEV_PERSIST): backstore
* - for non-persistent nodes: module ops if global, then memory
*/
if (dv->sdev_attrvp) {
} else {
}
return (error);
}
/*ARGSUSED4*/
static int
{
}
static int
{
int error;
/* return fs_fab_acl() if flavor matches, else do nothing */
return (ENOSYS);
}
return (error);
}
static int
{
int error;
return (0);
return (fs_nosys());
/*
* if coming in directly, the acl system call will
* have held the read-write lock via VOP_RWLOCK()
* If coming in via specfs, specfs will have
* held the rw lock on the realvp i.e. us.
*/
if (error) {
return (fs_nosys());
}
/* clean out the memory copy if any */
}
}
return (error);
}
int
{
int shift = 0;
shift += 3;
shift += 3;
}
if (mode == 0)
return (0);
}
static int
{
int ret = 0;
if (dv->sdev_attrvp) {
if (ret)
}
return (ret);
}
/*
* Lookup
*/
/*ARGSUSED3*/
static int
{
int error;
/* execute access is required to search the directory */
return (error);
if (!SDEV_IS_GLOBAL(parent))
}
/*ARGSUSED2*/
static int
{
int error = 0;
return (ENOTSUP);
return (ENOENT);
}
/* non-global do not allow pure node creation */
if (!SDEV_IS_GLOBAL(parent)) {
}
/* execute access is required to search the directory */
return (error);
/* check existing name */
/* XXXci - We may need to translate the C-I flags on VOP_LOOKUP */
/* name found */
if (error == 0) {
} else {
}
if (error) {
return (error);
}
/* truncation first */
if (error) {
return (error);
}
}
return (0);
}
/* bail out early */
return (error);
/* verify write access - compliance specifies ENXIO */
return (error);
}
/*
* For memory-based (ROFS) directory:
* - either disallow node creation;
* - or implement VOP_CREATE of its own
*/
if (!SDEV_IS_PERSIST(parent)) {
return (ENOTSUP);
}
cred, SDEV_READY);
if (error) {
if (self)
return (error);
}
/* take care the timestamps for the node and its parent */
if (SDEV_IS_GLOBAL(parent))
/* wake up other threads blocked on looking up this node */
return (error);
}
static int
{
int error;
int (*fn)(devname_handle_t *);
int len;
int bkstore = 0;
/* bail out early */
if (nm[0] == '.') {
if (len == 1) {
return (EINVAL);
return (EEXIST);
}
}
if (!SDEV_IS_GLOBAL(parent)) {
return (ENOTSUP);
}
/* execute access is required to search the directory */
return (error);
}
/* check existence first */
return (ENOENT);
}
return (ENOENT);
}
/* write access is required to remove an entry */
return (error);
}
if (error) {
return (error);
}
}
/*
* sdev_dirdelete does the real job of:
* - make sure no open ref count
* - destroying the sdev_node
* - releasing the hold on attrvp
*/
}
/* report errors other than EBUSY */
} else {
sdcmn_err2(("sdev_remove: cleaning node %s from cache "
/*
* best efforts clean up the backing store
*/
if (bkstore) {
/*
* do not report BUSY error
* because the backing store ref count is released
* when the last ref count on the sdev_node is
* released.
*/
sdcmn_err2(("sdev_remove: device %s is still on"
error = 0;
}
}
error = 0;
}
return (error);
}
/*
* Some restrictions for this file system:
* - both oldnm and newnm are in the scope of /dev file system,
* to simply the namespace management model.
*/
/*ARGSUSED6*/
static int
{
int samedir = 0; /* set if odvp == ndvp */
int len;
char nnm_path[MAXPATHLEN];
int (*fn)(devname_handle_t *, char *);
int (*rmfn)(devname_handle_t *);
int error = 0;
int bkstore = 0;
/* prevent modifying "." and ".." */
if ((onm[0] == '.' &&
(nnm[0] == '.' &&
return (EINVAL);
}
/* ZOMBIE parent doesn't allow new node creation */
return (ENOENT);
}
/* renaming only supported for global device nodes */
if (!SDEV_IS_GLOBAL(fromparent)) {
return (ENOTSUP);
}
return (ENOENT);
}
/*
* acquire the global lock to prevent
*/
/* check existence of the source node */
/* XXXci - We may need to translate the C-I flags on VOP_LOOKUP */
if (error) {
sdcmn_err2(("sdev_rename: the source node %s exists\n",
onm));
return (error);
}
}
/* check existence of destination */
/* XXXci - We may need to translate the C-I flags on VOP_LOOKUP */
return (error);
}
}
/*
* make sure the source and the destination are
* in the same dev filesystem
*/
return (error);
}
return (error);
}
return (EXDEV);
}
}
/* make sure the old entry can be deleted */
if (error) {
return (error);
}
/* make sure the destination allows creation */
if (!samedir) {
if (error) {
return (error);
}
}
/* check with the plug-in modules for the source directory */
if (samedir) {
} else {
}
if (error) {
sdcmn_err2(("sdev_rename: DBNR doesn't "
"allow rename, error %d", error));
return (error);
}
}
/* destination file exists */
if (nvp) {
}
/*
* link source to new target in the memory
*/
if (error) {
sdcmn_err2(("sdev_rename: renaming %s to %s failed "
if (nvp)
return (error);
}
/* notify the DBNR module the node is going away */
}
/*
* unlink from source
*/
sdcmn_err2(("sdev_rename: the source is deleted already\n"));
return (0);
}
sdcmn_err2(("sdev_rename: the source is being deleted\n"));
return (0);
}
/* clean out the directory contents before it can be removed */
sdcmn_err2(("sdev_rename: cleandir finished with %d\n",
error));
error = 0;
}
/* best effforts clean up the backing store */
if (bkstore) {
/* XXXci - We may need to translate the C-I flags on VOP_REMOVE */
} else {
/* XXXci - We may need to translate the C-I flags on VOP_RMDIR */
}
if (error) {
sdcmn_err2(("sdev_rename: device %s is "
"still on disk %s\n", onm,
fromparent->sdev_path));
error = 0;
}
}
/* once reached to this point, the rename is regarded successful */
return (0);
}
/*
* dev-fs version of "ln -s path dev-name"
* tnm - path, e.g. /devices/... or /dev/...
* lnm - dev_name
*/
/*ARGSUSED6*/
static int
{
int error;
sdcmn_err2(("sdev_symlink: parent %s is ZOMBIED \n",
return (ENOENT);
}
if (!SDEV_IS_GLOBAL(parent)) {
return (ENOTSUP);
}
/* execute access is required to search a directory */
return (error);
/* find existing name */
/* XXXci - We may need to translate the C-I flags here */
if (error == 0) {
return (EEXIST);
}
return (error);
/* write access is required to create a symlink */
return (error);
/* put it into memory cache */
cred, SDEV_READY);
if (error) {
if (self)
return (error);
}
/* take care the timestamps for the node and its parent */
if (SDEV_IS_GLOBAL(parent))
/* wake up other threads blocked on looking up this node */
return (0);
}
/*ARGSUSED6*/
static int
{
int error;
return (ENOENT);
}
/* non-global do not allow pure directory creation */
if (!SDEV_IS_GLOBAL(parent)) {
}
/* execute access is required to search the directory */
return (error);
}
/* find existing name */
/* XXXci - We may need to translate the C-I flags on VOP_LOOKUP */
if (error == 0) {
return (EEXIST);
}
return (error);
/* require write access to create a directory */
return (error);
}
/* put it into memory */
if (error) {
if (self)
return (error);
}
/* take care the timestamps for the node and its parent */
if (SDEV_IS_GLOBAL(parent))
/* wake up other threads blocked on looking up this node */
return (0);
}
/*
* allowing removing an empty directory under /dev
*/
/*ARGSUSED*/
static int
{
int error = 0;
/* bail out early */
return (EINVAL);
return (EEXIST); /* should be ENOTEMPTY */
/* no destruction of non-global node */
if (!SDEV_IS_GLOBAL(parent)) {
return (ENOTSUP);
}
/* execute access is required to search the directory */
return (error);
/* check existing name */
return (ENOENT);
}
return (ENOENT);
}
/* write access is required to remove a directory */
return (error);
}
/* some sanity checks */
return (EINVAL);
}
return (ENOTDIR);
}
if (vn_vfswlock(vp)) {
return (EBUSY);
}
return (EBUSY);
}
/* bail out on a non-empty directory */
return (ENOTEMPTY);
}
/* unlink it from the directory cache */
} else {
sdcmn_err2(("sdev_rmdir: cleaning node %s from directory "
/* best effort to clean up the backing store */
if (SDEV_IS_PERSIST(parent)) {
sdcmn_err2(("sdev_rmdir: cleaning device %s is on"
}
error = 0;
}
return (error);
}
/*
* read the contents of a symbolic link
*/
static int
{
int error = 0;
if (dv->sdev_attrvp) {
/* non-NULL attrvp implys a persisted node at READY state */
/* memory nodes, e.g. local nodes */
return (error);
}
return (ENOENT);
}
/*ARGSUSED4*/
static int
{
int error;
/* execute access is required to search the directory */
return (error);
if (!SDEV_IS_GLOBAL(parent))
}
/*ARGSUSED1*/
static void
{
}
/*ARGSUSED2*/
static int
{
return (ENOSPC);
}
return (0);
}
/*
* This pair of routines bracket all VOP_READ, VOP_WRITE
* and VOP_READDIR requests. The contents lock stops things
* moving around while we're looking at them.
*/
/*ARGSUSED2*/
static int
{
}
/*ARGSUSED1*/
static void
{
}
/*ARGSUSED1*/
static int
{
}
/*ARGSUSED1*/
static int
{
int error;
return (error);
}
static int
{
}
static int
{
switch (cmd) {
case _PC_ACL_ENABLED:
return (0);
}
}
const fs_operation_def_t sdev_vnodeops_tbl[] = {
};
int sdev_vnodeops_tbl_size = sizeof (sdev_vnodeops_tbl);