From b47edad6731dd3bda288e6cbe4c7420496b3e6e2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 8 Nov 2011 08:34:38 +0100 Subject: s4:torture:smb2: extract map_sharemode() to smb2_util_share_access() in util.c --- source4/torture/smb2/durable_open.c | 26 ++------------------------ source4/torture/smb2/util.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 24 deletions(-) (limited to 'source4') diff --git a/source4/torture/smb2/durable_open.c b/source4/torture/smb2/durable_open.c index 19b9e1d88a..1f2aeae877 100644 --- a/source4/torture/smb2/durable_open.c +++ b/source4/torture/smb2/durable_open.c @@ -50,28 +50,6 @@ } while(0) -static inline uint32_t map_sharemode(const char *sharemode) -{ - uint32_t val = NTCREATEX_SHARE_ACCESS_NONE; /* 0 */ - int i; - - for (i = 0; i < strlen(sharemode); i++) { - switch(sharemode[i]) { - case 'R': - val |= NTCREATEX_SHARE_ACCESS_READ; - break; - case 'W': - val |= NTCREATEX_SHARE_ACCESS_WRITE; - break; - case 'D': - val |= NTCREATEX_SHARE_ACCESS_DELETE; - break; - } - } - - return val; -} - /** * basic durable_open test. * durable state should only be granted when requested @@ -143,7 +121,7 @@ static bool test_one_durable_open_open1(struct torture_context *tctx, smb2_util_unlink(tree, fname); io.in.fname = fname; - io.in.share_access = map_sharemode(test.share_mode); + io.in.share_access = smb2_util_share_access(test.share_mode); io.in.oplock_level = test.level; status = smb2_create(tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); @@ -294,7 +272,7 @@ static bool test_one_durable_open_open2(struct torture_context *tctx, smb2_util_unlink(tree, fname); io.in.fname = fname; - io.in.share_access = map_sharemode(test.share_mode); + io.in.share_access = smb2_util_share_access(test.share_mode); io.in.oplock_level = SMB2_OPLOCK_LEVEL_LEASE; lease = random(); diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 49ffccda14..5be96b3167 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -521,3 +521,26 @@ uint32_t smb2_util_lease_state(const char *ls) return val; } + +uint32_t smb2_util_share_access(const char *sharemode) +{ + uint32_t val = NTCREATEX_SHARE_ACCESS_NONE; /* 0 */ + int i; + + for (i = 0; i < strlen(sharemode); i++) { + switch(sharemode[i]) { + case 'R': + val |= NTCREATEX_SHARE_ACCESS_READ; + break; + case 'W': + val |= NTCREATEX_SHARE_ACCESS_WRITE; + break; + case 'D': + val |= NTCREATEX_SHARE_ACCESS_DELETE; + break; + } + } + + return val; +} + -- cgit