Browse Source

tdb: support tdb_check() on r/o databases.

(Imported from SAMBA commit bc1c82ea137e1bf6cb55139a666c56ebb2226b23)

Author: Jeremy Allison <jra@samba.org>
Date:   Wed Jul 28 05:15:40 2010 -0700

Fix tdb_check() to work with read-only tdb databases. The function tdb_lockall() uses F_WRLCK internally, which doesn't work on a fd opened with O_RDONLY. Use tdb_lockall_read() instead.
    
Jeremy.
Rusty Russell 15 years ago
parent
commit
550246bb45
1 changed files with 3 additions and 3 deletions
  1. 3 3
      ccan/tdb/check.c

+ 3 - 3
ccan/tdb/check.c

@@ -328,7 +328,7 @@ int tdb_check(struct tdb_context *tdb,
 	bool found_recovery = false;
 	bool found_recovery = false;
 	tdb_len_t dead;
 	tdb_len_t dead;
 
 
-	if (tdb_lockall(tdb) == -1)
+	if (tdb_lockall_read(tdb) == -1)
 		return -1;
 		return -1;
 
 
 	/* Make sure we know true size of the underlying file. */
 	/* Make sure we know true size of the underlying file. */
@@ -444,12 +444,12 @@ int tdb_check(struct tdb_context *tdb,
 	}
 	}
 
 
 	free(hashes);
 	free(hashes);
-	tdb_unlockall(tdb);
+	tdb_unlockall_read(tdb);
 	return 0;
 	return 0;
 
 
 free:
 free:
 	free(hashes);
 	free(hashes);
 unlock:
 unlock:
-	tdb_unlockall(tdb);
+	tdb_unlockall_read(tdb);
 	return -1;
 	return -1;
 }
 }