Skip to content

Commit

Permalink
test updates
Browse files Browse the repository at this point in the history
Signed-off-by: Umer Saleem <[email protected]>
  • Loading branch information
usaleem-ix committed Jan 16, 2025
1 parent 00aecd6 commit cca7c87
Show file tree
Hide file tree
Showing 6 changed files with 369 additions and 172 deletions.
148 changes: 80 additions & 68 deletions include/zfsacl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#ifndef __ZFSACL_H__
#define __ZFSACL_H__ extern __attribute__((visibility("default")))
#define __ZFSACL_H__

#include <zfs_config.h>
#include <stdio.h>
Expand All @@ -35,9 +35,6 @@
#include <stdlib.h>
#include <sys/types.h>

#define zfsace4 zfsacl_entry
typedef unsigned int uint_t;

/*
* BRAND_ACCESS and BRAND_DEFAULT
* values chosen so can convert easily
Expand Down Expand Up @@ -75,86 +72,38 @@ struct native_acl {
zfsacl_brand_t brand;
};

#ifdef __linux__
struct zfsacl_entry { uint_t netlong[5]; };
#if defined (FREEBSD)

Check failure on line 75 in include/zfsacl.h

View workflow job for this annotation

GitHub Actions / checkstyle

extra space between function name and left paren

#define zfsacl_entry acl_entry

Check failure on line 77 in include/zfsacl.h

View workflow job for this annotation

GitHub Actions / checkstyle

#define followed by space instead of tab
#define zfsacl acl_t_struct

Check failure on line 78 in include/zfsacl.h

View workflow job for this annotation

GitHub Actions / checkstyle

#define followed by space instead of tab

#else

struct zfsacl_entry { uint netlong[5]; };

Check failure on line 82 in include/zfsacl.h

View workflow job for this annotation

GitHub Actions / checkstyle

non-POSIX typedef uint used: use uint_t instead
struct zfsacl {
size_t aclbuf_size;
zfsacl_brand_t brand;
uint_t *aclbuf;
size_t aclbuf_size;

Check failure on line 84 in include/zfsacl.h

View workflow job for this annotation

GitHub Actions / checkstyle

indent by spaces instead of tabs
zfsacl_brand_t brand;

Check failure on line 85 in include/zfsacl.h

View workflow job for this annotation

GitHub Actions / checkstyle

indent by spaces instead of tabs
uint *aclbuf;

Check failure on line 86 in include/zfsacl.h

View workflow job for this annotation

GitHub Actions / checkstyle

indent by spaces instead of tabs

Check failure on line 86 in include/zfsacl.h

View workflow job for this annotation

GitHub Actions / checkstyle

non-POSIX typedef uint used: use uint_t instead
};
#else
#define _ACL_PRIVATE
#define zfsacl_entry acl_entry
#define zfsacl acl_t_struct

#endif

typedef struct zfsacl_entry *zfsacl_entry_t;
typedef struct zfsacl *zfsacl_t;

typedef unsigned int zfsace_flagset_t;
typedef int zfsace_permset_t;
typedef unsigned int zfsace_permset_t;
typedef uid_t zfsace_id_t;
typedef unsigned int zfsacl_aclflags_t;

#define ZFSACL_UNDEFINED_ID ((uid_t)-1)
#define ZFSACL_APPEND_ENTRY -1
#define ZFSACL_MAX_ENTRIES 64
#define ZFSACL_UNDEFINED_ID ((uid_t)-1)

Check failure on line 99 in include/zfsacl.h

View workflow job for this annotation

GitHub Actions / checkstyle

#define followed by space instead of tab
#define ZFSACL_APPEND_ENTRY -1

Check failure on line 100 in include/zfsacl.h

View workflow job for this annotation

GitHub Actions / checkstyle

#define followed by space instead of tab
#define ZFSACL_MAX_ENTRIES 1024

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) ((int)(sizeof (a)/sizeof (a[0])))
#endif

/*
* this is a warning hack. The idea is to use this everywhere that we
* get the "discarding const" warning from gcc. That doesn't actually
* fix the problem of course, but it means that when we do get to
* cleaning them up we can do it by searching the code for
* discard_const.
*
* It also means that other error types aren't as swamped by the noise
* of hundreds of const warnings, so we are more likely to notice when
* we get new errors.
*
* Please only add more uses of this macro when you find it
* _really_ hard to fix const warnings. Our aim is to eventually use
* this function in only a very few places.
*
* Also, please call this via the discard_const_p() macro interface, as that
* makes the return type safe.
*/
#ifndef discard_const
#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
#endif

/*
* Type-safe version of discard_const
*/
#ifndef discard_const_p
#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
#endif

typedef struct aclflags2name {
zfsacl_aclflags_t flag;
const char *name;
} aclflags2name_t;

typedef struct aceperms2name {
zfsace_permset_t perm;
const char *name;
char letter;
} aceperms2name_t;

