From: Evan Broder Date: Thu, 19 Nov 2009 07:51:51 +0000 (-0500) Subject: Add a simple afs._fs module that exposes a whichcell function, and an X-Git-Tag: 0.1.0~10 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/python-afs.git/commitdiff_plain/f95acfabee62680cab0d953596cc7539585caff8?ds=sidebyside Add a simple afs._fs module that exposes a whichcell function, and an afs.fs module that simply exports the same whichcell function. Signed-off-by: Evan Broder --- diff --git a/.gitignore b/.gitignore index 4fd72a5..93a4719 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ afs/_pts.c afs/_pts.dep afs/_acl.c afs/_acl.dep +afs/_fs.c +afs/_fs.dep *.so build diff --git a/afs/_fs.pyx b/afs/_fs.pyx new file mode 100644 index 0000000..75653e2 --- /dev/null +++ b/afs/_fs.pyx @@ -0,0 +1,9 @@ +from afs cimport * +from afs import pyafs_error + +def whichcell(char* path): + """Determine which AFS cell a particular path is in.""" + cdef char cell[MAXCELLCHARS] + + pioctl_read(path, VIOC_FILE_CELL_NAME, cell, sizeof(cell), 1) + return cell diff --git a/afs/afs.pxd b/afs/afs.pxd index 2b02338..b5180f5 100644 --- a/afs/afs.pxd +++ b/afs/afs.pxd @@ -158,7 +158,7 @@ cdef extern from "afs/vice.h": cdef import from "afs/venus.h": enum: # PIOCTLS to Venus that we use - VIOCGETAL, VIOC_GETVCXSTATUS2, VIOCSETAL + VIOCGETAL, VIOC_GETVCXSTATUS2, VIOCSETAL, VIOC_FILE_CELL_NAME # pioctl doesn't actually have a header, so we have to define it here cdef extern int pioctl(char *, afs_int32, ViceIoctl *, afs_int32) diff --git a/afs/fs.py b/afs/fs.py new file mode 100644 index 0000000..0044c05 --- /dev/null +++ b/afs/fs.py @@ -0,0 +1,2 @@ +import _fs +from _fs import whichcell diff --git a/setup.py b/setup.py index 3e593e3..2a92096 100755 --- a/setup.py +++ b/setup.py @@ -45,8 +45,9 @@ setup( packages=['afs', 'afs.tests'], ext_modules=[ PyAFSExtension("afs.afs"), - PyAFSExtension("afs._pts", libraries=['krb5']), PyAFSExtension("afs._acl"), + PyAFSExtension("afs._fs"), + PyAFSExtension("afs._pts", libraries=['krb5']), ], cmdclass= {"build_ext": build_ext} )