mtools: Porting mtools
1
1 6 Porting mtools to architectures which are not supported yet
1 *************************************************************
1
1 This chapter is only interesting for those who want to port mtools to
1 an architecture which is not yet supported. For most common systems,
1 default drives are already defined. If you want to add default drives
1 for a still unsupported system, run configuration.guess, to see which
1 identification autoconf uses for that system. This identification is of
1 the form cpu-vendor-os (for example sparc-sun-sunos). The cpu and the
1 OS parts are passed to the compiler as preprocessor flags. The OS
1 part is passed to the compiler in three forms.
1 1. The complete OS name, with dots replaced by underscores. SCO3.2v2
1 would yield sco3_2v2
1
1 2. The base OS name. SCO3.2v2 would yield Sco
1
1 3. The base OS name plus its major version. SCO3.2v2 would yield Sco3
1
1 All three versions are passed, if they are different.
1
1 To define the devices, use the entries for the systems that are
1 already present as templates. In general, they have the following form:
1
1 #if (defined (my_cpu) && defined(my_os))
1 #define predefined_devices
1 struct device devices[] = {
1 { "/dev/first_drive", 'drive_letter', drive_description},
1 ...
1 { "/dev/last_drive", 'drive_letter', drive_description}
1 }
1 #define INIT_NOOP
1 #endif
1
1 "/dev/first_drive" is the name of the device or image file
1 representing the drive. Drive_letter is a letter ranging from a to z
1 giving access to the drive. Drive_description describes the type of the
1 drive:
1 `ED312'
1 extra density (2.88M) 3 1/2 disk
1
1 `HD312'
1 high density 3 1/2 disk
1
1 `DD312'
1 double density 3 1/2 disk
1
1 `HD514'
1 high density 5 1/4 disk
1
1 `DD514'
1 double density 5 1/4 disk
1
1 `DDsmall'
1 8 sector double density 5 1/4 disk
1
1 `SS514'
1 single sided double density 5 1/4 disk
1
1 `SSsmall'
1 single sided 8 sector double density 5 1/4 disk
1
1 `GENFD'
1 generic floppy drive (12 bit FAT)
1
1 `GENHD'
1 generic hard disk (16 bit FAT)
1
1 `GEN'
1 generic device (all parameters match)
1
1 `ZIPJAZ(flags)'
1 generic ZIP drive using normal access. This uses partition 4.
1 `Flags' are any special flags to be passed to open.
1
1 `RZIPJAZ(flags)'
1 generic ZIP drive using raw SCSI access. This uses partition 4.
1 `Flags' are any special flags to be passed to open.
1
1 `REMOTE'
1 the remote drive used for floppyd. Unlike the other items, this
1 macro also includes the file name ($DISPLAY) and the drive letter
1 (X)
1
1 Entries may be described in more detail:
1 fat_bits,open_flags,cylinders,heads,sectors,DEF_ARG
1 or, if you need to describe an offset (file system doesn't start at
1 beginning of file system)
1 fat_bits, open_flags, cylinders, heads, sectors, offset, DEF_ARG0
1
1 `fat_bits'
1 is either 12, 16 or 0. 0 means that the device accepts both types
1 of FAT.
1
1 `open_flags'
1 may include flags such as O_NDELAY, or O_RDONLY, which might be
1 necessary to open the device. 0 means no special flags are needed.
1
1 `cylinders,heads,sectors'
1 describe the geometry of the disk. If cylinders is 0, the heads
1 and sectors parameters are ignored, and the drive accepts any
1 geometry.
1
1 `offset'
1 is used if the DOS file system doesn't begin at the start of the
1 device or image file. This is mostly useful for Atari Ram disks
1 (which contain their device driver at the beginning of the file)
1 or for DOS emulator images (which may represent a partitioned
1 device.
1
1 Definition of defaults in the devices file should only be done if
1 these same devices are found on a large number of hosts of this type.
1 In that case, could you also let me know about your new definitions, so
1 that I can include them into the next release. For purely local file, I
1 recommend that you use the `/etc/mtools.conf' and `~/.mtoolsrc'
1 configuration files.
1
1 However, the devices files also allows to supply geometry setting
1 routines. These are necessary if you want to access high capacity disks.
1
1 Two routines should be supplied:
1
1 1. Reading the current parameters
1 static inline int get_parameters(int fd, struct generic_floppy_struct *floppy)
1
1 This probes the current configured geometry, and return it in the
1 structure generic_floppy_struct (which must also be declared).
1 Fd is an open file descriptor for the device, and buf is an already
1 filled in stat structure, which may be useful. This routine
1 should return 1 if the probing fails, and 0 otherwise.
1
1 2. Setting new parameters
1 static inline int set_parameters(int fd, struct generic_floppy_struct *floppy)
1 struct stat *buf)
1 This configures the geometry contained in floppy on the file
1 descriptor fd. Buf is the result of a stat call (already filled
1 in). This should return 1 if the new geometry cannot be
1 configured, and 0 otherwise.
1
1 A certain number of preprocessor macros should also be supplied:
1
1 `TRACKS(floppy)'
1 refers to the track field in the floppy structure
1
1 `HEADS(floppy)'
1 refers to the heads field in the floppy structure
1
1 `SECTORS(floppy)'
1 refers to the sectors per track field in the floppy structure
1
1 `SECTORS_PER_DISK(floppy)'
1 refers to the sectors per disk field in the floppy structure (if
1 applicable, otherwise leave undefined)
1
1 `BLOCK_MAJOR'
1 major number of the floppy device, when viewed as a block device
1
1 `CHAR_MAJOR'
1 major number of the floppy device, when viewed as a character
1 device (a.k.a. "raw" device, used for fsck) (leave this undefined,
1 if your OS doesn't have raw devices)
1
1 For the truly high capacity formats (XDF, 2m, etc), there is no clean
1 and documented interface yet.
1