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