1 /* Copyright 1986-1992 Emmet P. Gray.
2 * Copyright 1996-2003,2006,2007,2009 Alain Knaff.
3 * This file is part of mtools.
5 * Mtools is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * Mtools is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with Mtools. If not, see <http://www.gnu.org/licenses/>.
20 * Device tables. See the Configure file for a complete description.
24 #include "sysincludes.h"
31 #define DEF_ARG1(x) (x), 0x2,0,(char *)0, 0, 0
32 #define DEF_ARG0(x) 0,DEF_ARG1(x)
34 #define MDEF_ARG 0L,DEF_ARG0(MFORMAT_ONLY_FLAG)
35 #define FDEF_ARG 0L,DEF_ARG0(0)
36 #define VOLD_DEF_ARG 0L,DEF_ARG0(VOLD_FLAG|MFORMAT_ONLY_FLAG)
38 #define MED312 12,0,80,2,36,0,MDEF_ARG /* 3 1/2 extra density */
39 #define MHD312 12,0,80,2,18,0,MDEF_ARG /* 3 1/2 high density */
40 #define MDD312 12,0,80,2, 9,0,MDEF_ARG /* 3 1/2 double density */
41 #define MHD514 12,0,80,2,15,0,MDEF_ARG /* 5 1/4 high density */
42 #define MDD514 12,0,40,2, 9,0,MDEF_ARG /* 5 1/4 double density (360k) */
43 #define MSS514 12,0,40,1, 9,0,MDEF_ARG /* 5 1/4 single sided DD, (180k) */
44 #define MDDsmall 12,0,40,2, 8,0,MDEF_ARG /* 5 1/4 double density (320k) */
45 #define MSSsmall 12,0,40,1, 8,0,MDEF_ARG /* 5 1/4 single sided DD, (160k) */
47 #define FED312 12,0,80,2,36,0,FDEF_ARG /* 3 1/2 extra density */
48 #define FHD312 12,0,80,2,18,0,FDEF_ARG /* 3 1/2 high density */
49 #define FDD312 12,0,80,2, 9,0,FDEF_ARG /* 3 1/2 double density */
50 #define FHD514 12,0,80,2,15,0,FDEF_ARG /* 5 1/4 high density */
51 #define FDD514 12,0,40,2, 9,0,FDEF_ARG /* 5 1/4 double density (360k) */
52 #define FSS514 12,0,40,1, 9,0,FDEF_ARG /* 5 1/4 single sided DD, (180k) */
53 #define FDDsmall 12,0,40,2, 8,0,FDEF_ARG /* 5 1/4 double density (320k) */
54 #define FSSsmall 12,0,40,1, 8,0,FDEF_ARG /* 5 1/4 single sided DD, (160k) */
56 #define GENHD 16,0, 0,0, 0,0,MDEF_ARG /* Generic 16 bit FAT fs */
57 #define GENFD 12,0,80,2,18,0,MDEF_ARG /* Generic 12 bit FAT fs */
58 #define VOLDFD 12,0,80,2,18,0,VOLD_DEF_ARG /* Generic 12 bit FAT fs with vold */
59 #define GEN 0,0, 0,0, 0,0,MDEF_ARG /* Generic fs of any FAT bits */
61 #define ZIPJAZ(x,c,h,s,y) 16,(x),(c),(h),(s),(s),0L, 4, \
62 DEF_ARG1((y)|MFORMAT_ONLY_FLAG) /* Jaz disks */
64 #define JAZ(x) ZIPJAZ(x,1021, 64, 32, 0)
65 #define RJAZ(x) ZIPJAZ(x,1021, 64, 32, SCSI_FLAG|PRIV_FLAG)
66 #define ZIP(x) ZIPJAZ(x,96, 64, 32, 0)
67 #define RZIP(x) ZIPJAZ(x,96, 64, 32, SCSI_FLAG|PRIV_FLAG)
69 #define REMOTE {"$DISPLAY", 'X', 0,0, 0,0, 0,0,0L, DEF_ARG0(FLOPPYD_FLAG)}
73 #if defined(INIT_GENERIC) || defined(INIT_NOOP)
74 static int compare_geom(struct device *dev, struct device *orig_dev)
76 if(IS_MFORMAT_ONLY(orig_dev))
77 return 0; /* geometry only for mformatting ==> ok */
78 if(!orig_dev || !orig_dev->tracks || !dev || !dev->tracks)
79 return 0; /* no original device. This is ok */
80 return(orig_dev->tracks != dev->tracks ||
81 orig_dev->heads != dev->heads ||
82 orig_dev->sectors != dev->sectors);
86 #define devices const_devices
90 #define predefined_devices
91 struct device devices[] = {
92 {"\\\\\\\\.\\\\A:", 'A', GENFD },
98 #define predefined_devices
99 struct device devices[] = {
100 {"/dev/floppy0", 'A', GENFD },
101 {"/dev/rdsk/c104d0s31", 'J', JAZ(O_EXCL) },
102 {"/dev/rdsk/c105d0s31", 'Z', ZIP(O_EXCL) },
109 #define predefined_devices
110 struct device devices[] = {
111 {"/dev/fd1440.0", 'A', MHD312 },
118 #define predefined_devices
119 struct device devices[] = {
120 {"/dev/disk/floppy/raw", 'A', MHD312 },
128 #define predefined_devices
129 struct device devices[] = {
131 /* hpux10 uses different device names according to Frank Maritato
132 * <frank@math.hmc.edu> */
133 {"/dev/floppy/c0t0d0", 'A', MHD312 },
134 {"/dev/floppy/c0t0d1", 'B', MHD312 }, /* guessed by me */
135 {"/dev/rscsi", 'C', GENHD }, /* guessed by me */
137 /* Use rfloppy, according to Simao Campos <simao@iris.ctd.comsat.com> */
138 {"/dev/rfloppy/c201d0s0", 'A', FHD312 },
139 {"/dev/rfloppy/c20Ad0s0", 'A', FHD312 },
140 {"/dev/rfloppy/c201d1s0", 'B', FHD312 },
141 {"/dev/rfloppy/c20Ad1s0", 'B', FHD312 },
142 {"/dev/rscsi", 'C', GENHD },
144 {"/dev/rdsk/c201d4", 'J', RJAZ(O_EXCL) },
145 {"/dev/rdsk/c201d4s0", 'J', RJAZ(O_EXCL) },
146 {"/dev/rdsk/c201d5", 'Z', RZIP(O_EXCL) },
147 {"/dev/rdsk/c201d5s0", 'Z', RZIP(O_EXCL) },
151 #ifdef HAVE_SYS_FLOPPY
152 /* geometry setting ioctl's contributed by Paolo Zeppegno
153 * <paolo@to.sem.it>, may cause "Not a typewriter" messages on other
154 * versions according to support@vital.com */
156 #include <sys/floppy.h>
159 struct generic_floppy_struct
161 struct floppy_geometry fg;
164 #define BLOCK_MAJOR 24
165 #define CHAR_MAJOR 112
167 static inline int get_parameters(int fd, struct generic_floppy_struct *floppy)
169 if (ioctl(fd, FLOPPY_GET_GEOMETRY, &(floppy->fg)) != 0) {
170 perror("FLOPPY_GET_GEOMETRY");
177 #define TRACKS(floppy) floppy.fg.tracks
178 #define HEADS(floppy) floppy.fg.heads
179 #define SECTORS(floppy) floppy.fg.sectors
180 #define FD_SECTSIZE(floppy) floppy.fg.sector_size
181 #define FD_SET_SECTSIZE(floppy,v) { floppy.fg.sector_size = v; }
183 static inline int set_parameters(int fd, struct generic_floppy_struct *floppy,
186 if (ioctl(fd, FLOPPY_SET_GEOMETRY, &(floppy->fg)) != 0) {
199 #if (defined(OS_sinix) || defined(VENDOR_sni) || defined(SNI))
200 #define predefined_devices
201 struct device devices[] = {
202 #ifdef CPU_mips /* for Siemens Nixdorf's SINIX-N/O (mips) 5.4x SVR4 */
203 { "/dev/at/flp/f0t", 'A', FHD312},
204 { "/dev/fd0", 'A', GENFD},
206 #ifdef CPU_i386 /* for Siemens Nixdorf's SINIX-D/L (intel) 5.4x SVR4 */
207 { "/dev/fd0135ds18", 'A', FHD312},
208 { "/dev/fd0135ds9", 'A', FDD312},
209 { "/dev/fd0", 'A', GENFD},
210 { "/dev/fd1135ds15", 'B', FHD514},
211 { "/dev/fd1135ds9", 'B', FDD514},
212 { "/dev/fd1", 'B', GENFD},
213 #endif /* CPU_i386 */
220 #define predefined_devices
221 struct device devices[] = {
222 {"/dev/rfd0a", 'A', GENFD}, /* guessed */
223 {"/dev/rfd0c", 'A', GENFD}, /* guessed */
231 #define predefined_devices
232 #if (defined(OS_isc2) && defined(OLDSTUFF))
233 struct device devices[] = {
234 {"/dev/rdsk/f0d9dt", 'A', FDD514},
235 {"/dev/rdsk/f0q15dt", 'A', FHD514},
236 {"/dev/rdsk/f0d8dt", 'A', FDDsmall},
237 {"/dev/rdsk/f13ht", 'B', FHD312},
238 {"/dev/rdsk/f13dt", 'B', FDD312},
239 {"/dev/rdsk/0p1", 'C', GENHD},
240 {"/usr/vpix/defaults/C:",'D',12, 0, 0, 0, 0,8704L,DEF_ARG0},
241 {"$HOME/vpix/C:", 'E', 12, 0, 0, 0, 0,8704L,MDEF_ARG},
245 /* contributed by larry.jones@sdrc.com (Larry Jones) */
246 struct device devices[] = {
247 {"/dev/rfd0", 'A', GEN},
248 {"/dev/rfd1", 'B', GEN},
249 {"/dev/rdsk/0p1", 'C', GEN},
250 {"/usr/vpix/defaults/C:",'D', GEN, 1},
251 {"$HOME/vpix/C:", 'E', GEN, 1},
255 #include <sys/vtoc.h>
256 #include <sys/sysmacros.h>
258 #define BLOCK_MAJOR 1
260 #define generic_floppy_struct disk_parms
261 int ioctl(int, int, void *);
263 static int get_parameters(int fd, struct generic_floppy_struct *floppy)
268 off = lseek(fd, 0, SEEK_CUR);
270 perror("device seek 1");
274 /* need to read at least 1 sector to get correct info */
275 read(fd, buf, sizeof buf);
276 if(lseek(fd, 0, SEEK_SET) < 0) {
277 perror("device seek 2");
281 return ioctl(fd, V_GETPARMS, floppy);
284 #define TRACKS(floppy) (floppy).dp_cyls
285 #define HEADS(floppy) (floppy).dp_heads
286 #define SECTORS(floppy) (floppy).dp_sectors
287 #define FD_SECTSIZE(floppy) (floppy).dp_secsiz
288 #define FD_SET_SECTSIZE(floppy,v) { (floppy).dp_secsiz = (v); }
290 static int set_parameters(int fd, struct generic_floppy_struct *floppy,
301 #define predefined_devices
302 struct device devices[] = {
303 {"/dev/rfd0", 'A', GENFD},
306 #endif /* CPU_i370 */
309 /* modified by Federico Bianchi */
310 #define predefined_devices
311 struct device devices[] = {
312 {"/dev/fd0",'A',GENFD},
319 /* modified by Chris Samuel <chris@rivers.dra.hmg.gb> */
320 #define predefined_devices
321 struct device devices[] = {
322 {"/dev/fd0c",'A',GENFD},
330 #ifdef USING_NEW_VOLD
332 char *alias_name = NULL;
334 extern char *media_oldaliases(char *);
335 extern char *media_findname(char *);
337 char *getVoldName(struct device *dev, char *name)
341 if(!SHOULD_USE_VOLD(dev))
345 * Solaris specific routines to use the volume management
346 * daemon and libraries to get the correct device name...
348 rname = media_findname(name);
349 #ifdef HAVE_MEDIA_OLDALIASES
351 if ((alias_name = media_oldaliases(name)) != NULL)
352 rname = media_findname(alias_name);
357 "No such volume or no media in device: %s.\n",
363 #endif /* USING_NEW_VOLD */
365 #define predefined_devices
366 struct device devices[] = {
367 #ifdef USING_NEW_VOLD
368 {"floppy", 'A', VOLDFD },
370 {"/vol/dev/aliases/floppy0", 'A', GENFD},
371 {"/dev/rdiskette", 'B', GENFD},
372 #else /* ! USING_VOLD */
373 {"/dev/rdiskette", 'A', GENFD},
374 {"/vol/dev/aliases/floppy0", 'B', GENFD},
375 #endif /* USING_VOLD */
376 {"/dev/rdsk/c0t4d0s2", 'J', RJAZ(O_NDELAY)},
377 {"/dev/rdsk/c0t5d0s2", 'Z', RZIP(O_NDELAY)},
384 * Ofer Licht <ofer@stat.Berkeley.EDU>, May 14, 1997.
389 #include <sys/fdio.h>
390 #include <sys/mkdev.h> /* for major() */
392 struct generic_floppy_struct
394 struct fd_char fdchar;
397 #define BLOCK_MAJOR 36
398 #define CHAR_MAJOR 36
400 static inline int get_parameters(int fd, struct generic_floppy_struct *floppy)
402 if (ioctl(fd, FDIOGCHAR, &(floppy->fdchar)) != 0) {
404 ioctl(fd, FDEJECT, NULL);
410 #define TRACKS(floppy) floppy.fdchar.fdc_ncyl
411 #define HEADS(floppy) floppy.fdchar.fdc_nhead
412 #define SECTORS(floppy) floppy.fdchar.fdc_secptrack
413 /* SECTORS_PER_DISK(floppy) not used */
414 #define FD_SECTSIZE(floppy) floppy.fdchar.fdc_sec_size
415 #define FD_SET_SECTSIZE(floppy,v) { floppy.fdchar.fdc_sec_size = v; }
417 static inline int set_parameters(int fd, struct generic_floppy_struct *floppy,
420 if (ioctl(fd, FDIOSCHAR, &(floppy->fdchar)) != 0) {
421 ioctl(fd, FDEJECT, NULL);
431 #define predefined_devices
432 struct device devices[] = {
433 {"/dev/rfdl0c", 'A', FDD312},
434 {"/dev/rfd0c", 'A', FHD312},
437 #endif /* OS_sunos3 */
440 #define predefined_devices
441 struct device devices[] = {
442 {"/dev/fd096ds15", 'A', FHD514},
443 {"/dev/fd048ds9", 'A', FDD514},
444 {"/dev/fd1135ds18", 'B', FHD312},
445 {"/dev/fd1135ds9", 'B', FDD312},
446 {"/dev/hd0d", 'C', GENHD},
449 #endif /* OS_xenix */
452 #define predefined_devices
453 struct device devices[] = {
454 { "/dev/fd0135ds18", 'A', FHD312},
455 { "/dev/fd0135ds9", 'A', FDD312},
456 { "/dev/fd0", 'A', GENFD},
457 { "/dev/fd1135ds15", 'B', FHD514},
458 { "/dev/fd1135ds9", 'B', FDD514},
459 { "/dev/fd1", 'B', GENFD},
460 { "/dev/hd0d", 'C', GENHD},
467 #define predefined_devices
468 struct device devices[] = {
469 { "/dev/rdsk/fds0d2.3.5hi", 'A', FHD312},
470 { "/dev/rdsk/fds0d2.3.5", 'A', FDD312},
471 { "/dev/rdsk/fds0d2.96", 'A', FHD514},
472 {"/dev/rdsk/fds0d2.48", 'A', FDD514},
479 #include <sys/ioctl.h>
480 #include <sun/dkio.h>
482 #define predefined_devices
483 struct device devices[] = {
484 {"/dev/rfd0c", 'A', GENFD},
485 {"/dev/rsd4c", 'J', RJAZ(O_NDELAY)},
486 {"/dev/rsd5c", 'Z', RZIP(O_NDELAY)},
491 * Stuffing back the floppy parameters into the driver allows for gems
492 * like 10 sector or single sided floppies from Atari ST systems.
494 * Martin Schulz, Universite de Moncton, N.B., Canada, March 11, 1991.
499 struct generic_floppy_struct
501 struct fdk_char dkbuf;
505 #define BLOCK_MAJOR 16
506 #define CHAR_MAJOR 54
508 static inline int get_parameters(int fd, struct generic_floppy_struct *floppy)
510 if (ioctl(fd, DKIOCGPART, &(floppy->dkmap)) != 0) {
511 perror("DKIOCGPART");
512 ioctl(fd, FDKEJECT, NULL);
516 if (ioctl(fd, FDKIOGCHAR, &( floppy->dkbuf)) != 0) {
518 ioctl(fd, FDKEJECT, NULL);
524 #define TRACKS(floppy) floppy.dkbuf.ncyl
525 #define HEADS(floppy) floppy.dkbuf.nhead
526 #define SECTORS(floppy) floppy.dkbuf.secptrack
527 #define SECTORS_PER_DISK(floppy) floppy.dkmap.dkl_nblk
528 #define FD_SECTSIZE(floppy) floppy.dkbuf.sec_size
529 #define FD_SET_SECTSIZE(floppy,v) { floppy.dkbuf.sec_size = v; }
531 static inline int set_parameters(int fd, struct generic_floppy_struct *floppy,
534 if (ioctl(fd, FDKIOSCHAR, &(floppy->dkbuf)) != 0) {
535 ioctl(fd, FDKEJECT, NULL);
540 if (ioctl(fd, ( unsigned int) DKIOCSPART, &(floppy->dkmap)) != 0) {
541 ioctl(fd, FDKEJECT, NULL);
548 #endif /* sparc && sunos */
552 #define predefined_devices
553 struct device devices[] = {
554 /* [block device]: DPX1000 has /dev/flbm60, DPX2 has /dev/easyfb */
555 {"/dev/flbm60", 'A', MHD514};
556 {"/dev/flbm60", 'B', MDD514},
557 {"/dev/flbm60", 'C', MDDsmall},
558 {"/dev/flbm60", 'D', MSS},
559 {"/dev/flbm60", 'E', MSSsmall},
565 #define predefined_devices
566 struct device devices[] = {
567 /* [block device]: DPX1000 has /dev/flbm60, DPX2 has /dev/easyfb */
568 {"/dev/easyfb", 'A', MHD514},
569 {"/dev/easyfb", 'B', MDD514},
570 {"/dev/easyfb", 'C', MDDsmall},
571 {"/dev/easyfb", 'D', MSS},
572 {"/dev/easyfb", 'E', MSSsmall},
579 const char *error_msg[22]={
580 "Missing Data Address Mark",
582 "Scan not satisfied",
585 "CRC error in data field",
586 "Control Mark = deleted",
589 "Missing Address Mark",
591 "No Data - unreadable",
594 "CRC error in data or address",
602 "Equipment check error",
606 static __inline__ void print_message(RawRequest_t *raw_cmd,const char *message)
613 for (i=0; i< raw_cmd->cmd_count; i++)
614 fprintf(stderr,"%2.2x ",
615 (int)raw_cmd->cmd[i] );
616 fprintf(stderr,"\n");
617 for (i=0; i< raw_cmd->reply_count; i++)
618 fprintf(stderr,"%2.2x ",
619 (int)raw_cmd->reply[i] );
620 fprintf(stderr,"\n");
621 code = (raw_cmd->reply[0] <<16) +
622 (raw_cmd->reply[1] << 8) +
625 if ((code & (1 << i)) && error_msg[i])
626 fprintf(stderr,"%s\n",
633 * -1: Fatal error, don't bother retrying.
635 * 1: minor error, retry
638 int send_one_cmd(int fd, RawRequest_t *raw_cmd, const char *message)
640 if (ioctl( fd, FDRAWCMD, raw_cmd) >= 0) {
641 if (raw_cmd->reply_count < 7) {
642 fprintf(stderr,"Short reply from FDC\n");
650 fprintf(stderr, "FDC busy, sleeping for a second\n");
654 fprintf(stderr,"resetting controller\n");
655 if(ioctl(fd, FDRESET, 2) < 0){
671 * 1: more raw commands follow
674 int analyze_one_reply(RawRequest_t *raw_cmd, int *bytes, int do_print)
677 if(raw_cmd->reply_count == 7) {
680 if (raw_cmd->reply[3] != raw_cmd->cmd[2]) {
681 /* end of cylinder */
682 end = raw_cmd->cmd[6] + 1;
684 end = raw_cmd->reply[5];
687 *bytes = end - raw_cmd->cmd[4];
688 /* FIXME: over/under run */
689 *bytes = *bytes << (7 + raw_cmd->cmd[5]);
693 switch(raw_cmd->reply[0] & 0xc0){
695 if ((raw_cmd->reply[0] & 0x38) == 0 &&
696 (raw_cmd->reply[1]) == 0x80 &&
697 (raw_cmd->reply[2]) == 0) {
698 *bytes += 1 << (7 + raw_cmd->cmd[5]);
702 if ( raw_cmd->reply[1] & ST1_WP ){
705 "This disk is write protected\n");
708 if(!*bytes && do_print)
709 print_message(raw_cmd, "");
714 "invalid command given\n");
719 "abnormal termination caused by polling\n");
725 if(raw_cmd->flags & FD_RAW_MORE)
731 #define predefined_devices
732 struct device devices[] = {
733 {"/dev/fd0", 'A', 0, 0, 80,2, 18,0, MDEF_ARG},
734 {"/dev/fd1", 'B', 0, 0, 0,0, 0,0, FDEF_ARG},
735 /* we assume that the Zip or Jaz drive is the second on the SCSI bus */
736 {"/dev/sdb4",'J', GENHD },
737 {"/dev/sdb4",'Z', GENHD },
738 /* {"/dev/sda4",'D', GENHD },*/
743 * Stuffing back the floppy parameters into the driver allows for gems
744 * like 21 sector or single sided floppies from Atari ST systems.
746 * Alain Knaff, Université Joseph Fourier, France, November 12, 1993.
751 #define generic_floppy_struct floppy_struct
752 #define BLOCK_MAJOR 2
753 #define SECTORS(floppy) floppy.sect
754 #define TRACKS(floppy) floppy.track
755 #define HEADS(floppy) floppy.head
756 #define SECTORS_PER_DISK(floppy) floppy.size
757 #define STRETCH(floppy) floppy.stretch
758 #define USE_2M(floppy) ((floppy.rate & FD_2M) ? 0xff : 0x80 )
759 #define SSIZE(floppy) ((((floppy.rate & 0x38) >> 3 ) + 2) % 8)
761 static __inline__ void set_2m(struct floppy_struct *floppy, int value)
767 floppy->rate = (floppy->rate & ~FD_2M) | value;
769 #define SET_2M set_2m
771 static __inline__ void set_ssize(struct floppy_struct *floppy, int value)
773 value = (( (value & 7) + 6 ) % 8) << 3;
775 floppy->rate = (floppy->rate & ~0x38) | value;
778 #define SET_SSIZE set_ssize
780 static __inline__ int set_parameters(int fd, struct floppy_struct *floppy,
783 if ( ( MINOR(buf->st_rdev ) & 0x7f ) > 3 )
786 return ioctl(fd, FDSETPRM, floppy);
789 static __inline__ int get_parameters(int fd, struct floppy_struct *floppy)
791 return ioctl(fd, FDGETPRM, floppy);
799 #define predefined_devices
800 struct device devices[] = {
809 /*** /jes -- for D.O.S. 486 BL DX2/80 ***/
810 /*** Jean-Marc Zucconi <jmz@FreeBSD.org> 2001/03/30 ***/
812 #define predefined_devices
813 struct device devices[] = {
814 {"/dev/fd0.1440", 'A', FHD312},
815 {"/dev/fd0.720", 'A', FDD312},
816 {"/dev/fd1.1200", 'B', MHD514},
817 {"/dev/sd0s1", 'C', GENHD},
820 #endif /* __FreeBSD__ */
822 /*** /jes -- for ALR 486 DX4/100 ***/
823 #if defined(OS_netbsd) || defined(OS_netbsdelf)
824 #define predefined_devices
825 struct device devices[] = {
826 {"/dev/rfd0a", 'A', FHD312},
827 {"/dev/rfd0f", 'A', FDD312},
828 {"/dev/rfd0f", 'S', MDD312},
829 {"/dev/rfd1a", 'B', FHD514},
830 {"/dev/rfd1d", 'B', FDD514},
831 {"/dev/rfd1d", 'T', MDD514},
832 {"/dev/rwd0d", 'C', 16, 0, 0, 0, 0, 0, 63L*512L, DEF_ARG0(0)},
835 #endif /* OS_NetBSD */
837 /* fgsch@openbsd.org 2000/05/19 */
838 #if defined(OS_openbsd)
839 #define predefined_devices
840 struct device devices[] = {
841 {"/dev/rfd0Bc", 'A', FHD312},
842 {"/dev/rfd0Fc", 'A', FDD312},
843 {"/dev/rfd1Cc", 'B', FHD514},
844 {"/dev/rfd1Dc", 'B', FDD514},
845 {"/dev/rwd0c", 'C', 16, 0, 0, 0, 0, 0, 63L*512L, DEF_ARG0(0)},
848 #endif /* OS_openbsd */
852 #if (!defined(predefined_devices) && defined (CPU_m68000) && defined (OS_sysv))
853 #include <sys/gdioctl.h>
855 #define predefined_devices
856 struct device devices[] = {
857 {"/dev/rfp020", 'A', 12,O_NDELAY,40,2, 9, 0, MDEF_ARG},
858 {"/usr/bin/DOS/dvd000", 'C', GENFD},
863 int init_geom(int fd, struct device *dev, struct device *orig_dev,
864 struct MT_STAT *statbuf)
868 if (ioctl(fd, GDGETA, &gdbuf) == -1) {
869 ioctl(fd, GDDISMNT, &gdbuf);
872 if((dev->use_2m & 0x7f) || (dev->ssize & 0x7f))
875 SET_INT(gdbuf.params.cyls,dev->ntracks);
876 SET_INT(gdbuf.params.heads,dev->nheads);
877 SET_INT(gdbuf.params.psectrk,dev->nsect);
878 dev->ntracks = gdbuf.params.cyls;
879 dev->nheads = gdbuf.params.heads;
880 dev->nsect = gdbuf.params.psectrk;
884 gdbuf.params.pseccyl = gdbuf.params.psectrk * gdbuf.params.heads;
885 gdbuf.params.flags = 1; /* disk type flag */
886 gdbuf.params.step = 0; /* step rate for controller */
887 gdbuf.params.sectorsz = 512; /* sector size */
889 if (ioctl(fd, GDSETA, &gdbuf) < 0) {
890 ioctl(fd, GDDISMNT, &gdbuf);
895 #endif /* (defined (m68000) && defined (sysv))*/
900 #include <sys/fcntl.h>
901 #define predefined_devices
902 struct device devices[] = {
903 {"/dev/rfd0c", 'A', GENFD},
911 #ifndef predefined_devices
912 #define predefined_devices
913 struct device devices[] = {
914 {"/dev/fd0a", 'A', MHD312 } };
921 #define predefined_devices
922 struct device devices[] = {
924 {"/dev/rfd0b", 'A', MED312 },
927 {"/dev/rfd0b", 'A', MHD312 },
934 #if (!defined(predefined_devices) && defined(OS_sysv4))
936 #define predefined_devices
937 struct device devices[] = {
938 {"/dev/fpd0", 'A', FHD312},
939 {"/dev/fpd0", 'A', FDD312},
943 #define predefined_devices
944 struct device devices[] = {
945 {"/dev/rdsk/f1q15dt", 'B', FHD514},
946 {"/dev/rdsk/f1d9dt", 'B', FDD514},
947 {"/dev/rdsk/f1d8dt", 'B', FDDsmall},
948 {"/dev/rdsk/f03ht", 'A', FHD312},
949 {"/dev/rdsk/f03dt", 'A', FDD312},
950 {"/dev/rdsk/dos", 'C', GENHD},
956 #ifdef OS_mingw32msvc
957 #define predefined_devices
958 struct device devices[] = {
959 {"\\\\.\\A:", 'A', GENFD },
966 #define USE_2M(x) 0x80
970 #define SSIZE(x) 0x82
974 #define SET_2M(x,y) return -1
978 #define SET_SSIZE(x,y) return -1
982 int init_geom(int fd, struct device *dev, struct device *orig_dev,
983 struct MT_STAT *statbuf)
985 struct generic_floppy_struct floppy;
989 * succeed if we don't have a floppy
990 * this is the case for dosemu floppy image files for instance
992 if (!((S_ISBLK(statbuf->st_mode) &&
993 major(statbuf->st_rdev) == BLOCK_MAJOR)
995 || (S_ISCHR(statbuf->st_mode) &&
996 major(statbuf->st_rdev) == CHAR_MAJOR)
999 return compare_geom(dev, orig_dev);
1002 * We first try to get the current floppy parameters from the kernel.
1005 * 2. skip the parameter setting if the parameters are already o.k.
1008 if (get_parameters( fd, & floppy ) )
1010 * autodetection failure.
1011 * This mostly occurs because of an absent or unformatted disks.
1013 * It might also occur because of bizarre formats (for example
1014 * rate 1 on a 3 1/2 disk).
1016 * If this is the case, the user should do an explicit
1017 * setfdprm before calling mtools
1019 * Another cause might be pre-existing wrong parameters. The
1020 * user should do an setfdprm -c to repair this situation.
1022 * ...fail immediately... ( Theoretically, we could try to save
1023 * the situation by trying out all rates, but it would be slow
1030 * if we have already have the correct parameters, keep them.
1031 * the number of tracks doesn't need to match exactly, it may be bigger.
1032 * the number of heads and sectors must match exactly, to avoid
1033 * miscalculation of the location of a block on the disk
1036 if(compare(dev->sectors, SECTORS(floppy))){
1037 SECTORS(floppy) = dev->sectors;
1040 dev->sectors = SECTORS(floppy);
1042 if(compare(dev->heads, HEADS(floppy))){
1043 HEADS(floppy) = dev->heads;
1046 dev->heads = HEADS(floppy);
1048 if(compare(dev->tracks, TRACKS(floppy))){
1049 TRACKS(floppy) = dev->tracks;
1052 dev->tracks = TRACKS(floppy);
1055 if(compare(dev->use_2m, USE_2M(floppy))){
1056 SET_2M(&floppy, dev->use_2m);
1059 dev->use_2m = USE_2M(floppy);
1061 if( ! (dev->ssize & 0x80) )
1063 if(compare(dev->ssize, SSIZE(floppy) + 128)){
1064 SET_SSIZE(&floppy, dev->ssize);
1067 dev->ssize = SSIZE(floppy);
1070 /* no change, succeed */
1073 #ifdef SECTORS_PER_TRACK
1074 SECTORS_PER_TRACK(floppy) = dev->sectors * dev->heads;
1077 #ifdef SECTORS_PER_DISK
1078 SECTORS_PER_DISK(floppy) = dev->sectors * dev->heads * dev->tracks;
1082 /* ... and the stretch */
1083 if ( dev->tracks > 41 )
1084 STRETCH(floppy) = 0;
1086 STRETCH(floppy) = 1;
1089 return set_parameters( fd, &floppy, statbuf);
1091 #endif /* INIT_GENERIC */
1094 int init_geom(int fd, struct device *dev, struct device *orig_dev,
1095 struct MT_STAT *statbuf)
1097 return compare_geom(dev, orig_dev);
1101 #ifdef predefined_devices
1102 const int nr_const_devices = sizeof(const_devices) / sizeof(*const_devices);
1104 struct device devices[]={
1105 {"/dev/fd0", 'A', 0, O_EXCL, 0,0, 0,0, MDEF_ARG},
1106 /* to shut up Ultrix's native compiler, we can't make this empty :( */
1108 const int nr_const_devices = 0;