summaryrefslogtreecommitdiffstats
path: root/module/spl
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2011-01-11 11:53:05 -0800
committerBrian Behlendorf <[email protected]>2011-01-12 11:38:04 -0800
commit4295b530eeb68aaacbbeb5b2197ed14bf9295c2b (patch)
tree5ddb9621ba868c2e5a613568890cc5d1c595668f /module/spl
parent3f688a8c381d298062467a318994bb5849b1c8c1 (diff)
Add vn_mode_to_vtype/vn_vtype to_mode helpers
Add simple helpers to convert a vnode->v_type to a inode->i_mode. These should be used sparingly but they are handy to have.
Diffstat (limited to 'module/spl')
-rw-r--r--module/spl/spl-vnode.c41
1 files changed, 35 insertions, 6 deletions
diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c
index 1847c7794..765dc4e2e 100644
--- a/module/spl/spl-vnode.c
+++ b/module/spl/spl-vnode.c
@@ -42,8 +42,8 @@ static spl_kmem_cache_t *vn_file_cache;
static spinlock_t vn_file_lock = SPIN_LOCK_UNLOCKED;
static LIST_HEAD(vn_file_list);
-static vtype_t
-vn_get_sol_type(umode_t mode)
+vtype_t
+vn_mode_to_vtype(mode_t mode)
{
if (S_ISREG(mode))
return VREG;
@@ -70,7 +70,36 @@ vn_get_sol_type(umode_t mode)
return VCHR;
return VNON;
-} /* vn_get_sol_type() */
+} /* vn_mode_to_vtype() */
+EXPORT_SYMBOL(vn_mode_to_vtype);
+
+mode_t
+vn_vtype_to_mode(vtype_t vtype)
+{
+ if (vtype == VREG)
+ return S_IFREG;
+
+ if (vtype == VDIR)
+ return S_IFDIR;
+
+ if (vtype == VCHR)
+ return S_IFCHR;
+
+ if (vtype == VBLK)
+ return S_IFBLK;
+
+ if (vtype == VFIFO)
+ return S_IFIFO;
+
+ if (vtype == VLNK)
+ return S_IFLNK;
+
+ if (vtype == VSOCK)
+ return S_IFSOCK;
+
+ return VNON;
+} /* vn_vtype_to_mode() */
+EXPORT_SYMBOL(vn_vtype_to_mode);
vnode_t *
vn_alloc(int flag)
@@ -150,7 +179,7 @@ vn_open(const char *path, uio_seg_t seg, int flags, int mode,
mapping_set_gfp_mask(fp->f_mapping, saved_gfp & ~(__GFP_IO|__GFP_FS));
mutex_enter(&vp->v_lock);
- vp->v_type = vn_get_sol_type(stat.mode);
+ vp->v_type = vn_mode_to_vtype(stat.mode);
vp->v_file = fp;
vp->v_gfp_mask = saved_gfp;
*vpp = vp;
@@ -439,7 +468,7 @@ vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4)
if (rc)
SRETURN(-rc);
- vap->va_type = vn_get_sol_type(stat.mode);
+ vap->va_type = vn_mode_to_vtype(stat.mode);
vap->va_mode = stat.mode;
vap->va_uid = stat.uid;
vap->va_gid = stat.gid;
@@ -539,7 +568,7 @@ vn_getf(int fd)
SGOTO(out_vnode, rc);
mutex_enter(&vp->v_lock);
- vp->v_type = vn_get_sol_type(stat.mode);
+ vp->v_type = vn_mode_to_vtype(stat.mode);
vp->v_file = lfp;
mutex_exit(&vp->v_lock);