Home | History | Annotate | Line # | Download | only in lfs
      1  1.3  dholland /*	$NetBSD: ulfs_extattr.h,v 1.3 2016/06/20 01:56:21 dholland Exp $	*/
      2  1.3  dholland /*  from NetBSD: extattr.h,v 1.11 2014/12/19 10:59:21 manu 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.2  dholland  * Support for file system extended attributes on the ULFS1 file system.
     36  1.1  dholland  * Developed by the TrustedBSD Project.
     37  1.1  dholland  */
     38  1.1  dholland 
     39  1.2  dholland #ifndef _UFS_LFS_ULFS_EXTATTR_H_
     40  1.2  dholland #define	_UFS_LFS_ULFS_EXTATTR_H_
     41  1.1  dholland 
     42  1.2  dholland #define	ULFS_EXTATTR_MAGIC		0x00b5d5ec
     43  1.2  dholland #define	ULFS_EXTATTR_VERSION		0x00000003
     44  1.2  dholland #define	ULFS_EXTATTR_FSROOTSUBDIR	".attribute"
     45  1.2  dholland #define	ULFS_EXTATTR_SUBDIR_SYSTEM	"system"
     46  1.2  dholland #define	ULFS_EXTATTR_SUBDIR_USER		"user"
     47  1.3  dholland #define	ULFS_EXTATTR_MAXEXTATTRNAME	256	/* including null */
     48  1.2  dholland 
     49  1.2  dholland #define	ULFS_EXTATTR_ATTR_FLAG_INUSE	0x00000001	/* attr has been set */
     50  1.2  dholland #define	ULFS_EXTATTR_PERM_KERNEL		0x00000000
     51  1.2  dholland #define	ULFS_EXTATTR_PERM_ROOT		0x00000001
     52  1.2  dholland #define	ULFS_EXTATTR_PERM_OWNER		0x00000002
     53  1.2  dholland #define	ULFS_EXTATTR_PERM_ANYONE		0x00000003
     54  1.2  dholland 
     55  1.2  dholland #define	ULFS_EXTATTR_UEPM_INITIALIZED	0x00000001
     56  1.2  dholland #define	ULFS_EXTATTR_UEPM_STARTED	0x00000002
     57  1.2  dholland 
     58  1.2  dholland #define	ULFS_EXTATTR_CMD_START		EXTATTR_CMD_START
     59  1.2  dholland #define	ULFS_EXTATTR_CMD_STOP		EXTATTR_CMD_STOP
     60  1.2  dholland #define	ULFS_EXTATTR_CMD_ENABLE		0x00000003
     61  1.2  dholland #define	ULFS_EXTATTR_CMD_DISABLE		0x00000004
     62  1.1  dholland 
     63  1.2  dholland struct ulfs_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.2  dholland struct ulfs_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.2  dholland LIST_HEAD(ulfs_extattr_list_head, ulfs_extattr_list_entry);
     84  1.2  dholland struct ulfs_extattr_list_entry {
     85  1.2  dholland 	LIST_ENTRY(ulfs_extattr_list_entry)	uele_entries;
     86  1.2  dholland 	struct ulfs_extattr_fileheader		uele_fileheader;
     87  1.1  dholland 	int		uele_attrnamespace;
     88  1.2  dholland 	char		uele_attrname[ULFS_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.2  dholland struct ulfs_extattr_per_mount {
    100  1.1  dholland 	kmutex_t			uepm_lock;
    101  1.2  dholland 	struct ulfs_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.2  dholland void	ulfs_extattr_uepm_init(struct ulfs_extattr_per_mount *uepm);
    108  1.2  dholland void	ulfs_extattr_uepm_destroy(struct ulfs_extattr_per_mount *uepm);
    109  1.2  dholland int	ulfs_extattr_start(struct mount *mp, struct lwp *l);
    110  1.2  dholland int	ulfs_extattr_autostart(struct mount *mp, struct lwp *l);
    111  1.2  dholland void	ulfs_extattr_stop(struct mount *mp, struct lwp *l);
    112  1.2  dholland int	ulfs_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.2  dholland int	ulfs_getextattr(struct vop_getextattr_args *ap);
    116  1.1  dholland struct vop_deleteextattr_args;
    117  1.2  dholland int	ulfs_deleteextattr(struct vop_deleteextattr_args *ap);
    118  1.1  dholland struct vop_setextattr_args;
    119  1.2  dholland int	ulfs_setextattr(struct vop_setextattr_args *ap);
    120  1.1  dholland struct vop_listextattr_args;
    121  1.2  dholland int	ulfs_listextattr(struct vop_listextattr_args *ap);
    122  1.2  dholland void	ulfs_extattr_vnode_inactive(struct vnode *vp, struct lwp *l);
    123  1.1  dholland 
    124  1.2  dholland void	ulfs_extattr_init(void);
    125  1.2  dholland void	ulfs_extattr_done(void);
    126  1.1  dholland 
    127  1.1  dholland #endif /* !_KERNEL */
    128  1.1  dholland 
    129  1.2  dholland #endif /* !_UFS_LFS_ULFS_EXTATTR_H_ */
    130