| 1 | /* $NetBSD: ulfs_extattr.h,v 1.3 2016/06/20 01:56:21 dholland Exp $ */ |
| 2 | /* from NetBSD: extattr.h,v 1.11 2014/12/19 10:59:21 manu 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 ULFS1 file system. |
| 36 | * Developed by the TrustedBSD Project. |
| 37 | */ |
| 38 | |
| 39 | #ifndef _UFS_LFS_ULFS_EXTATTR_H_ |
| 40 | #define _UFS_LFS_ULFS_EXTATTR_H_ |
| 41 | |
| 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 256 /* including null */ |
| 48 | |
| 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 |
| 54 | |
| 55 | #define ULFS_EXTATTR_UEPM_INITIALIZED 0x00000001 |
| 56 | #define ULFS_EXTATTR_UEPM_STARTED 0x00000002 |
| 57 | |
| 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 |
| 62 | |
| 63 | struct { |
| 64 | uint32_t ; /* magic number for sanity checking */ |
| 65 | uint32_t ; /* version of attribute file */ |
| 66 | uint32_t ; /* size of attributes, w/o header */ |
| 67 | }; |
| 68 | |
| 69 | struct { |
| 70 | uint32_t ; /* flags for attribute */ |
| 71 | uint32_t ; /* local defined length; <= uef_size */ |
| 72 | uint32_t ; /* 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(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 ; |
| 87 | int uele_attrnamespace; |
| 88 | char uele_attrname[ULFS_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 ulfs_extattr_per_mount { |
| 100 | kmutex_t uepm_lock; |
| 101 | struct ulfs_extattr_list_head uepm_list; |
| 102 | kauth_cred_t uepm_ucred; |
| 103 | int uepm_lockcnt; |
| 104 | int uepm_flags; |
| 105 | }; |
| 106 | |
| 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); |
| 123 | |
| 124 | void ulfs_extattr_init(void); |
| 125 | void ulfs_extattr_done(void); |
| 126 | |
| 127 | #endif /* !_KERNEL */ |
| 128 | |
| 129 | #endif /* !_UFS_LFS_ULFS_EXTATTR_H_ */ |
| 130 | |