fs_subr.c revision 2f172c55ef76964744bc62b4500ece87f3089b4d
/*
* 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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Generic vnode operations.
*/
#include <fs/fs_reparse.h>
#include <acl/acl_common.h>
#include <sys/pathname.h>
/*
* Tunable to limit the number of retry to recover from STALE error.
*/
int fs_estale_retry = 5;
/*
* supports for reparse point door upcall
*/
static door_handle_t reparsed_door;
static kmutex_t reparsed_door_lock;
/*
* The associated operation is not supported by the file system.
*/
int
fs_nosys()
{
return (ENOSYS);
}
/*
* The associated operation is invalid (on this vnode).
*/
int
fs_inval()
{
return (EINVAL);
}
/*
* The associated operation is valid only for directories.
*/
int
{
return (ENOTDIR);
}
/*
* Free the file system specific resources. For the file systems that
* do not support the forced unmount, it will be a nop function.
*/
/*ARGSUSED*/
void
{
}
/* ARGSUSED */
int
{
return (ENOSYS);
}
/* ARGSUSED */
int
{
return (ENOSYS);
}
/* ARGSUSED */
int
register short events,
int anyyet,
register short *reventsp,
{
return (ENOSYS);
}
/*
* The file system has nothing to sync to disk. However, the
* VFS_SYNC operation must not fail.
*/
/* ARGSUSED */
int
{
return (0);
}
/*
* Does nothing but VOP_FSYNC must not fail.
*/
/* ARGSUSED */
int
{
return (0);
}
/*
* Does nothing but VOP_PUTPAGE must not fail.
*/
/* ARGSUSED */
int
{
return (0);
}
/*
* Does nothing but VOP_IOCTL must not fail.
*/
/* ARGSUSED */
int
int *rvalp)
{
return (0);
}
/*
*/
/* ARGSUSED */
int
{
return (-1);
}
/* ARGSUSED */
void
{
}
/*
* Compare two vnodes.
*/
/*ARGSUSED2*/
int
{
}
/*
* No-op seek operation.
*/
/* ARGSUSED */
int
{
}
/*
* File and record locking.
*/
/* ARGSUSED */
int
{
int frcmd;
int nlmid;
int error = 0;
int serialize = 0;
switch (cmd) {
case F_GETLK:
case F_O_GETLK:
if (flag & F_REMOTELOCK) {
} else if (flag & F_PXFSLOCK) {
} else {
frcmd = 0;
}
break;
case F_SETLK_NBMAND:
/*
* Are NBMAND locks allowed on this file?
*/
goto done;
}
goto done;
}
/*FALLTHROUGH*/
case F_SETLK:
if (flag & F_REMOTELOCK) {
} else if (flag & F_PXFSLOCK) {
} else {
}
if (cmd == F_SETLK_NBMAND &&
}
if (nbl_need_check(vp)) {
serialize = 1;
goto done;
}
}
}
break;
case F_SETLKW:
if (flag & F_REMOTELOCK) {
} else if (flag & F_PXFSLOCK) {
} else {
}
if (nbl_need_check(vp)) {
serialize = 1;
}
break;
case F_HASREMOTELOCKS:
if (nlmid != 0) { /* booted as a cluster */
} else { /* not booted as a cluster */
}
goto done;
default:
goto done;
}
/*
* If this is a blocking lock request and we're serializing lock
* requests, modify the callback list to leave the critical region
* while we're waiting for the lock.
*/
}
done:
if (serialize)
return (error);
}
/*
* Callback when a lock request blocks and we are serializing requests. If
* before sleeping, leave the critical region. If after wakeup, reenter
* the critical region.
*/
static callb_cpr_t *
{
if (when == FLK_BEFORE_SLEEP)
else {
}
return (NULL);
}
/*
* Allow any flags.
*/
/* ARGSUSED */
int
int oflags,
int nflags,
{
return (0);
}
/*
* Return the answer requested to poll() for non-device files.
* Only POLLIN, POLLRDNORM, and POLLOUT are recognized.
*/
/* ARGSUSED */
int
register short events,
int anyyet,
register short *reventsp,
{
*reventsp = 0;
if (events & POLLRDNORM)
*reventsp |= POLLRDNORM;
if (events & POLLRDBAND)
*reventsp |= POLLRDBAND;
if (events & POLLWRBAND)
*reventsp |= POLLWRBAND;
return (0);
}
/*
* POSIX pathconf() support.
*/
/* ARGSUSED */
int
int cmd,
{
register int error = 0;
switch (cmd) {
case _PC_LINK_MAX:
break;
case _PC_MAX_CANON:
break;
case _PC_MAX_INPUT:
break;
case _PC_NAME_MAX:
break;
break;
case _PC_PATH_MAX:
case _PC_SYMLINK_MAX:
val = MAXPATHLEN;
break;
case _PC_PIPE_BUF:
break;
case _PC_NO_TRUNC:
else
break;
case _PC_VDISABLE:
break;
case _PC_CHOWN_RESTRICTED:
if (rstchown)
else
break;
case _PC_FILESIZEBITS:
/*
* If ever we come here it means that underlying file system
* does not recognise the command and therefore this
* configurable limit cannot be determined. We return -1
* and don't change errno.
*/
break;
case _PC_ACL_ENABLED:
val = 0;
break;
case _PC_CASE_BEHAVIOR:
val |= _CASE_INSENSITIVE;
val &= ~_CASE_SENSITIVE;
break;
case _PC_SATTR_ENABLED:
case _PC_SATTR_EXISTS:
val = 0;
break;
case _PC_ACCESS_FILTERING:
val = 0;
break;
default:
break;
}
if (error == 0)
return (error);
}
/*
* Dispose of a page.
*/
/* ARGSUSED */
void
int fl,
int dn,
{
else
}
/* ARGSUSED */
void
int fl,
int dn,
{
}
/*
* fabricate acls for file systems that do not support acls.
*/
/* ARGSUSED */
int
int flag,
{
int error;
vsecattr->vsa_aclcnt = 0;
vsecattr->vsa_aclentsz = 0;
return (error);
aclentp++;
aclentp++;
aclentp++;
}
return (0);
}
/*
* Common code for implementing DOS share reservations
*/
/* ARGSUSED4 */
int
int cmd,
int flag,
{
int error;
/*
* Make sure that the file was opened with permissions appropriate
* for the request, and make sure the caller isn't trying to sneak
* in an NBMAND request.
*/
return (EBADF);
return (EINVAL);
return (EINVAL);
}
if (cmd == F_SHARE_NBMAND) {
/* make sure nbmand is allowed on the file */
return (EINVAL);
}
return (EINVAL);
}
}
switch (cmd) {
case F_SHARE_NBMAND:
/*FALLTHROUGH*/
case F_SHARE:
break;
case F_UNSHARE:
break;
case F_HASREMOTELOCKS:
/*
* We are overloading this command to refer to remote
* shares as well as remote locks, despite its name.
*/
error = 0;
break;
default:
break;
}
return (error);
}
/*ARGSUSED1*/
int
{
return (ENOTSUP);
}
/*ARGSUSED1*/
int
{
return (0);
}
/*
* return 1 for non-trivial ACL.
*
* NB: It is not necessary for the caller to VOP_RWLOCK since
* we only issue VOP_GETSECATTR.
*
* Returns 0 == trivial
* 1 == NOT Trivial
* <0 could not determine.
*/
int
{
int error;
int isnontrivial;
/* determine the forms of ACLs maintained */
/* clear bits we don't understand and establish default acl_style */
if (error || (acl_styles == 0))
vsecattr.vsa_aclcnt = 0;
vsecattr.vsa_dfaclcnt = 0;
while (acl_styles) {
/* select one of the styles as current flavor */
acl_flavor = 0;
if (acl_styles & _ACL_ACLENT_ENABLED) {
} else if (acl_styles & _ACL_ACE_ENABLED) {
}
if (error == 0)
break;
/* that flavor failed */
acl_styles &= ~acl_flavor;
}
/* if all styles fail then assume trivial */
if (acl_styles == 0)
return (0);
/* process the flavor that worked */
isnontrivial = 0;
if (acl_flavor & _ACL_ACLENT_ENABLED) {
isnontrivial = 1;
}
if (acl_flavor & _ACL_ACE_ENABLED) {
/* ACE has no vsecattr.vsa_dfaclcnt */
}
return (isnontrivial);
}
/*
* Check whether we need a retry to recover from STALE error.
*/
int
{
if (retry_count < fs_estale_retry)
return (1);
else
return (0);
}
/*
* Routine for anti-virus scanner to call to register its scanning routine.
*/
void
{
}
/*
* Routine for file systems to call to initiate anti-virus scanning.
* Scanning will only be done on REGular files (currently).
*/
int
{
int ret = 0;
return (ret);
}
/*
* support functions for reparse point
*/
/*
* reparse_vnode_parse
*
* Read the symlink data of a reparse point specified by the vnode
* and return the reparse data as name-value pair in the nvlist.
*/
int
{
int err;
char *lkdata;
return (EINVAL);
/*
* Set up io vector to read sym link data
*/
}
return (err);
}
void
{
}
static door_handle_t
{
} else
dh = reparsed_door;
}
return (dh);
}
static void
{
}
/*
* reparse_kderef
*
* Accepts the service-specific item from the reparse point and returns
* the service-specific data requested. The caller specifies the size of
* the buffer provided via *bufsz; the routine will fail with EOVERFLOW
* if the results will not fit in the buffer, in which case, *bufsz will
* contain the number of bytes needed to hold the results.
*
* if ok return 0 and update *bufsize with length of actual result
* else return error code.
*/
int
{
char *darg;
return (EINVAL);
/* get reparsed's door handle */
return (EBADF);
/* setup buffer for door_call args and results */
need_free = 1;
} else {
need_free = 0;
}
/* build argument string of door call */
/* setup args for door call */
/* do the door_call */
retried_doorhd = 0;
retries = 0;
if (++retries < REPARSED_DOORCALL_MAX_RETRY) {
continue;
}
/* door server goes away... */
if (retried_doorhd == 0) {
continue;
}
}
}
break;
}
if (rp_door)
if (need_free)
if (err != 0)
return (err);
/*
* have to save the length of the results before the
* bcopy below since it's can be an overlap copy that
* overwrites the reparsed_door_res_t structure at
* the beginning of the buffer.
*/
/* deref call is ok */
else
}
return (err);
}