#ifndef _SPL_MODE_H
#define _SPL_MODE_H
+#define IFTOVT(mode) vn_mode_to_vtype(mode)
+#define VTTOIF(vtype) vn_vtype_to_mode(vtype)
+#define MAKEIMODE(T, M) (VTTOIF(T) | ((M) & ~S_IFMT))
+
#endif /* SPL_MODE_H */
extern vnode_t *vn_alloc(int flag);
void vn_free(vnode_t *vp);
+extern vtype_t vn_mode_to_vtype(mode_t);
+extern mode_t vn_vtype_to_mode(vtype_t);
extern int vn_open(const char *path, uio_seg_t seg, int flags, int mode,
vnode_t **vpp, int x1, void *x2);
extern int vn_openat(const char *path, uio_seg_t seg, int flags, int mode,
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;
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)
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;
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;
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);