Skip to content

Commit

Permalink
OS-4463 cleanup lxsys_realvp
Browse files Browse the repository at this point in the history
  • Loading branch information
jjelinek committed Jun 30, 2015
1 parent d2a6ede commit 154f0da
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 108 deletions.
3 changes: 1 addition & 2 deletions usr/src/uts/common/brand/lx/sysfs/lx_sysfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ struct lxsys_node {
unsigned int lxsys_instance; /* instance ID node */
unsigned int lxsys_endpoint; /* endpoint ID node */
vnode_t *lxsys_vnode; /* vnode for the node */
vnode_t *lxsys_parent; /* parent directory */
vnode_t *lxsys_realvp; /* real vnode */
vnode_t *lxsys_parentvp; /* parent directory */
lxsys_node_t *lxsys_next; /* next list entry */
timestruc_t lxsys_time; /* creation time */
mode_t lxsys_mode; /* file mode bits */
Expand Down
17 changes: 5 additions & 12 deletions usr/src/uts/common/brand/lx/sysfs/lx_syssubr.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ lxsys_parentinode(lxsys_node_t *lxsnp)
lxsnp->lxsys_instance == LXSYS_INST_ROOT) {
return (lxsnp->lxsys_ino);
} else {
return (VTOLXS(lxsnp->lxsys_parent)->lxsys_ino);
return (VTOLXS(lxsnp->lxsys_parentvp)->lxsys_ino);
}
}

Expand Down Expand Up @@ -141,8 +141,7 @@ lxsys_getnode(vnode_t *dp, lxsys_nodetype_t type, unsigned int instance,
lxsnp->lxsys_instance = instance;
lxsnp->lxsys_endpoint = endpoint;
lxsnp->lxsys_next = NULL;
lxsnp->lxsys_realvp = NULL;
lxsnp->lxsys_parent = dp;
lxsnp->lxsys_parentvp = dp;
VN_HOLD(dp);

lxsnp->lxsys_time = now;
Expand Down Expand Up @@ -178,7 +177,7 @@ lxsys_getnode_static(vnode_t *dp, unsigned int instance)
lnp = lxsm->lxsysm_node;
while (1) {
if (lnp->lxsys_instance == instance) {
VERIFY(lnp->lxsys_parent == dp);
VERIFY(lnp->lxsys_parentvp == dp);

VN_HOLD(lnp->lxsys_vnode);
mutex_exit(&lxsm->lxsysm_lock);
Expand Down Expand Up @@ -265,17 +264,11 @@ lxsys_freenode(lxsys_node_t *lxsnp)
}
}

/*
* delete any association with realvp
*/
if (lxsnp->lxsys_realvp != NULL)
VN_RELE(lxsnp->lxsys_realvp);

/*
* delete any association with parent vp
*/
if (lxsnp->lxsys_parent != NULL)
VN_RELE(lxsnp->lxsys_parent);
if (lxsnp->lxsys_parentvp != NULL)
VN_RELE(lxsnp->lxsys_parentvp);

/*
* Release the lxsysnode.
Expand Down
97 changes: 3 additions & 94 deletions usr/src/uts/common/brand/lx/sysfs/lx_sysvnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ static int lxsys_readdir(vnode_t *, uio_t *, cred_t *, int *,
caller_context_t *, int);
static int lxsys_readlink(vnode_t *, uio_t *, cred_t *, caller_context_t *);
static int lxsys_cmp(vnode_t *, vnode_t *, caller_context_t *);
static int lxsys_realvp(vnode_t *, vnode_t **, caller_context_t *);
static int lxsys_sync(void);
static void lxsys_inactive(vnode_t *, cred_t *, caller_context_t *);

Expand Down Expand Up @@ -97,7 +96,6 @@ const fs_operation_def_t lxsys_vnodeops_template[] = {
VOPNAME_SEEK, { .error = lxsys_sync },
VOPNAME_INACTIVE, { .vop_inactive = lxsys_inactive },
VOPNAME_CMP, { .vop_cmp = lxsys_cmp },
VOPNAME_REALVP, { .vop_realvp = lxsys_realvp },
NULL, NULL
};

Expand Down Expand Up @@ -246,39 +244,13 @@ static int (*lxsys_readlink_function[LXSYS_MAXTYPE])() = {
static int
lxsys_open(vnode_t **vpp, int flag, cred_t *cr, caller_context_t *ct)
{
vnode_t *vp = *vpp;
lxsys_node_t *lxsnp = VTOLXS(vp);
vnode_t *rvp;
int error = 0;

/*
* We only allow reading in this file system
*/
if (flag & FWRITE)
return (EROFS);

/*
* If we are opening an underlying file only allow regular files,
* reject the open for anything else.
* Just do it if we are opening the current or root directory.
*/
if (lxsnp->lxsys_realvp != NULL) {
rvp = lxsnp->lxsys_realvp;

/*
* Need to hold rvp since VOP_OPEN() may release it.
*/
VN_HOLD(rvp);
error = VOP_OPEN(&rvp, flag, cr, ct);
if (error) {
VN_RELE(rvp);
} else {
*vpp = rvp;
VN_RELE(vp);
}
}

return (error);
return (0);
}


