03-30-2014 08:23 AM
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.
03-30-2014 11:40 AM
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.
03-30-2014 02:13 PM
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
04-01-2014 03:50 AM
>> >>> 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
2) ANALYZ/DISK... deal with results; Blow away the directory; re-ANALYZ/DISK; ... rename SYSLOST to desired directory.
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
04-02-2014 06:12 AM - edited 04-02-2014 06:16 AM
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.)
04-02-2014 06:44 AM
>> 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?
04-02-2014 08:24 AM
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?
04-02-2014 02:35 PM
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.
04-02-2014 08:56 PM
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?
04-02-2014 11:16 PM
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.
04-03-2014 12:40 PM
>> 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?
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.
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.
04-10-2014 08:09 AM
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.