author | Alberto Bertogli
<albertito@blitiri.com.ar> 2009-09-24 23:45:28 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2009-09-24 23:45:28 UTC |
parent | 3e389f6cc617cb6e8dd2dc309ae566fd24709125 |
libjio/check.c | +11 | -0 |
diff --git a/libjio/check.c b/libjio/check.c index f3e37e2..4afb9e3 100644 --- a/libjio/check.c +++ b/libjio/check.c @@ -123,6 +123,17 @@ enum jfsck_return jfsck(const char *name, const char *jdir, fs.name = (char *) name; + /* Locking the whole file protect us from concurrent runs, but it's + * not to be trusted nor assumed (lingering transactions break it): it + * just helps prevent some accidents. */ + lr = plockf(fs.fd, F_LOCKW, 0, 0); + if (lr == -1) { + /* In the future, we may want to differentiate this case from + * a normal I/O error. */ + ret = J_EIO; + goto exit; + } + if (jdir == NULL) { fs.jdir = (char *) malloc(PATH_MAX); if (fs.jdir == NULL) {