Expand Down Expand Up @@ -337,32 +309,6 @@ lxsys_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
caller_context_t *ct)
{
register lxsys_node_t *lxsnp = VTOLXS(vp);
int error;

/*
* Return attributes of underlying vnode if ATTR_REAL
*
* but keep fd files with the symlink permissions
*/
if (lxsnp->lxsys_realvp != NULL && (flags & ATTR_REAL)) {
vnode_t *rvp = lxsnp->lxsys_realvp;

/*
* limit attribute information to owner or root
*/
if ((error = VOP_ACCESS(rvp, 0, 0, cr, ct)) != 0) {
return (error);
}

/*
* now its attributes
*/
if ((error = VOP_GETATTR(rvp, vap, flags, cr, ct)) != 0) {
return (error);
}

return (0);
}

/* Default attributes, that may be overridden below */
bzero(vap, sizeof (*vap));
Expand Down Expand Up @@ -394,13 +340,6 @@ lxsys_access(vnode_t *vp, int mode, int flags, cred_t *cr, caller_context_t *ct)
* expects it to be writable so we can't just error if (mode & VWRITE).
*/

if (lxsnp->lxsys_realvp != NULL) {
/*
* For these we use the underlying vnode's accessibility.
*/
return (VOP_ACCESS(lxsnp->lxsys_realvp, mode, flags, cr, ct));
}

/* If user is root allow access regardless of permission bits */
if (secpolicy_proc_access(cr) == 0)
return (0);
Expand Down Expand Up @@ -451,8 +390,8 @@ lxsys_lookup(vnode_t *dp, char *comp, vnode_t **vpp, pathname_t *pathp,
* Just return the parent vnode if that's where we are trying to go.
*/
if (strcmp(comp, "..") == 0) {
VN_HOLD(lxsnp->lxsys_parent);
*vpp = lxsnp->lxsys_parent;
VN_HOLD(lxsnp->lxsys_parentvp);
*vpp = lxsnp->lxsys_parentvp;
return (0);
}

Expand Down Expand Up @@ -1146,38 +1085,8 @@ lxsys_sync()
static int
lxsys_cmp(vnode_t *vp1, vnode_t *vp2, caller_context_t *ct)
{
vnode_t *rvp;

while (vn_matchops(vp1, lxsys_vnodeops) &&
(rvp = VTOLXS(vp1)->lxsys_realvp) != NULL) {
vp1 = rvp;
}

while (vn_matchops(vp2, lxsys_vnodeops) &&
(rvp = VTOLXS(vp2)->lxsys_realvp) != NULL) {
vp2 = rvp;
}

if (vn_matchops(vp1, lxsys_vnodeops) ||
vn_matchops(vp2, lxsys_vnodeops))
return (vp1 == vp2);
return (VOP_CMP(vp1, vp2, ct));
}

/*
* lxsys_realvp(): Vnode operation for VOP_REALVP()
*/
static int
lxsys_realvp(vnode_t *vp, vnode_t **vpp, caller_context_t *ct)
{
vnode_t *rvp;

if ((rvp = VTOLXS(vp)->lxsys_realvp) != NULL) {
vp = rvp;
if (VOP_REALVP(vp, &rvp, ct) == 0)
vp = rvp;
}

*vpp = vp;
return (0);
}

0 comments on commit 154f0da

Please sign in to comment.