typedef struct aceflags2name {
zfsace_flagset_t flag;
const char *name;
char letter;
} aceflags2name_t;

typedef struct aceswho2name {
zfsace_who_t who;
const char *name;
} aceswho2name_t;

boolean_t zfsacl_set_fd(int _fd, zfsacl_t _acl);
boolean_t zfsacl_set_file(const char *_path_p, zfsacl_t _acl);
boolean_t zfsacl_set_link(const char *_path_p, zfsacl_t _acl);
Expand Down Expand Up @@ -290,6 +239,9 @@ boolean_t zfsace_set_who(zfsacl_entry_t _entry, zfsace_who_t _who,
zfsace_id_t _aeid);
boolean_t zfsace_set_entry_type(zfsacl_entry_t _entry, zfsace_entry_type_t _tp);

zfsacl_t zfsacl_calculate_inherited_acl(zfsacl_t p, zfsacl_t t, boolean_t dir);


/*
* NFSv4 ACL-wide flags
* used in zfsacl_get_aclflags() and zfsacl_set_aclflags()
Expand Down Expand Up @@ -379,4 +331,64 @@ boolean_t zfsace_set_entry_type(zfsacl_entry_t _entry, zfsace_entry_type_t _tp);
(who != ZFSACL_GROUP_OBJ) && (who != ZFSACL_GROUP) && \
(who != ZFSACL_EVERYONE))

static const struct {
zfsacl_aclflags_t flag;
const char *name;
} aclflag2name[] = {
{ ZFSACL_AUTO_INHERIT, "AUTO_INHERIT" },
{ ZFSACL_PROTECTED, "PROTECTED" },
{ ZFSACL_DEFAULTED, "DEFAULTED" },
{ ZFSACL_IS_TRIVIAL, "ACL_IS_TRIVIAL" },
{ ZFSACL_IS_DIR, "IS_DIRECTORY" },
};

static const struct {
zfsace_permset_t perm;
const char *name;
char letter;
} aceperm2name[] = {
{ ZFSACE_READ_DATA, "READ_DATA", 'r' },
{ ZFSACE_LIST_DIRECTORY, "LIST_DIRECTORY", '\0' },
{ ZFSACE_WRITE_DATA, "WRITE_DATA", 'w' },
{ ZFSACE_ADD_FILE, "ADD_FILE", '\0' },
{ ZFSACE_APPEND_DATA, "APPEND_DATA", 'p' },
{ ZFSACE_DELETE, "DELETE", 'd' },
{ ZFSACE_DELETE_CHILD, "DELETE_CHILD", 'D' },
{ ZFSACE_ADD_SUBDIRECTORY, "ADD_SUBDIRECTORY", '\0' },
{ ZFSACE_READ_ATTRIBUTES, "READ_ATTRIBUTES", 'a' },
{ ZFSACE_WRITE_ATTRIBUTES, "WRITE_ATTRIBUTES", 'A' },
{ ZFSACE_READ_NAMED_ATTRS, "READ_NAMED_ATTRS", 'R' },
{ ZFSACE_WRITE_NAMED_ATTRS, "WRITE_NAMED_ATTRS", 'W' },
{ ZFSACE_READ_ACL, "READ_ACL", 'c' },
{ ZFSACE_WRITE_ACL, "WRITE_ACL", 'C' },
{ ZFSACE_WRITE_OWNER, "WRITE_OWNER", 'o' },
{ ZFSACE_SYNCHRONIZE, "SYNCHRONIZE", 's' },
};

static const struct {
zfsace_flagset_t flag;
const char *name;
char letter;
} aceflag2name[] = {
{ ZFSACE_FILE_INHERIT, "FILE_INHERIT", 'f' },
{ ZFSACE_DIRECTORY_INHERIT, "DIRECTORY_INHERIT", 'd' },
{ ZFSACE_INHERIT_ONLY, "INHERIT_ONLY", 'i' },
{ ZFSACE_NO_PROPAGATE_INHERIT, "NO_PROPAGATE_INHERIT", 'n' },
{ ZFSACE_INHERITED_ACE, "INHERITED", 'I' },
};

static const struct {
zfsace_who_t who;
const char *name;
} acewho2name[] = {
{ ZFSACL_UNDEFINED_TAG, "UNDEFINED" },
{ ZFSACL_USER_OBJ, "USER_OBJ" },
{ ZFSACL_GROUP_OBJ, "GROUP_OBJ" },
{ ZFSACL_EVERYONE, "EVERYONE" },
{ ZFSACL_USER, "USER" },
{ ZFSACL_GROUP, "GROUP" },
{ ZFSACL_OTHER, "OTHER" },
{ ZFSACL_MASK, "MASK" },
};

#endif /* __ZFSACL_H__ */
Loading

0 comments on commit cca7c87

Please sign in to comment.