python/sanlock.py | 3 ++-
python/sanlockmod.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
New commits:
commit 2d7486c2f669543f10f53f09d315e43b81ba68fc
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Tue Jun 7 09:55:20 2011 -0400
python: add get_alignment function
diff --git a/python/sanlock.py b/python/sanlock.py
index 87e33b3..0909cc8 100644
--- a/python/sanlock.py
+++ b/python/sanlock.py
@@ -8,7 +8,8 @@ import sys
import sanlockmod
SANLOCK_FUNCTIONS = (
- 'register', 'add_lockspace', 'rem_lockspace',
'acquire', 'release'
+ 'register', 'add_lockspace', 'rem_lockspace',
'acquire', 'release',
+ 'get_alignment'
)
SanlockException = sanlockmod.exception
diff --git a/python/sanlockmod.c b/python/sanlockmod.c
index a042030..7e5f2af 100644
--- a/python/sanlockmod.c
+++ b/python/sanlockmod.c
@@ -287,6 +287,34 @@ exit_fail:
return NULL;
}
+static PyObject *
+py_get_alignment(PyObject *self, PyObject *args)
+{
+ int rv;
+ char *path;
+ struct sanlk_disk disk;
+
+ /* parse python tuple */
+ if (!PyArg_ParseTuple(args, "s", &path)) {
+ return NULL;
+ }
+
+ memset(&disk, 0, sizeof(struct sanlk_disk));
+ strncpy(disk.path, path, SANLK_PATH_LEN - 1);
+
+ /* get device alignment (gil disabled) */
+ Py_BEGIN_ALLOW_THREADS
+ rv = sanlock_direct_align(&disk);
+ Py_END_ALLOW_THREADS
+
+ if (rv < 0) {
+ __set_exception(SKERRNO(rv), "Unable to get device alignment");
+ return NULL;
+ }
+
+ return PyInt_FromLong(rv);
+}
+
static PyMethodDef
sanlockmod_methods[] = {
{"register", py_register, METH_NOARGS, "Register to SANLock
daemon."},
@@ -302,6 +330,8 @@ sanlockmod_methods[] = {
"Acquire a resource lease for the current process."},
{"release", py_release, METH_VARARGS,
"Release a resource lease for the current process."},
+ {"get_alignment", py_get_alignment, METH_VARARGS,
+ "Get device alignment."},
{NULL, NULL, 0, NULL}
};
Show replies by date