2005-01-06 18:10:42 +00:00
|
|
|
/*-
|
1994-05-24 10:09:53 +00:00
|
|
|
* Copyright (c) 1994 The Regents of the University of California.
|
|
|
|
* Copyright (c) 1994 Jan-Simon Pendry.
|
2006-12-02 19:35:56 +00:00
|
|
|
* Copyright (c) 2005, 2006 Masanori Ozawa <ozawa@ongs.co.jp>, ONGS Inc.
|
|
|
|
* Copyright (c) 2006 Daichi Goto <daichi@freebsd.org>
|
1994-05-24 10:09:53 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software donated to Berkeley by
|
|
|
|
* Jan-Simon Pendry.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1997-02-10 02:22:35 +00:00
|
|
|
* @(#)union.h 8.9 (Berkeley) 12/10/94
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
2006-12-02 19:35:56 +00:00
|
|
|
#ifdef _KERNEL
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2006-12-02 19:35:56 +00:00
|
|
|
/* copy method of attr from lower to upper */
|
|
|
|
typedef enum _unionfs_copymode {
|
|
|
|
UNIONFS_TRADITIONAL = 0,
|
|
|
|
UNIONFS_TRANSPARENT,
|
|
|
|
UNIONFS_MASQUERADE
|
|
|
|
} unionfs_copymode;
|
|
|
|
|
2007-10-14 13:55:38 +00:00
|
|
|
/* whiteout policy of upper layer */
|
|
|
|
typedef enum _unionfs_whitemode {
|
|
|
|
UNIONFS_WHITE_ALWAYS = 0,
|
|
|
|
UNIONFS_WHITE_WHENNEEDED
|
|
|
|
} unionfs_whitemode;
|
|
|
|
|
2006-12-02 19:35:56 +00:00
|
|
|
struct unionfs_mount {
|
|
|
|
struct vnode *um_lowervp; /* VREFed once */
|
|
|
|
struct vnode *um_uppervp; /* VREFed once */
|
|
|
|
struct vnode *um_rootvp; /* ROOT vnode */
|
|
|
|
unionfs_copymode um_copymode;
|
2007-10-14 13:55:38 +00:00
|
|
|
unionfs_whitemode um_whitemode;
|
2006-12-02 19:35:56 +00:00
|
|
|
uid_t um_uid;
|
|
|
|
gid_t um_gid;
|
|
|
|
u_short um_udir;
|
|
|
|
u_short um_ufile;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
|
|
|
|
2006-12-02 19:35:56 +00:00
|
|
|
/* unionfs status list */
|
|
|
|
struct unionfs_node_status {
|
|
|
|
LIST_ENTRY(unionfs_node_status) uns_list; /* Status list */
|
|
|
|
lwpid_t uns_tid; /* current thread id */
|
|
|
|
int uns_node_flag; /* uns flag */
|
|
|
|
int uns_lower_opencnt; /* open count of lower */
|
|
|
|
int uns_upper_opencnt; /* open count of upper */
|
|
|
|
int uns_lower_openmode; /* open mode of lower */
|
|
|
|
int uns_readdir_status; /* read status of readdir */
|
|
|
|
};
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2006-12-02 19:35:56 +00:00
|
|
|
/* union node status flags */
|
|
|
|
#define UNS_OPENL_4_READDIR 0x01 /* open lower layer for readdir */
|
|
|
|
|
|
|
|
/* A cache of vnode references */
|
|
|
|
struct unionfs_node {
|
|
|
|
struct vnode *un_lowervp; /* lower side vnode */
|
|
|
|
struct vnode *un_uppervp; /* upper side vnode */
|
|
|
|
struct vnode *un_dvp; /* parent unionfs vnode */
|
|
|
|
struct vnode *un_vnode; /* Back pointer */
|
|
|
|
LIST_HEAD(, unionfs_node_status) un_unshead; /* unionfs status head */
|
|
|
|
char *un_path; /* path */
|
|
|
|
int un_flag; /* unionfs node flag */
|
|
|
|
};
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
|
2007-10-14 13:46:11 +00:00
|
|
|
/*
|
|
|
|
* unionfs node flags
|
|
|
|
* It needs the vnode with exclusive lock, when changing the un_flag variable.
|
|
|
|
*/
|
|
|
|
#define UNIONFS_OPENEXTL 0x01 /* openextattr (lower) */
|
|
|
|
#define UNIONFS_OPENEXTU 0x02 /* openextattr (upper) */
|
2006-12-02 19:35:56 +00:00
|
|
|
|
|
|
|
#define MOUNTTOUNIONFSMOUNT(mp) ((struct unionfs_mount *)((mp)->mnt_data))
|
|
|
|
#define VTOUNIONFS(vp) ((struct unionfs_node *)(vp)->v_data)
|
|
|
|
#define UNIONFSTOV(xp) ((xp)->un_vnode)
|
|
|
|
|
|
|
|
int unionfs_init(struct vfsconf *vfsp);
|
|
|
|
int unionfs_uninit(struct vfsconf *vfsp);
|
|
|
|
int unionfs_nodeget(struct mount *mp, struct vnode *uppervp, struct vnode *lowervp, struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, struct thread *td);
|
2007-10-14 13:46:11 +00:00
|
|
|
void unionfs_noderem(struct vnode *vp, struct thread *td);
|
2006-12-02 19:35:56 +00:00
|
|
|
void unionfs_get_node_status(struct unionfs_node *unp, struct thread *td, struct unionfs_node_status **unspp);
|
|
|
|
void unionfs_tryrem_node_status(struct unionfs_node *unp, struct thread *td, struct unionfs_node_status *unsp);
|
|
|
|
|
|
|
|
int unionfs_check_rmdir(struct vnode *vp, struct ucred *cred, struct thread *td);
|
|
|
|
int unionfs_copyfile(struct unionfs_node *unp, int docopy, struct ucred *cred, struct thread *td);
|
|
|
|
void unionfs_create_uppervattr_core(struct unionfs_mount *ump, struct vattr *lva, struct vattr *uva, struct thread *td);
|
|
|
|
int unionfs_create_uppervattr(struct unionfs_mount *ump, struct vnode *lvp, struct vattr *uva, struct ucred *cred, struct thread *td);
|
|
|
|
int unionfs_mkshadowdir(struct unionfs_mount *ump, struct vnode *duvp, struct unionfs_node *unp, struct componentname *cnp, struct thread *td);
|
|
|
|
int unionfs_mkwhiteout(struct vnode *dvp, struct componentname *cnp, struct thread *td, char *path);
|
|
|
|
int unionfs_relookup_for_create(struct vnode *dvp, struct componentname *cnp, struct thread *td);
|
|
|
|
int unionfs_relookup_for_delete(struct vnode *dvp, struct componentname *cnp, struct thread *td);
|
|
|
|
int unionfs_relookup_for_rename(struct vnode *dvp, struct componentname *cnp, struct thread *td);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
2006-12-02 19:35:56 +00:00
|
|
|
struct vnode *unionfs_checklowervp(struct vnode *vp, char *fil, int lno);
|
|
|
|
struct vnode *unionfs_checkuppervp(struct vnode *vp, char *fil, int lno);
|
|
|
|
#define UNIONFSVPTOLOWERVP(vp) unionfs_checklowervp((vp), __FILE__, __LINE__)
|
|
|
|
#define UNIONFSVPTOUPPERVP(vp) unionfs_checkuppervp((vp), __FILE__, __LINE__)
|
|
|
|
#else
|
|
|
|
#define UNIONFSVPTOLOWERVP(vp) (VTOUNIONFS(vp)->un_lowervp)
|
|
|
|
#define UNIONFSVPTOUPPERVP(vp) (VTOUNIONFS(vp)->un_uppervp)
|
1994-05-24 10:09:53 +00:00
|
|
|
#endif
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
|
2006-12-02 19:35:56 +00:00
|
|
|
extern struct vop_vector unionfs_vnodeops;
|
1998-01-20 10:02:54 +00:00
|
|
|
|
2006-12-02 19:35:56 +00:00
|
|
|
#ifdef MALLOC_DECLARE
|
|
|
|
MALLOC_DECLARE(M_UNIONFSNODE);
|
|
|
|
MALLOC_DECLARE(M_UNIONFSPATH);
|
|
|
|
#endif
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
|
2006-12-02 19:35:56 +00:00
|
|
|
#ifdef UNIONFS_DEBUG
|
|
|
|
#define UNIONFSDEBUG(format, args...) printf(format ,## args)
|
|
|
|
#else
|
|
|
|
#define UNIONFSDEBUG(format, args...)
|
|
|
|
#endif /* UNIONFS_DEBUG */
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
|
2006-12-02 19:35:56 +00:00
|
|
|
#endif /* _KERNEL */
|