[uClinux-dev] Locking files

Jimi Simpson j.simpson at pryormarking.com
Fri Nov 23 09:45:28 EST 2001


Firstly to set the scene: I am working on a system that uses a number of
uClinux/Linux machines each with a mapping to a shared Windows
directory, each of which needs to have the ability to gain exclusive
read/write access to a shared file.

I have successfully setup a mount from each machine to the shared
directory/file using smbmount and all the machines can access the file
without problem. As a quick test I have tried simply reading a number
from the file and then storing the number+1 back to the file. Obviously
in order to perform this reliably I need to lock the file at certain
points and I have tried this with some success using both fcntl and
flock, however I am experiencing some problems.

If I spawn two threads of client execution from a Linux PC, then all
appears to be well, but when I include an M5272C3 evaluation board
running the same client application under uClinux, then it all goes
horribly wrong. If I use the F_RDLCK macro as part of an fcntl call and
then display the results, then the Linux PC looks right, but the eval
board sees a false picture of the lock condition.

If anyone has any ideas as to the likely causes of this problem, then
please feel free to share them. It may be that my understanding and
expectations from linux/smbmount/flock etc. is incorrect. Every bit of
constructive help that I can get will be most appreciated.

Best Regards

j.simpson at pryormarking.com

PC. Just to be clear about the system setup. I am using multiple
hardware systems each running Linux, all of which are sharing a global
file on a Windows filesystem located somewhere across a network.

This message resent by the uclinux-dev at uclinux.org list server http://www.uClinux.org/

More information about the uClinux-dev mailing list