xref: /minix3/sys/ufs/lfs/ulfs_extattr.h (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc /*	$NetBSD: ulfs_extattr.h,v 1.2 2013/06/06 00:48:04 dholland Exp $	*/
2*84d9c625SLionel Sambuc /*  from NetBSD: extattr.h,v 1.10 2011/10/09 21:15:34 chs Exp  */
3*84d9c625SLionel Sambuc 
4*84d9c625SLionel Sambuc /*-
5*84d9c625SLionel Sambuc  * Copyright (c) 1999-2001 Robert N. M. Watson
6*84d9c625SLionel Sambuc  * All rights reserved.
7*84d9c625SLionel Sambuc  *
8*84d9c625SLionel Sambuc  * This software was developed by Robert Watson for the TrustedBSD Project.
9*84d9c625SLionel Sambuc  *
10*84d9c625SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
11*84d9c625SLionel Sambuc  * modification, are permitted provided that the following conditions
12*84d9c625SLionel Sambuc  * are met:
13*84d9c625SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
14*84d9c625SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
15*84d9c625SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
16*84d9c625SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
17*84d9c625SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
18*84d9c625SLionel Sambuc  *
19*84d9c625SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20*84d9c625SLionel Sambuc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21*84d9c625SLionel Sambuc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22*84d9c625SLionel Sambuc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23*84d9c625SLionel Sambuc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24*84d9c625SLionel Sambuc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25*84d9c625SLionel Sambuc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26*84d9c625SLionel Sambuc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27*84d9c625SLionel Sambuc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28*84d9c625SLionel Sambuc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29*84d9c625SLionel Sambuc  * SUCH DAMAGE.
30*84d9c625SLionel Sambuc  *
31*84d9c625SLionel Sambuc  * $FreeBSD: src/sys/ufs/ufs/extattr.h,v 1.20 2005/01/31 08:16:45 imp Exp $
32*84d9c625SLionel Sambuc  */
33*84d9c625SLionel Sambuc 
34*84d9c625SLionel Sambuc /*
35*84d9c625SLionel Sambuc  * Support for file system extended attributes on the ULFS1 file system.
36*84d9c625SLionel Sambuc  * Developed by the TrustedBSD Project.
37*84d9c625SLionel Sambuc  */
38*84d9c625SLionel Sambuc 
39*84d9c625SLionel Sambuc #ifndef _UFS_LFS_ULFS_EXTATTR_H_
40*84d9c625SLionel Sambuc #define	_UFS_LFS_ULFS_EXTATTR_H_
41*84d9c625SLionel Sambuc 
42*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_MAGIC		0x00b5d5ec
43*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_VERSION		0x00000003
44*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_FSROOTSUBDIR	".attribute"
45*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_SUBDIR_SYSTEM	"system"
46*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_SUBDIR_USER		"user"
47*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_MAXEXTATTRNAME	65	/* including null */
48*84d9c625SLionel Sambuc 
49*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_ATTR_FLAG_INUSE	0x00000001	/* attr has been set */
50*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_PERM_KERNEL		0x00000000
51*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_PERM_ROOT		0x00000001
52*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_PERM_OWNER		0x00000002
53*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_PERM_ANYONE		0x00000003
54*84d9c625SLionel Sambuc 
55*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_UEPM_INITIALIZED	0x00000001
56*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_UEPM_STARTED	0x00000002
57*84d9c625SLionel Sambuc 
58*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_CMD_START		EXTATTR_CMD_START
59*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_CMD_STOP		EXTATTR_CMD_STOP
60*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_CMD_ENABLE		0x00000003
61*84d9c625SLionel Sambuc #define	ULFS_EXTATTR_CMD_DISABLE		0x00000004
62*84d9c625SLionel Sambuc 
63*84d9c625SLionel Sambuc struct ulfs_extattr_fileheader {
64*84d9c625SLionel Sambuc 	uint32_t	uef_magic;	/* magic number for sanity checking */
65*84d9c625SLionel Sambuc 	uint32_t	uef_version;	/* version of attribute file */
66*84d9c625SLionel Sambuc 	uint32_t	uef_size;	/* size of attributes, w/o header */
67*84d9c625SLionel Sambuc };
68*84d9c625SLionel Sambuc 
69*84d9c625SLionel Sambuc struct ulfs_extattr_header {
70*84d9c625SLionel Sambuc 	uint32_t	ueh_flags;	/* flags for attribute */
71*84d9c625SLionel Sambuc 	uint32_t	ueh_len;	/* local defined length; <= uef_size */
72*84d9c625SLionel Sambuc 	uint32_t	ueh_i_gen;	/* generation number for sanity */
73*84d9c625SLionel Sambuc 	/* data follows the header */
74*84d9c625SLionel Sambuc };
75*84d9c625SLionel Sambuc 
76*84d9c625SLionel Sambuc #ifdef _KERNEL
77*84d9c625SLionel Sambuc 
78*84d9c625SLionel Sambuc #ifdef MALLOC_DECLARE
79*84d9c625SLionel Sambuc MALLOC_DECLARE(M_EXTATTR);
80*84d9c625SLionel Sambuc #endif
81*84d9c625SLionel Sambuc 
82*84d9c625SLionel Sambuc struct vnode;
83*84d9c625SLionel Sambuc LIST_HEAD(ulfs_extattr_list_head, ulfs_extattr_list_entry);
84*84d9c625SLionel Sambuc struct ulfs_extattr_list_entry {
85*84d9c625SLionel Sambuc 	LIST_ENTRY(ulfs_extattr_list_entry)	uele_entries;
86*84d9c625SLionel Sambuc 	struct ulfs_extattr_fileheader		uele_fileheader;
87*84d9c625SLionel Sambuc 	int		uele_attrnamespace;
88*84d9c625SLionel Sambuc 	char		uele_attrname[ULFS_EXTATTR_MAXEXTATTRNAME];
89*84d9c625SLionel Sambuc 	struct vnode	*uele_backing_vnode;
90*84d9c625SLionel Sambuc 	int		uele_flags;
91*84d9c625SLionel Sambuc };
92*84d9c625SLionel Sambuc 
93*84d9c625SLionel Sambuc /* uele_flags */
94*84d9c625SLionel Sambuc #define	UELE_F_NEEDSWAP		0x01	/* needs byte swap */
95*84d9c625SLionel Sambuc 
96*84d9c625SLionel Sambuc #define	UELE_NEEDSWAP(uele)	((uele)->uele_flags & UELE_F_NEEDSWAP)
97*84d9c625SLionel Sambuc 
98*84d9c625SLionel Sambuc struct lock;
99*84d9c625SLionel Sambuc struct ulfs_extattr_per_mount {
100*84d9c625SLionel Sambuc 	kmutex_t			uepm_lock;
101*84d9c625SLionel Sambuc 	struct ulfs_extattr_list_head	uepm_list;
102*84d9c625SLionel Sambuc 	kauth_cred_t			uepm_ucred;
103*84d9c625SLionel Sambuc 	int				uepm_lockcnt;
104*84d9c625SLionel Sambuc 	int				uepm_flags;
105*84d9c625SLionel Sambuc };
106*84d9c625SLionel Sambuc 
107*84d9c625SLionel Sambuc void	ulfs_extattr_uepm_init(struct ulfs_extattr_per_mount *uepm);
108*84d9c625SLionel Sambuc void	ulfs_extattr_uepm_destroy(struct ulfs_extattr_per_mount *uepm);
109*84d9c625SLionel Sambuc int	ulfs_extattr_start(struct mount *mp, struct lwp *l);
110*84d9c625SLionel Sambuc int	ulfs_extattr_autostart(struct mount *mp, struct lwp *l);
111*84d9c625SLionel Sambuc void	ulfs_extattr_stop(struct mount *mp, struct lwp *l);
112*84d9c625SLionel Sambuc int	ulfs_extattrctl(struct mount *mp, int cmd, struct vnode *filename,
113*84d9c625SLionel Sambuc 	    int attrnamespace, const char *attrname);
114*84d9c625SLionel Sambuc struct vop_getextattr_args;
115*84d9c625SLionel Sambuc int	ulfs_getextattr(struct vop_getextattr_args *ap);
116*84d9c625SLionel Sambuc struct vop_deleteextattr_args;
117*84d9c625SLionel Sambuc int	ulfs_deleteextattr(struct vop_deleteextattr_args *ap);
118*84d9c625SLionel Sambuc struct vop_setextattr_args;
119*84d9c625SLionel Sambuc int	ulfs_setextattr(struct vop_setextattr_args *ap);
120*84d9c625SLionel Sambuc struct vop_listextattr_args;
121*84d9c625SLionel Sambuc int	ulfs_listextattr(struct vop_listextattr_args *ap);
122*84d9c625SLionel Sambuc void	ulfs_extattr_vnode_inactive(struct vnode *vp, struct lwp *l);
123*84d9c625SLionel Sambuc 
124*84d9c625SLionel Sambuc void	ulfs_extattr_init(void);
125*84d9c625SLionel Sambuc void	ulfs_extattr_done(void);
126*84d9c625SLionel Sambuc 
127*84d9c625SLionel Sambuc #endif /* !_KERNEL */
128*84d9c625SLionel Sambuc 
129*84d9c625SLionel Sambuc #endif /* !_UFS_LFS_ULFS_EXTATTR_H_ */
130