Whamcloud - gitweb
f2281baa705ec8a741d2ecba1ea3d7502e886059
[fs/lustre-release.git] / lustre / include / lustre_eacl.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/lustre/include/lustre_idmap.h
37  *
38  * MDS data structures.
39  * See also lustre_idl.h for wire formats of requests.
40  */
41
42 #ifndef _LUSTRE_EACL_H
43 #define _LUSTRE_EACL_H
44
45 #ifdef CONFIG_FS_POSIX_ACL
46
47 # ifdef HAVE_XATTR_ACL
48 #  include <linux/xattr_acl.h>
49 # endif /* HAVE_XATTR_ACL */
50 # ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
51 #  include <linux/posix_acl_xattr.h>
52 # endif /* HAVE_LINUX_POSIX_ACL_XATTR_H */
53
54 #include <lustre_idmap.h>
55 #include <md_object.h>
56 #include <lu_object.h>
57
58 typedef struct {
59         __u16                   e_tag;
60         __u16                   e_perm;
61         __u32                   e_id;
62         __u32                   e_stat;
63 } ext_acl_xattr_entry;
64
65 typedef struct {
66         __u32                   a_count;
67         ext_acl_xattr_entry     a_entries[0];
68 } ext_acl_xattr_header;
69
70 #define CFS_ACL_XATTR_SIZE(count, prefix) \
71         (sizeof(prefix ## _header) + (count) * sizeof(prefix ## _entry))
72
73 #define CFS_ACL_XATTR_COUNT(size, prefix) \
74         (((size) - sizeof(prefix ## _header)) / sizeof(prefix ## _entry))
75
76 extern int lustre_posix_acl_permission(struct md_ucred *mu, struct lu_attr *la,
77                                        int want, posix_acl_xattr_entry *entry,
78                                        int count);
79 extern int lustre_posix_acl_chmod_masq(posix_acl_xattr_entry *entry,
80                                        __u32 mode, int count);
81 extern int lustre_posix_acl_create_masq(posix_acl_xattr_entry *entry,
82                                         __u32 *pmode, int count);
83
84 extern ext_acl_xattr_header *
85 lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size);
86 extern int
87 lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size,
88                               posix_acl_xattr_header **out);
89 extern int
90 lustre_posix_acl_xattr_id2client(struct md_ucred *mu,
91                                  struct lustre_idmap_table *t,
92                                  posix_acl_xattr_header *header,
93                                  int size, int flags);
94 extern void
95 lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size);
96 extern int
97 lustre_ext_acl_xattr_id2server(struct md_ucred *mu,
98                                struct lustre_idmap_table *t,
99                                ext_acl_xattr_header *header);
100 extern void
101 lustre_ext_acl_xattr_free(ext_acl_xattr_header *header);
102 extern int
103 lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size,
104                              ext_acl_xattr_header *ext_header,
105                              posix_acl_xattr_header **out);
106 extern ext_acl_xattr_header *
107 lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size,
108                            ext_acl_xattr_header *ext_header);
109
110 #endif /* CONFIG_FS_POSIX_ACL */
111
112 #endif