tdb: Fix tdb_check() to work with read-only tdb databases.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 16 Aug 2010 00:43:32 +0000 (10:13 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 16 Aug 2010 00:50:59 +0000 (10:20 +0930)
(Import from SAMBA bc1c82ea137e1bf6cb55139a666c56ebb2226b23)
The function tdb_lockall() uses F_WRLCK internally, which doesn't work on
a fd opened with O_RDONLY. Use tdb_lockall_read() instead.

lib/tdb/common/check.c

index 6bbfd7d82aceecc4114395a2d61619e373525f2e..2c640434ee42360dd573f6706b134b55b26d340f 100644 (file)
@@ -311,7 +311,7 @@ int tdb_check(struct tdb_context *tdb,
        struct tdb_record rec;
        bool found_recovery = false;
 
-       if (tdb_lockall(tdb) == -1)
+       if (tdb_lockall_read(tdb) == -1)
                return -1;
 
        /* Make sure we know true size of the underlying file. */
@@ -412,12 +412,12 @@ int tdb_check(struct tdb_context *tdb,
        }
 
        free(hashes);
-       tdb_unlockall(tdb);
+       tdb_unlockall_read(tdb);
        return 0;
 
 free:
        free(hashes);
 unlock:
-       tdb_unlockall(tdb);
+       tdb_unlockall_read(tdb);
        return -1;
 }