xref: /openbmc/linux/include/linux/nfsacl.h (revision 8edc0648)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2a257cdd0SAndreas Gruenbacher /*
3a257cdd0SAndreas Gruenbacher  * File: linux/nfsacl.h
4a257cdd0SAndreas Gruenbacher  *
5a257cdd0SAndreas Gruenbacher  * (C) 2003 Andreas Gruenbacher <agruen@suse.de>
6a257cdd0SAndreas Gruenbacher  */
7a257cdd0SAndreas Gruenbacher #ifndef __LINUX_NFSACL_H
8a257cdd0SAndreas Gruenbacher #define __LINUX_NFSACL_H
9a257cdd0SAndreas Gruenbacher 
10a257cdd0SAndreas Gruenbacher 
11a257cdd0SAndreas Gruenbacher #include <linux/posix_acl.h>
12d7031582SBoaz Harrosh #include <linux/sunrpc/xdr.h>
13607ca46eSDavid Howells #include <uapi/linux/nfsacl.h>
14a257cdd0SAndreas Gruenbacher 
15a257cdd0SAndreas Gruenbacher /* Maximum number of ACL entries over NFS */
16a257cdd0SAndreas Gruenbacher #define NFS_ACL_MAX_ENTRIES	1024
17a257cdd0SAndreas Gruenbacher 
18a257cdd0SAndreas Gruenbacher #define NFSACL_MAXWORDS		(2*(2+3*NFS_ACL_MAX_ENTRIES))
19a257cdd0SAndreas Gruenbacher #define NFSACL_MAXPAGES		((2*(8+12*NFS_ACL_MAX_ENTRIES) + PAGE_SIZE-1) \
20a257cdd0SAndreas Gruenbacher 				 >> PAGE_SHIFT)
21a257cdd0SAndreas Gruenbacher 
22ae46141fSTrond Myklebust #define NFS_ACL_MAX_ENTRIES_INLINE	(5)
23ae46141fSTrond Myklebust #define NFS_ACL_INLINE_BUFSIZE	((2*(2+3*NFS_ACL_MAX_ENTRIES_INLINE)) << 2)
24ae46141fSTrond Myklebust 
25a257cdd0SAndreas Gruenbacher static inline unsigned int
nfsacl_size(struct posix_acl * acl_access,struct posix_acl * acl_default)26a257cdd0SAndreas Gruenbacher nfsacl_size(struct posix_acl *acl_access, struct posix_acl *acl_default)
27a257cdd0SAndreas Gruenbacher {
28a257cdd0SAndreas Gruenbacher 	unsigned int w = 16;
29a257cdd0SAndreas Gruenbacher 	w += max(acl_access ? (int)acl_access->a_count : 3, 4) * 12;
30a257cdd0SAndreas Gruenbacher 	if (acl_default)
31a257cdd0SAndreas Gruenbacher 		w += max((int)acl_default->a_count, 4) * 12;
32a257cdd0SAndreas Gruenbacher 	return w;
33a257cdd0SAndreas Gruenbacher }
34a257cdd0SAndreas Gruenbacher 
35731f3f48SChuck Lever extern int
36a257cdd0SAndreas Gruenbacher nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,
37a257cdd0SAndreas Gruenbacher 	      struct posix_acl *acl, int encode_entries, int typeflag);
38731f3f48SChuck Lever extern int
39a257cdd0SAndreas Gruenbacher nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,
40a257cdd0SAndreas Gruenbacher 	      struct posix_acl **pacl);
416bb844b4SChuck Lever extern bool
426bb844b4SChuck Lever nfs_stream_decode_acl(struct xdr_stream *xdr, unsigned int *aclcnt,
436bb844b4SChuck Lever 		      struct posix_acl **pacl);
44*8edc0648SChuck Lever extern bool
45*8edc0648SChuck Lever nfs_stream_encode_acl(struct xdr_stream *xdr, struct inode *inode,
46*8edc0648SChuck Lever 		      struct posix_acl *acl, int encode_entries, int typeflag);
47a257cdd0SAndreas Gruenbacher 
48a257cdd0SAndreas Gruenbacher #endif  /* __LINUX_NFSACL_H */
49