The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/ufs/ufs/extattr.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1999-2001 Robert N. M. Watson
    3  * All rights reserved.
    4  *
    5  * This software was developed by Robert Watson for the TrustedBSD Project.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   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.
   15  *
   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
   26  * SUCH DAMAGE.
   27  *
   28  * $FreeBSD$
   29  */
   30 /*
   31  * Developed by the TrustedBSD Project.
   32  * Support for extended filesystem attributes.
   33  */
   34 
   35 #ifndef _UFS_UFS_EXTATTR_H_
   36 #define _UFS_UFS_EXTATTR_H_
   37 
   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 */
   44 
   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
   50 
   51 #define UFS_EXTATTR_UEPM_INITIALIZED    0x00000001
   52 #define UFS_EXTATTR_UEPM_STARTED        0x00000002
   53 
   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
   58 
   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 */
   63 };
   64 
   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 */
   70 };
   71 
   72 /*
   73  * This structure defines the required fields of an extended-attribute header.
   74  */
   75 struct extattr {
   76         int32_t ea_length;          /* length of this attribute */
   77         int8_t  ea_namespace;       /* name space of this attribute */
   78         int8_t  ea_contentpadlen;   /* bytes of padding at end of attribute */
   79         int8_t  ea_namelength;      /* length of attribute name */
   80         char    ea_name[1];         /* null-terminated attribute name */
   81         /* extended attribute content follows */
   82 };
   83 
   84 /*
   85  * These macros are used to access and manipulate an extended attribute:
   86  *
   87  * EXTATTR_NEXT(eap) returns a pointer to the next extended attribute
   88  *      following eap.
   89  * EXTATTR_CONTENT(eap) returns a pointer to the extended attribute
   90  *      content referenced by eap.
   91  * EXTATTR_CONTENT_SIZE(eap) returns the size of the extended attribute
   92  *      content referenced by eap.
   93  * EXTATTR_SET_LENGTHS(eap, contentsize) called after initializing the
   94  *      attribute name to calculate and set the ea_length, ea_namelength,
   95  *      and ea_contentpadlen fields of the extended attribute structure.
   96  */
   97 #define EXTATTR_NEXT(eap) \
   98         ((struct extattr *)(((void *)(eap)) + (eap)->ea_length))
   99 #define EXTATTR_CONTENT(eap) (((void *)(eap)) + EXTATTR_BASE_LENGTH(eap))
  100 #define EXTATTR_CONTENT_SIZE(eap) \
  101         ((eap)->ea_length - EXTATTR_BASE_LENGTH(eap) - (eap)->ea_contentpadlen)
  102 #define EXTATTR_BASE_LENGTH(eap) \
  103         ((sizeof(struct extattr) + (eap)->ea_namelength + 7) & ~7)
  104 #define EXTATTR_SET_LENGTHS(eap, contentsize) do { \
  105         KASSERT(((eap)->ea_name[0] != 0), \
  106                 ("Must initialize name before setting lengths")); \
  107         (eap)->ea_namelength = strlen((eap)->ea_name); \
  108         (eap)->ea_contentpadlen = ((contentsize) % 8) ? \
  109                 8 - ((contentsize) % 8) : 0; \
  110         (eap)->ea_length = EXTATTR_BASE_LENGTH(eap) + \
  111                 (contentsize) + (eap)->ea_contentpadlen; \
  112 } while (0)
  113 
  114 #ifdef _KERNEL
  115 
  116 #include <sys/_sx.h>
  117 
  118 #ifdef MALLOC_DECLARE
  119 MALLOC_DECLARE(M_EXTATTR);
  120 #endif
  121 
  122 struct vnode;
  123 LIST_HEAD(ufs_extattr_list_head, ufs_extattr_list_entry);
  124 struct ufs_extattr_list_entry {
  125         LIST_ENTRY(ufs_extattr_list_entry)      uele_entries;
  126         struct ufs_extattr_fileheader           uele_fileheader;
  127         int     uele_attrnamespace;
  128         char    uele_attrname[UFS_EXTATTR_MAXEXTATTRNAME];
  129         struct vnode    *uele_backing_vnode;
  130 };
  131 
  132 struct ucred;
  133 struct ufs_extattr_per_mount {
  134         struct sx       uepm_lock;
  135         struct ufs_extattr_list_head    uepm_list;
  136         struct ucred    *uepm_ucred;
  137         int     uepm_flags;
  138 };
  139 
  140 void    ufs_extattr_uepm_init(struct ufs_extattr_per_mount *uepm);
  141 void    ufs_extattr_uepm_destroy(struct ufs_extattr_per_mount *uepm);
  142 int     ufs_extattr_start(struct mount *mp, struct thread *td);
  143 int     ufs_extattr_autostart(struct mount *mp, struct thread *td);
  144 int     ufs_extattr_stop(struct mount *mp, struct thread *td);
  145 int     ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename,
  146             int attrnamespace, const char *attrname);
  147 int     ufs_getextattr(struct vop_getextattr_args *ap);
  148 int     ufs_deleteextattr(struct vop_deleteextattr_args *ap);
  149 int     ufs_setextattr(struct vop_setextattr_args *ap);
  150 void    ufs_extattr_vnode_inactive(struct vnode *vp, struct thread *td);
  151 
  152 #else
  153 
  154 /* User-level definition of KASSERT for macros above */
  155 #define KASSERT(cond, str) do { \
  156         if (!(cond)) { printf("panic: "); printf(str); printf("\n"); exit(1); }\
  157 } while (0)
  158 
  159 #endif /* !_KERNEL */
  160 
  161 #endif /* !_UFS_UFS_EXTATTR_H_ */

Cache object: 8540f5d506e1949df0f1089c2bf7f5c3


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.