1 /* $NetBSD: ulfs_extattr.h,v 1.2 2013/06/06 00:48:04 dholland Exp $ */
2 /* from NetBSD: extattr.h,v 1.10 2011/10/09 21:15:34 chs Exp */
5 * Copyright (c) 1999-2001 Robert N. M. Watson
8 * This software was developed by Robert Watson for the TrustedBSD Project.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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
31 * $FreeBSD: src/sys/ufs/ufs/extattr.h,v 1.20 2005/01/31 08:16:45 imp Exp $
35 * Support for file system extended attributes on the ULFS1 file system.
36 * Developed by the TrustedBSD Project.
39 #ifndef _UFS_LFS_ULFS_EXTATTR_H_
40 #define _UFS_LFS_ULFS_EXTATTR_H_
42 #define ULFS_EXTATTR_MAGIC 0x00b5d5ec
43 #define ULFS_EXTATTR_VERSION 0x00000003
44 #define ULFS_EXTATTR_FSROOTSUBDIR ".attribute"
45 #define ULFS_EXTATTR_SUBDIR_SYSTEM "system"
46 #define ULFS_EXTATTR_SUBDIR_USER "user"
47 #define ULFS_EXTATTR_MAXEXTATTRNAME 65 /* including null */
49 #define ULFS_EXTATTR_ATTR_FLAG_INUSE 0x00000001 /* attr has been set */
50 #define ULFS_EXTATTR_PERM_KERNEL 0x00000000
51 #define ULFS_EXTATTR_PERM_ROOT 0x00000001
52 #define ULFS_EXTATTR_PERM_OWNER 0x00000002
53 #define ULFS_EXTATTR_PERM_ANYONE 0x00000003
55 #define ULFS_EXTATTR_UEPM_INITIALIZED 0x00000001
56 #define ULFS_EXTATTR_UEPM_STARTED 0x00000002
58 #define ULFS_EXTATTR_CMD_START EXTATTR_CMD_START
59 #define ULFS_EXTATTR_CMD_STOP EXTATTR_CMD_STOP
60 #define ULFS_EXTATTR_CMD_ENABLE 0x00000003
61 #define ULFS_EXTATTR_CMD_DISABLE 0x00000004
63 struct ulfs_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 */
69 struct ulfs_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 */
79 MALLOC_DECLARE(M_EXTATTR
);
83 LIST_HEAD(ulfs_extattr_list_head
, ulfs_extattr_list_entry
);
84 struct ulfs_extattr_list_entry
{
85 LIST_ENTRY(ulfs_extattr_list_entry
) uele_entries
;
86 struct ulfs_extattr_fileheader uele_fileheader
;
87 int uele_attrnamespace
;
88 char uele_attrname
[ULFS_EXTATTR_MAXEXTATTRNAME
];
89 struct vnode
*uele_backing_vnode
;
94 #define UELE_F_NEEDSWAP 0x01 /* needs byte swap */
96 #define UELE_NEEDSWAP(uele) ((uele)->uele_flags & UELE_F_NEEDSWAP)
99 struct ulfs_extattr_per_mount
{
101 struct ulfs_extattr_list_head uepm_list
;
102 kauth_cred_t uepm_ucred
;
107 void ulfs_extattr_uepm_init(struct ulfs_extattr_per_mount
*uepm
);
108 void ulfs_extattr_uepm_destroy(struct ulfs_extattr_per_mount
*uepm
);
109 int ulfs_extattr_start(struct mount
*mp
, struct lwp
*l
);
110 int ulfs_extattr_autostart(struct mount
*mp
, struct lwp
*l
);
111 void ulfs_extattr_stop(struct mount
*mp
, struct lwp
*l
);
112 int ulfs_extattrctl(struct mount
*mp
, int cmd
, struct vnode
*filename
,
113 int attrnamespace
, const char *attrname
);
114 struct vop_getextattr_args
;
115 int ulfs_getextattr(struct vop_getextattr_args
*ap
);
116 struct vop_deleteextattr_args
;
117 int ulfs_deleteextattr(struct vop_deleteextattr_args
*ap
);
118 struct vop_setextattr_args
;
119 int ulfs_setextattr(struct vop_setextattr_args
*ap
);
120 struct vop_listextattr_args
;
121 int ulfs_listextattr(struct vop_listextattr_args
*ap
);
122 void ulfs_extattr_vnode_inactive(struct vnode
*vp
, struct lwp
*l
);
124 void ulfs_extattr_init(void);
125 void ulfs_extattr_done(void);
127 #endif /* !_KERNEL */
129 #endif /* !_UFS_LFS_ULFS_EXTATTR_H_ */