- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- How to know in a file is locked ?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2015 07:48 AM
02-02-2015 07:48 AM
How to know in a file is locked ?
Hello,
I'm running Alpha VMS V6.2-H3 & need to know if a file is locked via a DCL procefure.
I tried to use the lexical F$FILE("file_name","LOCKED"), but instead of getting "TRUE", the command crashes with a "conflict" warning message.
Any idea why this lexical does not work, as it should work, with the "LOCKED" argument ?
Regards /Ofer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2015 04:59 PM
02-02-2015 04:59 PM
Re: How to know in a file is locked ?
Ah, this old chestnut. The lexicals and the rest of the bits you're looking at are remnants of the old RSX-11M file deaccess locking mechanisms, and are completely unrelated to the OpenVMS lock manager.
From the lexical function help text:
"LOCKED String TRUE if a file is deaccessed-locked; otherwise FALSE."
From current OpenVMS, the related command (if you follow through from the UNLOCK command):
SET
FILE
/UNLOCK
Clears a file marked as deaccess locked. Deaccess locking is
required by and used by those few applications that maintain
their own locking and consistency, typically without the use
of the OpenVMS distributed lock manager, and potentially also
without the use of RMS. When an application using deaccess
locking does not correctly deaccess the file (often due to an
application or system failure), the file is marked as locked, and
is thus inaccessible until the integrity of the contents of the
file are verified and the SET FILE/UNLOCK command is used.
This command does not affect the state of files that are locked
using RMS or the distributed lock manager.
For details on file deaccess locking, see the HP OpenVMS I/O
User's Reference Manual, the ACP-QIO interface documentation, and
specifically the FIB$V_DLOCK option available on the IO$_CREATE
and IO$_ACCESS functions.
The SET FILE/UNLOCK command can clear the cause of the following
error message:
%SYSTEM-W-FILELOCKED, file is deaccess locked
However, this command cannot resolve the cause of the error
message:
%RMS-W-FLK, file currently locked by another user
Topic?
As for your question, there isn't one. The usual way to determine if there is a lock conflct is to try to perform an operation that is incompatible, and catch the error. There's no DCL lexical, knob, flag, option nor item to determine that a particular file is locked. The OPEN command is one such approach, or just perform the intended operation and (via ON or equivalent) catch the error. Even if you did go to the effort of using the system services and following the (undocumented) file resources and locks around, you'd still have to trap for errors as the file lock state can easily change between the time of the probe and the file access.
There are ways to mask the DCL error messages, if that's the issue here.
It's long past time to upgrade to OpenVMS V8.4, too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2015 10:46 PM
02-02-2015 10:46 PM
Re: How to know in a file is locked ?
To solve that, I just "wait 00:00:05" (few seconds) until the "another" user will close the file before I try to open it & it works.
Regards /Ofer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2015 08:53 AM
02-03-2015 08:53 AM
Re: How to know in a file is locked ?
Adding a delay is rather more of a hack than a solution, as you undoubtedly know. Looping with a delay might or might not ever gain access to the target file, depending on details of the processing involved. The usual approach involves enabling sharing, though that depends on access into the primary application controlling the access, or overriding file sharing interlocks entirely. But the best approach depends on some understanding of the application involved and the environment and the requirements.
imeouts and loops can tend to just push the problems downstream, not fix them.
I'm going to guess this is some FTP drop-box application — that on absolutely zero evidence — so one of the approaches that arise with that is to rename the file as the last step in the transfer. That greatly reduces the exposure to a locked file, if you can keep the filenames sufficiently unique between the files that are in transit, and the files that in place and ready for post-processing. Further along and more advanced would be some sort of queue-related processing; getting FTP out of the way, or a customized FTP server.
Beyond the lack of locking APIs discussed earlier, VMS also lacks any form of generic notification API here, unfortunately. But details on the environment and the requirements would help folks tailor the answer, obviously.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2015 12:18 PM
02-04-2015 12:18 PM
Re: How to know in a file is locked ?
fwiw, I also favor yust trying what you need to do an handle the error.
Still, sometimes it is nice to know without the error messages.
For that I typically use (from memory) :
$ CLOS/NOLOG x
$ OPEN /READ/NOSHARE/ERROR=wait_a_while x name.exe
$ CLOSE/NOLOG x
Of cours you may want to check $STATUS in 'wait_a_while' for FNF, FLK and other typical errors.
Hein