Hi,
I added these lines to smb.conf:
kernel op locks = false
op locks = false
strict locking = true
so I could see some locks from the unix level.
It worked sorta, I see the locks for big files
(but not the locks I was expecting), but for little
files it shows nothing:
# ./lock_list /opt/testsambashare/mattest.doc
# ./lock_list /opt/testsambashare/contents.doc
0 22086 W 2147483539 1
0 22086 W 2147483559 1
0 22086 W 2147483599 1
(the output is l_sysid, l_pid, l_start, l_len of struct flock)
(lock_list.c source given below)
The only difference I can see is that the contents.doc is
much bigger:
# ls -l /opt/testsambashare
total 5210
-rwxrw-r-- 1 matt other 1460736 Oct 29 15:24 contents.doc
-rw-r--r-- 1 matt other 1176738 Oct 29 15:23 contents.txt
-rwxrw-r-- 1 matt other 2168 Oct 29 16:19 mattest.doc
-rwxrw-r-- 1 matt other 54 Oct 29 16:52 ~$attest.doc
-rwxrw-r-- 1 matt other 54 Oct 29 16:47 ~$ntents.doc
Why is there 3 1 byte locks at some position
way beyond the end of the file?
This is Samba 2.2.6 on Solaris 2.6.
Regards,
Matt
Here's the source. NOTE: you will have to change it for
Linux as Linux doesn't have l_sysid in struct flock.
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
int
main (int argc, char **argv)
{
char c;
int fd;
int debug = 1;
struct flock lck;
lck.l_whence = 0;
lck.l_start = 0L;
lck.l_len = 0L;
if (-1 == (fd = open(argv[1], O_RDONLY)))
{
perror(argv[1]);
exit(1);
}
do {
lck.l_type = F_WRLCK;
if(-1 == fcntl(fd, F_GETLK, &lck))
{
perror("fcntl getlk");
exit(1);
};
if (lck.l_type != F_UNLCK) {
printf("%d %d %c %8ld %8ld\n", lck.l_sysid,
lck.l_pid,
(lck.l_type == F_WRLCK) ? 'W' :
'R', lck.l_start, lck.l_len);
/* If this lock goes to the end of the address space, no
* need to look further, so break out. */
if (lck.l_len == 0) {
break;
}
else {
/* else, look for new lock after the one just
found. */
lck.l_start += lck.l_len;
lck.l_len = 0;
/* printf("looking at start %d len
%d\n", lck.l_start, lck.l_len); */
}
}
} while (lck.l_type != F_UNLCK);
}
On Tue, Oct 29, 2002 at 06:17:20PM +1100, Matthew Hannigan wrote:> so I could see some locks from the unix level. > It worked sorta, I see the locks for big files > (but not the locks I was expecting), but for little > files it shows nothing: > > # ./lock_list /opt/testsambashare/mattest.doc > # ./lock_list /opt/testsambashare/contents.doc > 0 22086 W 2147483539 1 > 0 22086 W 2147483559 1 > 0 22086 W 2147483599 1 > (the output is l_sysid, l_pid, l_start, l_len of struct flock) > > (lock_list.c source given below) > > The only difference I can see is that the contents.doc is > much bigger: > > # ls -l /opt/testsambashare > total 5210 > -rwxrw-r-- 1 matt other 1460736 Oct 29 15:24 contents.doc > -rw-r--r-- 1 matt other 1176738 Oct 29 15:23 contents.txt > -rwxrw-r-- 1 matt other 2168 Oct 29 16:19 mattest.doc > -rwxrw-r-- 1 matt other 54 Oct 29 16:52 ~$attest.doc > -rwxrw-r-- 1 matt other 54 Oct 29 16:47 ~$ntents.doc > > > Why is there 3 1 byte locks at some position > way beyond the end of the file?The locks you see here are used by MS Office as semaphores. No one really knows why (well the MS Office programmers do, but they're not telling :-). Jeremy.
Maybe Matching Threads
- [PATCH] fs: Add new pre-allocation ioctls to vfs for compatibility with legacy xfs ioctls
- unable to update the matrix values within a function
- Reproducable Infiniband panic
- [PATCH 1/3] VFS/ioctl: Add punching-hole support to ioctl().
- [PATCH 1/3] VFS/ioctl: Add punching-hole support to ioctl().