Add a simple afs._fs module that exposes a whichcell function, and an
authorEvan Broder <broder@mit.edu>
Thu, 19 Nov 2009 07:51:51 +0000 (02:51 -0500)
committerEvan Broder <broder@mit.edu>
Thu, 19 Nov 2009 07:55:55 +0000 (02:55 -0500)
afs.fs module that simply exports the same whichcell function.

Signed-off-by: Evan Broder <broder@mit.edu>

.gitignore
afs/_fs.pyx [new file with mode: 0644]
afs/afs.pxd
afs/fs.py [new file with mode: 0644]
setup.py

index 4fd72a5..93a4719 100644 (file)
@@ -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 (file)
index 0000000..75653e2
--- /dev/null
@@ -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
index 2b02338..b5180f5 100644 (file)
@@ -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 (file)
index 0000000..0044c05
--- /dev/null
+++ b/afs/fs.py
@@ -0,0 +1,2 @@
+import _fs
+from _fs import whichcell
index 3e593e3..2a92096 100755 (executable)
--- 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}
 )