Unable to open file getting -SYSTEM-W-BADIRECTORY, bad directory file format. (977 Views)
Reply
Frequent Advisor
allin-in-one
Posts: 55
Registered: ‎10-21-2012
Message 1 of 20 (977 Views)

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.

Please use plain text.
Honored Contributor
Steven Schweda
Posts: 9,084
Registered: ‎02-23-2005
Message 2 of 20 (964 Views)

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

Please use plain text.
Frequent Advisor
allin-in-one
Posts: 55
Registered: ‎10-21-2012
Message 3 of 20 (961 Views)

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.

Please use plain text.
Honored Contributor
Steven Schweda
Posts: 9,084
Registered: ‎02-23-2005
Message 4 of 20 (958 Views)

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

Please use plain text.
Honored Contributor
John Gillings
Posts: 2,994
Registered: ‎07-31-2003
Message 5 of 20 (950 Views)

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
Please use plain text.
Honored Contributor
Hein van den Heuvel
Posts: 6,585
Registered: ‎05-19-2003
Message 6 of 20 (867 Views)

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

 

 

 

 

 

 

 

 

Please use plain text.
Honored Contributor
Steven Schweda
Posts: 9,084
Registered: ‎02-23-2005
Message 7 of 20 (857 Views)

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

Please use plain text.
Frequent Advisor
allin-in-one
Posts: 55
Registered: ‎10-21-2012
Message 8 of 20 (849 Views)

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.

Please use plain text.
Frequent Advisor
allin-in-one
Posts: 55
Registered: ‎10-21-2012
Message 9 of 20 (794 Views)

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

[ Edited ]

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.

Please use plain text.
Honored Contributor
Hein van den Heuvel
Posts: 6,585
Registered: ‎05-19-2003
Message 10 of 20 (783 Views)

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

 

 
Please use plain text.
Frequent Advisor
allin-in-one
Posts: 55
Registered: ‎10-21-2012
Message 11 of 20 (787 Views)

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

Than you.

I will try your suggestions and let you know the outcome.

 

 

Please use plain text.
Honored Contributor
Hein van den Heuvel
Posts: 6,585
Registered: ‎05-19-2003
Message 12 of 20 (780 Views)

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

btw... my favourite reason to use QIO to access a fiel is to be able to use:

 

fib.fib$l_acctl = FIB$M_NOLOCK;

 

 

>> and resultant-filespec was passed to sys$qiow.

 

Device and all?

What do you do with the DEVICE from the file-spec?

Do you properly assigne a channel?

 

Using SYS$PARSE i typically use somthing like:

 

devnam_desc.addr = nam.nam$l_dev;
devnam_desc.len = nam.nam$b_dev;
if (((status=sys$assign(&devnam_desc,&channel,0,0,0)) & 1) != 1) lib$stop(status);

 

If you need further help with this then you should answer the general question on whether the target file can be accessed with other methods, and you should  trim down your program to the minimum needed to reproduce the issue and attach it?

 

Perhaps the program is simply mis-managing the filename descriptor and passing a bad string under certain circumstances?

 

Hein

 

 

 

Please use plain text.
Honored Contributor
Steven Schweda
Posts: 9,084
Registered: ‎02-23-2005
Message 13 of 20 (768 Views)

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

Please use plain text.
Trusted Contributor
John McL
Posts: 280
Registered: ‎02-24-2008
Message 14 of 20 (764 Views)

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

General question - what does RENAME do if you are moving a file between directories and it can't find the source .DIR?

 

I imagine that RENAME has to alter the directory backlink (ie. the DID) in INDEXF.SYS, then go and modify the two (i.e. old and new) .DIR files.  Or does it do this in a different sequence (e.g. add to new .DIR, remove from old .DIR and then change INDEXF.SYS)?

 

The reason for my question is that I was wondering if the files in the failed directory have known names and RENAME will be able to insert them into a new directory even if the old directory is broken.

 

Mind you, we've seen nothing about what DUMP/DIRECTORY displayed, or ANALYZE/DISK and I don't think anyone has inquired about errors being logged for that disk... 

 

If this forum is to be a useful resource then solutions or people's stuff-ups should be reported here so that other people can benefit from the knowledge. 

Please use plain text.
Honored Contributor
Steven Schweda
Posts: 9,084
Registered: ‎02-23-2005
Message 15 of 20 (752 Views)

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

Please use plain text.
Trusted Contributor
John McL
Posts: 280
Registered: ‎02-24-2008
Message 16 of 20 (745 Views)

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

What you might be trying to say but saying badly is that the RENAME will have to access the .DIR file to find the file's FID so that it can locate the entry in INDEXF.SYS.

 

That would make sense.  How else could it get the FID?

Please use plain text.
Frequent Advisor
allin-in-one
Posts: 55
Registered: ‎10-21-2012
Message 17 of 20 (736 Views)

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

Accessing file using DIR/full  X.Dir  or editing the file having no issues.

Some other applications could access the file for backup.

 

But only some files in the directory having issue with sys$qiow for accessing in my application.

 

Thank you.

 

 

 

 

Please use plain text.
Honored Contributor
Hein van den Heuvel
Posts: 6,585
Registered: ‎05-19-2003
Message 18 of 20 (712 Views)

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

 

>> Accessing file using DIR/full  X.Dir

 

Unfortunate typo when it matters most? 

I though we were talkign about accessing a normal file, not a directory !?!

 

Is this a datafile called .DIR ?

 

>>  or editing the file having no issues.

>> Some other applications could access the file for backup.

 

I think we have our answer.

Everything can work with the file except the QIO program, which can access other files.

May I respectfully submit there is something broken in that program.

 

At this point my money would be on a FIB$W_DID contents being hosed/stuck/mismanaged.

 

 

>> But only some files in the directory having issue with sys$qiow for accessing in my application.

 

So what is special about those files? Name-length?

Odd characters?

Version number?

UpperCase / LOWERCASE ?

 

Admittedly this would all likely lead to 'file-not-found' but still...

 

Do a DIR/FILE on a file that does not work and see if you can back-translate it.

(xxxx,yy,z)

 

For example:

write sys$output F$fid("SYS$DISK:",f$file("login.com","FID"))

 

Or $ DUMP/HEAD/BLOCK=COUNT=1/ID=xxxx sys$disk

 

Show us some goodies! Actual directory listings, Actual error messages...

maybe the program trashes the return code... wouldn't be the first or the last.

 

Thank you.

Hein

 

Please use plain text.
Frequent Advisor
allin-in-one
Posts: 55
Registered: ‎10-21-2012
Message 19 of 20 (674 Views)

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

Hi,

 

I got output for failed and sucessful files deader dump. (i.e.  DUMP/HEAD/BLOCK=COUNT=1/ID=xxxx sys$disk)

I couldn't make any difference between them.

 

Thanks

Please use plain text.
Honored Contributor
Steven Schweda
Posts: 9,084
Registered: ‎02-23-2005
Message 20 of 20 (662 Views)

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

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation