home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume12 / sparc-mtools / patch01 next >
Encoding:
Text File  |  1990-05-11  |  13.7 KB  |  448 lines

  1. Newsgroups: comp.sources.misc
  2. keywords: DOS, floppy
  3. subject: v12i051: Recent mtools,  official patches.
  4. from: viktor@melon.princeton.edu (Viktor Dukhovni)
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 12, Issue 51
  8. Submitted-by: viktor@melon.princeton.edu (Viktor Dukhovni)
  9. Archive-name: sparc-mtools/patch01
  10.  
  11.     I have had such a flood of requests for the mtools patches
  12. that posting them here seems mandatory.  I have been holding back,  for
  13. though the code works,  and is reasonably fast,  there is room for improvement.
  14. I wanted to take a closer look at it after the initial posting,  and see
  15. what improvements would come back from net.readers.
  16.  
  17.     Anyway,  I've not had the time for the next round of changes,  and
  18. may never get to it now.  Here is a short list of suggested improvements for the
  19. next volunteer:
  20.  
  21. i)  "mkdfs" is a gross badly written hack!  I had to write it very quickly,
  22. as I do not convenient access to DOS machines for formatting disks,  and 
  23. could not get off the ground without it.  It needs to be driven by an external
  24. table of disk descriptions,  giving the physical and file system layout.
  25. The name of the system low level format program should also come from this
  26. table,  or the "-f" flag can be dropped without much loss.  Disk types should
  27. be *named*  the "-h" flag needs to be retired.  The bootblock should be built
  28. by filling in the structure in "msdos.h".  Finally an option for actual boot
  29. code needs to exist for compatibility with some older DOS systems.  (Perhaps
  30. a "-b" flag to load a custom boot file,  though a UNIX "expert" would simply
  31. use "dd" and bypass "mkdfs" altogether in this case.)
  32.  
  33. ii)  Mtools should gracefully handle interrupts,  zap the working FAT chain,
  34. and write out the FAT table.
  35.  
  36. iii)  Directory caching would be sensible,  but only if done carefully.
  37.  
  38. iv)  Mfsck!!!
  39.  
  40.     ---------------
  41.     Anyway here are all the patches:  1,2 are the ones that were posted
  42. to comp.sources.bugs soon after release,  3 fixes a problem with "-l"
  43. (custom labels),  and wrong media byte in "mkdfs".  bootblk.h  is made
  44. byte order independent, though I would like to see it disappear altogether
  45. in the long run.
  46.     ---------------
  47.  
  48. #! /bin/sh
  49. # This is a shell archive.  Remove anything before this line, then unpack
  50. # it by saving it into a file and typing "sh file".  To overwrite existing
  51. # files, type "sh file -c".  You can also feed this as standard input via
  52. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  53. # will see the following message at the end:
  54. #        "End of shell archive."
  55. # Contents:  patch1 patch2 patch3
  56. # Wrapped by viktor@melon on Sat Apr 28 02:34:17 1990
  57. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  58. if test -f 'patch1' -a "${1}" != "-c" ; then 
  59.   echo shar: Will not clobber existing file \"'patch1'\"
  60. else
  61. echo shar: Extracting \"'patch1'\" \(4811 characters\)
  62. sed "s/^X//" >'patch1' <<'END_OF_FILE'
  63. XNewsgroups: comp.sources.bugs
  64. XSubject: Mtools Patch1,  (Priority High)
  65. X
  66. X    Patch1 fixes fixes alignment dependency problems in
  67. Xmsdos.h that made the code fail on the 3/80.  Somehow this worked
  68. Xon the SparcStation,  I hang my head in shame.  Also minor change in
  69. Xmkdfs.c allowing custom disk labels,  and defaulting to blank.
  70. X
  71. X*** /tmp/,RCSt1a17064    Mon Mar 26 17:32:44 1990
  72. X--- mkdfs.c    Mon Mar 26 17:32:43 1990
  73. X***************
  74. X*** 27,33 ****
  75. X  #define FAT720 0xf9
  76. X  #define FAT1440 0xf0
  77. X  static char floppy[] = "/dev/rfd0c" ;
  78. X! static char disklabel[] = "ANYDSKLABEL" ;
  79. X  
  80. X  void move(), Write(), usage(), formatit() ;
  81. X  
  82. X--- 27,33 ----
  83. X  #define FAT720 0xf9
  84. X  #define FAT1440 0xf0
  85. X  static char floppy[] = "/dev/rfd0c" ;
  86. X! char disklabel[12] = "" ;
  87. X  
  88. X  void move(), Write(), usage(), formatit() ;
  89. X  
  90. X***************
  91. X*** 41,50 ****
  92. X    int fat = FAT720 ;
  93. X    int dir_len = 7 ;
  94. X    int hdflag=0, fflag = 0 ;
  95. X  
  96. X    progname = argv[0] ;
  97. X  
  98. X!   while( (c=getopt(argc,argv,"hf")) != EOF ) {
  99. X      switch(c) {
  100. X      case 'f' :
  101. X        fflag++ ;
  102. X--- 41,51 ----
  103. X    int fat = FAT720 ;
  104. X    int dir_len = 7 ;
  105. X    int hdflag=0, fflag = 0 ;
  106. X+   extern char *optarg;
  107. X  
  108. X    progname = argv[0] ;
  109. X  
  110. X!   while( (c=getopt(argc,argv,"hfl:")) != EOF ) {
  111. X      switch(c) {
  112. X      case 'f' :
  113. X        fflag++ ;
  114. X***************
  115. X*** 51,56 ****
  116. X--- 52,60 ----
  117. X        break;
  118. X      case 'h' :
  119. X        hdflag++ ;
  120. X+       break;
  121. X+     case 'l' :
  122. X+       strncpy(disklabel, optarg, 11) ;
  123. X        break;
  124. X      case '?':
  125. X      default:
  126. X*** /tmp/,RCSt1a17064    Mon Mar 26 17:32:45 1990
  127. X--- msdos.h    Mon Mar 26 17:18:43 1990
  128. X***************
  129. X*** 18,42 ****
  130. X      unsigned char    size[4];    /* size of the file */
  131. X  };
  132. X  
  133. X- struct dos_word {
  134. X-   unsigned char dw_low ;        /* LSB */
  135. X-   unsigned char dw_high ;        /* MSB */
  136. X- } ;
  137. X- 
  138. X  struct superblock {
  139. X    unsigned char jump[3] ;       /* Jump to boot code */
  140. X!   unsigned char banner[8];      /* OEM name & version */
  141. X!   struct dos_word secsiz;       /* Bytes per sector hopefully 512 */
  142. X    unsigned char clsiz ;         /* Cluster size in sectors */
  143. X!   struct dos_word nrsvsect;     /* Number of reserved (boot) sectors */
  144. X    unsigned char nfat;           /* Number of FAT tables hopefully 2 */
  145. X!   struct dos_word dirents;      /* Number of directory slots */
  146. X!   struct dos_word psect;        /* Total sectors on disk */
  147. X    unsigned char descr;          /* Media descriptor=first byte of FAT */
  148. X!   struct dos_word fatlen;       /* Sectors in FAT */
  149. X!   struct dos_word nsect;        /* Sectors/track */
  150. X!   struct dos_word ntrack;       /* tracks/cyl */
  151. X!   struct dos_word nhs;          /* number of hidden sectors ? */
  152. X  } ;
  153. X  
  154. X  union bootblock {
  155. X--- 18,37 ----
  156. X      unsigned char    size[4];    /* size of the file */
  157. X  };
  158. X  
  159. X  struct superblock {
  160. X    unsigned char jump[3] ;       /* Jump to boot code */
  161. X!   unsigned char banner[8];    /* OEM name & version */
  162. X!   unsigned char secsiz[2];    /* Bytes per sector hopefully 512 */
  163. X    unsigned char clsiz ;         /* Cluster size in sectors */
  164. X!   unsigned char nrsvsect[2];    /* Number of reserved (boot) sectors */
  165. X    unsigned char nfat;           /* Number of FAT tables hopefully 2 */
  166. X!   unsigned char dirents[2];    /* Number of directory slots */
  167. X!   unsigned char psect[2];    /* Total sectors on disk */
  168. X    unsigned char descr;          /* Media descriptor=first byte of FAT */
  169. X!   unsigned char fatlen[2];    /* Sectors in FAT */
  170. X!   unsigned char nsect[2];    /* Sectors/track */
  171. X!   unsigned char ntrack[2];    /* tracks/cyl */
  172. X!   unsigned char nhs[2];        /* number of hidden sectors ? */
  173. X  } ;
  174. X  
  175. X  union bootblock {
  176. X***************
  177. X*** 44,50 ****
  178. X    struct superblock sb ;
  179. X  } ;
  180. X  
  181. X! #define WORD_VAL(x) (x.dw_low + (x.dw_high <<8))
  182. X  
  183. X  #define SECSIZ(x)    WORD_VAL(x.secsiz)
  184. X  #define CLSIZ(x)    (x.clsiz)
  185. X--- 39,45 ----
  186. X    struct superblock sb ;
  187. X  } ;
  188. X  
  189. X! #define WORD_VAL(x) ((x)[0] + ((x)[1] << 8))
  190. X  
  191. X  #define SECSIZ(x)    WORD_VAL(x.secsiz)
  192. X  #define CLSIZ(x)    (x.clsiz)
  193. X*** /tmp/,RCSt1a17064    Mon Mar 26 17:32:45 1990
  194. X--- Mkdfs.1    Mon Mar 26 17:32:44 1990
  195. X***************
  196. X*** 9,14 ****
  197. X--- 9,18 ----
  198. X  [
  199. X  .B -f
  200. X  ]
  201. X+ [
  202. X+ .B -l
  203. X+ .I label
  204. X+ ]
  205. X  .SH DESCRIPTION
  206. X  .I Mkdfs
  207. X  Mkdfs formats and initializes a DOS file system on a 3.5 inch Sun 4/60 or
  208. X***************
  209. X*** 25,31 ****
  210. X  .TP
  211. X  .B f
  212. X  First reformat the drive,  useful for new or abused drives.  (Using the drive
  213. X! in a Mac counts in the last category)
  214. X  .SH SEE ALSO
  215. X  mdir(1), mread(1), mtype(1), mren(1), mkd(1), mrd(1), mdel(1), mcopy(1)
  216. X  .SH AUTHOR
  217. X--- 29,38 ----
  218. X  .TP
  219. X  .B f
  220. X  First reformat the drive,  useful for new or abused drives.  (Using the drive
  221. X! in a Mac counts in the last category).
  222. X! .TP
  223. X! .B l \fIlabel\fR
  224. X! Use \fIlabel\fR as the disk volume label (up to 11 characters).
  225. X  .SH SEE ALSO
  226. X  mdir(1), mread(1), mtype(1), mren(1), mkd(1), mrd(1), mdel(1), mcopy(1)
  227. X  .SH AUTHOR
  228. END_OF_FILE
  229. if test 4811 -ne `wc -c <'patch1'`; then
  230.     echo shar: \"'patch1'\" unpacked with wrong size!
  231. fi
  232. # end of 'patch1'
  233. fi
  234. if test -f 'patch2' -a "${1}" != "-c" ; then 
  235.   echo shar: Will not clobber existing file \"'patch2'\"
  236. else
  237. echo shar: Extracting \"'patch2'\" \(1854 characters\)
  238. sed "s/^X//" >'patch2' <<'END_OF_FILE'
  239. XNewsgroups: comp.sources.bugs
  240. XSubject: Mtools official patch 2,  please apply.
  241. X
  242. X    A number of people complained about problems with binary files,
  243. Xthis was due a small slip in wmrite.c introduced while cleaning up the code.
  244. XIt continued to work on High Density disks where clus_size = 1,  but
  245. Xbroke badly on 720K disks where clus_size = 2,  the effect was that only 8
  246. Xout of 9 blocks made it to the floppy.  I also changed the makefile to install
  247. Xthe Mkdfs.1 man-page,  and to correct the object list for MREN.
  248. X
  249. X*** /tmp/,RCSt1a06212    Mon Mar 26 20:03:16 1990
  250. X--- Makefile    Mon Mar 26 18:20:15 1990
  251. X***************
  252. X*** 23,29 ****
  253. X  MTYPE    = mtype.o match.o $(CMNOBJ)
  254. X  MMD    = mmd.o fixname.o putfat.o mkentry.o $(CMNOBJ)
  255. X  MRD    = mrd.o putfat.o $(CMNOBJ)
  256. X! MREN    = mren.o fixname.o putfat.c isdir.o $(CMNOBJ)
  257. X  MCOPY    = mcopy.o
  258. X  
  259. X  all:    $(PROGS)
  260. X--- 23,29 ----
  261. X  MTYPE    = mtype.o match.o $(CMNOBJ)
  262. X  MMD    = mmd.o fixname.o putfat.o mkentry.o $(CMNOBJ)
  263. X  MRD    = mrd.o putfat.o $(CMNOBJ)
  264. X! MREN    = mren.o fixname.o putfat.o isdir.o $(CMNOBJ)
  265. X  MCOPY    = mcopy.o
  266. X  
  267. X  all:    $(PROGS)
  268. X***************
  269. X*** 74,79 ****
  270. X--- 74,80 ----
  271. X      cp Mread.1 $(MANDIR)/mread.1
  272. X      cp Mdir.1 $(MANDIR)/mdir.1
  273. X      cp Mwrite.1 $(MANDIR)/mwrite.1
  274. X+     cp Mkdfs.1 $(MANDIR)/mkdfs.1
  275. X      cp Mdel.1 $(MANDIR)/mdel.1
  276. X      cp Mtype.1 $(MANDIR)/mtype.1
  277. X      cp Mmd.1 $(MANDIR)/mmd.1
  278. X*** /tmp/,RCSt1a06212    Mon Mar 26 20:03:16 1990
  279. X--- mwrite.c    Mon Mar 26 19:57:58 1990
  280. X***************
  281. X*** 351,357 ****
  282. X  {
  283. X      static int blk;
  284. X      int c, nclust, current, eof=0;
  285. X!     int buflen = ( end - start ) * MSECSIZ ;
  286. X      register char *tbuf=outbuf;
  287. X  
  288. X      blk = (start - 2)*clus_size + dir_start + dir_len;
  289. X--- 351,357 ----
  290. X  {
  291. X      static int blk;
  292. X      int c, nclust, current, eof=0;
  293. X!     int buflen = ( end - start ) * MSECSIZ * clus_size ;
  294. X      register char *tbuf=outbuf;
  295. X  
  296. X      blk = (start - 2)*clus_size + dir_start + dir_len;
  297. END_OF_FILE
  298. if test 1854 -ne `wc -c <'patch2'`; then
  299.     echo shar: \"'patch2'\" unpacked with wrong size!
  300. fi
  301. # end of 'patch2'
  302. fi
  303. if test -f 'patch3' -a "${1}" != "-c" ; then 
  304.   echo shar: Will not clobber existing file \"'patch3'\"
  305. else
  306. echo shar: Extracting \"'patch3'\" \(3052 characters\)
  307. sed "s/^X//" >'patch3' <<'END_OF_FILE'
  308. X*** /tmp/,RCSt1a26646    Wed Apr 25 17:18:31 1990
  309. X--- mkdfs.c    Wed Apr 25 17:16:46 1990
  310. X***************
  311. X*** 9,15 ****
  312. X       * table parsing routines etc.,  not too hard,  just unpleasant.
  313. X       */
  314. X      main() {
  315. X!         printf("Do not know how to format disks on your system\n";
  316. X          exit(1) ;
  317. X      }
  318. X  #else
  319. X--- 9,15 ----
  320. X       * table parsing routines etc.,  not too hard,  just unpleasant.
  321. X       */
  322. X      main() {
  323. X!         printf("Do not know how to format disks on your system\n");
  324. X          exit(1) ;
  325. X      }
  326. X  #else
  327. X***************
  328. X*** 24,33 ****
  329. X  #include "bootblk.h"
  330. X  
  331. X  #define VOLLBL 0x8
  332. X! #define FAT720 0xf9
  333. X! #define FAT1440 0xf0
  334. X  static char floppy[] = "/dev/rfd0c" ;
  335. X! char disklabel[12] = "" ;
  336. X  
  337. X  void move(), Write(), usage(), formatit() ;
  338. X  
  339. X--- 24,33 ----
  340. X  #include "bootblk.h"
  341. X  
  342. X  #define VOLLBL 0x8
  343. X! #define FAT 0xf9
  344. X! 
  345. X  static char floppy[] = "/dev/rfd0c" ;
  346. X! static char disklabel[12] ;
  347. X  
  348. X  void move(), Write(), usage(), formatit() ;
  349. X  
  350. X***************
  351. X*** 38,44 ****
  352. X  {
  353. X    int c, fd, sec ;
  354. X    int fat_len = 3 ;
  355. X!   int fat = FAT720 ;
  356. X    int dir_len = 7 ;
  357. X    int hdflag=0, fflag = 0 ;
  358. X    extern char *optarg;
  359. X--- 38,44 ----
  360. X  {
  361. X    int c, fd, sec ;
  362. X    int fat_len = 3 ;
  363. X!   int fat = FAT ;
  364. X    int dir_len = 7 ;
  365. X    int hdflag=0, fflag = 0 ;
  366. X    extern char *optarg;
  367. X***************
  368. X*** 45,50 ****
  369. X--- 45,53 ----
  370. X  
  371. X    progname = argv[0] ;
  372. X  
  373. X+   /* Initialize with spaces */
  374. X+   sprintf(disklabel,"%-11.11s","") ;
  375. X+ 
  376. X    while( (c=getopt(argc,argv,"hfl:")) != EOF ) {
  377. X      switch(c) {
  378. X      case 'f' :
  379. X***************
  380. X*** 54,60 ****
  381. X        hdflag++ ;
  382. X        break;
  383. X      case 'l' :
  384. X!       strncpy(disklabel, optarg, 11) ;
  385. X        break;
  386. X      case '?':
  387. X      default:
  388. X--- 57,63 ----
  389. X        hdflag++ ;
  390. X        break;
  391. X      case 'l' :
  392. X!       sprintf(disklabel,"%-11.11s",optarg) ;
  393. X        break;
  394. X      case '?':
  395. X      default:
  396. X***************
  397. X*** 77,83 ****
  398. X    if ( hdflag ) {
  399. X      dir_len=14 ;
  400. X      fat_len=9 ;
  401. X-     fat=FAT1440 ;
  402. X    }
  403. X    
  404. X    bzero(buf,sizeof(buf)) ;
  405. X--- 80,85 ----
  406. X*** /tmp/,RCSt1a26649    Wed Apr 25 17:18:59 1990
  407. X--- bootblk.h    Mon Apr 23 13:47:39 1990
  408. X***************
  409. X*** 6,17 ****
  410. X   * and make sure to create the "hidden" files in mkdfs.c
  411. X   * (this is not easy!)
  412. X   */
  413. X! static unsigned short hdboot[] = {
  414. X! 0xeb34,0x9020,0x2020,0x2020,0x2020,0x2000,0x0201,0x0100,
  415. X! 0x02e0,0x0040,0x0bf0,0x0900,0x1200,0x0200,0x0000,0x0000,
  416. X  } ;
  417. X  
  418. X! static unsigned short ldboot[] = {
  419. X! 0xeb34,0x9020,0x2020,0x2020,0x2020,0x2000,0x0202,0x0100,
  420. X! 0x0270,0x00a0,0x05f9,0x0300,0x0900,0x0200,0x0000,0x0000,
  421. X  } ;
  422. X--- 6,17 ----
  423. X   * and make sure to create the "hidden" files in mkdfs.c
  424. X   * (this is not easy!)
  425. X   */
  426. X! static unsigned char hdboot[] = {
  427. X! 0xeb,0x34,0x90,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x02,0x01,0x01,0x00,
  428. X! 0x02,0xe0,0x00,0x40,0x0b,0xf9,0x09,0x00,0x12,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
  429. X  } ;
  430. X  
  431. X! static unsigned char ldboot[] = {
  432. X! 0xeb,0x34,0x90,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x02,0x02,0x01,0x00,
  433. X! 0x02,0x70,0x00,0xa0,0x05,0xf9,0x03,0x00,0x09,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
  434. X  } ;
  435. END_OF_FILE
  436. if test 3052 -ne `wc -c <'patch3'`; then
  437.     echo shar: \"'patch3'\" unpacked with wrong size!
  438. fi
  439. # end of 'patch3'
  440. fi
  441. echo shar: End of shell archive.
  442. exit 0
  443.     Viktor Dukhovni <viktor@math.princeton.edu>    : ARPA
  444.         <...!uunet!princeton!math!viktor>    : UUCP
  445.     Fine Hall, Washington Rd., Princeton, NJ 08544  : US-Post
  446.         +1-(609)-258-5792             : VOICE
  447.  
  448.