Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sec_posixacl.h « local_includes « cygwin « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0f9e7bde3e6f9118ac32dd3ff3c6ea8acad1ff32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* sec_posixacl.h: Internal definitions for POSIX ACLs.

This file is part of Cygwin.

This software is a copyrighted work licensed under the terms of the
Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
details. */

#include <cygwin/acl.h>
#include <sys/acl.h>
#include <acl/libacl.h>

/* Magic marker for acl_t. */
#define ACL_MAGIC		(0xacdccdcadcaccacdULL)

/* Only used internally as a_type for deleted entries. */
#define ACL_DELETED_TAG		(0xffff)

/* Only used internally from acl_to_text/acl_to_any_text. */
#define TEXT_END_SEPARATOR	(0x1000)
#define TEXT_IS_POSIX		(0x2000)

/* Internal ACL representation. */
struct __acl_t
{
  uint64_t magic;	/* Must be ACL_MAGIC.				*/
  uint16_t max_count;	/* Max. number of entries.			*/
  uint16_t count;	/* Number of used entries.			*/
  uint16_t deleted;	/* Number of used but deleted entries.		*/
  uint16_t next;	/* Next entry to be returned by acl_get_entry.	*/
  aclent_t *entry;	/* Pointer to variable array of ACL entries.	*/
};

inline acl_entry_t
__to_entry (acl_t acl, uint16_t idx)
{
  return ((uint64_t) idx << 48) | (uint64_t) ((uintptr_t) acl);
}
#define __to_permset(a,i)	((acl_permset_t)__to_entry((a),(i)))

inline acl_t
__from_entry (acl_entry_t entry_d, uint16_t &idx)
{
  idx = entry_d >> 48;
  acl_t acl = (acl_t) (entry_d & ~((uint64_t) 0xffff << 48));
  if (acl->magic != ACL_MAGIC)
    return NULL;
  if (idx >= acl->count)
    return NULL;
  if (acl->entry[idx].a_type == ACL_DELETED_TAG)
    return NULL;
  return acl;
}
#define __from_permset(p,i)	__from_entry((acl_permset_t)(p),(i))

/* External (but opaque) ACL representation. */
struct __acl_ext_t
{
  uint16_t count;	/* Number of used entries.			*/
  aclent_t entry[0];	/* Variable array of ACL entries.		*/
};

/* Shared functions defined in sec_acl.cc. */
mode_t __aclcalcmask (aclent_t *, int);
int __aclsort (int, aclent_t *);
int __aclcheck (aclent_t *, int, int *, bool);
char *__acltotext (aclent_t *, int, const char *, char, int);
void *__aclfromtext (const char *, int *, bool);