/*
* 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) 2013, Joyent, Inc. All rights reserved.
* Copyright 2016 Nexenta Systems, Inc. All rights reserved.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#include <sys/pathname.h>
#include <sys/vfs_opreg.h>
#include <sys/rwstlock.h>
#include <sys/sysmacros.h>
#include <fs/fs_reparse.h>
/* Determine if this vnode is a file that is read-only */
/*
* Array of vopstats_t for per-FS-type vopstats. This array has the same
* number of entries as and parallel to the vfssw table. (Arguably, it could
* be part of the vfssw table.) Once it's initialized, it's accessed using
* the same fstype index that is used to index into the vfssw table.
*/
/* vopstats initialization template used for fast initialization via bcopy() */
/* Kmem cache handle for vsk_anchor_t allocations */
/* file events cleanup routine */
extern void free_fopdata(vnode_t *);
/*
* Root of AVL tree for the kstats associated with vopstats. Lock protects
* updates to vsktat_tree.
*/
/*
* forward declarations for internal vnode specific data (vsd)
*/
/*
* forward declarations for reparse point functions
*/
/*
* VSD -- VNODE SPECIFIC DATA
* The v_data pointer is typically used by a file system to store a
* pointer to the file system's private node (e.g. ufs inode, nfs rnode).
* However, there are times when additional project private data needs
* to be stored separately from the data (node) pointed to by v_data.
* This additional data could be stored by the file system itself or
* by a completely different kernel entity. VSD provides a way for
* callers to obtain a key and store a pointer to private data associated
* with a vnode.
*
* Callers are responsible for protecting the vsd by holding v_vsd_lock
* for calls to vsd_set() and vsd_get().
*/
/*
* vsd_lock protects:
* vsd_nkeys - creation and deletion of vsd keys
* vsd_list - insertion and deletion of vsd_node in the vsd_list
* vsd_destructor - adding and removing destructors to the list
*/
/* list of vsd_node's */
/* per-key destructor funcs */
static void (**vsd_destructor)(void *);
/*
* The following is the common set of actions needed to update the
* vopstats structure from a vnode op. Both VOPSTATS_UPDATE() and
* VOPSTATS_UPDATE_IO() do almost the same thing, except for the
* recording of the bytes transferred. Since the code is similar
* but small, it is nearly a duplicate. Consequently any changes
* to one may need to be reflected in the other.
* Rundown of the variables:
* vp - Pointer to the vnode
* counter - Partial name structure member to update in vopstats for counts
* bytecounter - Partial name structure member to update in vopstats for bytes
* bytesval - Value to update in vopstats for bytes
* fstype - Index into vsanchor_fstype[], same as index into vfssw[]
* vsp - Pointer to vopstats structure (either in vfs or vsanchor_fstype[i])
*/
(*stataddr)++; \
} \
} \
}
(*stataddr)++; \
} \
} \
}
/*
* If the filesystem does not support XIDs map credential
* If the vfsp is NULL, perhaps we should also map?
*/
}
/*
* Convert stat(2) formats to vnode types and vice versa. (Knows about
* numerical order of S_IFMT and vnode types.)
*/
};
};
/*
* The system vnode cache.
*/
/*
* Vnode operations vector.
*/
};
/* Extensible attribute (xva) routines. */
/*
* set AT_XVATTR in the embedded vattr_t's va_mask, and set up the pointer
* to the returned attributes array.
*/
void
{
}
/*
* If AT_XVATTR is set, returns a pointer to the embedded xoptattr_t
* structure. Otherwise, returns NULL.
*/
{
return (xoap);
}
/*
* Used by the AVL routines to compare two vsk_anchor_t structures in the tree.
* We use the f_fsid reported by VFS_STATVFS() since we use that for the
* kstat name.
*/
static int
{
int ret;
ret = -1;
ret = 1;
} else {
ret = 0;
}
return (ret);
}
/*
* Used to create a single template which will be bcopy()ed to a newly
* allocated vsanchor_combo_t structure in new_vsanchor(), below.
*/
static vopstats_t *
{
/* VOP_OPEN */
/* VOP_CLOSE */
/* VOP_READ I/O */
/* VOP_WRITE I/O */
/* VOP_IOCTL */
/* VOP_SETFL */
/* VOP_GETATTR */
/* VOP_SETATTR */
/* VOP_ACCESS */
/* VOP_LOOKUP */
/* VOP_CREATE */
/* VOP_REMOVE */
/* VOP_LINK */
/* VOP_RENAME */
/* VOP_MKDIR */
/* VOP_RMDIR */
/* VOP_READDIR I/O */
/* VOP_SYMLINK */
/* VOP_READLINK */
/* VOP_FSYNC */
/* VOP_INACTIVE */
/* VOP_FID */
/* VOP_RWLOCK */
/* VOP_RWUNLOCK */
/* VOP_SEEK */
/* VOP_CMP */
/* VOP_FRLOCK */
/* VOP_SPACE */
/* VOP_REALVP */
/* VOP_GETPAGE */
/* VOP_PUTPAGE */
/* VOP_MAP */
/* VOP_ADDMAP */
/* VOP_DELMAP */
/* VOP_POLL */
/* VOP_DUMP */
/* VOP_PATHCONF */
/* VOP_PAGEIO */
/* VOP_DUMPCTL */
/* VOP_DISPOSE */
/* VOP_SETSECATTR */
/* VOP_GETSECATTR */
/* VOP_SHRLOCK */
/* VOP_VNEVENT */
/* VOP_REQZCBUF */
/* VOP_RETZCBUF */
return (vsp);
}
/*
* Creates a kstat structure associated with a vopstats structure.
*/
kstat_t *
{
if (!vopstats_enabled) {
return (NULL);
}
sizeof (vopstats_t)/sizeof (kstat_named_t),
if (ksp) {
}
return (ksp);
}
/*
* Called from vfsinit() to initialize the support mechanisms for vopstats
*/
void
{
if (!vopstats_enabled)
return;
/*
* Creates the AVL tree which holds per-vfs vopstat anchors. This
* is necessary since we need to check if a kstat exists before we
* attempt to create it. Also, initialize its lock.
*/
/*
* Set up the array of pointers for the vopstats-by-FS-type.
* The entries will be allocated/initialized as each file system
* goes through modload/mod_installfs.
*/
/* Set up the global vopstats initialization template */
}
/*
* We need to have the all of the counters zeroed.
* The initialization of the vopstats_t includes on the order of
* 50 calls to kstat_named_init(). Rather that do that on every call,
* we do it once in a template (vs_templatep) then bcopy it over.
*/
void
{
return;
}
/*
* If possible, determine which vopstats by fstype to use and
* return a pointer to the caller.
*/
{
return (NULL);
/*
* Set up the fstype. We go to so much trouble because all versions
* of NFS use the same fstype in their vfs even though they have
* distinct entries in the vfssw[] table.
* NOTE: A special vfs (e.g., EIO_vfs) may not have an entry.
*/
if (vswp) {
} else {
}
/*
* Point to the per-fstype vopstats. The only valid values are
* non-zero positive values less than the number of vfssw[] table
* entries.
*/
}
return (vsp);
}
/*
* Generate a kstat name, create the kstat structure, and allocate a
* vsk_anchor_t to hold it together. Return the pointer to the vsk_anchor_t
* to the caller. This must only be called from a mount.
*/
{
return (NULL);
/* Need to get the fsid to build a kstat name */
/* Create a name for our kstats based on fsid */
/* Allocate and initialize the vsk_anchor_t */
/*
* Now that we've got the anchor in the AVL
* tree, we can create the kstat.
*/
if (ksp) {
}
} else {
/* Oops, found one! Release memory and lock. */
}
}
return (vskp);
}
/*
* We're in the process of tearing down the vfs and need to cleanup
* the data structures associated with the vopstats. Must only be called
* from dounmount().
*/
void
{
return;
/* This is a safe check since VFS_STATS must be set (see above) */
return;
/* Whack the pointer right away */
/* Lock the tree, remove the node, and delete the kstat */
}
}
}
/*
* Read or write a vnode. Called from kernel code.
*/
int
int ioflag,
{
int error;
int in_crit = 0;
return (EROFS);
if (len < 0)
return (EIO);
/*
* We have to enter the critical region before calling VOP_RWLOCK
* to avoid a deadlock with ufs.
*/
if (nbl_need_check(vp)) {
int svmand;
in_crit = 1;
if (error != 0)
goto done;
goto done;
}
}
(void) VOP_RWLOCK(vp,
} else {
}
if (residp)
done:
if (in_crit)
return (error);
}
/*
* Release a vnode. Call VOP_INACTIVE on last reference or
* decrement reference count.
*
* To avoid race conditions, the v_count is left at 1 for
* the call to VOP_INACTIVE. This prevents another thread
* from reclaiming and releasing the vnode *before* the
* VOP_INACTIVE routine has a chance to destroy the vnode.
* We can't have more than 1 thread calling VOP_INACTIVE
* on a vnode.
*/
void
{
return;
}
}
/*
* Release a vnode referenced by the DNLC. Multiple DNLC references are treated
* as a single reference, so v_count is not decremented until the last DNLC hold
* is released. This makes it possible to distinguish vnodes that are referenced
* only by the DNLC.
*/
void
{
if (--vp->v_count_dnlc == 0) {
return;
}
}
}
/*
* Like vn_rele() except that it clears v_stream under v_lock.
* This is used by sockfs when it dismantels the association between
* the sockfs node and the vnode in the underlaying file system.
* v_lock has to be held to prevent a thread coming through the lookupname
* path from accessing a stream head that is going away.
*/
void
{
return;
}
}
static void
{
}
/*
* Like vn_rele() except if we are going to call VOP_INACTIVE() then do it
* asynchronously using a taskq. This can avoid deadlocks caused by re-entering
* the file system as a result of releasing the vnode. Note, file systems
* already have to handle the race where the vnode is incremented before the
* inactive routine is called and does its locking.
*
* Warning: Excessive use of this routine can lead to performance problems.
* This is because taskqs throttle back allocation if too many are created.
*/
void
{
return;
}
}
int
char *pnamep,
int filemode,
int createmode,
{
}
/*
* This may be callable by the kernel, the only known use
* of user context being that the current user credentials
* are used for permissions. crwhy is defined iff filemode & FCREAT.
*/
int
char *pnamep,
int filemode,
int createmode,
int fd)
{
int mode;
int accessflags;
int error;
int in_crit = 0;
int open_done = 0;
int shrlock_done = 0;
int estale_retry = 0;
mode = 0;
accessflags = 0;
/* symlink interpretation */
else
accessflags |= V_APPEND;
top:
/*
* Wish to create a file.
*/
}
else
if (error =
return (error);
} else {
/*
* Wish to open a file. Just look it up.
*/
goto top;
return (error);
}
/*
* Get the attributes to check whether file is large.
* We do this only if the FOFFMAX flag is not set and
* only for regular files.
*/
goto out;
}
/*
* Large File API - regular open fails
* if FOFFMAX flag is set in file mode
*/
goto out;
}
}
/*
* Can't write directories, active texts, or
* read-only filesystems. Can't truncate files
* on which mandatory locking is in effect.
*/
/*
* Allow writable directory if VDIROPEN flag is set.
*/
goto out;
}
goto out;
}
/*
* Can't truncate files on which
* sysv mandatory locking is in effect.
*/
}
}
if (error)
goto out;
}
/*
* Check permissions.
*/
goto out;
/*
* Require FSEARCH to return a directory.
* Require FEXEC to return a regular file.
*/
goto out;
}
goto out;
}
}
/*
* Do remaining checks for FNOFOLLOW and FNOLINKS.
*/
goto out;
}
goto out;
}
goto out;
}
}
/*
* Opening a socket corresponding to the AF_UNIX pathname
* in the filesystem name space is not supported.
* However, VSOCK nodes in namefs are supported in order
* to make fattach work for sockets.
*
* XXX This uses VOP_REALVP to distinguish between
* an unopened namefs node (where VOP_REALVP returns a
* different VSOCK vnode) and a VSOCK created by vn_create
* in some file system (where VOP_REALVP would never return
* a different vnode).
*/
error = EOPNOTSUPP;
goto out;
}
}
/* get share reservation */
NULL);
if (error)
goto out;
shrlock_done = 1;
/* nbmand conflict check if truncating file */
in_crit = 1;
goto out;
NULL)) {
goto out;
}
}
}
/*
* Do opening protocol.
*/
if (error)
goto out;
open_done = 1;
/*
* Truncate if required.
*/
goto out;
}
out:
if (in_crit) {
in_crit = 0;
}
if (error) {
if (open_done) {
NULL);
open_done = 0;
shrlock_done = 0;
}
if (shrlock_done) {
NULL);
shrlock_done = 0;
}
/*
* The following clause was added to handle a problem
* with NFS consistency. It is possible that a lookup
* of the file to be opened succeeded, but the file
* itself doesn't actually exist on the server. This
* is chiefly due to the DNLC containing an entry for
* the file which has been removed on the server. In
* this case, we just start over. If there was some
* other cause for the ESTALE error, then the lookup
* of the file will fail and the error will be returned
* above instead of looping around from here.
*/
goto top;
} else
return (error);
}
/*
* The following two accessor functions are for the NFSv4 server. Since there
* is no VOP_OPEN_UP/DOWNGRADE we need a way for the NFS server to keep the
* vnode open counts correct when a client "upgrades" an open or does an
* open_downgrade. In NFS, an upgrade or downgrade can not only change the
* modes. However, share reservations are not integrated with OPEN, yet, so
* we need to handle each separately. These functions are cleaner than having
* the NFS server manipulate the counts directly, however, nobody else should
* use these functions.
*/
void
int filemode)
{
}
void
int filemode)
{
}
}
}
int
char *pnamep,
int mode,
int flag,
{
}
/*
* Create a vnode (makenode).
*/
int
char *pnamep,
int mode,
int flag,
{
int error;
int in_crit = 0;
int estale_retry = 0;
/* symlink interpretation */
else
top:
/*
* Lookup directory.
* If new object is a file, call lower level to create it.
* Note that it is up to the lower level to enforce exclusive
* creation, if the file is already there.
* This allows the lower level to do whatever
* locking or protocol that is needed to prevent races.
* If the new object is directory call lower level to make
* the new directory, with "." and "..".
*/
return (error);
if (auditing)
/*
* lookup will find the parent directory for the vnode.
* When it is done the pn holds the name of the entry
* in the directory.
* If this is a non-exclusive create we also find the node itself.
*/
if (error) {
goto top;
return (error);
}
/*
* If default ACLs are defined for the directory don't apply the
* umask if umask is passed.
*/
if (umask) {
vsec.vsa_aclcnt = 0;
vsec.vsa_dfaclcnt = 0;
/*
* If error is ENOSYS then treat it as no error
* Don't want to force all file systems to support
* aclent_t style of ACL's.
*/
error = 0;
if (error) {
goto out;
} else {
/*
* Apply the umask if no default ACLs.
*/
if (vsec.vsa_dfaclcnt == 0)
/*
* VOP_GETSECATTR() may have allocated memory for
* ACLs we didn't request, so double-check and
* free it if necessary.
*/
}
}
/*
* In general we want to generate EROFS if the file system is
* readonly. However, POSIX (IEEE Std. 1003.1) section 5.3.1
* documents the open system call, and it says that O_CREAT has no
* effect if the file already exists. Bug 1119649 states
* that open(path, O_CREAT, ...) fails when attempting to open an
* existing file on a read only file system. Thus, the first part
* of the following if statement has 3 checks:
* if the file exists &&
* it is being open with write access &&
* the file system is read only
* then generate EROFS
*/
if (*vpp)
/*
* File already exists. If a mandatory lock has been
* applied, return error.
*/
in_crit = 1;
}
goto out;
}
goto out;
}
/*
* File cannot be truncated if non-blocking mandatory
* locks are currently on the file.
*/
goto out;
}
}
}
/*
* If the file is the root of a VFS, we've crossed a
* mount point and the "containing" directory that we
* acquired above (dvp) is irrelevant because it's in
* a different file system. We apply VOP_CREATE to the
* target itself instead of to the containing directory
* and supply a null path name to indicate (conventionally)
* the node itself as the "component" of interest.
*
* The call to VOP_CREATE() is necessary to ensure
* that the appropriate permission checks are made,
* i.e. EISDIR, EACCES, etc. We already know that vpp
* exists since we are in the else condition where this
* was checked.
*/
/*
* If the create succeeded, it will have created a
* new reference on a new vnode (*vpp) in the child
* file system, so we want to drop our reference on
* the old (vp) upon exit.
*/
goto out;
}
/*
* Large File API - non-large open (FOFFMAX flag not set)
* of regular file fails if the file size exceeds MAXOFF32_T.
*/
goto out;
}
goto out;
}
}
}
if (error == 0) {
/*
* Call mkdir() if specified, otherwise create().
*/
/*
* N.B., if vn_createat() ever requests
* case-insensitive behavior then it will need
* to be passed to VOP_MKDIR(). VOP_CREATE()
* will already get it via "flag"
*/
else if (!must_be_dir)
else
}
out:
if (auditing)
if (in_crit) {
in_crit = 0;
}
}
/*
* The following clause was added to handle a problem
* with NFS consistency. It is possible that a lookup
* of the file to be created succeeded, but the file
* itself doesn't actually exist on the server. This
* is chiefly due to the DNLC containing an entry for
* the file which has been removed on the server. In
* this case, we just start over. If there was some
* other cause for the ESTALE error, then the lookup
* of the file will fail and the error will be returned
* above instead of looping around from here.
*/
goto top;
return (error);
}
int
{
}
int
{
int error;
int estale_retry = 0;
top:
return (error);
goto out;
goto out;
/*
* Make sure both source vnode and target directory vnode are
* in the same vfs and that it is writeable.
*/
goto out;
goto out;
goto out;
}
goto out;
}
/*
* Do the link.
*/
(void) pn_fixslash(&pn);
out:
if (fvp)
if (tdvp)
goto top;
return (error);
}
int
{
}
int
{
int error;
int estale_retry = 0;
top:
in_crit_src = in_crit_targ = 0;
/*
* Get to and from pathnames.
*/
return (error);
return (error);
}
/*
* First we need to resolve the correct directories
* The passed in directories may only be a starting point,
* but we need the real directories the file(s) live in.
* and we were passed in the / directory, but we need to
* use the lib directory for the rename.
*/
/*
* Lookup to and from directories.
*/
goto out;
}
/*
* Make sure there is an entry.
*/
goto out;
}
goto out;
}
/*
* Make sure both the from vnode directory and the to directory
* are in the same vfs and the to directory is writable.
* We check fsid's, not vfs pointers, so loopback fs works.
*/
goto out;
goto out;
goto out;
}
}
goto out;
}
/*
* Make sure "from" vp is not a mount point.
* Note, lookup did traverse() already, so
* we'll be looking at the mounted FS root.
* (but allow files like mnttab)
*/
goto out;
}
in_crit_targ = 1;
goto out;
}
}
if (nbl_need_check(fvp)) {
in_crit_src = 1;
goto out;
}
}
/*
* Do the rename.
*/
(void) pn_fixslash(&tpn);
NULL, 0);
out:
if (in_crit_src)
if (in_crit_targ)
if (fromvp)
if (tovp)
if (targvp)
if (fvp)
goto top;
return (error);
}
/*
* Remove a file or directory.
*/
int
{
}
int
{
int error;
int in_crit = 0;
int estale_retry = 0;
top:
return (error);
goto top;
return (error);
}
/*
* Make sure there is an entry.
*/
goto out;
}
/*
* If the named file is the root of a mounted filesystem, fail,
* unless it's marked unlinkable. In that case, unmount the
* filesystem and proceed to unlink the covered vnode. (If the
* covered vnode is a directory, use rmdir instead of unlink,
* to avoid file system corruption.)
*/
goto out;
}
/*
* Namefs specific code starts here.
*/
if (dirflag == RMDIRECTORY) {
/*
* User called rmdir(2) on a file that has
* been namefs mounted on top of. Since
* namefs doesn't allow directories to
* be mounted on other files we know
* vp is not of type VDIR so fail to operation.
*/
goto out;
}
/*
* If VROOT is still set after grabbing vp->v_lock,
* noone has finished nm_unmount so far and coveredvp
* is valid.
* If we manage to grab vn_vfswlock(coveredvp) before releasing
* vp->v_lock, any race window is eliminated.
*/
/* Someone beat us to the unmount */
goto out;
}
/*
* Note: Implementation of vn_vfswlock shows that ordering of
* v_lock / vn_vfswlock is not an issue here.
*/
if (error)
goto out;
/*
* Unmounted the namefs file system; now get
* the object it was mounted over.
*/
/*
* If namefs was mounted over a directory, then
* we want to use rmdir() instead of unlink().
*/
if (error)
goto out;
}
/*
* Make sure filesystem is writeable.
* We check the parent directory's vfs in case this is an lofs vnode.
*/
goto out;
}
/*
* If there is the possibility of an nbmand share reservation, make
* sure it's okay to remove the file. Keep a reference to the
* vnode, so that we can exit the nbl critical region after
* calling VOP_REMOVE.
* If there is no possibility of an nbmand share reservation,
* release the vnode reference now. Filesystems like NFS may
* behave differently if there is an extra reference, so get rid of
* this one. Fortunately, we can't have nbmand mounts on NFS
* filesystems.
*/
if (nbl_need_check(vp)) {
in_crit = 1;
goto out;
}
} else {
}
if (dirflag == RMDIRECTORY) {
/*
* Caller is using rmdir(2), which can only be applied to
* directories.
*/
} else {
NULL, 0);
}
} else {
/*
* Unlink(2) can be applied to anything.
*/
}
out:
if (in_crit) {
in_crit = 0;
}
goto top;
return (error);
}
/*
* Utility function to compare equality of vnodes.
* Compare the underlying real vnodes, if there are underlying vnodes.
* This is a more thorough comparison than the VN_CMP() macro provides.
*/
int
{
}
/*
* The number of locks to hash into. This value must be a power
* of 2 minus 1 and should probably also be prime.
*/
struct vn_vfslocks_bucket {
};
/*
* Total number of buckets will be NUM_BUCKETS + 1 .
*/
/*
* vn_vfslocks_getlock() uses an HASH scheme to generate
*
* vn_vfslocks_rele() releases a reference in the
* HASH table which allows the entry allocated by
* vn_vfslocks_getlock() to be freed at a later
* stage when the refcount drops to zero.
*/
{
return (vep);
}
}
/*
* There is already an entry in the hash
* destroy what we just allocated.
*/
return (tvep);
}
}
return (vep);
}
void
{
else {
/* LINTED */
}
return;
}
}
}
}
/*
* vn_vfswlock_wait is used to implement a lock which is logically a writers
* lock protecting the v_vfsmountedhere field.
* vn_vfswlock_wait has been modified to be similar to vn_vfswlock,
* except that it blocks to acquire the lock VVFSLOCK.
*
* traverse() and routines re-implementing part of traverse (e.g. autofs)
* need to hold this lock. mount(), vn_rename(), vn_remove() and so on
* need the non-blocking version of the writers lock i.e. vn_vfswlock
*/
int
{
int retval;
return (EINTR);
}
return (retval);
}
int
{
int retval;
return (EINTR);
}
return (retval);
}
/*
* vn_vfswlock is used to implement a lock which is logically a writers lock
* protecting the v_vfsmountedhere field.
*/
int
{
/*
* If vp is NULL then somebody is trying to lock the covered vnode
* of /. (vfs_vnodecovered is NULL for /). This situation will
* only happen when unmounting /. Since that operation will fail
* anyway, return EBUSY here instead of in VFS_UNMOUNT.
*/
return (EBUSY);
return (0);
return (EBUSY);
}
int
{
/*
* If vp is NULL then somebody is trying to lock the covered vnode
* of /. (vfs_vnodecovered is NULL for /). This situation will
* only happen when unmounting /. Since that operation will fail
* anyway, return EBUSY here instead of in VFS_UNMOUNT.
*/
return (EBUSY);
return (0);
return (EBUSY);
}
void
{
/*
* ve_refcnt needs to be decremented twice.
* 1. To release refernce after a call to vn_vfslocks_getlock()
* 2. To release the reference from the locking routines like
* vn_vfsrlock/vn_vfswlock etc,.
*/
}
int
{
int held;
return (held);
}
int
const char *name, /* Name of file system */
{
int unused_ops;
int error;
if (error) {
}
#if DEBUG
if (unused_ops != 0)
#endif
return (error);
}
/*
* Free the vnodeops created as a result of vn_make_ops()
*/
void
{
}
/*
* Vnode cache.
*/
/* ARGSUSED */
static int
{
return (0);
}
/* ARGSUSED */
static void
{
}
void
vn_create_cache(void)
{
/* LINTED */
NULL, 0);
}
void
vn_destroy_cache(void)
{
}
/*
* Used by file systems when fs-specific nodes (e.g., ufs inodes) are
* cached by the file system and vnodes remain associated.
*/
void
{
/*
* XXX - This really belongs in vn_reinit(), but we have some issues
* with the counts. Best to have it here for clean initialization.
*/
vp->v_mmap_read = 0;
vp->v_mmap_write = 0;
/*
* If FEM was in use, make sure everything gets cleaned up
* NOTE: vp->v_femhead is initialized to NULL in the vnode
* constructor.
*/
/* XXX - There should be a free_femhead() that does all this */
}
}
}
}
/*
* Used to reset the vnode fields including those that are directly accessible
* as well as those which require an accessor function.
*
* Does not initialize:
* synchronization objects: v_lock, v_vsd_lock, v_nbllock, v_cv
* v_data (since FS-nodes and vnodes point to each other and should
* be updated simultaneously)
* v_op (in case someone needs to make a VOP call on this object)
*/
void
{
vp->v_count_dnlc = 0;
vn_recycle(vp);
}
vnode_t *
{
}
return (vp);
}
void
{
/*
* Some file systems call vn_free() with v_count of zero,
* some with v_count of 1. In any case, the value should
* never be anything else.
*/
}
/* If FEM was in use, make sure everything gets cleaned up */
/* XXX - There should be a free_femhead() that does all this */
}
}
}
/*
* vnode status changes, should define better states than 1, 0.
*/
void
{
return;
}
}
void
{
return;
}
}
void
{
return;
}
}
void
{
return;
}
}
/* Vnode event notification */
int
{
return (EINVAL);
}
void
{
return;
}
}
void
{
return;
}
}
void
{
return;
}
}
void
{
return;
}
}
void
{
return;
}
}
void
{
return;
}
}
void
{
return;
}
}
void
{
return;
}
}
void
{
return;
}
}
void
{
return;
}
}
void
{
return;
}
}
void
{
return;
}
}
/*
* Vnode accessors.
*/
int
{
}
int
{
}
int
{
}
int
{
}
/*
* Return 0 if the vnode in question shouldn't be permitted into a zone via
* zone_enter(2).
*/
int
{
if (nfs_global_client_only != 0)
return (1);
/*
* We always want to look at the underlying vnode if there is one.
*/
/*
* Some pseudo filesystems (including doorfs) don't actually register
* their vfsops_t, so the following may return NULL; we happily let
* such vnodes switch zones.
*/
allow = 0;
}
return (allow);
}
/*
* Return nonzero if the vnode is a mount point, zero if not.
*/
int
{
}
/* Retrieve the vfs (if any) mounted on this vnode */
vfs_t *
{
return (vp->v_vfsmountedhere);
}
/*
* Return nonzero if the vnode is referenced by the dnlc, zero if not.
*/
int
{
return (vp->v_count_dnlc > 0);
}
/*
* vn_has_other_opens() checks whether a particular file is opened by more than
* This routine is for calling after the caller has already called VOP_OPEN()
* and the caller wishes to know if they are the only one with it open for
* the mode(s) specified.
*
* Vnode counts are only kept on regular files (v_type=VREG).
*/
int
{
switch (mode) {
case V_WRITE:
return (V_TRUE);
break;
case V_RDORWR:
return (V_TRUE);
break;
case V_RDANDWR:
return (V_TRUE);
break;
case V_READ:
return (V_TRUE);
break;
}
return (V_FALSE);
}
/*
* vn_is_opened() checks whether a particular file is opened and
*
* Vnode counts are only kept on regular files (v_type=VREG).
*/
int
{
switch (mode) {
case V_WRITE:
return (V_TRUE);
break;
case V_RDANDWR:
return (V_TRUE);
break;
case V_RDORWR:
return (V_TRUE);
break;
case V_READ:
return (V_TRUE);
break;
}
return (V_FALSE);
}
/*
* vn_is_mapped() checks whether a particular file is mapped and whether
*/
int
{
#if !defined(_LP64)
switch (mode) {
/*
* The atomic_add_64_nv functions force atomicity in the
* case of 32 bit architectures. Otherwise the 64 bit values
* require two fetches. The value of the fields may be
* (potentially) changed between the first fetch and the
* second
*/
case V_WRITE:
return (V_TRUE);
break;
case V_RDANDWR:
return (V_TRUE);
break;
case V_RDORWR:
return (V_TRUE);
break;
case V_READ:
return (V_TRUE);
break;
}
#else
switch (mode) {
case V_WRITE:
if (vp->v_mmap_write)
return (V_TRUE);
break;
case V_RDANDWR:
return (V_TRUE);
break;
case V_RDORWR:
return (V_TRUE);
break;
case V_READ:
if (vp->v_mmap_read)
return (V_TRUE);
break;
}
#endif
return (V_FALSE);
}
/*
* Set the operations vector for a vnode.
*
* FEM ensures that the v_femhead pointer is filled in before the
* v_op pointer is changed. This means that if the v_femhead pointer
* is NULL, and the v_op field hasn't changed since before which checked
* the v_femhead pointer; then our update is ok - we are not racing with
* FEM.
*/
void
{
/*
* If vp->v_femhead == NULL, then we'll call atomic_cas_ptr() to do
* the compare-and-swap on vp->v_op. If either fails, then FEM is
* in effect on the vnode and we need to have FEM deal with it.
*/
op) {
}
}
/*
* Retrieve the operations vector for a vnode
* As with vn_setops(above); make sure we aren't racing with FEM.
* FEM sets the v_op to a special, internal, vnodeops that wouldn't
* make sense to the callers of this routine.
*/
{
return (op);
} else {
return (fem_getvnops(vp));
}
}
/*
* Returns non-zero (1) if the vnodeops matches that of the vnode.
* Returns zero (0) if not.
*/
int
{
}
/*
* Returns non-zero (1) if the specified operation matches the
* corresponding operation for that the vnode.
* Returns zero (0) if not.
*/
int
{
loc = (fs_generic_func_p *)
break;
}
}
}
/*
* fs_new_caller_id() needs to return a unique ID on a given local system.
* The IDs do not need to survive across reboots. These are primarily
* used so that (FEM) monitors can detect particular callers (such as
*/
{
}
/*
* Given a starting vnode and a path, updates the path in the target vnode in
* a safe manner. If the vnode already has path information embedded, then the
* cached path is left untouched.
*/
void
{
char *rpath;
if (*path == '/') {
path++;
plen--;
} else {
}
/*
* We cannot grab base->v_lock while we hold vp->v_lock because of
* the potential for deadlock.
*/
return;
}
/* Avoid adding a slash if there's already one there */
doslash = 0;
else
rpathalloc++;
/*
* We don't want to call kmem_alloc(KM_SLEEP) with kernel locks held,
* so we must do this dance. If, by chance, something changes the path,
* just give up since there is no real harm.
*/
/* Paths should stay within reason */
if (rpathalloc > max_vnode_path)
return;
return;
}
if (doslash)
} else {
}
}
/*
* Sets the path to the vnode to be the given string, regardless of current
* context. The string must be a complete path from rootdir. This is only used
* by fsop_root() for setting the path based on the mountpoint.
*/
void
{
return;
}
}
/*
* Called from within filesystem's vop_rename() to handle renames once the
* target vnode is available.
*/
void
{
char *tmp;
}
/*
* Similar to vn_setpath_str(), this function sets the path of the destination
* vnode to the be the same as the source vnode.
*/
void
{
char *buf;
int alloc;
return;
}
/* avoid kmem_alloc() with lock held */
return;
}
return;
}
}
/*
* XXX Private interface for segvn routines that handle vnode
* large page segments.
*
* return 1 if vp's file system VOP_PAGEIO() implementation
* can be safely used instead of VOP_GETPAGE() for handling
* pagefaults against regular non swap files. VOP_PAGEIO()
* interface is considered safe here if its implementation
* is very close to VOP_GETPAGE() implementation.
* e.g. It zero's out the part of the page beyond EOF. Doesn't
* panic if there're file holes but instead returns an error.
* Doesn't assume file won't be changed by user writes, etc.
*
* return 0 otherwise.
*
* For now allow segvn to only use VOP_PAGEIO() with ufs and nfs.
*/
int
{
return (0);
}
return (1);
}
}
return (0);
}
/* VOP_XXX() macros call the corresponding fop_xxx() function */
int
int mode,
{
int ret;
/*
* Adding to the vnode counts before calling open
* avoids the need for a mutex. It circumvents a race
* condition where a query made on the vnode counts results in a
* false negative. The inquirer goes away believing the file is
* not open when there is an open on the file already under way.
*
* The counts are meant to prevent NFS from granting a delegation
* when it would be dangerous to do so.
*
* The vnode counts are only kept on regular files
*/
}
if (ret) {
/*
* Use the saved vp just in case the vnode ptr got trashed
* by the error.
*/
} else {
/*
* Some filesystems will return a different vnode,
* but the same path was still used to open it.
* So if we do change the vnode and need to
* copy over the path, do so here, rather than special
* casing each filesystem. Adjust the vnode counts to
* reflect the vnode switch.
*/
}
}
return (ret);
}
int
int flag,
int count,
{
int err;
/*
* Check passed in count to handle possible dups. Vnode counts are only
* kept on regular files
*/
}
}
}
return (err);
}
int
int ioflag,
{
int err;
return (err);
}
int
int ioflag,
{
int err;
return (err);
}
int
int cmd,
int flag,
int *rvalp,
{
int err;
return (err);
}
int
int oflags,
int nflags,
{
int err;
return (err);
}
int
int flags,
{
int err;
/*
* If this file system doesn't understand the xvattr extensions
* then turn off the xvattr bit.
*/
}
/*
* We're only allowed to skip the ACL check iff we used a 32 bit
* ACE mask with VOP_ACCESS() to determine permissions.
*/
if ((flags & ATTR_NOACLCHECK) &&
return (EINVAL);
}
return (err);
}
int
int flags,
{
int err;
/*
* If this file system doesn't understand the xvattr extensions
* then turn off the xvattr bit.
*/
}
/*
* We're only allowed to skip the ACL check iff we used a 32 bit
* ACE mask with VOP_ACCESS() to determine permissions.
*/
if ((flags & ATTR_NOACLCHECK) &&
return (EINVAL);
}
return (err);
}
int
int mode,
int flags,
{
int err;
if ((flags & V_ACE_MASK) &&
return (EINVAL);
}
return (err);
}
int
char *nm,
int flags,
int *deflags, /* Returned per-dirent flags */
{
int ret;
/*
* If this file system doesn't support case-insensitive access
* and said access is requested, fail quickly. It is required
* that if the vfs supports case-insensitive lookup, it also
* supports extended dirent flags.
*/
if (flags & FIGNORECASE &&
return (EINVAL);
} else {
}
}
}
return (ret);
}
int
char *name,
int mode,
int flags,
{
int ret;
return (EINVAL);
}
/*
* If this file system doesn't support case-insensitive access
* and said access is requested, fail quickly.
*/
if (flags & FIGNORECASE &&
return (EINVAL);
}
}
return (ret);
}
int
char *nm,
int flags)
{
int err;
/*
* If this file system doesn't support case-insensitive access
* and said access is requested, fail quickly.
*/
if (flags & FIGNORECASE &&
return (EINVAL);
return (err);
}
int
char *tnm,
int flags)
{
int err;
/*
* If the target file system doesn't support case-insensitive access
* and said access is requested, fail quickly.
*/
if (flags & FIGNORECASE &&
return (EINVAL);
return (err);
}
int
char *snm,
char *tnm,
int flags)
{
int err;
/*
* If the file system involved does not support
* case-insensitive access and said access is requested, fail
* quickly.
*/
if (flags & FIGNORECASE &&
return (EINVAL);
return (err);
}
int
char *dirname,
int flags,
{
int ret;
return (EINVAL);
}
/*
* If this file system doesn't support case-insensitive access
* and said access is requested, fail quickly.
*/
if (flags & FIGNORECASE &&
return (EINVAL);
}
}
return (ret);
}
int
char *nm,
int flags)
{
int err;
/*
* If this file system doesn't support case-insensitive access
* and said access is requested, fail quickly.
*/
if (flags & FIGNORECASE &&
return (EINVAL);
return (err);
}
int
int *eofp,
int flags)
{
int err;
/*
* If this file system doesn't support retrieving directory
* entry flags and said access is requested, fail quickly.
*/
if (flags & V_RDDIR_ENTFLAGS &&
return (EINVAL);
return (err);
}
int
char *linkname,
char *target,
int flags)
{
int err;
/*
* If this file system doesn't support case-insensitive access
* and said access is requested, fail quickly.
*/
if (flags & FIGNORECASE &&
return (EINVAL);
/* check for reparse point */
strlen(FS_REPARSE_TAG_STR)) == 0)) {
}
return (err);
}
int
{
int err;
return (err);
}
int
int syncflag,
{
int err;
return (err);
}
void
{
/* Need to update stats before vop call since we may lose the vnode */
}
int
{
int err;
return (err);
}
int
int write_lock,
{
int ret;
return (ret);
}
void
int write_lock,
{
}
int
{
int err;
return (err);
}
int
{
int err;
return (err);
}
int
int cmd,
int flag,
struct flk_callback *flk_cbp,
{
int err;
return (err);
}
int
int cmd,
int flag,
{
int err;
return (err);
}
int
{
int err;
return (err);
}
int
{
int err;
return (err);
}
int
int flags,
{
int err;
return (err);
}
int
{
int err;
return (err);
}
int
{
int error;
/*
* If file is declared MAP_PRIVATE, it can't be written back
* even if open for write. Handle as read.
*/
if (flags & MAP_PRIVATE) {
} else {
/*
* atomic_add_64 forces the fetch of a 64 bit value to
* be atomic on 32 bit machines
*/
if (maxprot & PROT_WRITE)
}
}
return (error);
}
int
{
int error;
/*
* NFS calls into delmap twice, the first time
* it simply establishes a callback mechanism and returns EAGAIN
* while the real work is being done upon the second invocation.
* We have to detect this here and only decrement the counts upon
* the second delmap request.
*/
if (flags & MAP_PRIVATE) {
} else {
/*
* atomic_add_64 forces the fetch of a 64 bit value
* to be atomic on 32 bit machines
*/
if (maxprot & PROT_WRITE)
}
}
return (error);
}
int
short events,
int anyyet,
short *reventsp,
{
int err;
return (err);
}
int
{
int err;
/* ensure lbdn and dblks can be passed safely to bdev_dump */
return (EIO);
return (err);
}
int
int cmd,
{
int err;
return (err);
}
int
int flags,
{
int err;
return (err);
}
int
int action,
{
int err;
return (err);
}
void
int flag,
int dn,
{
/* Must do stats first since it's possible to lose the vnode */
}
int
int flag,
{
int err;
/*
* We're only allowed to skip the ACL check iff we used a 32 bit
* ACE mask with VOP_ACCESS() to determine permissions.
*/
if ((flag & ATTR_NOACLCHECK) &&
return (EINVAL);
}
return (err);
}
int
int flag,
{
int err;
/*
* We're only allowed to skip the ACL check iff we used a 32 bit
* ACE mask with VOP_ACCESS() to determine permissions.
*/
if ((flag & ATTR_NOACLCHECK) &&
return (EINVAL);
}
return (err);
}
int
int cmd,
int flag,
{
int err;
return (err);
}
int
{
int err;
return (err);
}
int
{
int err;
return (ENOTSUP);
return (err);
}
int
{
int err;
return (ENOTSUP);
return (err);
}
/*
* Default destructor
* Needed because NULL destructor means that the key is unused
*/
/* ARGSUSED */
void
{}
/*
* Create a key (index into per vnode array)
* Locks out vsd_create, vsd_destroy, and vsd_free
* May allocate memory with lock held
*/
void
{
int i;
/*
* if key is allocated, do nothing
*/
if (*keyp) {
return;
}
/*
* find an unused key
*/
if (destructor == NULL)
for (i = 0; i < vsd_nkeys; ++i)
if (vsd_destructor[i] == NULL)
break;
/*
* if no unused keys, increase the size of the destructor array
*/
if (i == vsd_nkeys) {
nkeys = 1;
(void (**)(void *))vsd_realloc((void *)vsd_destructor,
}
/*
* allocate the next available unused key
*/
vsd_destructor[i] = destructor;
*keyp = i + 1;
/* create vsd_list, if it doesn't exist */
}
}
/*
* Destroy a key
*
* Assumes that the caller is preventing vsd_set and vsd_get
* Locks out vsd_create, vsd_destroy, and vsd_free
* May free memory with lock held
*/
void
{
/*
* protect the key namespace and our destructor lists
*/
*keyp = 0;
/*
* if the key is valid
*/
if (key != 0) {
/*
* for every vnode with VSD, call key's destructor
*/
/*
* no VSD for key in this vnode
*/
continue;
/*
* call destructor for key
*/
/*
* reset value for key
*/
}
/*
* actually free the key (NULL destructor == unused)
*/
vsd_destructor[k] = NULL;
}
}
/*
* Quickly return the per vnode value that was stored with the specified key
* Assumes the caller is protecting key from vsd_create and vsd_destroy
* Assumes the caller is holding v_vsd_lock to protect the vsd.
*/
void *
{
return (NULL);
}
/*
* Set a per vnode value indexed with the specified key
* Assumes the caller is holding v_vsd_lock to protect the vsd.
*/
int
{
if (key == 0)
return (EINVAL);
/*
* If the vsd was just allocated, vs_nkeys will be 0, so the following
* code won't happen and we will continue down and allocate space for
* the vs_value array.
* If the caller is replacing one value with another, then it is up
*/
return (0);
}
/*
* Link onto list of all VSD nodes.
*/
}
/*
* Allocate vnode local storage and set the value for key
*/
key * sizeof (void *));
return (0);
}
/*
* Called from vn_free() to run the destructor function for each vsd
* Locks out vsd_create and vsd_destroy
* Assumes that the destructor *DOES NOT* use vsd
*/
void
{
int i;
return;
return;
}
/*
* lock out vsd_create and vsd_destroy, call
* the destructor, and mark the value as destroyed.
*/
}
/*
* remove from linked list of VSD nodes
*/
/*
* free up the VSD
*/
}
/*
* realloc
*/
static void *
{
void *new;
if (old) {
}
return (new);
}
/*
* Setup the extensible system attribute for creating a reparse point.
* The symlink data 'target' is validated for proper format of a reparse
* string and a check also made to make sure the symlink data does not
* point to an existing file.
*
* return 0 if ok else -1.
*/
static int
{
return (-1);
/* validate reparse string */
if (reparse_validate((const char *)target))
return (-1);
return (0);
}
/*
* Function to check whether a symlink is a reparse point.
* Return B_TRUE if it is a reparse point, else return B_FALSE
*/
{
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
}