2 General PyAFS utilities, such as error handling
7 # otherwise certain headers are unhappy
8 cdef extern from "netinet/in.h": pass
9 cdef extern from "afs/vice.h": pass
13 # pioctl convenience wrappers
15 cdef extern int pioctl_read(char *dir, afs_int32 op, void *buffer, unsigned short size, afs_int32 follow) except -1:
21 code = pioctl(dir, op, &blob, follow)
22 # This might work with the rest of OpenAFS, but I'm not convinced
23 # the rest of it is consistent
25 raise OSError(errno, strerror(errno))
29 cdef extern int pioctl_write(char *dir, afs_int32 op, char *buffer, afs_int32 follow) except -1:
33 blob.in_size = 1 + strlen(buffer)
35 code = pioctl(dir, op, &blob, follow)
36 # This might work with the rest of OpenAFS, but I'm not convinced
37 # the rest of it is consistent
39 raise OSError(errno, strerror(errno))
45 class AFSException(Exception):
46 def __init__(self, errno):
48 self.strerror = afs_error_message(errno)
51 return "AFSException(%s)" % (self.errno)
54 return "[%s] %s" % (self.errno, self.strerror)
56 def pyafs_error(code):
58 initialize_ACFG_error_table()
59 initialize_KTC_error_table()
60 initialize_PT_error_table()
61 initialize_RXK_error_table()
62 initialize_U_error_table()
67 raise AFSException(code)