Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!husc6!cmcl2!brl-adm!adm!PEPRBV@cfaamp.bitnet From: PEPRBV@cfaamp.bitnet Newsgroups: comp.lang.c Subject: Re: Volume labels from MS-DOS function calls Message-ID: <8612@brl-adm.ARPA> Date: Sun, 2-Aug-87 19:00:44 EDT Article-I.D.: brl-adm.8612 Posted: Sun Aug 2 19:00:44 1987 Date-Received: Sun, 2-Aug-87 22:41:04 EDT Sender: news@brl-adm.ARPA Lines: 40 Tim Jones asks >I need an algorithm for reading/writing the volume label of a diskette >from MS-DOS 2.11. I have successfully read and written volume labels using a C program to issue DOS calls under MS-DOS 2.11. First a few warnings about DOS bugs (I don't know if these have been fixed under DOS 3.x): 1. You cannot use functions 0x4e and 0x4f to read volume labels. If the volume label is the first entry in the directory it will not be found, and if the label contains blanks it will not be read properly. 2. You should not use function 0x13 to erase a volume label. This will clobber the file access table entry for the first file on the disk, at least if this file is a hidden system file. I don't know how to remove a volume label with a DOS call (short of doing absolute disk writes to the directory), but you can use function 0x17 to rename. 3. You cannot create or rename volumes with illegal names, i.e. no lower case letters. To read a volume label, first use function 0x1a to set the DTA (disk transfer address) to point to an unopened (extended) FCB. In the FCB, set the flag to 0xff, the attribute to 0x08, the appropriate drive number, and file name to "???????????". Then use function 0x11 to search for a matching entry. Writing or renaming are similar; use function 0x16 or 0x17. It may also be a good idea to issue function 0x0d to flush disk buffers before doing anything, although the only case I have seen where this seemed necessary was with a defective disk cache utility, and it didn't help. If this isn't enough to get you going, I can send you my code for writing labels. However, the code I use for reading labels is a modification of source code which cam with my compiler, and thus is still covered by the license agreement. I figured out most of this by disassembling 2 volume labeling utilities and reading between the lines of my DOS manual. But it is spelled out on page 158 of Advanced MS-DOS by Ray Duncan and Microsoft Press