diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-04-02 07:06:49 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:49:41 -0500 |
commit | 15ceca1956620711a062631e8cc0fed391edd4d2 (patch) | |
tree | 0e5a1e8226e3ab33b9b3246d409b87ea14b379a3 | |
parent | f00f7a34a9affde0c179f73c5a07d732fe22499c (diff) | |
download | samba-15ceca1956620711a062631e8cc0fed391edd4d2.tar.gz samba-15ceca1956620711a062631e8cc0fed391edd4d2.tar.bz2 samba-15ceca1956620711a062631e8cc0fed391edd4d2.zip |
r22025: patch from Ronnie to make locktest also test the behaviour of pid
changes in the locks
(This used to be commit 369b185f291f73e4e92481952781c13d59c068fd)
-rw-r--r-- | source4/torture/locktest.c | 66 |
1 files changed, 60 insertions, 6 deletions
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c index 608974ec65..636cb598d4 100644 --- a/source4/torture/locktest.c +++ b/source4/torture/locktest.c @@ -58,6 +58,7 @@ struct record { char conn, f; uint64_t start, len; char needed; + uint16_t pid; }; #define PRESETS 0 @@ -208,9 +209,35 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], case OP_LOCK: /* set a lock */ for (server=0;server<NSERVERS;server++) { - ret[server] = NT_STATUS_IS_OK(smbcli_lock64(cli[server][conn]->tree, - fnum[server][conn][f], - start, len, LOCK_TIMEOUT, op)); + NTSTATUS res; + struct smbcli_tree *tree=cli[server][conn]->tree; + int fn=fnum[server][conn][f]; + + if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) { + res=smbcli_lock(tree, fn, start, len, LOCK_TIMEOUT, rec->lock_op); + } else { + union smb_lock parms; + int ltype; + struct smb_lock_entry lock[1]; + + parms.lockx.level = RAW_LOCK_LOCKX; + parms.lockx.in.file.fnum = fn; + + ltype = (rec->lock_op == READ_LOCK? 1 : 0); + ltype |= LOCKING_ANDX_LARGE_FILES; + parms.lockx.in.mode = ltype; + parms.lockx.in.timeout = LOCK_TIMEOUT; + parms.lockx.in.ulock_cnt = 0; + parms.lockx.in.lock_cnt = 1; + lock[0].pid = rec->pid; + lock[0].offset = start; + lock[0].count = len; + parms.lockx.in.locks = &lock[0]; + + res = smb_raw_lock(tree, &parms); + } + + ret[server] = NT_STATUS_IS_OK(res); status[server] = smbcli_nt_error(cli[server][conn]->tree); if (!exact_error_codes && NT_STATUS_EQUAL(status[server], @@ -231,9 +258,32 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], case OP_UNLOCK: /* unset a lock */ for (server=0;server<NSERVERS;server++) { - ret[server] = NT_STATUS_IS_OK(smbcli_unlock64(cli[server][conn]->tree, - fnum[server][conn][f], - start, len)); + NTSTATUS res; + struct smbcli_tree *tree=cli[server][conn]->tree; + int fn=fnum[server][conn][f]; + + + if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) { + res=smbcli_unlock(tree, fn, start, len); + } else { + union smb_lock parms; + struct smb_lock_entry lock[1]; + + parms.lockx.level = RAW_LOCK_LOCKX; + parms.lockx.in.file.fnum = fn; + parms.lockx.in.mode = LOCKING_ANDX_LARGE_FILES; + parms.lockx.in.timeout = 0; + parms.lockx.in.ulock_cnt = 1; + parms.lockx.in.lock_cnt = 0; + lock[0].pid = rec->pid; + lock[0].count = len; + lock[0].offset = start; + parms.lockx.in.locks = &lock[0]; + + res = smb_raw_lock(tree, &parms); + } + + ret[server] = NT_STATUS_IS_OK(res); status[server] = smbcli_nt_error(cli[server][conn]->tree); } if (showall || @@ -358,6 +408,10 @@ static void test_locks(char *share[NSERVERS]) random() % (lock_range-(recorded[n].start-lock_base)); recorded[n].start *= RANGE_MULTIPLE; recorded[n].len *= RANGE_MULTIPLE; + recorded[n].pid = random()%3; + if (recorded[n].pid == 2) { + recorded[n].pid = 0xFFFF; /* see if its magic */ + } r1 = random() % 100; r2 = random() % 100; if (r1 < READ_PCT) { |