home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / disk-man / mtools-3.000 / mtools-3 / mtools-3.0 / devices.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-08  |  15.0 KB  |  661 lines

  1. /*
  2.  * Device tables.  See the Configure file for a complete description.
  3.  */
  4.  
  5. #define NO_TERMIO
  6. #include "sysincludes.h"
  7. #include "msdos.h"
  8. #include "mtools.h"
  9. #include "devices.h"
  10.  
  11. #define DEF_ARG0 0,0x2,0,0
  12. #define DEF_ARG 0L,DEF_ARG0
  13.  
  14. #define ED312    12,0,80,2,36,DEF_ARG /* 3 1/2 extra density */
  15. #define HD312    12,0,80,2,18,DEF_ARG /* 3 1/2 high density */
  16. #define DD312    12,0,80,2, 9,DEF_ARG /* 3 1/2 double density */
  17. #define HD514    12,0,80,2,15,DEF_ARG /* 5 1/4 high density */
  18. #define DD514    12,0,40,2, 9,DEF_ARG /* 5 1/4 double density (360k) */
  19. #define DDsmall    12,0,40,2, 8,DEF_ARG /* 5 1/4 double density (320k) */
  20. #define SS514    12,0,40,1, 9,DEF_ARG /* 5 1/4 single sided DD, (180k) */
  21. #define SSsmall    12,0,40,1, 8,DEF_ARG /* 5 1/4 single sided DD, (160k) */
  22. #define GENHD    16,0, 0,0, 0,DEF_ARG /* Generic 16 bit FAT fs */
  23. #define GENFD    12,0, 0,0, 0,DEF_ARG /* Generic 12 bit FAT fs */
  24. #define GEN         0,0, 0,0, 0,DEF_ARG /* Generic fs of any FAT bits */
  25.  
  26. static int compare_geom(struct device *dev, struct device *orig_dev)
  27. {
  28.     if(!orig_dev || !orig_dev->tracks || !dev || !dev->tracks)
  29.         return 0; /* no original device. This is ok */
  30.     return(orig_dev->tracks != dev->tracks ||
  31.            orig_dev->heads != dev->heads ||
  32.            orig_dev->sectors  != dev->sectors);
  33. }
  34.  
  35. #define devices const_devices
  36.  
  37. #ifdef hpux
  38. #define predefined_devices
  39. struct device devices[] = {
  40.     {"/dev/floppy/c201d0s0",    'A', HD312 },
  41.     {"/dev/floppy/c20Ad0s0",     'A', HD312 },
  42.      {"/dev/floppy/c201d1s0",    'B', HD312 },
  43.      {"/dev/floppy/c20Ad1s0",    'B', HD312 },
  44.      {"/dev/rscsi",            'C', GENHD },
  45. };
  46. #endif /* hpux */
  47.  
  48.  
  49. #ifdef sinix
  50. #define predefined_devices
  51. struct device devices[] = {
  52.     {"/dev/fd0135ds18",    'A', GENFD },
  53. };
  54. #endif
  55.  
  56. #ifdef isc2
  57. #define predefined_devices
  58. struct device devices[] = {
  59.     {"/dev/rdsk/f0d9dt",       'A', DD514},
  60.     {"/dev/rdsk/f0q15dt",    'A', HD514},
  61.     {"/dev/rdsk/f0d8dt",    'A', DDsmall},
  62.     {"/dev/rdsk/f13ht",    'B', HD312},
  63.     {"/dev/rdsk/f13dt",    'B', DD312},
  64.     {"/dev/rdsk/0p1",    'C', GENHD},
  65.     {"/usr/vpix/defaults/C:",'D',12, 0, 0, 0, 0,8704L,DEF_ARG0},
  66.     {"$HOME/vpix/C:",     'E', 12, 0, 0, 0, 0,8704L,DEF_ARG},
  67. };
  68.  
  69. #define INIT_NOOP
  70. #endif /* isc2 */
  71.  
  72. #ifdef i370
  73. #define predefined_devices
  74. struct device devices[] = {
  75.     {"/dev/rfd0", 'A', HD514},
  76.     {"/dev/rfd0", 'A', DD514},
  77. };
  78. #define INIT_NOOP
  79. #endif /* i370 */
  80.  
  81. #ifdef aix
  82. /* modified by Federico Bianchi */
  83. #define predefined_devices
  84. struct device devices[] = {
  85.   {"/dev/fd0",'A',HD312},
  86.   {"/dev/fd0",'A',DD312},
  87. };
  88. #define INIT_NOOP
  89. #endif /* aix */
  90.  
  91. #ifdef solaris
  92. #define predefined_devices
  93. #ifdef    USING_VOLD
  94. struct device devices[] = {
  95.     {"/vol/dev/aliases/floppy0", 'A', HD312},
  96.     {"/vol/dev/aliases/floppy0", 'A', DD312},
  97. };
  98. #else    /* ! USING_VOLD */
  99. struct device devices[] = {
  100.     {"/dev/diskette", 'A', HD312},
  101.     {"/dev/diskette", 'A', DD312},
  102. };
  103. #endif    /* USING_VOLD */
  104. #define INIT_NOOP
  105. #endif /* solaris */
  106.  
  107. #ifdef sunos3
  108. #define predefined_devices
  109. struct device devices[] = {
  110.     {"/dev/rfdl0c",    'A', DD312},
  111.     {"/dev/rfd0c",    'A', HD312},
  112. };
  113. #define INIT_NOOP
  114. #endif /* sunos3 */
  115.  
  116. #ifdef xenix
  117. #define predefined_devices
  118. struct device devices[] = {
  119.     {"/dev/fd096ds15",    'A', HD514},
  120.     {"/dev/fd048ds9",    'A', DD514},
  121.     {"/dev/fd1135ds18",    'B', HD312},
  122.     {"/dev/fd1135ds9",    'B', DD312},
  123.     {"/dev/hd0d",        'C', GENHD},
  124. };
  125. #define INIT_NOOP
  126. #endif /* xenix */
  127.  
  128. #ifdef sco
  129. #define predefined_devices
  130. struct device devices[] = {
  131.     { "/dev/fd0135ds18",    'A', HD312},
  132.     { "/dev/fd0135ds9",    'A', DD312},
  133.     { "/dev/fd0",        'A', GENFD},
  134.     { "/dev/fd1135ds15",    'B', HD514},
  135.     { "/dev/fd1135ds9",    'B', DD514},
  136.     { "/dev/fd1",        'B', GENFD},
  137.     { "/dev/hd0d",        'C', GENHD},
  138. };
  139. #define INIT_NOOP
  140. #endif /* sco */
  141.  
  142.  
  143. #ifdef irix
  144. #define predefined_devices
  145. struct device devices[] = {
  146.   { "/dev/rdsk/fds0d2.3.5hi",    'A', HD312},
  147.   { "/dev/rdsk/fds0d2.3.5",    'A', DD312},
  148.   { "/dev/rdsk/fds0d2.96",    'A', HD514},
  149.   {"/dev/rdsk/fds0d2.48",    'A', DD514},
  150. };
  151. #define INIT_NOOP
  152. #endif /* irix */
  153.  
  154. #ifdef sunos4
  155. #include <sys/ioctl.h>
  156. #include <sun/dkio.h>
  157.  
  158. #define predefined_devices
  159. struct device devices[] = {
  160.     {"/dev/rfd0c",    'A', GENFD},
  161. };
  162.  
  163. /*
  164.  * Stuffing back the floppy parameters into the driver allows for gems
  165.  * like 10 sector or single sided floppies from Atari ST systems.
  166.  * 
  167.  * Martin Schulz, Universite de Moncton, N.B., Canada, March 11, 1991.
  168.  */
  169.  
  170. #define INIT_GENERIC
  171.  
  172. struct generic_floppy_struct
  173. {
  174.   struct fdk_char dkbuf;
  175.   struct dk_map dkmap;
  176. };
  177.  
  178. #define BLOCK_MAJOR 16
  179. #define CHAR_MAJOR 54
  180.  
  181. static inline int get_parameters(int fd, struct generic_floppy_struct *floppy)
  182. {
  183.     if (ioctl(fd, DKIOCGPART, &(floppy->dkmap)) != 0) {
  184.         perror("DKIOCGPART");
  185.         ioctl(fd, FDKEJECT, NULL);
  186.         return(1);
  187.     }
  188.     
  189.     if (ioctl(fd, FDKIOGCHAR, &( floppy->dkbuf)) != 0) {
  190.         perror("");
  191.         ioctl(fd, FDKEJECT, NULL);
  192.         return(1);
  193.     }
  194.     return 0;
  195. }
  196.  
  197. #define TRACKS(floppy) floppy.dkbuf.ncyl
  198. #define HEADS(floppy) floppy.dkbuf.nhead
  199. #define SECTORS(floppy) floppy.dkbuf.secptrack
  200. #define SECTORS_PER_DISK(floppy) floppy.dkmap.dkl_nblk
  201. #define FD_SECTSIZE(floppy) floppy.dkbuf.sec_size
  202. #define FD_SET_SECTSIZE(floppy,v) { floppy.dkbuf.sec_size = v; }
  203.  
  204. static inline int set_parameters(int fd, struct generic_floppy_struct *floppy, 
  205.                  struct stat *buf)
  206. {
  207.     if (ioctl(fd, FDKIOSCHAR, &(floppy->dkbuf)) != 0) {
  208.         ioctl(fd, FDKEJECT, NULL);
  209.         perror("");
  210.         return(1);
  211.     }
  212.     
  213.     if (ioctl(fd, ( unsigned int) DKIOCSPART, &(floppy->dkmap)) != 0) {
  214.         ioctl(fd, FDKEJECT, NULL);
  215.         perror("");
  216.         return(1);
  217.     }
  218.     return 0;
  219. }
  220. #define INIT_GENERIC
  221. #endif /* sparc && sunos */
  222.  
  223.  
  224. #ifdef DPX1000
  225. #define predefined_devices
  226. struct device devices[] = {
  227.     /* [block device]: DPX1000 has /dev/flbm60, DPX2 has /dev/easyfb */
  228.     {"/dev/flbm60", 'A', HD514};
  229.     {"/dev/flbm60", 'B', DD514},
  230.     {"/dev/flbm60", 'C', DDsmall},
  231.     {"/dev/flbm60", 'D', SS},
  232.     {"/dev/flbm60", 'E', SSsmall},
  233. };
  234. #define INIT_NOOP
  235. #endif /* DPX1000 */
  236.  
  237. #ifdef bosx
  238. #define predefined_devices
  239. struct device devices[] = {
  240.     /* [block device]: DPX1000 has /dev/flbm60, DPX2 has /dev/easyfb */
  241.     {"/dev/easyfb", 'A', HD514},
  242.     {"/dev/easyfb", 'B', DD514},
  243.     {"/dev/easyfb", 'C', DDsmall},
  244.     {"/dev/easyfb", 'D', SS},
  245.     {"/dev/easyfb", 'E', SSsmall},
  246. };
  247. #define INIT_NOOP
  248. #endif /* bosx */
  249.  
  250. #ifdef linux
  251.  
  252. #include <linux/fdreg.h>
  253. #include <linux/major.h>
  254. #include <linux/fs.h>
  255.  
  256. #ifndef major
  257. #define major(x) MAJOR(x)
  258. #endif
  259.  
  260. char *error_msg[22]={
  261. "Missing Data Address Mark",
  262. "Bad cylinder",
  263. "Scan not satisfied",
  264. "Scan equal hit",
  265. "Wrong cylinder",
  266. "CRC error in data field",
  267. "Control Mark = deleted",
  268. 0,
  269.  
  270. "Missing Address Mark",
  271. "Write Protect",
  272. "No Data - unreadable",
  273. 0,
  274. "OverRun",
  275. "CRC error in data or address",
  276. 0,
  277. "End Of Cylinder",
  278.  
  279. 0,
  280. 0,
  281. 0,
  282. "Not ready",
  283. "Equipment check error",
  284. "Seek end" };
  285.  
  286.  
  287. static inline void print_message(RawRequest_t *raw_cmd,char *message)
  288. {
  289.     int i, code;
  290.     if(!message)
  291.         return;
  292.  
  293.     fprintf(stderr,"   ");
  294.     for (i=0; i< raw_cmd->cmd_count; i++)
  295.         fprintf(stderr,"%2.2x ", 
  296.             (int)raw_cmd->cmd[i] );
  297.     fprintf(stderr,"\n");
  298.     for (i=0; i< raw_cmd->reply_count; i++)
  299.         fprintf(stderr,"%2.2x ",
  300.             (int)raw_cmd->reply[i] );
  301.     fprintf(stderr,"\n");
  302.     code = (raw_cmd->reply[0] <<16) + 
  303.         (raw_cmd->reply[1] << 8) + 
  304.         raw_cmd->reply[2];
  305.     for(i=0; i<22; i++){
  306.         if ((code & (1 << i)) && error_msg[i])
  307.             fprintf(stderr,"%s\n",
  308.                 error_msg[i]);
  309.     }
  310. }
  311.  
  312.  
  313. /* return values:
  314.  *  -1: Fatal error, don't bother retrying.
  315.  *   0: OK
  316.  *   1: minor error, retry
  317.  */
  318.  
  319. int send_one_cmd(int fd, RawRequest_t *raw_cmd, char *message)
  320. {
  321.     if (ioctl( fd, FDRAWCMD, raw_cmd) >= 0) {
  322.         if (raw_cmd->reply_count < 7) {
  323.             fprintf(stderr,"Short reply from FDC\n");
  324.             return -1;
  325.         }        
  326.         return 0;
  327.     }
  328.  
  329.     switch(errno) {
  330.         case EBUSY:
  331.             fprintf(stderr, "FDC busy, sleeping for a second\n");
  332.             sleep(1);
  333.             return 1;
  334.         case EIO:
  335.             fprintf(stderr,"resetting controller\n");
  336.             if(ioctl(fd, FDRESET, 2)  < 0){
  337.                 perror("reset");
  338.                 return -1;
  339.             }
  340.             return 1;
  341.         default:
  342.             perror(message);
  343.             return -1;
  344.     }
  345. }
  346.  
  347.  
  348. /*
  349.  * return values
  350.  *  -1: error
  351.  *   0: OK, last sector
  352.  *   1: more raw commands follow
  353.  */
  354.  
  355. int analyze_one_reply(RawRequest_t *raw_cmd, int *bytes, int do_print)
  356. {
  357.     
  358.     if(raw_cmd->reply_count == 7) {
  359.         *bytes = (raw_cmd->reply[5] - raw_cmd->cmd[4]);
  360.         /* FIXME: over/under run */
  361.         *bytes = *bytes << (7 + raw_cmd->cmd[6]);
  362.     } else
  363.         *bytes = 0;       
  364.  
  365.     switch(raw_cmd->reply[0] & 0xc0){
  366.         case 0x40:
  367.             if ( raw_cmd->reply[1] & ST1_WP ){
  368.                 *bytes = 0;
  369.                 fprintf(stderr,
  370.                     "This disk is write protected\n");
  371.                 return -1;
  372.             }
  373.             if(!*bytes && do_print)
  374.                 print_message(raw_cmd, "");
  375.             return -1;
  376.         case 0x80:
  377.             *bytes = 0;
  378.             fprintf(stderr,
  379.                 "invalid command given\n");
  380.             return -1;
  381.         case 0xc0:
  382.             *bytes = 0;
  383.             fprintf(stderr,
  384.                 "abnormal termination caused by polling\n");
  385.             return -1;
  386.         default:
  387. #ifdef FD_RAW_MORE
  388.             if(raw_cmd->flags & FD_RAW_MORE)
  389.                 return 1;
  390. #endif
  391.             return 0;
  392.     }    
  393. }
  394.  
  395. #define predefined_devices
  396. struct device devices[] = {
  397.     {"/dev/fd0", 'A', 0, O_EXCL, 0,0, 0,DEF_ARG},
  398.     {"/dev/fd1", 'B', 0, O_EXCL, 0,0, 0,DEF_ARG},
  399. };
  400.  
  401. /*
  402.  * Stuffing back the floppy parameters into the driver allows for gems
  403.  * like 21 sector or single sided floppies from Atari ST systems.
  404.  * 
  405.  * Alain Knaff, UniversitΘ Joseph Fourier, France, November 12, 1993.
  406.  */
  407.  
  408.  
  409. #define INIT_GENERIC
  410. #define generic_floppy_struct floppy_struct
  411. #define BLOCK_MAJOR 2
  412. #define SECTORS(floppy) floppy.sect
  413. #define TRACKS(floppy) floppy.track
  414. #define HEADS(floppy) floppy.head
  415. #define SECTORS_PER_DISK(floppy) floppy.size
  416. #define STRETCH(floppy) floppy.stretch
  417. #define USE_2M(floppy) ((floppy.rate & FD_2M) ? 0xff : 0x80 )
  418. #define SSIZE(floppy) ((((floppy.rate & 0x38) >> 3 ) + 2) % 8)
  419.  
  420. static inline void set_2m(struct floppy_struct *floppy, int value)
  421. {
  422.     if (value & 0x7f)
  423.         value = FD_2M;
  424.     else
  425.         value = 0;
  426.     floppy->rate = (floppy->rate & ~FD_2M) | value;       
  427. }
  428. #define SET_2M set_2m
  429.  
  430. static inline void set_ssize(struct floppy_struct *floppy, int value)
  431. {
  432.     value = (( (value & 7) + 6 ) % 8) << 3;
  433.  
  434.     floppy->rate = (floppy->rate & ~0x38) | value;    
  435. }
  436.  
  437. #define SET_SSIZE set_ssize
  438.  
  439. static inline int set_parameters(int fd, struct floppy_struct *floppy, 
  440.                  struct stat *buf)
  441. {
  442.     if ( ( MINOR(buf->st_rdev ) & 0x7f ) > 3 )
  443.         return 1;
  444.     
  445.     return ioctl(fd, FDSETPRM, floppy);
  446. }
  447.  
  448. static inline int get_parameters(int fd, struct floppy_struct *floppy)
  449. {
  450.     return ioctl(fd, FDGETPRM, floppy);
  451. }
  452.  
  453. #endif /* linux */
  454.  
  455.  
  456. #if (!defined(predefined_devices) && defined (m68000) && defined (sysv))
  457. #include <sys/gdioctl.h>
  458.  
  459. #define predefined_devices
  460. struct device devices[] = {
  461.     {"/dev/rfp020",        'A', 12,O_NDELAY,40,2, 9,DEF_ARG},
  462.     {"/usr/bin/DOS/dvd000", 'C', GENFD},
  463. };
  464.  
  465. int init_geom(int fd, struct device *dev, struct device *orig_dev,
  466.           struct stat *stat)
  467. {
  468.     struct gdctl gdbuf;
  469.  
  470.     if (ioctl(fd, GDGETA, &gdbuf) == -1) {
  471.         ioctl(fd, GDDISMNT, &gdbuf);
  472.         return 1;
  473.     }
  474.     if((dev->use_2m & 0x7f) || (dev->ssize & 0x7f))
  475.         return 1;
  476.     
  477.     set_int(&gdbuf.params.cyls,dev->ntracks);
  478.     set_int(&gdbuf.params.heads,dev->nheads);
  479.     set_int(&gdbuf.params.psectrk,dev->nsect);
  480.     dev->ntracks = gdbuf.params.cyls;
  481.     dev->nheads = gdbuf.params.heads;
  482.     dev->nsect = gdbuf.params.psectrk;
  483.     dev->use_2m = 0x80;
  484.     dev->ssize = 0x82;
  485.  
  486.     gdbuf.params.pseccyl = gdbuf.params.psectrk * gdbuf.params.heads;
  487.     gdbuf.params.flags = 1;        /* disk type flag */
  488.     gdbuf.params.step = 0;        /* step rate for controller */
  489.     gdbuf.params.sectorsz = 512;    /* sector size */
  490.  
  491.     if (ioctl(fd, GDSETA, &gdbuf) < 0) {
  492.         ioctl(fd, GDDISMNT, &gdbuf);
  493.         return(1);
  494.     }
  495.     return(0);
  496. }
  497. #endif /* (defined (m68000) && defined (sysv))*/
  498.  
  499. #if (!defined(predefined_devices) && defined(sysv4))
  500. #define predefined_devices
  501. struct device devices[] = {
  502.     {"/dev/rdsk/f1q15dt",    'B', HD514},
  503.     {"/dev/rdsk/f1d9dt",    'B', DD514},
  504.     {"/dev/rdsk/f1d8dt",    'B', DDsmall},
  505.     {"/dev/rdsk/f03ht",    'A', HD312},
  506.     {"/dev/rdsk/f03dt",    'A', DD312},
  507.     {"/dev/rdsk/dos",    'C', GENHD},
  508. };
  509. #define INIT_NOOP
  510. #endif /* sysv4 */
  511.  
  512. #ifdef INIT_GENERIC
  513.  
  514. #ifndef USE_2M
  515. #define USE_2M(x) 0x80
  516. #endif
  517.  
  518. #ifndef SSIZE
  519. #define SSIZE(x) 0x82
  520. #endif
  521.  
  522. #ifndef SET_2M
  523. #define SET_2M(x,y) return -1
  524. #endif
  525.  
  526. #ifndef SET_SSIZE
  527. #define SET_SSIZE(x,y) return -1
  528. #endif
  529.  
  530. int init_geom(int fd, struct device *dev, struct device *orig_dev,
  531.           struct stat *stat)
  532. {
  533.     struct generic_floppy_struct floppy;
  534.     int change;
  535.     
  536.     /* 
  537.      * succeed if we don't have a floppy
  538.      * this is the case for dosemu floppy image files for instance
  539.      */
  540.     if (!((S_ISBLK(stat->st_mode) && major(stat->st_rdev) == BLOCK_MAJOR)
  541. #ifdef CHAR_MAJOR
  542.           || (S_ISCHR(stat->st_mode) && major(stat->st_rdev) == CHAR_MAJOR) 
  543. #endif
  544.         ))
  545.         return compare_geom(dev, orig_dev);
  546.     
  547.     /*
  548.      * We first try to get the current floppy parameters from the kernel.
  549.      * This allows us to
  550.      * 1. get the rate
  551.      * 2. skip the parameter setting if the parameters are already o.k.
  552.      */
  553.     
  554.     if (get_parameters( fd, & floppy ) )
  555.         /* 
  556.          * autodetection failure.
  557.          * This mostly occurs because of an absent or unformatted disks.
  558.          *
  559.          * It might also occur because of bizarre formats (for example 
  560.          * rate 1 on a 3 1/2 disk).
  561.  
  562.          * If this is the case, the user should do an explicit 
  563.          * setfdprm before calling mtools
  564.          *
  565.          * Another cause might be pre-existing wrong parameters. The 
  566.          * user should do an setfdprm -c to repair this situation.
  567.          *
  568.          * ...fail immediately... ( Theoretically, we could try to save
  569.          * the situation by trying out all rates, but it would be slow 
  570.          * and awkward)
  571.          */
  572.         return 1;
  573.  
  574.  
  575.     /* 
  576.      * if we have already have the correct parameters, keep them.
  577.      * the number of tracks doesn't need to match exactly, it may be bigger.
  578.      * the number of heads and sectors must match exactly, to avoid 
  579.      * miscalculation of the location of a block on the disk
  580.      */
  581.     change = 0;
  582.     if(compare(dev->sectors, SECTORS(floppy))){
  583.         SECTORS(floppy) = dev->sectors;
  584.         change = 1;
  585.     } else
  586.         dev->sectors = SECTORS(floppy);
  587.  
  588.     if(compare(dev->heads, HEADS(floppy))){
  589.         HEADS(floppy) = dev->heads;
  590.         change = 1;
  591.     } else
  592.         dev->heads = HEADS(floppy);
  593.      
  594.     if(compare(dev->tracks, TRACKS(floppy))){
  595.         TRACKS(floppy) = dev->tracks;
  596.         change = 1;
  597.     } else
  598.         dev->tracks = TRACKS(floppy);
  599.  
  600.  
  601.     if(compare(dev->use_2m, USE_2M(floppy))){
  602.         SET_2M(&floppy, dev->use_2m);
  603.         change = 1;
  604.     } else
  605.         dev->use_2m = USE_2M(floppy);
  606.     
  607.     if( ! (dev->ssize & 0x80) )
  608.         dev->ssize = 0;
  609.     if(compare(dev->ssize, SSIZE(floppy) + 128)){
  610.         SET_SSIZE(&floppy, dev->ssize);
  611.         change = 1;
  612.     } else
  613.         dev->ssize = SSIZE(floppy);
  614.  
  615.     if(!change)
  616.         /* no change, succeed */
  617.         return 0;
  618.  
  619. #ifdef SECTORS_PER_TRACK
  620.     SECTORS_PER_TRACK(floppy) = dev->sectors * dev->heads;
  621. #endif
  622.  
  623. #ifdef SECTORS_PER_DISK
  624.     SECTORS_PER_DISK(floppy) = dev->sectors * dev->heads * dev->tracks;
  625. #endif
  626.     
  627. #ifdef STRETCH
  628.     /* ... and the stretch */
  629.     if ( dev->tracks > 41 ) 
  630.         STRETCH(floppy) = 0;
  631.     else
  632.         STRETCH(floppy) = 1;
  633. #endif
  634.     
  635.     return set_parameters( fd, &floppy, stat) ;
  636. }
  637. #endif /* INIT_GENERIC */  
  638.  
  639. #ifdef INIT_NOOP
  640. int init_geom(int fd, struct device *dev, struct device *orig_dev,
  641.           struct stat *stat)
  642. {
  643.     return compare_geom(dev, orig_dev);
  644. }
  645. #endif
  646.  
  647. #ifdef predefined_devices
  648. const int nr_const_devices = sizeof(const_devices) / sizeof(*const_devices);
  649. #else
  650. int init_geom(int fd, struct device *dev, struct device *orig_dev,
  651.           struct stat *stat)
  652. {
  653.   return 0;
  654. }
  655. struct device devices[]={
  656.     {"/dev/fd0", 'A', 0, O_EXCL, 0,0, 0,DEF_ARG},
  657.     /* to shut up Ultrix's native compiler, we can't make this empty :( */
  658. };
  659. const nr_const_devices = 0;
  660. #endif
  661.