Operating System - OpenVMS
1748066 Members
5357 Online
108758 Solutions
New Discussion юеВ

Re: Unable to open file getting -SYSTEM-W-BADIRECTORY, bad directory file format.

 
allin-in-one
Frequent Advisor

Unable to open file getting -SYSTEM-W-BADIRECTORY, bad directory file format.

Unable to open file getting error  -SYSTEM-W-BADIRECTORY, bad directory file format.

Using sys$qiow for openiing file.

In the same directory other files could be open with sys$qiow.

I didn't find any difference in file properites for file that could be open without any issue and files failed to open.

Please advise.

19 REPLIES 19
Steven Schweda
Honored Contributor

Re: Unable to open file getting -SYSTEM-W-BADIRECTORY, bad directory file format.

 
allin-in-one
Frequent Advisor

Re: Unable to open file getting -SYSTEM-W-BADIRECTORY, bad directory file format.

Thanks for the responese.

 

>Using sys$qiow for openiing file.

>Is that with or without sys$parse and/or sys$search? What, exactly, gets the error? What happens if you use some other p>rogram (like, say, TYPE or EDIT) to open the same file?

 

>>> not using sys$parse or sys$search.  Using sys$qiow to access (i.e. IO$_ACCESS | IO$M_ACCESS,)

 

 

> I didn't find any difference in file properites for file that could be  open without any issue and files failed to open.

>>   The error refers to the properties of a directory, not the properties of a file which is in a directory.

 

>>> In the same directory other files are accessible, hence I assumed directory properties are not the issue.

 

> HELP /MESSAGE BADIRECTORY

>See especially "User Action"

 

User Action: Use the DCL command SET FILE/NODIRECTORY
to delete the corrupt directory file, then use the DCL command
ANALYZE/DISK_STRUCTURE/REPAIR to place the lost files in the
[SYSLOST] directory. The lost files can then be copied to a new directory.

I couldn't suggest this to my customer as this may cause loss of data.

 

Thank you.

Steven Schweda
Honored Contributor

Re: Unable to open file getting -SYSTEM-W-BADIRECTORY, bad directory file format.

 
John Gillings
Honored Contributor

Re: Unable to open file getting -SYSTEM-W-BADIRECTORY, bad directory file format.

What does a DCL DIRECTORY command show?

What does any other DCL command which opens your target file do? (without knowing the type and size of file, I don't know which command(s) are appropriate - ANALYZE/RMS maybe?).

If DCL works and your $QIO code doesn't, what do you think that means?

 

Look at the directory contents with DUMP/DIRECTORY. Does your target entry look OK?

 

Remember that directories are just lists of pointers to files. They're really only a convenience for humans. The data is safe, pointed to by the "real" directory INDEXF.SYS. If a directory really is corrupt, you can:

 

1) Try to patch the file yourself (and since you're asking this question, that's not really an option)

2) Do the right thing - Delete the directory and recover the directory entries with ANALYZE/DISK/REPAIR

 

 

A crucible of informative mistakes
Hein van den Heuvel
Honored Contributor

Re: Unable to open file getting -SYSTEM-W-BADIRECTORY, bad directory file format.

>> >>> not using sys$parse or sys$search.  Using sys$qiow to access (i.e. IO$_ACCESS | IO$M_ACCESS,)

 

 

As per John... Surely a programming error.

 

If you use DCL OPEN x x.x, or just a DIR/DATE x.x ... does that work?

 

1) Rename all files from suspect directory to fresh directory

and/or

2) ANALYZ/DISK... deal with results; Blow away the directory; re-ANALYZ/DISK; ... rename SYSLOST to desired directory.

and/or

3) SEARCH/NUM/FORM=NON  x.dir x.x ...$DUMP/REC=(STA=n,COU=1) x.dir ;  $DUMP/BLO=(STA=m,COU=1) x.dir  ; $DUMP/DIR/BLOC=(STA=m,COU=1) x.dir

 

Good luck,

Hein

 

 

 

 

 

 

 

 

Steven Schweda
Honored Contributor

Re: Unable to open file getting -SYSTEM-W-BADIRECTORY, bad directory file format.

 
allin-in-one
Frequent Advisor

Re: Unable to open file getting -SYSTEM-W-BADIRECTORY, bad directory file format.

Thanks for all the suggestions.

I will collect all  the information and let you know the outcome.

 

Thank you.

allin-in-one
Frequent Advisor

Re: Unable to open file getting -SYSTEM-W-BADIRECTORY, bad directory file format.

Instead of using sys$parse+sys$search using LIB$FIND_FILE.
Will that make any difference ?
Or I need to use only sys$parse+sys$search before calling sys$qiow.

In the existing code calling LIB$FIND_FILE before sys$qiow which is retuning RMS$_NORMAL

and resultant-filespec was passed to sys$qiow.(here the returned resultant-filespec is valid filename and exists on disk.)

 

Thank you.

Hein van den Heuvel
Honored Contributor

Re: Unable to open file getting -SYSTEM-W-BADIRECTORY, bad directory file format.

 

>> Instead of using sys$parse+sys$search using LIB$FIND_FILE.
Will that make any difference ?

 

The main goal of LIB$FIND_FILE is to deliver a file specification string, NOT a NAM block with FID.

 

To do so it internally uses SYS$PARSE/SYS$SEARCH allocating a FAB and NAM block which you are supposed to give back by calling LIB$FIND_FILE_END.

 

You can get to the NAM block through the CTX variable.

That works, but is not supported..

 

By using PARSE+SEARCH you take ownership of the FAB/NAM and can use them as you see fit, notably to get the FID.

 

>> Or I need to use only sys$parse+sys$search before calling sys$qiow.

 

Much better IMHO... because you can now open by file-ID which avoids going back through the (cached) directories

 

>> In the existing code calling LIB$FIND_FILE before sys$qiow which is retuning RMS$_NORMAL

 

Sure, but WHY? It's double work.

 

>> and resultant-filespec was passed to sys$qiow.(here the returned resultant-filespec is valid filename and exists on disk.)

 

Sure, but WHY? It's double work.

 

In Fact, WHY do you even use SYS$QIO to open the file?

Just use RMS  in block mode FAB$V_BIOand SYS$READ / SYS$WRITE as needed?

 

Hein