xref: /csrg-svn/sys/miscfs/union/union.h (revision 68078)
165933Spendry /*
265933Spendry  * Copyright (c) 1994 The Regents of the University of California.
365933Spendry  * Copyright (c) 1994 Jan-Simon Pendry.
465933Spendry  * All rights reserved.
565933Spendry  *
665933Spendry  * This code is derived from software donated to Berkeley by
765933Spendry  * Jan-Simon Pendry.
865933Spendry  *
965933Spendry  * %sccs.include.redist.c%
1065933Spendry  *
11*68078Spendry  *	@(#)union.h	8.9 (Berkeley) 12/10/94
1265933Spendry  */
1365933Spendry 
1465933Spendry struct union_args {
1565933Spendry 	char		*target;	/* Target of loopback  */
1666034Spendry 	int		mntflags;	/* Options on the mount */
1765933Spendry };
1865933Spendry 
1966034Spendry #define UNMNT_ABOVE	0x0001		/* Target appears below mount point */
2066034Spendry #define UNMNT_BELOW	0x0002		/* Target appears below mount point */
2166034Spendry #define UNMNT_REPLACE	0x0003		/* Target replaces mount point */
2266034Spendry #define UNMNT_OPMASK	0x0003
2366034Spendry 
2465933Spendry struct union_mount {
2565933Spendry 	struct vnode	*um_uppervp;
2665933Spendry 	struct vnode	*um_lowervp;
2765933Spendry 	struct ucred	*um_cred;	/* Credentials of user calling mount */
2865997Spendry 	int		um_cmode;	/* cmask from mount process */
2966152Spendry 	int		um_op;		/* Operation mode */
3065933Spendry };
3165933Spendry 
3265933Spendry #ifdef KERNEL
3365933Spendry 
3465933Spendry /*
3565933Spendry  * DEFDIRMODE is the mode bits used to create a shadow directory.
3665933Spendry  */
3765933Spendry #define VRWXMODE (VREAD|VWRITE|VEXEC)
3865933Spendry #define VRWMODE (VREAD|VWRITE)
3965933Spendry #define UN_DIRMODE ((VRWXMODE)|(VRWXMODE>>3)|(VRWXMODE>>6))
4065933Spendry #define UN_FILEMODE ((VRWMODE)|(VRWMODE>>3)|(VRWMODE>>6))
4165933Spendry 
4265933Spendry /*
4365933Spendry  * A cache of vnode references
4465933Spendry  */
4565933Spendry struct union_node {
4666053Spendry 	LIST_ENTRY(union_node)	un_cache;	/* Hash chain */
4765991Spendry 	struct vnode		*un_vnode;	/* Back pointer */
4865933Spendry 	struct vnode	        *un_uppervp;	/* overlaying object */
4965933Spendry 	struct vnode	        *un_lowervp;	/* underlying object */
5065933Spendry 	struct vnode		*un_dirvp;	/* Parent dir of uppervp */
5167415Spendry 	struct vnode		*un_pvp;	/* Parent vnode */
5265933Spendry 	char			*un_path;	/* saved component name */
5366027Spendry 	int			un_hash;	/* saved un_path hash value */
5466027Spendry 	int			un_openl;	/* # of opens on lowervp */
5567071Spendry 	unsigned int		un_flags;
56*68078Spendry 	struct vnode		**un_dircache;	/* cached union stack */
5767108Spendry 	off_t			un_uppersz;	/* size of upper object */
5867108Spendry 	off_t			un_lowersz;	/* size of lower object */
5966027Spendry #ifdef DIAGNOSTIC
6065933Spendry 	pid_t			un_pid;
6166027Spendry #endif
6265933Spendry };
6365933Spendry 
6466051Spendry #define UN_WANT		0x01
6566051Spendry #define UN_LOCKED	0x02
6666051Spendry #define UN_ULOCK	0x04		/* Upper node is locked */
6766051Spendry #define UN_KLOCK	0x08		/* Keep upper node locked on vput */
6867071Spendry #define UN_CACHED	0x10		/* In union cache */
6965933Spendry 
7065994Spendry extern int union_allocvp __P((struct vnode **, struct mount *,
7165994Spendry 				struct vnode *, struct vnode *,
7265994Spendry 				struct componentname *, struct vnode *,
73*68078Spendry 				struct vnode *, int));
7467168Spendry extern int union_copyfile __P((struct vnode *, struct vnode *,
7567168Spendry 					struct ucred *, struct proc *));
7667168Spendry extern int union_copyup __P((struct union_node *, int, struct ucred *,
7767168Spendry 				struct proc *));
7867785Spendry extern int union_dowhiteout __P((struct union_node *, struct ucred *,
7967785Spendry 					struct proc *));
8065997Spendry extern int union_mkshadow __P((struct union_mount *, struct vnode *,
8165997Spendry 				struct componentname *, struct vnode **));
8267575Spendry extern int union_mkwhiteout __P((struct union_mount *, struct vnode *,
8367575Spendry 				struct componentname *, char *));
8465994Spendry extern int union_vn_create __P((struct vnode **, struct union_node *,
8565997Spendry 				struct proc *));
8666028Spendry extern int union_cn_close __P((struct vnode *, int, struct ucred *,
8766028Spendry 				struct proc *));
8866027Spendry extern void union_removed_upper __P((struct union_node *un));
8966028Spendry extern struct vnode *union_lowervp __P((struct vnode *));
9066053Spendry extern void union_newlower __P((struct union_node *, struct vnode *));
9166053Spendry extern void union_newupper __P((struct union_node *, struct vnode *));
9267108Spendry extern void union_newsize __P((struct vnode *, off_t, off_t));
9365933Spendry 
9465933Spendry #define	MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data))
9565933Spendry #define	VTOUNION(vp) ((struct union_node *)(vp)->v_data)
9665933Spendry #define	UNIONTOV(un) ((un)->un_vnode)
9765933Spendry #define	LOWERVP(vp) (VTOUNION(vp)->un_lowervp)
9865965Spendry #define	UPPERVP(vp) (VTOUNION(vp)->un_uppervp)
9965933Spendry #define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp))
10065933Spendry 
10165933Spendry extern int (**union_vnodeop_p)();
10265933Spendry extern struct vfsops union_vfsops;
10365933Spendry #endif /* KERNEL */
104