Skip to contentSkip to conversation

Opening a file for exclusive access in DOSEMU

DISCUSSION Vasil Daskalov 2 participants 2 messages Jan 30, 2004

lore
Share & tools
lore
#0 lore raw

Hi all,

I'm trying to run a Clipper database program in network mode in DOSEMU. The program opens some files for exclusive access, assuming that no other program can open them. This assumption holds true under MSDOS 6.22, Windows 2000 and other network environments. However, two instances of this program, running in two instances of DOSEMU on one Linux machine, can open these files simultaneously, ruining the program logic. The machine runs Debian Linux 3.0, kernel version 2.2.20. The DOSEMU is the latest version, 1.2, the DOS is MS DOS 6.22. The database files are located on the DOSEMU drive C: , which is a linux directory, with a symlink " ~/.dosemu/drives/c " pointing to it. I tried moving the files to a lredir-ed drive with no success. Tried to run SHARE.EXE in AUTOEXEC.BAT - again no success. This problem is apparently not Clipper-related, because it can be easily reproduced with two instances of a simple QBASIC program, which opens a file in the following fashion:

OPEN "FILE.TMP" FOR BINARY ACCESS READ WRITE LOCK READ WRITE AS #1

Then the two instances easily open the file simultaneously, which shouldn't be possible.

Besides, DOSEMU gives me the following message:

SHAREing doesn't work on drive C: (probably NFS volume?)

This is probably related to the problem. I wonder, why SHAREing doesn't work? I'm sure I don't have any NFS volumes in my system. Any suggestions?

TIA,
Vassil Daskalov

#1 lore raw
Quoted 7 lines · Vasil Daskalov

I'm trying to run a Clipper database program in network mode in DOSEMU. The program opens some files for exclusive access, assuming that no other program can open them. This assumption holds true under MSDOS 6.22, Windows 2000 and other network environments. However, two instances of this program, running in two instances of DOSEMU on one Linux machine, can open these files simultaneously, ruining the program logic. The machine runs Debian Linux 3.0, kernel version 2.2.20.

The fundamental problem is that DOS locking and Linux locking are inherently incompatible. The emulation attempted by DOSEMU may work or may not work. But in your case it doesn't even try since DOSEMU failed its first "get lock" attempt.

You can try:
- to run kernel 2.4.x instead of 2.2. it supports large file locking which may be more reliable.
- play with $_full_file_locks in dosemu.conf or ~/.dosemurc

using SHARE won't have any effect on lredir'ed drives.

Bart