记录linux和Windows之间的锁定问题

发布于 2024-08-04 18:00:14 字数 769 浏览 8 评论 0 原文

我需要在 DOSEMU 下的 Linux 中运行一堆旧的 DOS FoxPro / Clipper 应用程序。 这些程序访问位于网络服务器(可以是 Windows 或 Linux服务器)

实际上,程序运行良好,但我无法使记录锁定工作 如假设的:我可以在两个终端(或服务器和任何终端)中运行程序 实例)并在两者中锁定相同的记录。

现在,我使用 Tiny Core Linux 作为终端,Windows XP 作为服务器,访问共享 通过 CIFS 和最新的 DOSEMU (1.4.0) 文件,但我尝试了各种组合 服务器(Ubuntu 7 到 9、该死的小型 Linux、XP)<->协议(CIFS、samba、各种版本的 smbclient)<->客户端(与服务器相同)没有运气

我尝试将服务器部分配置为在 samba 中没有机会锁的情况下工作(在阅读了 http://oreilly.com/catalog/samba/chapter/book/ch05_05.html ) 和 XP 中 (\HKEY_LOCAL_MACHINE\SYSTEM\ CurrentControlSet\Services\LanmanServer\Parameters\UseOpportunisticLocking = 0),但问题仍然存在。

有什么想法吗?

TIA, 巴勃罗

I need to run a bunch of old DOS FoxPro / Clipper applications in linux under DOSEMU.
The programs access their "databases" located on a network server (could be a Windows or
Linux server)

Actually, the programs ran fine, but I cannot manage to make the record locking work
as supposed: I can run a program in two terminals (or the server and any terminal for
instance) and lock the same record in both.

Now, I'm using Tiny Core Linux as terminal and Windows XP as server, accesing the shared
files via CIFS and the latest DOSEMU (1.4.0), but I tried with various combinations of
server (Ubuntu 7 to 9, Damn Small Linux, XP) <-> protocol (CIFS, samba, various versions of smbclient) <-> client (same as server) with no luck

I tried to configure the server part to work without oplocks in samba (after reading the entire O'Reilly Samba book locking chapter in http://oreilly.com/catalog/samba/chapter/book/ch05_05.html ) and in XP (\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\UseOpportunisticLocking = 0) but the problem persist.

Any ideas?

TIA,
Pablo

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

ζ澈沫 2024-08-11 18:00:14

@Michael:这些程序可以在任何 DOS(Lantastic、WFW)或 Windows(95、NT、XP、...)网络上正常运行。

我创建了一个最小的 C 程序来重现该行为:

#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <process.h>
#include <share.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
 int handle, status;
 long length;

 handle = sopen("testlock.txt", O_RDONLY,SH_DENYNO,S_IREAD);

 if (!handle)
 {
    printf("sopen failed\n");
    exit(1);
 }

 length = filelength(handle);
 status = lock(handle,0L,length/2);

 if (status == 0)
    printf("lock succeeded\n");
 else
    printf("lock failed\n");

 printf ("Press a key...\n");
 getch();

 status = unlock(handle,0L,length/2);

 if (status == 0)
    printf("unlock succeeded\n");
 else
    printf("unlock failed\n");

 close(handle);
 return 0;
}

它在 DOS / Windows 上运行良好(第一个终端可以锁定,第二个终端不能),但在 DOSEMU 下的 Linux 中执行失败(您可以同时运行该程序的两个实例)网络共享,并且两者都可以独立于运行顺序(Linux-Windows / Windows-Linux)获取锁定。

@Michael: the programs works fine on any DOS (Lantastic, WFW) or Windows (95, NT, XP, ...) network.

I created a minimal C program to reproduce the behavior:

#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <process.h>
#include <share.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
 int handle, status;
 long length;

 handle = sopen("testlock.txt", O_RDONLY,SH_DENYNO,S_IREAD);

 if (!handle)
 {
    printf("sopen failed\n");
    exit(1);
 }

 length = filelength(handle);
 status = lock(handle,0L,length/2);

 if (status == 0)
    printf("lock succeeded\n");
 else
    printf("lock failed\n");

 printf ("Press a key...\n");
 getch();

 status = unlock(handle,0L,length/2);

 if (status == 0)
    printf("unlock succeeded\n");
 else
    printf("unlock failed\n");

 close(handle);
 return 0;
}

