author | Alberto Bertogli
<albertito@blitiri.com.ar> 2009-02-25 06:07:09 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2009-02-25 07:48:23 UTC |
parent | 97c8dc5e4894dad4ca71073bf33aed5044d3e5e3 |
UPGRADING | +5 | -0 |
bindings/python/libjio.c | +7 | -3 |
doc/libjio.3 | +6 | -4 |
libjio.h | +3 | -3 |
diff --git a/UPGRADING b/UPGRADING index 87d6465..452594b 100644 --- a/UPGRADING +++ b/UPGRADING @@ -11,6 +11,11 @@ take much. If it's mandatory, it will be noted. If you want to see what motivated the changes, see the changelog or just ask. +0.22 -> 0.23 +* The return values of jfsck() have changed, so applications using it need to + be recompiled. The Python version now raises IOError on failures, and + no longer returns None. + 0.21 -> 0.22 * Applications need to be recompiled due to a change in the jfs structure. diff --git a/bindings/python/libjio.c b/bindings/python/libjio.c index ef0b171..7dc2a9f 100644 --- a/bindings/python/libjio.c +++ b/bindings/python/libjio.c @@ -545,8 +545,9 @@ PyDoc_STRVAR(jf_jfsck__doc, \n\ Checks the integrity of the file with the given name, using (optionally) jdir\n\ as the journal directory; returns a dictionary with all the different values\n\ -of the check (equivalent to the 'struct jfsck_result'), or None if there was\n\ -nothing to check.\n\ +of the check (equivalent to the 'struct jfsck_result'). If the path is\n\ +incorrect, or there is no journal associated with it, an IOError will be\n\ +raised.\n\ It's a wrapper to jfsck().\n"); static PyObject *jf_jfsck(PyObject *self, PyObject *args) @@ -568,9 +569,12 @@ static PyObject *jf_jfsck(PyObject *self, PyObject *args) Py_END_ALLOW_THREADS if (rv == J_ENOMEM) { + Py_XDECREF(dict); return PyErr_NoMemory(); } else if (rv != 0) { - return Py_None; + Py_XDECREF(dict); + PyErr_SetObject(PyExc_IOError, PyInt_FromLong(rv)); + return NULL; } PyDict_SetItemString(dict, "total", PyLong_FromLong(res.total)); diff --git a/doc/libjio.3 b/doc/libjio.3 index 7a86a37..76b2e1e 100644 --- a/doc/libjio.3 +++ b/doc/libjio.3 @@ -36,7 +36,7 @@ libjio - A library for Journaled I/O .BI "int jfsck(const char *" name ", struct jfsck_result *" res " ); -.BI "int jfsck_cleanup(const char *" name" );" +.BI "int jfsck_cleanup(const char *" name" ); .SH STRUCTURES .PP @@ -121,9 +121,11 @@ jfsck_cleanup(). The first one, jfsck(), is used to perform journal checking and recovery in case of a crash. It must be performed when nobody else is using the file (like in the case of a filesystem which can't be mounted), and it returns 0 if -success or -1 in case of a failure. If it succeed, a structure jfsck_result -that summarizes the outcome of the operation. There is also a program named -jiofsck which is just a simple human frontend to this function. +success or an error code != 0 in case of a failure. If it succeeded, it will +fill jfsck_result summarizing the outcome of the operation. The error codes +can be either J_ENOENT (no such file), J_ENOJOURNAL (no journal associated +with that file) or J_ENOMEM (not enough free memory). There is also a program +named jiofsck which is just a simple human frontend to this function. The second, jfsck_cleanup(), is intended to be used after jfsck() by programs wanting to remove all the stall transaction files and leave the journal diff --git a/libjio.h b/libjio.h index c48b47d..39be877 100644 --- a/libjio.h +++ b/libjio.h @@ -161,9 +161,9 @@ FILE *jfsopen(struct jfs *stream, const char *mode); /* jfsck constants (return values) */ #define J_ESUCCESS 0 /* success - shouldn't be used */ -#define J_ENOENT 1 /* no such file */ -#define J_ENOJOURNAL 2 /* no journal associated */ -#define J_ENOMEM 3 /* no enough free memory */ +#define J_ENOENT -1 /* no such file */ +#define J_ENOJOURNAL -2 /* no journal associated */ +#define J_ENOMEM -3 /* no enough free memory */ #ifdef __cplusplus