tom@h-three.UUCP (tom) (05/18/88)
I am writing a C program which needs to open a DOS sub-directory for both reading and writing. I am using MS-C 5.1. Whenever I try to open a sub-directory (whether for reading only or read/write) it always fails with errno set to "permission denied". These sub-directories had just been created by myself and a stat() prior to the open() showed that I had read/write permission. Is this just not allowed?!?!? Are there any lib. functions that I am overlooking that are used to open/modify directories? Thanks in advance for any help. Tom Neal mcnc!rti!h-three!tom h-three Systems Corp. RTP, NC
Robert_C_Tellefson@cup.portal.com (05/19/88)
In order to treat directories as files, you need to open them using the old FCB (File Control Block) functions. Inconsistent and more complicated - but it does work. Robert 'Bob' Tellefson uucp: tellefson@cup.portal.com RCT Design Compuserve: 73417,545 Genie: R.TELLEFSON Voice: (408) 749-9826 USPS: 663 S. Bernardo #7 Sunnyvale, CA 94087
leisner@parcvax.Xerox.COM (Martin Leisner) (05/23/88)
In article <5631@cup.portal.com> Robert_C_Tellefson@cup.portal.com writes: >In order to treat directories as files, you need to open them using the >old FCB (File Control Block) functions. Inconsistent and more >complicated - but it does work. I've tried this and I couldn't get it to work on Dos 3.2. Can someone please post or send me some code which works if this is possible? My understanding is since directories have length = 0, reading it just returns end of file. Being able to read raw physical directories would be most useful to speeding up directory searching software. I've thought of writing software to work through fat tables to provide a raw directory searching interface, but never got around to it. leisner.henr@xerox.com leisner@parcvax.uucp
jon@chiron.UUCP (Jon L. Griffeth) (05/27/88)
In article <907@parcvax.Xerox.COM>, leisner@parcvax.Xerox.COM (Martin Leisner) writes: > In article <5631@cup.portal.com> Robert_C_Tellefson@cup.portal.com writes: > >In order to treat directories as files, you need to open them using the > >old FCB (File Control Block) functions. Inconsistent and more > >complicated - but it does work. > > I've tried this and I couldn't get it to work on Dos 3.2. > Can someone please post or send me some code which works if this is possible? I believe I remember reading that you CANNOT open a directory for I/O. The only way to access it is through the "find first" and "find next" system calls. I don't believe it wise to try and get around this.
Robert_C_Tellefson@cup.portal.com (05/29/88)
It seems I jumped to an invalid conclusion based on a reasonable assumption - easy to do when working with DOS. My company produces a hard disk manager and DOS shell called JOBS (an acronym for Job Organization and Backup System). We use FCB's to create/rename disk volume labels and to rename directories. These functions can not be accomplished using DOS file handles. Examples: We create a disk label by creating a file with a volume label attribute and then close it (using DOS functions 16h & 10h). We rename directories using FCB's and function 17h. These old FCB functions are the only way to perform these operations in a DOS compatible way, IE., directories can not be renamed using the Change Directory Entry function (56h). My error was to assume that DOS would support the other FCB functions as well. After these many years with DOS, I should know better than to assume anything. I tested the other function calls and it seems none of the other FCB functions can be applied to a directory entry with an attribute of 10h, the attribute given to subdirectories. Directories are just files allocated space one cluster at a time. With proper DOS support they could be read into memory and treated as ordinary data. As it is, the only way to accomplish this is to use interrupts 25h & 26h (absolute disk read/write) to get a directory's cluster assignment and then translate (using the File Allocation Table) to a physical cluster address followed by an absolute disk read of that cluster or possibly clusters. Int 25h & 26h access is used by a number of popular disk managers. I agree with Jon L. Griffeth when he says that is unwise to go around DOS to access directories directly. JOBS is 100% DOS & BIOS compatible and one benefit of that is its ability to be used on Unix partitions (under DOS-merge or the like) without modification. Try that with Qdos or other programs that use direct knowledge of a disk's layout! Information about JOBS' Sharware version and JOBS+ (not Shareware) is available upon request. Bob Tellefson uucp: tellefson@cup.portal.com RCT Design Compuserve: 73417,545 Genie: R.TELLEFSON Voice: (408) 749-9826 USPS: 663 S. Bernardo #7 Sunnyvale, CA 94087 ---------------------------------------------------------------------- I began with nothing and I still have most of it.
rlb@polari.UUCP (rlb) (05/31/88)
In article <6015@cup.portal.com>, Robert_C_Tellefson@cup.portal.com writes: > It seems I jumped to an invalid conclusion based on a reasonable > .... As it is, the only way to accomplish this is to use interrupts 25h & > 26h (absolute disk read/write) to get a directory's cluster assignment > and then translate (using the File Allocation Table) to a physical ... I vaguely remember good ol' Ray Duncan (before he became a MicroSoft thug :-) detailing how to do neato directory I/O with FCB functions. Try back issues of Dr. Dobbs (or are you saying this don't work for newer versions of DOS?). I seem to remember that the FCB "open" comes back with a file size of zero, so you have to do FAT calculations to fill in the correct size yerself, then you go do yer I/O and I can't remember whether there's a trick you have to do if you change the physical size of the directory "file". -Ron Burk