[linux-cifs-client] fcntl(): file unlocking failure
Loris Boillet
lb at 2m.dk
Tue Nov 14 10:19:02 GMT 2006
Hello,
I need to open a file and to lock it for both read and write access.
The file is in a network directory on a Windows server. To access it
from Linux (Debian), I use CIFS with mandatory locks activated:
mount -t cifs -o mand \\\\server\\share MountFolder
I test it with a C program using fcntl(). It behaves well if I mount the
share with SMBFS. But with CIFS, unlocking operation fails: I get Error
5: Input / Output Error.
Test program:
fd = open("MountFolder/b.txt", O_RDWR | O_EXCL | O_APPEND);
if (fd == -1)
{
// erreur ...
}
fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
if (fcntl(fd, F_SETLK, &fl) == -1)
{
// Error...
}
else
{
printf("Lock granted.\n");
// Unlock the locked bytes
fl.l_type = F_UNLCK;
if (fcntl(fd, F_SETLK, &fl) == -1)
{
printf("Unlocking operation failed.\nError: %i \n", errno);
perror(s);
}
else
{
printf("File unlocked.\n");
}
}
Why does unlock fail?
Thanks
More information about the linux-cifs-client
mailing list