我在两台Linux机器上安装了一个cifs文件。我有一个可以修改共享文件的Perl脚本。在这种情况下,我们如何在网络上锁定文件?如何锁定Perl网络中的共享文件?
1
A
回答
0
我无法在CPAN上找到实现此目的的模块。看起来包装libsmbclient的模块没有实现协议的OPLOCKing部分。
在smbfs来源中,功能smbfs_smb_lock
似乎可以满足您的需求。 要么写你自己的XS包装模块,要么使用Inline :: C。
2
看起来我们可以用fcntl()来锁定文件。我刚刚找到了它的工作:) 如果你想做到这一点通过NFS,尝试File::NFSLock此链接可能是有用的
http://www.cpan.org/scripts/file-handling/flock.using.fcntl.example
感谢您的答复
_Anandan
+1
在网络上,你必须做更多的工作。它也可能取决于您的网络文件系统支持的内容。 – 2009-07-17 17:43:35
1
。
1
如果你的文件服务器是桑巴,那么也要看smb.conf手册页:
...
阻塞锁(S)
This parameter controls the behavior of smbd(8) when given a request by a client
to obtain a byte range lock on a region of an open file, and the request has a
time limit associated with it.
If this parameter is set and the lock range requested cannot be immediately
satisfied, samba will internally queue the lock request, and periodically attempt
to obtain the lock until the timeout period expires.
If this parameter is set to no, then samba will behave as previous versions of
Samba would and will fail the lock request immediately if the lock range cannot
be obtained.
Default: blocking locks = yes
...
锁定(S)
This controls whether or not locking will be performed by the server in response
to lock requests from the client.
If locking = no, all lock and unlock requests will appear to succeed and all lock
queries will report that the file in question is available for locking.
If locking = yes, real locking will be performed by the server.
This option may be useful for read-only filesystems which may not need locking
(such as CDROM drives), although setting this parameter of no is not really
recommended even in this case.
Be careful about disabling locking either globally or in a specific service, as
lack of locking may result in data corruption. You should never need to set this
parameter.
相关问题
- 1. 共享文件锁
- 2. 文件更改事件网络共享
- 3. 如何在Windows中从Perl访问网络共享?
- 4. 访问共享网络文件夹
- 5. 将文件写入网络共享
- 6. 在网络共享上移动文件
- 7. 在网络上重新共享文件
- 8. 写入文件卡住网络共享
- 9. PHP - 访问文件夹共享网络
- 10. 监视网络共享文件夹
- 11. 如何从网络共享文件中获取关联图标
- 12. 锁定行为是通过网络共享
- 13. 如何打开共享文件夹的本地网络上Win10
- 14. 网络上的Java文件锁定
- 15. 网络文件锁定的可靠性
- 16. 如何将ADF文件保存到网络共享?
- 17. 如何利用网络在Android平台上共享p2p文件?
- 18. IOS - 如何将文件写入网络共享?
- 19. 如何从批处理文件写入Windows网络共享?
- 20. Zend_Search_Lucene,如何通过网络共享索引存储文件夹
- 21. 如何使用JavaScript访问共享/网络文件夹?
- 22. PyCharm如何从网络共享
- 23. 如何访问网络共享域(IIS)
- 24. 如何备份到网络共享?
- 25. 如何通过网络共享jboss
- 26. 如何从网络共享文件夹删除回收文件/文件夹
- 27. 通过网络访问Windows共享文件夹上的文件
- 28. 复制的PDF文件共享网络和文件损坏
- 29. 位于HTML页面的网络共享中的“打开文件”?
这是什么样的网络? – 2009-07-17 17:42:20