It works fine on DOS / Windows (the first terminal can lock, the 2nd one no), but fails executing in Linux under DOSEMU (you can concurrently run two instances of the program in a network share, and both can obtain the lock independently of the run sequence Linux-Windows / Windows-Linux).

夕嗳→ 2024-08-11 18:00:14

首先:这些程序有关于锁定的任何线索吗?它们是否与网络共享上的 db 文件一起运行?

早在 DOS 时代,网络共享并不常见(即使常见,也常常是 Netware)。如果数据库引擎不知道底层 db 文件可能被共享,那么您使用 cifs 做什么并不重要 - 它不会锁定,因此它不会工作。

现在,如果您已经在 DOS 机器网络上正确运行了该程序,并且您正在尝试升级到 Linux,那么当前的 DOS 网络是什么?是cifs,还是更像Netware?数据库引擎是否有可能了解网络堆栈并做一些有趣的事情?这可能会在数据库引擎不知道网络的新环境中导致问题。

如果您确实需要弄清楚发生了什么,您可以尝试使用 Wireshark 来跟踪 CIFS 流量并尝试了解它如何使用(或不使用)锁定。但这是一项巨大的工作,除非您可以生成一些简单的应用程序来测试,否则工作量很大。

First off: Do these programs have any clue about locking? Are they made to be run with the db file on a network share?

Back in the DOS days, a network share wasn't real common (and when it was, it was Netware as often as not). If the database engine doesn't have any ideas that the underlying db file might be shared, then it doesn't matter what you with cifs - it's not locking, so it's not going to work.

Now, if you are already running this correctly on a network of DOS boxes and you are trying to upgrade to Linux, what's the current DOS network? Is it cifs, or is it more like Netware? Is there any chance that the database engine is aware of the network stack and doing something funny? That might lead to problems in a new environment where the db engine isn't aware of the network.

If you really need to figure out what's going on, you might try using Wireshark to trace the CIFS traffic and try to understand how it's using (or not using) locking. That's a big effort though, and unless you can generate some trivial apps to test with, then it's a lot of work.

不弃不离 2024-08-11 18:00:14

我可以确认这个问题确实存在,如上所述。一种解决方案是将共享 DBF 文件从 Windows 服务器移至 Linux 服务器上。然后,这些文件可以通过 CIFS (SAMBA) 共享给感兴趣的 Windows 各方,并通过 vi NFS(使用 -osync nolock 选项)共享给感兴趣的 Linux 各方。
这对我们来说非常有效

Brett

I can confirm this problem does exist as indicated above. One solution is to move the shared DBF files off of the windows server and onto a linux server. these files can then be shared via CIFS (SAMBA) to interested windows parties and vi NFS (with the -o sync nolock options) to interested linux parties.
It works for us quite well

Brett

得不到的就毁灭 2024-08-11 18:00:14

这似乎是一个已知的、持续存在的问题

我确实知道字节范围锁定(又名 Windows 风格的记录锁定)需要最新的内核版本,尽管我不知道它是否出现在 2.4 系列中。

如果 DosEMU 无法为您服务,您可能不得不诉诸一些更“奇特”的东西。也许在 FreeDOS /Guest_Support_Status" rel="nofollow noreferrer">KVM 虚拟机会让你更接近你的目标,尽管你必须做一些手动设置才能获得网络支持(或者弄清楚如何进行网络共享)在来宾中显示为本地驱动器号)。滚动到 KVM 兼容列表的底部,查看各种类似 DOS 安装的状态。

如果您可以使用原始的 6.22 安装,那么这实际上可能是您的最佳选择。

This appears to be a known, ongoing issue.

