git » libjio » commit 1aefbaf

[API BREAK] Make jfsck() do not call jfsck_cleanup() by default

author Alberto Bertogli
2009-08-02 00:45:47 UTC
committer Alberto Bertogli
2009-08-02 01:16:44 UTC
parent a861705c94df826bfb98458511ac221fd708fb54

[API BREAK] Make jfsck() do not call jfsck_cleanup() by default

J_NOCLEANUP was removed in favour of J_CLEANUP, and the default behaviour
of jfsck() is now not to clean up unless J_CLEANUP is passed in the flags.

This also fixes the UPGRADING document which had a wrong version number
for the recent changes.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

UPGRADING +3 -1
bindings/python/libjio.c +3 -0
libjio/check.c +2 -2
libjio/jiofsck.c +2 -2
libjio/libjio.3 +2 -2
libjio/libjio.h +4 -4
tests/behaviour/tf.py +3 -3

diff --git a/UPGRADING b/UPGRADING
index 18d69a9..884e8f8 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -6,12 +6,14 @@ You should always clean all your files before upgrading. While I don't expect
 the transaction on-disk format to change, it's a good practise and it doesn't
 take much effort. When it's mandatory, it will be noted.
 
--> 0.51
+-> 0.90 (On-disk format change, pre 1.0 freeze)
   - The way transactions are stored on disk has changed. It is mandatory that
     you jfsck all your files before upgrading. Hopefully this will be the last
     backwards-incompatible format change before 1.0.
   - jtrans_new() now takes an additional flags parameter.
   - jopen() jflags parameter is now unsigned.
+  - J_NOCLEANUP was removed in favour of J_CLEANUP, and the default behaviour
+    of jfsck() is now not to clean up unless J_CLEANUP is passed in the flags.
 
 -> 0.50 (Big API change)
   - Structures are now opaque types:
diff --git a/bindings/python/libjio.c b/bindings/python/libjio.c
index caf76ac..4e04366 100644
--- a/bindings/python/libjio.c
+++ b/bindings/python/libjio.c
@@ -885,6 +885,9 @@ static void populate_module(PyObject *m)
 	PyModule_AddIntConstant(m, "J_ECLEANUP", J_ECLEANUP);
 	PyModule_AddIntConstant(m, "J_EIO", J_EIO);
 
+	/* jfsck() flags */
+	PyModule_AddIntConstant(m, "J_CLEANUP", J_CLEANUP);
+
 	/* open constants (at least the POSIX ones) */
 	PyModule_AddIntConstant(m, "O_RDONLY", O_RDONLY);
 	PyModule_AddIntConstant(m, "O_WRONLY", O_WRONLY);
diff --git a/libjio/check.c b/libjio/check.c
index 73202be..f3e37e2 100644
--- a/libjio/check.c
+++ b/libjio/check.c
@@ -329,8 +329,8 @@ nounlink_loop:
 		res->total++;
 	}
 
-	if ( !(flags & J_NOCLEANUP) ) {
-		if (jfsck_cleanup(name, jdir) < 0) {
+	if (flags & J_CLEANUP) {
+		if (jfsck_cleanup(name, fs.jdir) < 0) {
 			ret = J_ECLEANUP;
 		}
 	}
diff --git a/libjio/jiofsck.c b/libjio/jiofsck.c
index 1508e9c..48fc084 100644
--- a/libjio/jiofsck.c
+++ b/libjio/jiofsck.c
@@ -59,8 +59,8 @@ int main(int argc, char **argv)
 	memset(&res, 0, sizeof(res));
 
 	flags = 0;
-	if (!do_cleanup)
-		flags |= J_NOCLEANUP;
+	if (do_cleanup)
+		flags |= J_CLEANUP;
 
 	printf("Checking journal: ");
 	fflush(stdout);
diff --git a/libjio/libjio.3 b/libjio/libjio.3
index 5fa6cd6..e0aa316 100644
--- a/libjio/libjio.3
+++ b/libjio/libjio.3
@@ -135,8 +135,8 @@ to the journal directory (usually NULL for the default, unless you've changed
 it manually using
 .BR jmove_journal() ),
 and optionally a flags parameter, which can be 0 for the default behaviour, or
-J_NOCLEANUP to indicate that the journal should not be cleaned up after
-successful recovery.
+J_CLEANUP to indicate that the journal should be cleaned up after successful
+recovery.
 
 It 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
diff --git a/libjio/libjio.h b/libjio/libjio.h
index a7c5250..0f2e4a3 100644
--- a/libjio/libjio.h
+++ b/libjio/libjio.h
@@ -263,8 +263,8 @@ int jfs_autosync_stop(jfs_t *fs);
  * @param jdir journal directory of the given file, use NULL for the default
  * @param res structure where to store the result
  * @param flags flags that change the checking behaviour, currently only
- *	J_NOCLEANUP is supported, which avoids cleaning up the journal
- *	directory after a successful recovery
+ *	J_CLEANUP is supported, which removes the journal directory after a
+ *	successful recovery
  * @see struct jfsck_result
  * @returns 0 on success, < 0 on error, with the following possible negative
  * 	values from enum jfsck_return: J_ENOENT if there was no such file with
@@ -462,11 +462,11 @@ FILE *jfsopen(jfs_t *stream, const char *mode);
  * jfsck() flags
  */
 
-/** Do not perform a journal cleanup. Used in jfsck().
+/** Perform a journal cleanup. Used in jfsck().
  *
  * @see jfsck()
  * @ingroup check */
-#define J_NOCLEANUP	1
+#define J_CLEANUP	1
 
 #endif
 
diff --git a/tests/behaviour/tf.py b/tests/behaviour/tf.py
index 9b0a189..2f3f55c 100644
--- a/tests/behaviour/tf.py
+++ b/tests/behaviour/tf.py
@@ -111,9 +111,9 @@ def transpath(path, ntrans):
 	jpath = jiodir(path)
 	return jpath + '/' + str(ntrans)
 
-def fsck(path):
+def fsck(path, flags = 0):
 	"Calls libjio's jfsck()."
-	res = libjio.jfsck(path)
+	res = libjio.jfsck(path, flags = flags)
 	return res
 
 def fsck_verify(n, **kwargs):
@@ -130,7 +130,7 @@ def fsck_verify(n, **kwargs):
 	}
 	expected.update(kwargs)
 	expected['total'] = sum(expected.values())
-	res = fsck(n)
+	res = fsck(n, flags = libjio.J_CLEANUP)
 
 	for k in expected:
 		if k not in res: