2 * Copyright (c) 1999-2001 Robert N. M. Watson
5 * This software was developed by Robert Watson for the TrustedBSD Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * Developed by the TrustedBSD Project.
32 * Support for extended filesystem attributes.
35 #ifndef _UFS_UFS_EXTATTR_H_
36 #define _UFS_UFS_EXTATTR_H_
38 #define UFS_EXTATTR_MAGIC 0x00b5d5ec
39 #define UFS_EXTATTR_VERSION 0x00000003
40 #define UFS_EXTATTR_FSROOTSUBDIR ".attribute"
41 #define UFS_EXTATTR_SUBDIR_SYSTEM "system"
42 #define UFS_EXTATTR_SUBDIR_USER "user"
43 #define UFS_EXTATTR_MAXEXTATTRNAME 65 /* including null */
45 #define UFS_EXTATTR_ATTR_FLAG_INUSE 0x00000001 /* attr has been set */
46 #define UFS_EXTATTR_PERM_KERNEL 0x00000000
47 #define UFS_EXTATTR_PERM_ROOT 0x00000001
48 #define UFS_EXTATTR_PERM_OWNER 0x00000002
49 #define UFS_EXTATTR_PERM_ANYONE 0x00000003
51 #define UFS_EXTATTR_UEPM_INITIALIZED 0x00000001
52 #define UFS_EXTATTR_UEPM_STARTED 0x00000002
54 #define UFS_EXTATTR_CMD_START 0x00000001
55 #define UFS_EXTATTR_CMD_STOP 0x00000002
56 #define UFS_EXTATTR_CMD_ENABLE 0x00000003
57 #define UFS_EXTATTR_CMD_DISABLE 0x00000004
59 struct ufs_extattr_fileheader {
60 u_int uef_magic; /* magic number for sanity checking */
61 u_int uef_version; /* version of attribute file */
62 u_int uef_size; /* size of attributes, w/o header */
65 struct ufs_extattr_header {
66 u_int ueh_flags; /* flags for attribute */
67 u_int ueh_len; /* local defined length; <= uef_size */
68 u_int32_t ueh_i_gen; /* generation number for sanity */
69 /* data follows the header */
75 MALLOC_DECLARE(M_EXTATTR);
79 LIST_HEAD(ufs_extattr_list_head, ufs_extattr_list_entry);
80 struct ufs_extattr_list_entry {
81 LIST_ENTRY(ufs_extattr_list_entry) uele_entries;
82 struct ufs_extattr_fileheader uele_fileheader;
83 int uele_attrnamespace;
84 char uele_attrname[UFS_EXTATTR_MAXEXTATTRNAME];
85 struct vnode *uele_backing_vnode;
90 struct ufs_extattr_per_mount {
91 struct lock uepm_lock;
92 struct ufs_extattr_list_head uepm_list;
93 struct ucred *uepm_ucred;
97 void ufs_extattr_uepm_init(struct ufs_extattr_per_mount *uepm);
98 void ufs_extattr_uepm_destroy(struct ufs_extattr_per_mount *uepm);
99 int ufs_extattr_start(struct mount *mp, struct thread *td);
100 int ufs_extattr_autostart(struct mount *mp, struct thread *td);
101 int ufs_extattr_stop(struct mount *mp, struct thread *td);
102 int ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename,
103 int attrnamespace, const char *attrname, struct thread *td);
104 int ufs_getextattr(struct vop_getextattr_args *ap);
105 int ufs_deleteextattr(struct vop_deleteextattr_args *ap);
106 int ufs_setextattr(struct vop_setextattr_args *ap);
107 void ufs_extattr_vnode_inactive(struct vnode *vp, struct thread *td);
109 #endif /* !_KERNEL */
111 #endif /* !_UFS_UFS_EXTATTR_H_ */