I do know that byte-range locking (aka Windows-style record locking) requires recent kernel versions, although I don't know if it appeared in the 2.4 series or not.

If DosEMU cannot be made to work for you, you might have to resort to something a little more "exotic". Perhaps running FreeDOS under a KVM virtual machine would get you closer to your goals, although you'll have to do some manual setup to get networking support (that or figure out how to make a network share appear as a local drive letter in the guest). Scroll to the bottom of the KVM compat list to see the status of various DOS-like installs.

If you have the original 6.22 installs to work with then that might actually be your best option.

千纸鹤带着心事 2024-08-11 18:00:14

我们在 Windows 98、Xp 工作站上的 samba 共享上运行 dos epos 应用程序,并在 samba 共享上进行正确的锁定设置,我们还可以通过 dosmeu 运行该应用程序。 samba 共享上有一系列锁定设置,我们使用以下设置。

 [data]
        comment = data Share
        inherit acls = Yes
        path = /data/
        read only = No
        oplocks = no
        locking = Yes
        strict locking = No
        create mask = 0774
        directory mask = 0775
        browseable = Yes
        default case = upper

We run a dos epos application on a samba share with both windows 98,Xp workstations with the correct locking setting on the samba share we are also able to run the application through dosmeu. There are a range of lock setting on the samba share we used the following settings.

 [data]
        comment = data Share
        inherit acls = Yes
        path = /data/
        read only = No
        oplocks = no
        locking = Yes
        strict locking = No
        create mask = 0774
        directory mask = 0775
        browseable = Yes
        default case = upper
深空失忆 2024-08-11 18:00:14

答案其实很简单:posix 锁
不适合该任务。这就是我们的全部
直到 2014 年底,linux-3.15 和 glibc-2.20
开始提供 OFD 锁 - 5 年后
这里提出了问题。

CIFS在2018年才获得OFD锁:
https://www.spinics.net/lists/linux-cifs/msg14795。 html

osemu2 在 git (2020) 中具有实验性 OFD 锁支持。

所以,回答你的问题:技术
2009 年(该问题发布时)没有
足够先进来执行您的任务。实际上,
这项工作仅在 5 年后才开始,当时
linux获得OFD锁,花了6年多的时间
所有其他涉及的软件组件都要捕获
向上。

注意:除了记录锁定之外,foxpro/clipper 还
也对所谓的“分享支持”“感兴趣”-
MS 的另一项技术,本质上是
与 posix 不兼容。分享支持不会
即使现在也可以在您的场景中工作。最好的情况下,你可以
在多剂量mu2之间获得适当的份额支持
会话在同一台机器上运行。但你不会
如果您在 Windows 上打开文件即可获得共享
同时在服务器和dosemu2下。和
即使您运行多个dosemu2实例
不同机器,不保证共享支持
去工作。但如果你需要的只是区域锁定,
那么它将在所有配置下工作,以防万一
你的软件足够新。

The answer is actually quite simple: posix locks
are not suitable for that task. And this is all we
had until late 2014, when linux-3.15 and glibc-2.20
started to provide OFD locks - 5 years after this
question was asked here.

CIFS only got OFD locks in 2018:
https://www.spinics.net/lists/linux-cifs/msg14795.html

dosemu2 has experimental OFD locks support in git (2020).

So, to answer your question: the technologies
of 2009 (when that question was posted) were not
advanced enough to perform your task. In fact,
the work was started only 5 years later, when
linux got OFD locks, and it took 6+ years for
all other involved software components to catch
up.

Note: besides record locking, foxpro/clipper are
also "interested" in a so called "share support" -
another technology from MS, that is inherently
incompatible with posix. Share support will not
work in your scenario even now. At best, you can
get proper share support between multiple dosemu2
sessions running on the same machine. But you won't
get share if you open your files on your windows
server and under dosemu2 at the same time. And
even if you run several dosemu2 instances on
different machines, share support is not guaranteed
to work. But if all you need is region locking,
then it will work in all configurations, in case
your software is recent enough.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文