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