I observed it while running the following modified torture test:
static BOOL run_locktest7(int dummy)
{
static struct cli_state cli1;
const char *fname = "\\lockt7.lck";
int fnum1;
BOOL ret;
char buf[200];
BOOL correct = True;
if (!torture_open_connection(&cli1)) {
return False;
}
cli_sockopt(&cli1, sockops);
printf("starting locktest7\n");
cli_unlink(&cli1, fname);
fnum1 = cli_open(&cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
memset(buf, 0, sizeof(buf));
if (cli_write(&cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
printf("Failed to create file\n");
correct = False;
goto fail;
}
cli_setpid(&cli1, 1);
if (!cli_lock(&cli1, fnum1, 130, 4, 0, READ_LOCK))
{
printf("Unable to apply read lock on range 130:4\n");
goto fail;
}
else
{
printf("pid1 successfully read locked range 130:4\n");
}
if (cli_read(&cli1, fnum1, buf, 130, 4) != 4)
{
printf("pid1 unable to read the range 130:4\n");
}
else
{
printf("pid1 successfully read the range 130:4\n");
}
if (cli_write(&cli1, fnum1, 0, buf, 130, 4) != 4)
{
printf("pid1 unable to write to the range 130:4\n");
}
else
{
printf("pid1 successfully wrote to the range 130:4\n");
}
cli_setpid(&cli1, 2);
if (cli_read(&cli1, fnum1, buf, 130, 4) != 4)
{
printf("pid2 unable to read the range 130:4\n");
}
else
{
printf("pid2 successfully read the range 130:4\n");
}
if (cli_write(&cli1, fnum1, 0, buf, 130, 4) != 4)
{
printf("pid2 unable to write to the range 130:4\n");
}
else
{
printf("pid2 successfully wrote to the range 130:4\n");
}
cli_setpid(&cli1, 1);
fail:
cli_close(&cli1, fnum1);
cli_unlink(&cli1, fname);
torture_close_connection(&cli1);
printf("finished locktest7\n");
return correct;
}
-----Original Message-----
From: jra@xxxxxxxxxxxx [mailto:jra@xxxxxxxxxxxx]
Sent: Thursday, February 20, 2003 8:51 PM
To: Srikanta Shivanna
Cc: samba-technical@xxxxxxxxxxxxxxx
Subject: Re: Byte range locking
On Thu, Feb 20, 2003 at 07:50:22PM -0800, Srikanta Shivanna wrote:
> I noticed a difference in byte range locking behavior between Samba (2.2.x) and
> Windows 2000 server, basically on Samba 2.2.x
> with strict locking enabled, a client process which owns a shared byte range lock
> can write to the locked region, this is not allowed
> on Windows 2000 server. Is there a reason for this Samba behavior? Is it because
> of default value of some config option?
Can you give me more information on what open modes, access requested
etc. from the client Win32 code please ?
Thanks,
Jeremy.