home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / bsd / 3009 < prev    next >
Encoding:
Text File  |  1992-07-27  |  4.5 KB  |  114 lines

  1. Path: sparky!uunet!bonnie.concordia.ca!daily-planet.concordia.ca!davinci!steve
  2. From: steve@concordia.ca
  3. Newsgroups: comp.unix.bsd
  4. Subject: Using Mtools with DOS fixed disk
  5. Message-ID: <4621@daily-planet.concordia.ca>
  6. Date: 28 Jul 92 03:40:02 GMT
  7. Sender: usenet@daily-planet.concordia.ca
  8. Organization: Concordia University, Montreal, Quebec
  9. Lines: 102
  10. Originator: steve@davinci
  11.  
  12.  
  13. Despite all the talk about getting mtools to work with a DOS fixed
  14. disk, none of it seemed to work.  I ended up getting things working
  15. by taking the following approach:
  16.  
  17. 1) Get a decent disk/sector editor ( I used 'DiskEdit', available
  18. on wuarchives as /mirrors/msdos/dskutl/diskedt.zip ).  Use this
  19. to find out what's in cylinder 0, head 0, sector 1.  The magic
  20. offsets are 01EE, 01DE, O1CE and 01BE for the 4 possible partitions
  21. that fdisk will report in that order.
  22.  
  23. My disk looked like this:
  24.       0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
  25.    -------------------------------------------------
  26. 1B | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <- Unused
  27. 1C | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <- Unused
  28. 1D | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 <- DOS
  29.                                                   ^^
  30. 1E | 01 00 06 0C B3 50 33 00 00 00 94 FF 05 00 80 00 <- 386BSD
  31.      ^^ ^^ ^^
  32.            || BIGDOS System Indicator (32 bit sectors)
  33.  
  34. 1F | 81 51 A5 OC B3 D2 C7 FF 05 00 AE 50 01 00 55 AA
  35.            ^^                                  ^^^^^
  36.            386BSD System Indicator             End of MBR
  37.  
  38. Now, offset 01DE to 01ED is for my DOS partition, which is
  39. indicated by the hex value 06 at offset 01E2.  Other valid
  40. DOS System Indicators are 01 for DOS 12 bit FAT and 04 for
  41. DOS 16 bit FAT (16 bit sectors).
  42.  
  43. 2) Enough background. At offset 01DF the value indicates
  44. the head(track) on which the DOS partition starts, which in
  45. my case is track #1.  At offsets 01E0-01E1 the values are
  46. interpreted as follows:
  47.  
  48.    01E0      01E1
  49.  
  50.  00 000001 00000000
  51.  ^^ ^^^^^^
  52.  |  |
  53.  |   -> Starting sector of DOS partition = 1.
  54.  |
  55.  |-> Add to value at 01E1 to get 00 00000000 = 0,
  56.      the starting cylinder # of the DOS partition.
  57.  
  58. 3) Therefore we get the start of the DOS partition to be at
  59. Cylinder # 0, Head # 1 and Sector # 1.  The same calculation
  60. for the 386BSD partition would yield Cylinder # 593, Head # 1
  61. and Sector #1. To turn these values into an offset usable by
  62. the mtools device structure, we need to know a bit of the disk
  63. geometry.  This can be obtained by looking at your disktab entry
  64. (or by executing disklabel -r wd?).  My disktab looks like:
  65.  
  66. qlp240A|Quantum 245MB IDE (DOS in cyl. 0-592): \
  67.     :dt=ST506:ty=winchester:se#512:nt#13:ns#51:nc#723: \
  68.     :pa#21216:oa#393159:ta=4.2BSD:ba#4096:fa#512: \
  69.     :pb#42432:ob#414375:tb=swap: \
  70.     :pc#84864:oc#393159: \
  71.     :pd#478023:od#0: \
  72.     :ph#21216:oh#456807:th=4.2BSD:bh#4096:fh#512:
  73.  
  74. Note that the entry for partition d spans the WHOLE disk,
  75. and partition c only spans the 386BSD portion of the disk.
  76.  
  77. You need the value for ns which is the number of sectors/head,
  78. and nt which is the number of heads/cylinder, and se which is the
  79. sector size in bytes.  The final calculation is:
  80.  
  81. offset = [(Cyl# * nt *ns) + (Head# * ns) + Sect# - 1] * se
  82.  
  83. which in my case yields 26112, giving the following device
  84. description in the mtools devices.c file
  85.  
  86. #ifdef __386BSD__
  87. struct device devices[] = {
  88.     {'C', "/dev/rwd0d", 26112L, 16, 0, (int (O) ()) 0, 0, 0, 0},
  89.     {'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 18}, /* 1.44m */
  90.     {'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 15}, /* 1.2m */
  91.     {'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 9},  /* 720k */
  92.     {'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},  /* 360k */
  93.     {'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 40, 2, 8},  /* 320k */
  94.     {'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 18}, /* 1.44m */
  95.     {'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 15}, /* 1.2m */
  96.     {'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 9},  /* 720k */
  97.     {'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},  /* 360k */
  98.     {'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 40, 2, 8},  /* 320k */
  99.     {'\0', (char O) NULL, 0L, 0, 0, (int (*) ()) 0, 0, 0, 0}
  100. };
  101. #endif /* __386BSD__ */
  102.  
  103. It works for me.  If there is an easier way to get this information,
  104. I don't know about it.  The closest I can get is INT 21,32 but this
  105. doesn't seem to get me the information I want.
  106.  
  107. Hope this helps.
  108.  
  109. -- 
  110.    Steve Biedlingmaier
  111.    Tel.   : (514) 682-3400 ext. 284
  112.    Fax    : (514) 686-1990
  113.    E-mail : sbiedling@ccrit.doc.ca, steve@davinci.concordia.ca 
  114.