s3/doc: document the ignore system acls option of vfs_acl_xattr and vfs_acl_tdb
[Samba/gebeck_regimport.git] / lib / tdb2 / test / run-tdb1-readonly-check.c
blobf42a8f5e27464d2870fc0d385e38c66e9399d470
1 /* We should be able to tdb_check a O_RDONLY tdb, and we were previously allowed
2 * to tdb_check() inside a transaction (though that's paranoia!). */
3 #include "tdb2-source.h"
4 #include <ccan/tap/tap.h>
5 #include <stdlib.h>
6 #include <err.h>
7 #include "logging.h"
9 int main(int argc, char *argv[])
11 struct tdb_context *tdb;
12 TDB_DATA key, data;
13 union tdb_attribute hsize;
15 hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
16 hsize.base.next = &tap_log_attr;
17 hsize.tdb1_hashsize.hsize = 1024;
19 plan_tests(10);
20 tdb = tdb_open("run-readonly-check.tdb1",
21 TDB_VERSION1,
22 O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
24 ok1(tdb);
25 key.dsize = strlen("hi");
26 key.dptr = (void *)"hi";
27 data.dsize = strlen("world");
28 data.dptr = (void *)"world";
30 ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
31 ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);
33 /* We are also allowed to do a check inside a transaction. */
34 ok1(tdb_transaction_start(tdb) == TDB_SUCCESS);
35 ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);
36 ok1(tdb_close(tdb) == 0);
38 tdb = tdb_open("run-readonly-check.tdb1",
39 TDB_DEFAULT, O_RDONLY, 0, &tap_log_attr);
41 ok1(tdb);
42 ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_RDONLY);
43 ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS);
44 ok1(tdb_close(tdb) == 0);
46 return exit_status();