#ifdef _KERNEL
typedef enum _unionfs_copymode {
UNIONFS_TRADITIONAL = 0,
UNIONFS_TRANSPARENT,
UNIONFS_MASQUERADE
} unionfs_copymode;
typedef enum _unionfs_whitemode {
UNIONFS_WHITE_ALWAYS = 0,
UNIONFS_WHITE_WHENNEEDED
} unionfs_whitemode;
struct unionfs_mount {
struct mount *um_lowermp;
struct mount *um_uppermp;
struct vnode *um_lowervp;
struct vnode *um_uppervp;
struct vnode *um_rootvp;
struct mount_upper_node um_lower_link;
struct mount_upper_node um_upper_link;
unionfs_copymode um_copymode;
unionfs_whitemode um_whitemode;
uid_t um_uid;
gid_t um_gid;
u_short um_udir;
u_short um_ufile;
};
struct unionfs_node_status {
LIST_ENTRY(unionfs_node_status) uns_list;
pid_t uns_pid;
int uns_node_flag;
int uns_lower_opencnt;
int uns_upper_opencnt;
int uns_lower_openmode;
int uns_readdir_status;
};
#define UNS_OPENL_4_READDIR 0x01
struct unionfs_node {
struct vnode *un_lowervp;
struct vnode *un_uppervp;
struct vnode *un_dvp;
struct vnode *un_vnode;
LIST_HEAD(, unionfs_node_status) un_unshead;
LIST_HEAD(unionfs_node_hashhead, unionfs_node) *un_hashtbl;
union {
LIST_ENTRY(unionfs_node) un_hash;
STAILQ_ENTRY(unionfs_node) un_rele;
};
char *un_path;
int un_pathlen;
#define UNIONFS_OPENEXTL 0x01
#define UNIONFS_OPENEXTU 0x02
#define UNIONFS_COPY_IN_PROGRESS 0x04
#define UNIONFS_LOOKUP_IN_PROGRESS 0x08
unsigned int un_flag;
};
extern struct vop_vector unionfs_vnodeops;
static inline struct unionfs_node *
unionfs_check_vnode(struct vnode *vp, const char *file __unused,
int line __unused)
{
KASSERT(vp->v_op == &unionfs_vnodeops || vp->v_data == NULL,
("%s:%d: non-unionfs vnode %p", file, line, vp));
return ((struct unionfs_node *)vp->v_data);
}
#define MOUNTTOUNIONFSMOUNT(mp) ((struct unionfs_mount *)((mp)->mnt_data))
#define VTOUNIONFS(vp) unionfs_check_vnode(vp, __FILE__, __LINE__)
#define UNIONFSTOV(xp) ((xp)->un_vnode)
int unionfs_init(struct vfsconf *);
int unionfs_uninit(struct vfsconf *);
int unionfs_nodeget(struct mount *, struct vnode *, struct vnode *,
struct vnode *, struct vnode **, struct componentname *);
void unionfs_noderem(struct vnode *);
struct unionfs_node_status * unionfs_find_node_status(struct unionfs_node *,
struct thread *td);
void unionfs_get_node_status(struct unionfs_node *, struct thread *,
struct unionfs_node_status **);
void unionfs_tryrem_node_status(struct unionfs_node *,
struct unionfs_node_status *);
int unionfs_check_rmdir(struct vnode *, struct ucred *, struct thread *td);
int unionfs_copyfile(struct vnode *, int, struct ucred *,
struct thread *);
void unionfs_create_uppervattr_core(struct unionfs_mount *, struct vattr *,
struct vattr *, struct thread *);
int unionfs_create_uppervattr(struct unionfs_mount *, struct vnode *,
struct vattr *, struct ucred *, struct thread *);
int unionfs_mkshadowdir(struct vnode *, struct vnode *,
struct componentname *, struct thread *);
int unionfs_mkwhiteout(struct vnode *, struct vnode *,
struct componentname *, struct thread *, char *, int);
int unionfs_relookup(struct vnode *, struct vnode **,
struct componentname *, struct componentname *, struct thread *,
char *, int, u_long);
void unionfs_forward_vop_start_pair(struct vnode *, int *,
struct vnode *, int *);
bool unionfs_forward_vop_finish_pair(struct vnode *, struct vnode *, int,
struct vnode *, struct vnode *, int);
int unionfs_set_in_progress_flag(struct vnode *, unsigned int);
void unionfs_clear_in_progress_flag(struct vnode *, unsigned int);
static inline void
unionfs_forward_vop_start(struct vnode *basevp, int *lkflags)
{
unionfs_forward_vop_start_pair(basevp, lkflags, NULL, NULL);
}
static inline bool
unionfs_forward_vop_finish(struct vnode *unionvp, struct vnode *basevp,
int lkflags)
{
return (unionfs_forward_vop_finish_pair(unionvp, basevp, lkflags,
NULL, NULL, 0));
}
#define UNIONFSVPTOLOWERVP(vp) (VTOUNIONFS(vp)->un_lowervp)
#define UNIONFSVPTOUPPERVP(vp) (VTOUNIONFS(vp)->un_uppervp)
#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_UNIONFSNODE);
MALLOC_DECLARE(M_UNIONFSPATH);
#endif
#ifdef UNIONFS_DEBUG
#define UNIONFSDEBUG(format, args...) printf(format ,## args)
#else
#define UNIONFSDEBUG(format, args...)
#endif
#endif