dos(C) 19 June 1992 dos(C) Name dos: doscat, doscp, dosdir, dosformat, dosmkdir, dosls, dosrm, dosrmdir - access to and manipulation of DOS files and DOS filesystems Syntax doscat [ -r | -c | -m ] file ... doscp [ -r | -c | -m ] file1 file2 doscp [ -r | -c | -m ] file ... directory dosdir [ -c ] directory ... dosformat [ -fqv ] drive dosls [ -c ] directory ... dosrm [ -c ] file ... dosmkdir [ -c ] directory ... dosrmdir [ -c ] directory ... Description The dos commands provide access to the files and directories on MS-DOS floppy disks and on DOS partitions of a hard disk. Note that in order to use these commands on a DOS 4.0 partition the DOS volume label must be non null and the DOS serial number must be set. In order to use these commands on a DOS 3 partition the DOS volume label must be non null. It is also possible to mount and access a DOS filesystem while operating from the UNIX System partition. The dos commands perform the following actions: doscat Copies one or more DOS files to the standard output. If -r is given, the files are copied without newline conversions. If -m is given, the files are copied with newline conversions (see ``Conversions'' below). If -c is given, execution halts immediately if a file on a mounted filesystem is encountered (see ``Accessing UNIX System File Systems with DOS Utili- ties'' below). doscp Copies files between a DOS disk and a UNIX System filesystem. If file1 and file2 are given, file1 is copied to file2. If a directory is given, one or more files are copied to that directory. If -r is given, the files are copied without new- line conversions. If -m is given, the files are copied with newline conversions (see ``Conversions'' below). If -c is given, execution halts immediately if a file on a mounted filesystem is encountered. dosdir Lists DOS files in the standard DOS style directory format. If -c is given, execution halts immediately if a file on a mounted filesystem is encountered. dosformat Creates a DOS 2.0 formatted diskette. The drive may be specified in either DOS drive convention, using the default file /etc/default/msdos, or using the UNIX System special file name. dosformat cannot be used to format a hard disk. The -f option suppresses the interactive feature. The -q (quiet) option is used to suppress information normally dis- played during dosformat. The -q option does not suppress the interactive feature. The -v option prompts the user for a volume label after the diskette has been formatted. The -c option causes execution to halt immediately if a file on a mounted filesystem is encountered. The maximum size of the volume label is 11 characters. dosls Lists DOS directories and files in a UNIX System format (see ls(C)) The -c option causes execution to halt at once if a file on a mounted filesystem is encountered. dosrm Removes files from a DOS disk. If -c is given, execution halts immediately if a file on a mounted filesystem is encountered. dosmkdir Creates a directory on a DOS disk. If -c is given, execution halts immediately if a file on a mounted filesystem is encountered. dosrmdir Deletes a directory from a DOS disk. The -c option causes execution to stop if a file on a mounted filesystem is encountered. The file and directory arguments for DOS files and directories have the form: device:name where device is a UNIX System pathname for the special device file con- taining the DOS disk, and name is a pathname to a file or directory on the DOS disk. The two components are separated by a colon (:). For example, the argument: /dev/fd0:/src/file.asm specifies the DOS file, file.asm, in the directory, /src, on the disk in the device file /dev/fd0. Note that slashes (and not backslashes) are used as filename separators for DOS pathnames. Arguments without a de- vice: are assumed to be UNIX System files. For convenience, the user configurable default file, /etc/default/msdos, can define DOS drive names to be used in place of the special device file pathnames. It can contain lines with the following format: A=/dev/fd0 C=/dev/dsk/0sC D=/dev/dsk/0sD K=/dev/dsk/1sC The drive letter ``A'' may be used in place of special device file path- name /dev/fd0 when referencing DOS files (see ``Examples'' below). The drive letters ``C'' or ``K'' refer to the DOS partition on the first or second hard disk, and ``D'' refers to a logical drive in the extended partition on the first hard drive. The commands operate on the following kinds of disks: DOS partitions on a hard disk 5 1/4 inch DOS 3 1/2 inch DOS 8, 9, 15, or 18 sectors per track 40 or 80 tracks per side 1 or 2 sides DOS versions 1.0, 2.0, 3.0, 3.3 or 4.0 Conversions In the case of doscp, certain conversions are performed when copying a UNIX System file. Filenames with a basename longer than eight characters are truncated. Filename extensions (the part of the name following separating period) longer than three characters are truncated. For exam- ple, the file 123456789.12345 becomes 12345678.123. A message informs the user that the name has been changed and the altered name is dis- played. Filenames containing illegal DOS characters are stripped when writing to the MS-DOS format. A message informs the user that characters have been removed and displays the name as written. All DOS text files use a carriage-return/linefeed combination, CR-LF, to indicate a newline. UNIX System files use a single newline LF character. When the doscat and doscp commands transfer DOS text files to the UNIX System filesystem, they automatically strip the CR. When text files are transferred to DOS, the commands insert a CR before each LF character. Under some circumstances the automatic newline conversions do not occur. The -m option may be used to ensure the newline conversion. The -r option can be used to override the automatic conversion and force the command to perform a true byte copy regardless of file type. Examples Note that the forward slash character (/) must be used as the directory separator character when dealing with DOS filesystems under UNIX. This is at variance with the usual DOS practice of using the backslash (\) char- acter as the directory separator character. For example, doscat /dev/fd0:/docs/memo.txt is used instead of the DOS path syntax, which would be doscat a:\docs\memo.txt Other examples of the dos(C) commands are: doscat /tmp/f1 /tmp/f2 /dev/fd0:/src/file.asm doscp /tmp/myfile.txt /dev/fd0:/docs/memo.txt doscp /tmp/f1 /tmp/f2 /dev/fd0:/mydir dosdir /dev/fd0:/src dosdir A:/src A:/dev dosformat /dev/fd0 dosls /dev/fd0:/src dosls B: dosrm /dev/fd0:/docs/memo.txt dosrm A:/docs/memo1.txt dosmkdir /dev/fd0:/usr/docs dosrmdir /dev/fd0:/usr/docs Accessing DOS filesystems from the UNIX System partition The ability to mount DOS filesystems is an extension of the DOS utilities documented here. There are several limitations within the DOS directory structure which make this a difficult task. In short, the DOS filesystem does not associate as much information with each file as the UNIX System filesystem does. Therefore, allowances and assumptions have to be made for information that would be present under the UNIX System but that does not exist under DOS. The DOS directory structure contains the following information: + Filename: up to 8 characters with 3 character extension (foo.bat) + File Attribute: read-only/read-write, hidden/visible file, system/normal file, Volume name/normal file name, subdirectory/normal file, archive/modified bit + Time of last modification + Date of last modification + Starting point (reference through FAT) + File size in bytes Using this information, it is converted to a UNIX System inode. There are some UNIX System provisions which cannot be carried over, because the filesystem must remain sane under DOS. + Any date in the UNIX System inode table for the DOS filesystem is the same as the modification date (ctime = atime = mtime). + The only types of nodes allowed in the DOS filesystem are directories and normal files. Pipes, semaphores, and special device files do not exist because they do not have a counterpart under DOS. + The permissions are 0777 for readable/writable files and 0555 for read only files. If a user can access the filesystem, the user will be limited by the permissions available under the DOS directory struc- ture. This permission is read-only or read write. When creating a file, the creator's umask/mode is examined. The creation mode is based on the owner write bit. + The GID/UID for all files on the DOS filesystem is the same as the mount point. The mount point will maintain the necessary security. If a user can get into the mount point, then the user has the same access as the owner. + There is only one link for each file under the DOS filesystem. ``.'' and ``..'' are a special case and are not links. + On every change of the modification time (which on a UNIX system would change atime, ctime, mtime) the DOS archive bit is set. + Following DOS filesystem requirements, all blocks previous to a writ- ten block are allocated before the original block is written. This differs from UNIX systems where the program may seek out beyond the end of a file and write a block. UNIX systems do not necessarily write blocks which have been skipped over. + If a program does not use the directory(S) system calls, but opens the directory in the DOS filesystem as a file, the program should see the DOS directory structure as it really exists. By using the directory system calls, the filesystem switch code will put together a UNIX Sys- tem style directory entry. + File contents are not mapped from the DOS filesystem. The file appears exactly as it is under DOS. For example, \r\n combinations are left as \r\n and not mapped to just \n. The file and directory names are mapped to uppercase. Accessing UNIX System File Systems with DOS Utilities If an attempt is made to access a mounted UNIX System filesystem using the DOS utilities the message command: devicename is mounted is printed on stderr and the attempt fails. If possible, the command continues to operate on the remaining parameters and returns a value of 1. Upon normal completion, these commands return a value of 0. If the -c option is used, execution of the command halts immediately upon encountering a file in a mounted filesystem. DOS file conversion The utilities xtod(C) and dtox(C) can be used to convert the EOL sequences used to and from DOS, respectively. Files /etc/default/msdos Default information /dev/fd* Floppy disk devices /dev/dsk/ Hard disk devices See also assign(C), dtox(C), dtype(C), mkfs(ADM), xtod(C) ``MS-DOS and other DOS operating systems'' in the System Administrator's Guide Notes Using the DOS utilities, it is not possible to refer to DOS files with wild card specifications. The programs mentioned above cooperate among themselves so no two programs will access the same DOS disk. Only one process will access a given DOS disk at any time, while other processes wait. If a process has to wait too long, it displays the error message, ``can't seize a device'', and exits with an exit code of 1. You cannot use the dosformat command to format device A: because it is aliased to /dev/install, which cannot be formatted. Use /dev/rfd0/ instead. The Development System supports the creation of DOS executable files, using cc(CP). Refer to the C User's Guide and C Library Guide for more information on using your UNIX system to create programs suitable for DOS systems. All of the DOS utilities leave temporary files in /tmp. These files are automatically removed when the system is rebooted. They can also be man- ually removed. Value added doscat, doscp, dosdir, dosformat, dosls, dosmkdir, dosrm and dosrmdir are extensions of AT&T System V provided by The Santa Cruz Operation, Inc.