diff options
Diffstat (limited to 'source4/torture/raw/oplock.c')
-rw-r--r-- | source4/torture/raw/oplock.c | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 7a921af422..1f44f96b44 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -29,14 +29,14 @@ if ((v) != (correct)) { \ torture_comment(tctx, "(%s): wrong value for %s got 0x%x - should be 0x%x\n", \ __location__, #v, (int)v, (int)correct); \ - ret = False; \ + ret = false; \ }} while (0) #define CHECK_STATUS(tctx, status, correct) do { \ if (!NT_STATUS_EQUAL(status, correct)) { \ torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \ nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -53,10 +53,11 @@ static struct { /* a handler function for oplock break requests. Ack it as a break to level II if possible */ -static BOOL oplock_handler_ack_to_levelII(struct smbcli_transport *transport, uint16_t tid, - uint16_t fnum, uint8_t level, void *private) +static bool oplock_handler_ack_to_levelII(struct smbcli_transport *transport, + uint16_t tid, uint16_t fnum, + uint8_t level, void *private) { - struct smbcli_tree *tree = private; + struct smbcli_tree *tree = (struct smbcli_tree *)private; break_info.fnum = fnum; break_info.level = level; break_info.count++; @@ -69,11 +70,11 @@ static BOOL oplock_handler_ack_to_levelII(struct smbcli_transport *transport, ui /* a handler function for oplock break requests. Ack it as a break to none */ -static BOOL oplock_handler_ack_to_none(struct smbcli_transport *transport, uint16_t tid, - uint16_t fnum, uint8_t level, - void *private) +static bool oplock_handler_ack_to_none(struct smbcli_transport *transport, + uint16_t tid, uint16_t fnum, + uint8_t level, void *private) { - struct smbcli_tree *tree = private; + struct smbcli_tree *tree = (struct smbcli_tree *)private; break_info.fnum = fnum; break_info.level = level; break_info.count++; @@ -96,11 +97,11 @@ static void oplock_handler_close_recv(struct smbcli_request *req) /* a handler function for oplock break requests - close the file */ -static BOOL oplock_handler_close(struct smbcli_transport *transport, uint16_t tid, +static bool oplock_handler_close(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private) { union smb_close io; - struct smbcli_tree *tree = private; + struct smbcli_tree *tree = (struct smbcli_tree *)private; struct smbcli_request *req; break_info.fnum = fnum; @@ -113,13 +114,13 @@ static BOOL oplock_handler_close(struct smbcli_transport *transport, uint16_t ti req = smb_raw_close_send(tree, &io); if (req == NULL) { printf("failed to send close in oplock_handler_close\n"); - return False; + return false; } req->async.fn = oplock_handler_close_recv; req->async.private = NULL; - return True; + return true; } static bool test_raw_oplock_normal(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) @@ -1308,10 +1309,10 @@ struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx) /* stress testing of oplocks */ -BOOL torture_bench_oplock(struct torture_context *torture) +bool torture_bench_oplock(struct torture_context *torture) { struct smbcli_state **cli; - BOOL ret = True; + bool ret = true; TALLOC_CTX *mem_ctx = talloc_new(torture); int torture_nprocs = torture_setting_int(torture, "nprocs", 4); int i, count=0; @@ -1325,7 +1326,7 @@ BOOL torture_bench_oplock(struct torture_context *torture) torture_comment(torture, "Opening %d connections\n", torture_nprocs); for (i=0;i<torture_nprocs;i++) { if (!torture_open_connection_ev(&cli[i], i, ev)) { - return False; + return false; } talloc_steal(mem_ctx, cli[i]); smbcli_oplock_handler(cli[i]->transport, oplock_handler_close, @@ -1333,7 +1334,7 @@ BOOL torture_bench_oplock(struct torture_context *torture) } if (!torture_setup_dir(cli[0], BASEDIR)) { - ret = False; + ret = false; goto done; } @@ -1396,20 +1397,21 @@ static struct hold_oplock_info { uint32_t share_access; uint16_t fnum; } hold_info[] = { - { BASEDIR "\\notshared_close", True, + { BASEDIR "\\notshared_close", true, NTCREATEX_SHARE_ACCESS_NONE, }, - { BASEDIR "\\notshared_noclose", False, + { BASEDIR "\\notshared_noclose", false, NTCREATEX_SHARE_ACCESS_NONE, }, - { BASEDIR "\\shared_close", True, + { BASEDIR "\\shared_close", true, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, }, - { BASEDIR "\\shared_noclose", False, + { BASEDIR "\\shared_noclose", false, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, }, }; -static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid, - uint16_t fnum, uint8_t level, void *private) +static bool oplock_handler_hold(struct smbcli_transport *transport, + uint16_t tid, uint16_t fnum, uint8_t level, + void *private) { - struct smbcli_tree *tree = private; + struct smbcli_tree *tree = (struct smbcli_tree *)private; struct hold_oplock_info *info; int i; @@ -1419,7 +1421,7 @@ static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid if (i == ARRAY_SIZE(hold_info)) { printf("oplock break for unknown fnum %u\n", fnum); - return False; + return false; } info = &hold_info[i]; @@ -1428,7 +1430,7 @@ static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid printf("oplock break on %s - closing\n", info->fname); oplock_handler_close(transport, tid, fnum, level, private); - return True; + return true; } printf("oplock break on %s - acking break\n", info->fname); @@ -1441,16 +1443,17 @@ static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid used for manual testing of oplocks - especially interaction with other filesystems (such as NFS and local access) */ -BOOL torture_hold_oplock(struct torture_context *torture, +bool torture_hold_oplock(struct torture_context *torture, struct smbcli_state *cli) { - struct event_context *ev = cli->transport->socket->event.ctx; + struct event_context *ev = + (struct event_context *)cli->transport->socket->event.ctx; int i; printf("Setting up open files with oplocks in %s\n", BASEDIR); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } smbcli_oplock_handler(cli->transport, oplock_handler_hold, cli->tree); @@ -1480,14 +1483,14 @@ BOOL torture_hold_oplock(struct torture_context *torture, if (!NT_STATUS_IS_OK(status)) { printf("Failed to open %s - %s\n", hold_info[i].fname, nt_errstr(status)); - return False; + return false; } if (io.ntcreatex.out.oplock_level != BATCH_OPLOCK_RETURN) { printf("Oplock not granted for %s - expected %d but got %d\n", hold_info[i].fname, BATCH_OPLOCK_RETURN, io.ntcreatex.out.oplock_level); - return False; + return false; } hold_info[i].fnum = io.ntcreatex.out.file.fnum; } @@ -1495,5 +1498,5 @@ BOOL torture_hold_oplock(struct torture_context *torture, printf("Waiting for oplock events\n"); event_loop_wait(ev); - return True; + return true; } |