2006-10-11 12:20:50 +04:00
/*
2006-10-11 12:20:53 +04:00
File : fs / ext4 / acl . h
2006-10-11 12:20:50 +04:00
( C ) 2001 Andreas Gruenbacher , < a . gruenbacher @ computer . org >
*/
# include <linux/posix_acl_xattr.h>
2006-10-11 12:20:53 +04:00
# define EXT4_ACL_VERSION 0x0001
2006-10-11 12:20:50 +04:00
typedef struct {
__le16 e_tag ;
__le16 e_perm ;
__le32 e_id ;
2006-10-11 12:20:53 +04:00
} ext4_acl_entry ;
2006-10-11 12:20:50 +04:00
typedef struct {
__le16 e_tag ;
__le16 e_perm ;
2006-10-11 12:20:53 +04:00
} ext4_acl_entry_short ;
2006-10-11 12:20:50 +04:00
typedef struct {
__le32 a_version ;
2006-10-11 12:20:53 +04:00
} ext4_acl_header ;
2006-10-11 12:20:50 +04:00
2006-10-11 12:20:53 +04:00
static inline size_t ext4_acl_size ( int count )
2006-10-11 12:20:50 +04:00
{
if ( count < = 4 ) {
2006-10-11 12:20:53 +04:00
return sizeof ( ext4_acl_header ) +
count * sizeof ( ext4_acl_entry_short ) ;
2006-10-11 12:20:50 +04:00
} else {
2006-10-11 12:20:53 +04:00
return sizeof ( ext4_acl_header ) +
4 * sizeof ( ext4_acl_entry_short ) +
( count - 4 ) * sizeof ( ext4_acl_entry ) ;
2006-10-11 12:20:50 +04:00
}
}
2006-10-11 12:20:53 +04:00
static inline int ext4_acl_count ( size_t size )
2006-10-11 12:20:50 +04:00
{
ssize_t s ;
2006-10-11 12:20:53 +04:00
size - = sizeof ( ext4_acl_header ) ;
s = size - 4 * sizeof ( ext4_acl_entry_short ) ;
2006-10-11 12:20:50 +04:00
if ( s < 0 ) {
2006-10-11 12:20:53 +04:00
if ( size % sizeof ( ext4_acl_entry_short ) )
2006-10-11 12:20:50 +04:00
return - 1 ;
2006-10-11 12:20:53 +04:00
return size / sizeof ( ext4_acl_entry_short ) ;
2006-10-11 12:20:50 +04:00
} else {
2006-10-11 12:20:53 +04:00
if ( s % sizeof ( ext4_acl_entry ) )
2006-10-11 12:20:50 +04:00
return - 1 ;
2006-10-11 12:20:53 +04:00
return s / sizeof ( ext4_acl_entry ) + 4 ;
2006-10-11 12:20:50 +04:00
}
}
2008-10-11 04:02:48 +04:00
# ifdef CONFIG_EXT4_FS_POSIX_ACL
2006-10-11 12:20:50 +04:00
/* acl.c */
2011-07-23 19:37:31 +04:00
struct posix_acl * ext4_get_acl ( struct inode * inode , int type ) ;
2013-12-20 17:16:44 +04:00
int ext4_set_acl ( struct inode * inode , struct posix_acl * acl , int type ) ;
2008-09-09 06:25:24 +04:00
extern int ext4_init_acl ( handle_t * , struct inode * , struct inode * ) ;
2006-10-11 12:20:50 +04:00
2008-10-11 04:02:48 +04:00
# else /* CONFIG_EXT4_FS_POSIX_ACL */
2006-10-11 12:20:50 +04:00
# include <linux/sched.h>
2011-07-23 19:37:31 +04:00
# define ext4_get_acl NULL
2013-12-20 17:16:44 +04:00
# define ext4_set_acl NULL
2006-10-11 12:20:50 +04:00
static inline int
2006-10-11 12:20:53 +04:00
ext4_init_acl ( handle_t * handle , struct inode * inode , struct inode * dir )
2006-10-11 12:20:50 +04:00
{
return 0 ;
}
2008-10-11 04:02:48 +04:00
# endif /* CONFIG_EXT4_FS_POSIX_ACL */
2006-10-11 12:20:50 +04:00