Mark _init as global in pyafs_error
[invirt/packages/python-afs.git] / afs / _acl.pyx
1 from afs._util cimport *
2 from afs._util import pyafs_error
3
4 cdef extern from "afs/prs_fs.h":
5     enum:
6         PRSFS_READ, PRSFS_WRITE, PRSFS_INSERT, PRSFS_LOOKUP,
7         PRSFS_DELETE, PRSFS_LOCK, PRSFS_ADMINISTER,
8         PRSFS_USR0, PRSFS_USR1, PRSFS_USR2, PRSFS_USR2, PRSFS_USR3,
9         PRSFS_USR4, PRSFS_USR5, PRSFS_USR6, PRSFS_USR7
10
11 # This is defined in afs/afs.h, but I can't figure how to include the
12 # header. Also, venus/fs.c redefines the struct, so why not!
13 cdef struct vcxstat2:
14     afs_int32 callerAccess
15     afs_int32 cbExpires
16     afs_int32 anyAccess
17     char mvstat
18
19 READ = PRSFS_READ
20 WRITE = PRSFS_WRITE
21 INSERT = PRSFS_INSERT
22 LOOKUP = PRSFS_LOOKUP
23 DELETE = PRSFS_DELETE
24 LOCK = PRSFS_LOCK
25 ADMINISTER = PRSFS_ADMINISTER
26 USR0 = PRSFS_USR0
27 USR1 = PRSFS_USR1
28 USR2 = PRSFS_USR2
29 USR3 = PRSFS_USR3
30 USR4 = PRSFS_USR4
31 USR5 = PRSFS_USR5
32 USR6 = PRSFS_USR6
33 USR7 = PRSFS_USR7
34
35 DEF MAXSIZE = 2048
36
37 def getAcl(char* dir, int follow=1):
38     cdef char space[MAXSIZE]
39     pioctl_read(dir, VIOCGETAL, space, MAXSIZE, follow)
40     return space
41
42 def getCallerAccess(char *dir, int follow=1):
43     cdef vcxstat2 stat
44     pioctl_read(dir, VIOC_GETVCXSTATUS2, <void*>&stat, sizeof(vcxstat2), follow)
45     return stat.callerAccess
46
47 def setAcl(char* dir, char* acl, int follow=1):
48     pioctl_write(dir, VIOCSETAL, acl, follow)