#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/flock.h>
#include <sys/statvfs.h>
#include <sys/vfs.h>
#include <sys/vnode.h>
#include <sys/cred.h>
#include <sys/poll.h>
#include <sys/debug.h>
#include <sys/cmn_err.h>
#include <sys/share.h>
#include <sys/file.h>
#include <sys/kmem.h>
#include <sys/nbmlock.h>
#include <sys/acl.h>
#include <acl/acl_common.h>
#include <fs/fs_subr.h>
int fs_estale_retry = 5;
int
fs_nosys()
{
return (ENOSYS);
}
int
fs_inval()
{
return (EINVAL);
}
int
fs_notdir()
{
return (ENOTDIR);
}
void
fs_freevfs(vfs_t *vfsp)
{
}
int
fs_nosys_map(struct vnode *vp, offset_t off, struct as *as, caddr_t *addrp,
size_t len, uchar_t prot, uchar_t maxprot, uint_t flags, struct cred *cr,
caller_context_t *ct)
{
return (ENOSYS);
}
int
fs_nosys_addmap(struct vnode *vp, offset_t off, struct as *as, caddr_t addr,
size_t len, uchar_t prot, uchar_t maxprot, uint_t flags, struct cred *cr,
caller_context_t *ct)
{
return (ENOSYS);
}
int
fs_nosys_poll(vnode_t *vp, short events, int anyyet, short *reventsp,
struct pollhead **phpp, caller_context_t *ct)
{
return (ENOSYS);
}
int
fs_sync(struct vfs *vfspp, short flag, cred_t *cr)
{
return (0);
}
int
fs_fsync(vnode_t *vp, int syncflag, cred_t *cr, caller_context_t *ct)
{
return (0);
}
int
fs_putpage(vnode_t *vp, offset_t off, size_t len, int flags, cred_t *cr,
caller_context_t *ctp)
{
return (0);
}
int
fs_ioctl(vnode_t *vp, int com, intptr_t data, int flag, cred_t *cred,
int *rvalp)
{
return (0);
}
int
fs_rwlock(vnode_t *vp, int write_lock, caller_context_t *ctp)
{
return (-1);
}
void
fs_rwunlock(vnode_t *vp, int write_lock, caller_context_t *ctp)
{
}
int
fs_cmp(vnode_t *vp1, vnode_t *vp2, caller_context_t *ct)
{
return (vp1 == vp2);
}
int
fs_seek(vnode_t *vp, offset_t ooff, offset_t *noffp, caller_context_t *ct)
{
return (*noffp < 0 ? EINVAL : 0);
}
int
fs_frlock(vnode_t *vp, int cmd, struct flock64 *bfp, int flag, offset_t offset,
flk_callback_t *flk_cbp, cred_t *cr, caller_context_t *ct)
{
return (ENOSYS);
}
int
fs_setfl(vnode_t *vp, int oflags, int nflags, cred_t *cr, caller_context_t *ct)
{
return (0);
}
struct pollhead fs_pollhd;
int
fs_poll(vnode_t *vp, short events, int anyyet, short *reventsp,
struct pollhead **phpp, caller_context_t *ct)
{
if (events & POLLET) {
return (EPERM);
}
*reventsp = 0;
if (events & POLLIN)
*reventsp |= POLLIN;
if (events & POLLRDNORM)
*reventsp |= POLLRDNORM;
if (events & POLLRDBAND)
*reventsp |= POLLRDBAND;
if (events & POLLOUT)
*reventsp |= POLLOUT;
if (events & POLLWRBAND)
*reventsp |= POLLWRBAND;
if (*reventsp == 0 && !anyyet) {
*phpp = &fs_pollhd;
}
return (0);
}
int
fs_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr,
caller_context_t *ct)
{
return (EINVAL);
}
void
fs_dispose(struct vnode *vp, page_t *pp, int fl, int dn, struct cred *cr,
caller_context_t *ct)
{
}
void
fs_nodispose(struct vnode *vp, page_t *pp, int fl, int dn, struct cred *cr,
caller_context_t *ct)
{
cmn_err(CE_PANIC, "fs_nodispose invoked");
}
int
fs_fab_acl(vnode_t *vp, vsecattr_t *vsecattr, int flag, cred_t *cr,
caller_context_t *ct)
{
struct vattr vattr;
int error;
vsecattr->vsa_aclcnt = 0;
vsecattr->vsa_aclentsz = 0;
vsecattr->vsa_aclentp = NULL;
vsecattr->vsa_dfaclcnt = 0;
vsecattr->vsa_dfaclentp = NULL;
vattr.va_mask = AT_MODE | AT_UID | AT_GID;
if (error = VOP_GETATTR(vp, &vattr, 0, cr, ct))
return (error);
if (vsecattr->vsa_mask & (VSA_ACLCNT | VSA_ACL)) {
return (ENOSYS);
}
if (vsecattr->vsa_mask & (VSA_ACECNT | VSA_ACE)) {
VERIFY(0 == acl_trivial_create(vattr.va_mode,
(vp->v_type == VDIR), (ace_t **)&vsecattr->vsa_aclentp,
&vsecattr->vsa_aclcnt));
vsecattr->vsa_aclentsz = vsecattr->vsa_aclcnt * sizeof (ace_t);
}
return (error);
}
int
fs_shrlock(struct vnode *vp, int cmd, struct shrlock *shr, int flag, cred_t *cr,
caller_context_t *ct)
{
return (ENOSYS);
}
int
fs_vnevent_nosupport(vnode_t *vp, vnevent_t e, vnode_t *dvp, char *fnm,
caller_context_t *ct)
{
ASSERT(vp != NULL);
return (ENOTSUP);
}
int
fs_vnevent_support(vnode_t *vp, vnevent_t e, vnode_t *dvp, char *fnm,
caller_context_t *ct)
{
ASSERT(vp != NULL);
return (0);
}
int
fs_need_estale_retry(int retry_count)
{
if (retry_count < fs_estale_retry)
return (1);
else
return (0);
}
void
cleanlocks(vnode_t *vp, pid_t pid, int sysid)
{
}
void
cleanshares(struct vnode *vp, pid_t pid)
{
}
int
convoff(struct vnode *vp, struct flock64 *lckdat, int whence, offset_t offset)
{
int error;
struct vattr vattr;
if ((lckdat->l_whence == 2) || (whence == 2)) {
vattr.va_mask = AT_SIZE;
if (error = VOP_GETATTR(vp, &vattr, 0, CRED(), NULL))
return (error);
}
switch (lckdat->l_whence) {
case 1:
lckdat->l_start += offset;
break;
case 2:
lckdat->l_start += vattr.va_size;
case 0:
break;
default:
return (EINVAL);
}
if (lckdat->l_start < 0)
return (EINVAL);
switch (whence) {
case 1:
lckdat->l_start -= offset;
break;
case 2:
lckdat->l_start -= vattr.va_size;
case 0:
break;
default:
return (EINVAL);
}
lckdat->l_whence = (short)whence;
return (0);
}