mdlawler@bsu-cs.bsu.edu (Mike Lawler) (06/30/89)
I'm interrested in writing a program that will allow me to set, delete, or remove the volume label from a disk. I'd like to be able to include spaces in the label. I'd like to be able to place multiple labels for multiple drives on the command line. I want the program to be command line driven not menu driven. I'm aware of Norton's program, but a program over 10 K to do this simple task is absurd. If anyone has source code will you please mail it to me if it is small < 2 K bytes. If it is large send me an US mail address so I can send a disk for the program. I prefer source in C or assembler, but I'll take it in Pascal as well. Thanks. -- Mike Lawler UUCP: <backbones>!{iuvax,pur-ee}!bsu-cs!mdlawler ARPA: mdlawler@bsu-cs.bsu.edu
maa@nbires.nbi.com (Mark Armbrust) (06/30/89)
In article <8002bsu-cs.bsu.edu> mdlawler@bsu-cs.bsu.edu (Mike Lawler) writes: > > ... but a program over 10 K to do this simple task is absurd. Not if it's written in C; the runtime library makes even the simplest C program quite big. For example, using MSC 5.1 the following program generates a 7233 byte .EXE file: main(){ printf ("Hello world\n"); } Also, any program that contains help text grows very quickley. -- Mark Armbrust maa@nbires.nbi.com maa@nbires.UUCP
wtm@neoucom.UUCP (Bill Mayhew) (07/04/89)
The volume label is just another file name in the root directory with one of the attribute bits set to indicate that it is the volume ID. You could read the absolute disk block(s) that comprise the root directory and set the name with an assembly program, I suppose. The root directory is easy to find, as it always begins on the first disk block following the File Allocation Table (FAT). The size of the FAT, however, varies with the media type and size of the disk (if it is a hard disk). Hard disks of 10 megabytes or less get a FAT with 12 bit pointers to file clusters, while larger hard disks get 16 bit pointers beginning with DOS 3.1. Older DOSes have 12 bit FATs for all HDUs. Some brands like AT&T and [probably] Compaq likely don't follow the normal FAT size rules with respect to DOS version number. A truely generic disk label setting program is going to have to be smart enough to figure out various FAT configurations and possibly deal with DOSes from various vendors. The label is usually the third or fourth entry in the directory, but not always, especially if the disk was formatted and labeled later on .. or relabeled at some point. You might be able to use the DOS function calls of 17H or 56H to rename the disk, but I am not optimistic. I didn't feel like writing a C program at this instant to be sure, so the exercise is left to the reader for verification. I did try using the command.com internal REN command to change the label, and that gagged with a FILE NOT FOUND OR DUPLICATE NAME error under IBM DOS 3.3 and Tandy DOS 3.2. Here is function 17H AH=17H DS:DX=pointer to modified FCB The modified FCB has the usual information, but has the new name at DS:DX+11H. Any ?s in the new name wildcard the characters in the original name. On return: AL=0, it worked. AL=FFH, it failed. Here is function 56H AH=56H DS:DX=pointer to null terminated path and name of target ES:DI=pointer to new path and name Note that this function allows a file to be moved to another directory, but not anonter drive. On return: carry bit clear, it worked, if carrry is set, AX=error code Here is the structure of a directory entry: bytes 0-7: file name bytes 8-10: extension (of last 3 characters of volume ID) byte 11: attributes bit 0: read only bit 1: hidden bit 2: system file bit 3: volume id bit 4: directory bit 5: archive bit 6-7: reserved, must be 0 bytes 12-21 reserved bytes 22-23 file time 23 22 hhhhhmmm | mmmxxxxxx h=hour, m=minute, x=step of 2 seconds bytes 24-25 file date 25 26 yyyyyyym | mmmddddd y=year, m=minute, d=day bytes 26-27 number of starting disk cluster bytes 28-31 file size in bytes Hope this helps a bit, Bill
ralf@b.gp.cs.cmu.edu (Ralf Brown) (07/05/89)
In article <1676@neoucom.UUCP> wtm@neoucom.UUCP (Bill Mayhew) writes: } }The volume label is just another file name in the root directory }with one of the attribute bits set to indicate that it is the }volume ID. } }You could read the absolute disk block(s) that comprise the root }directory and set the name with an assembly program, I suppose. Not only is that more work, it can be dangerous if used on nonstandard disks. DOS calls suffice, as the following excerpt from running "INTERCEP" on DOS 3.10 "LABEL.COM" shows: 71DC:03EA 2111 Search for first file matching FCB at 71DC:0115 71DC:0573 2113 Delete file using FCB at 71DC:0142 71DC:0585 215b Create new file (name at 71DC:0103, attr. 08) 71DC:058D 213e Close file handle #0005 First, we search for the label using the FCB version of FINDFIRST/FINDNEXT, passing an extended FCB with the attribute mask set to find volume labels. Since this call will also find normal files, we have to loop until the file found actually has the volume label bit set. Next, the existing label is removed by doing a DELETE call using an extended FCB with the attribute mask set to volume label. Finally, we create a new file with the volume label attribute (bit 3==08h) set. INT 21h/AH=5Bh does not exist under DOS 2.x, so you would have to use the FCB file creation function. Since the create opens the file, we have to close it. }You might be able to use the DOS function calls of 17H or 56H to }rename the disk, but I am not optimistic. I didn't feel like I believe that these calls will fail. -- {harvard,uunet,ucbvax}!b.gp.cs.cmu.edu!ralf -=-=- AT&T: (412)268-3053 (school) ARPA: RALF@CS.CMU.EDU |"The optimist is the kind of person who believes a FIDO: Ralf Brown 1:129/46 | housefly is looking for a way out."--Geo.J.Nathan BITnet: RALF%CS.CMU.EDU@CMUCCVMA -=-=-=-=-=- DISCLAIMER? I claimed something?
stephen@ziebmef.uucp (Stephen M. Dunn) (07/11/89)
The volume label may or may not be at the start of the directory. It is placed just like any other filename is placed - in the first available filename entry in the directory. If you LABEL your disk immediately after formatting it, it will be the first thing (if you didn't FORMAT/S) or it will come immediately after the DOS files (if you did). You can use the extended FCB calls to read and set the volume label. Look it up in one of Peter Norton's books. -- ------------------------------------------------------------------------------- ! Stephen M. Dunn stephen@ziebmef.UUCP ! DISCLAIMER: Who'd ever ! ! My puppy died late last fall ! claim such dumb ideas? ! ! He's still rotting in the hall (O.E.) ! I sure as heck wouldn't !