Good day folks, I'm using Samba 2.2.8a [1] on Slackware 9.1 with 2000/XP clients. I'm attempting to have a process by which a user drags a file using Windows Explorer into a share. On the server side, I have a unix process that polls the directory for new files and then reads them and deletes them. I'm having a problem where I can gain the lock but the process is still writing to the file. Python code: import fcntl # open file in rw so I gain exclusive lock f = open("cygwin.tar","r+") # if this doesn't raise an IOError, the lock is acquired fcntl.lockf(f,fcntl.LOCK_EX|fcntl.LOCK_NB) which maps into a fcntl exclusive lock with 0 as the start, end, and whence arguments in the flock structure. In smb.conf, "locking = yes" had no effect on my process. The next thing I tried was "strict locking = yes". This had the effect that as soon as my code performs the lock, a windows dialog appears: ``Cannot copy cygwin: The process cannot access the file because another process has locked a portion of the file'' This leads me to suspect that either Windows Explorer or samba doesn't gain a lock on the file on creation. Is there a way to tell samba to set that lock? Thanks, Chris Footnotes: [1] Samba is compiled: --with-fhs \ --prefix=/usr \ --localstatedir=/var \ --bindir=/usr/bin \ --sbindir=/usr/sbin \ --with-lockdir=/var/cache/samba \ --sysconfdir=/etc \ --with-configdir=/etc/samba \ --with-privatedir=/etc/samba/private \ --with-codepagedir=/etc/codepages \ --with-smbmount \ --with-quotas \ --with-syslog \ --with-utmp \ --with-sambabook=/usr/share/swat/using_samba \ --with-ssl \ --with-sslinc=/usr/include/openssl \ --with-ssllib=/usr \ --with-msdfs \ --with-vfs \ --with-libsmbclient \ i386-slackware-linux -- Chris Green <cmg@dok.org> To err is human, to moo bovine.
Chris Green
2004-Jul-20 19:52 UTC
[Samba] Re: locks cooperating with a server side process
Chris Green <cmg@dok.org> writes:> I'm having a problem where I can gain the lock but the process is > still writing to the file.OK, I realized that putting python in might have scared away anyone that knew C enough to help me out on my problem so I wrote a tiny util to look at the fcntl based locks. http://cmg.dok.org/code/lockview.c As I copy the file from NT -> Linux 2.4, There are no locks set on the file. However, if I turn strict locking on, posix.c/is_posix_locked will return true as soon as I gain the lock and abort the copy. If just plain locking is on, the file will be deleted as soon as the copy is complete if another process has gained a write lock. Does anyone else use samba as a drop box for a unix process? Is there anyway to make a file be locked upon creation with the copy command? I have a hard time figuring out all the paramters for open_file_shared1 [2004/07/20 13:21:37, 5] smbd/files.c:file_new(123) allocated file structure 5634, fnum = 9730 (2 used) [2004/07/20 13:21:37, 10] smbd/open.c:open_file_shared1(807) open_file_shared: fname = output/Testing/cygwin.tar, share_mode = 11, ofun = 10, mode = 660, oplock request = 3 Thanks, Chris -- Chris Green <cmg@dok.org> Eschew obfuscation.
Gerald (Jerry) Carter
2004-Jul-20 20:31 UTC
[Samba] Re: locks cooperating with a server side process
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Chris Green wrote: ... | Does anyone else use samba as a drop box for a unix process? | | Is there anyway to make a file be locked upon creation with the copy | command? I have a hard time figuring out all the paramters for | open_file_shared1 Chris, This kind og question is probably better suited for the samba-technical mailing list. I would repost there. cheers, jerry - ---------------------------------------------------------------------- Hewlett-Packard ------------------------- http://www.hp.com SAMBA Team ---------------------- http://www.samba.org GnuPG Key ---- http://www.plainjoe.org/gpg_public.asc "...a hundred billion castaways looking for a home." ----------- Sting -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFA/YEHIR7qMdg1EfYRArGLAJ9cDIX+qpu1jo3MDK8wt4CitjBn8wCePDzn tNaMlQ4irMheC+EwD8vUAa8=IOzG -----END PGP SIGNATURE-----
Reasonably Related Threads
- ANNOUNCE: portable openssh-2.1.0
- changes in behaviour of Rcmd SHLIB since 2.4.0
- Carrier Access CMG/FXS MGCP to Asterisk, Works Fine
- Samba Translation Dok to German, first file, deutsche Übersetzung Der Samba Doku erste Datei
- Force set group id on samba domain member