home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / diskutil / mtools / xenixpat.ch < prev   
Encoding:
Text File  |  1993-08-05  |  10.7 KB  |  356 lines

  1. Submitted-By: vancleef@netcom.netcom.com (Henry van Cleef)
  2. Posting-Number: Volume 25, Issue 103
  3. Archive-Name: mtools2-xenixpatch
  4.  
  5. This patch to Emmett Gray's Mtools revision 2.0.5 was produced from the
  6. changes I made to the distribution to install mtools on my Xenix 286
  7. system.  There were a number of places where the Xenix int of 16 bits caused
  8. trouble, particularly with use of mtools on hard disks.  
  9.  
  10. The table in devices.c is one that illustrates several ways of handling
  11. /dev/drivers.  It is set up to work with two hard disks, one of which has
  12. two DOS partitions.  
  13.  
  14. You will have to change the permissions on the /dev/hd* disks to use this
  15. code.  I did not set these programs up for setuid/setgid.  
  16.  
  17. My thanks to Emmett Gray for writing mtools.  It was a fairly easy port as
  18. things go with Xenix.  I had to prepare this patch file on my 3b1 Unix PC
  19. because Xenix 286 does not have a context switch in diff, and the gnu diff
  20. program blows up the compiler because the macros in regex.c are too big.  So
  21. it goes.
  22.  
  23. WARNING:  If you have problems, they will most likely be with the fat
  24. calculations in fat_read.c and fat_write.c and show up when working with
  25. hard disks.  BACK UP YOUR SYSTEM before you try writing to the hard disk.  I
  26. blew up my hard disk fat a number of times and was glad I had nothing sacred
  27. on those disks.  A good check is to see that file sizes and free space are
  28. reported correctly with mdir, but this does not test fat_write.c.  Take a
  29. careful look at the patches for these two files---the context lines,
  30. particularly the ones showing showing start = num * 2 are important---this
  31. was a bug in earlier releases.  
  32.  
  33.     vancleef@netcom.netcom.com (Henry van Cleef)
  34.  
  35. #!/bin/sh
  36. # This is a shell archive (produced by shar 3.49)
  37. # To extract the files from this archive, save it to a file, remove
  38. # everything above the "!/bin/sh" line above, and type "sh file_name".
  39. #
  40. # made 01/12/1992 05:09 UTC by install@jennifer
  41. # Source directory /users/xenix/patches
  42. #
  43. # existing files will NOT be overwritten unless -c is specified
  44. #
  45. # This shar contains:
  46. # length  mode       name
  47. # ------ ---------- ------------------------------------------
  48. #   7978 -rw-r--r-- mtools.patch
  49. #
  50. # ============= mtools.patch ==============
  51. if test -f 'mtools.patch' -a X"$1" != X"-c"; then
  52.     echo 'x - skipping mtools.patch (File already exists)'
  53. else
  54. echo 'x - extracting mtools.patch (Text)'
  55. sed 's/^X//' << 'SHAR_EOF' > 'mtools.patch' &&
  56. diff -c ../mtools/Makefile .//Makefile
  57. *** ../mtools/Makefile    Sat Jan  4 18:59:15 1992
  58. --- .//Makefile    Sat Jan 11 23:21:39 1992
  59. ***************
  60. *** 3,17 ****
  61. X  #
  62. X  # check the Configure file for some examples of device-specific setups
  63. X  # Berkeley flavors of Unix should include -DBSD in the CFLAGS
  64. X  
  65. ! CFLAGS    = -O
  66. ! LDFLAGS    = -s
  67. X  LD    = cc
  68. X  LINT    = lint
  69. X  SHLIB    =
  70. ! SHAR    = shar -a
  71. X  BINDIR    = /usr/local/bin
  72. ! MANSECT    = 1
  73. X  MANDIR    = /usr/man/man$(MANSECT)
  74. X  #
  75. X  # for AT&T Unix PC 7300/3b1 style shared libraries.
  76. --- 3,18 ----
  77. X  #
  78. X  # check the Configure file for some examples of device-specific setups
  79. X  # Berkeley flavors of Unix should include -DBSD in the CFLAGS
  80. + # This setup is for Xenix 286.  A stack of 5000 seems to work OK.
  81. X  
  82. ! CFLAGS    = -O -M2e
  83. ! LDFLAGS    = -s -M2e -i -F 5000  #Small model, separate I and D space
  84. X  LD    = cc
  85. X  LINT    = lint
  86. X  SHLIB    =
  87. ! SHAR    = shar 
  88. X  BINDIR    = /usr/local/bin
  89. ! MANSECT    = LOCAL
  90. X  MANDIR    = /usr/man/man$(MANSECT)
  91. X  #
  92. X  # for AT&T Unix PC 7300/3b1 style shared libraries.
  93. ***************
  94. *** 116,122 ****
  95. X      cp Mkmanifest.1 $(MANDIR)/mkmanifest.$(MANSECT)
  96. X  
  97. X  clean:
  98. !     rm $(PROGS)
  99. X  
  100. X  lint:
  101. X      $(LINT) mattrib.c buf_read.c buf_write.c devices.c dir_read.c \
  102. --- 117,126 ----
  103. X      cp Mkmanifest.1 $(MANDIR)/mkmanifest.$(MANSECT)
  104. X  
  105. X  clean:
  106. !     rm -f $(PROGS) core *.o
  107. ! relink:
  108. !     rm -f $(PROGS)
  109. X  
  110. X  lint:
  111. X      $(LINT) mattrib.c buf_read.c buf_write.c devices.c dir_read.c \
  112. diff -c ../mtools/buf_read.c .//buf_read.c
  113. *** ../mtools/buf_read.c    Sat Jan  4 18:59:30 1992
  114. --- .//buf_read.c    Sat Jan 11 17:09:06 1992
  115. ***************
  116. *** 27,32 ****
  117. --- 27,34 ----
  118. X      long where, tail, lseek();
  119. X      void perror(), exit(), disk_flush();
  120. X  
  121. +     long debug_num;
  122. X                      /* don't use cache? */
  123. X      if (disk_size == 1) {
  124. X          where = (start * MSECTOR_SIZE) + disk_offset;
  125. diff -c ../mtools/devices.c .//devices.c
  126. *** ../mtools/devices.c    Sat Jan  4 18:59:32 1992
  127. --- .//devices.c    Sat Jan 11 18:05:52 1992
  128. ***************
  129. *** 46,51 ****
  130. --- 46,77 ----
  131. X  };
  132. X  #endif /* SPARC */
  133. X  
  134. + /* The following table is for a 1.44 3.5 drive in A:, a 1.2 5.25 
  135. +  * drive in B:, and two hard disks, each beginning with a DOS 
  136. +  * partition.  Drives H: and L: force drive A: to hi and lo 
  137. +  * density; X: and Y: do the same for B:.  This shows all the
  138. +  * possibilities.  /dev/install and /dev/install1 are the preferred
  139. +  * driver entries.  If you do not have a second hard disk, do not
  140. +  * include an entry for /dev/hd1d. (Table added by H. van Cleef,
  141. +  * 12-20-91)
  142. +  */
  143. + #ifdef M_XENIX
  144. + struct device devices[] = {
  145. +     {'A', "/dev/install", 0L, 12, 0, (int (*) ()) 0, 80, 2, 18},
  146. +     {'A', "/dev/install", 0L, 12, 0, (int (*) ()) 0, 80, 2, 9},
  147. +     {'B', "/dev/install1", 0L, 12, 0, (int (*) ()) 0, 80, 2, 15},
  148. +     {'B', "/dev/install1", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},
  149. +     {'C', "/dev/hd0d", 0L, 16, 0, (int (*) ()) 0, 0, 0, 0},
  150. +     {'D', "/dev/hd1d", 0L, 16, 0, (int (*) ()) 0, 0, 0, 0},
  151. +     {'E', "/dev/hd12", 0L, 16, 0, (int (*) ()) 0, 0, 0, 0},
  152. +     {'H', "/dev/fd0135ds18", 0L, 12, 0, (int (*) ()) 0, 80, 2, 18},
  153. +     {'L', "/dev/fd0135ds9", 0L, 12, 0, (int (*) ()) 0, 80, 2, 9},
  154. +     {'X', "/dev/fd196ds15", 0L, 12, 0, (int (*) ()) 0, 80, 2, 15},
  155. +     {'Y', "/dev/fd148ds9", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},
  156. +     {'\0', (char *) NULL, 0L, 0, 0, (int (*) ()) 0, 0, 0, 0}
  157. + };
  158. + #endif /*M_XENIX*/
  159. X  #ifdef UNIXPC
  160. X  #include <sys/gdioctl.h>
  161. X  #include <fcntl.h>
  162. diff -c ../mtools/fat_read.c .//fat_read.c
  163. *** ../mtools/fat_read.c    Sat Jan  4 18:59:54 1992
  164. --- .//fat_read.c    Sat Jan 11 01:12:31 1992
  165. ***************
  166. *** 17,24 ****
  167. X  fat_decode(num)
  168. X  unsigned int num;
  169. X  {
  170. !     unsigned int fat, fat_hi, fat_low, byte_1, byte_2;
  171. !     int start;
  172. X  
  173. X      if (fat_bits == 12) {
  174. X          /*
  175. --- 17,24 ----
  176. X  fat_decode(num)
  177. X  unsigned int num;
  178. X  {
  179. !     unsigned long fat, fat_hi, fat_low, byte_1, byte_2;
  180. !     long start;
  181. X  
  182. X      if (fat_bits == 12) {
  183. X          /*
  184. ***************
  185. *** 60,66 ****
  186. X           */
  187. X                      /* which bytes contain the entry */
  188. X          start = num * 2;
  189. !         if (start <= 3 || start + 1 > (fat_len * MSECTOR_SIZE))
  190. X              return(1);
  191. X  
  192. X          fat = (*(fat_buf + start + 1) * 0x100) + *(fat_buf + start);
  193. --- 60,66 ----
  194. X           */
  195. X                      /* which bytes contain the entry */
  196. X          start = num * 2;
  197. !         if (start <= 3 || start + 1 > ((long)fat_len * MSECTOR_SIZE))
  198. X              return(1);
  199. X  
  200. X          fat = (*(fat_buf + start + 1) * 0x100) + *(fat_buf + start);
  201. ***************
  202. *** 76,82 ****
  203. X  fat_read(start)
  204. X  int start;
  205. X  {
  206. !     int buflen;
  207. X      char *malloc();
  208. X      void perror(), exit(), disk_read();
  209. X                      /* only the first copy of the FAT */
  210. --- 76,82 ----
  211. X  fat_read(start)
  212. X  int start;
  213. X  {
  214. !     long buflen;
  215. X      char *malloc();
  216. X      void perror(), exit(), disk_read();
  217. X                      /* only the first copy of the FAT */
  218. diff -c ../mtools/fat_write.c .//fat_write.c
  219. *** ../mtools/fat_write.c    Sat Jan  4 18:59:55 1992
  220. --- .//fat_write.c    Sat Jan 11 01:13:49 1992
  221. ***************
  222. *** 14,20 ****
  223. X  unsigned int num;
  224. X  unsigned int code;
  225. X  {
  226. !     int start;
  227. X  
  228. X      if (fat_bits == 12) {
  229. X          /*
  230. --- 14,20 ----
  231. X  unsigned int num;
  232. X  unsigned int code;
  233. X  {
  234. !     long start;
  235. X  
  236. X      if (fat_bits == 12) {
  237. X          /*
  238. ***************
  239. *** 52,58 ****
  240. X           */
  241. X                      /* which bytes contain the entry */
  242. X          start = num * 2;
  243. !         if (start <= 3 || start + 1 > (fat_len * MSECTOR_SIZE))
  244. X              return(1);
  245. X  
  246. X          *(fat_buf + start + 1) =  code / 0x100;
  247. --- 52,58 ----
  248. X           */
  249. X                      /* which bytes contain the entry */
  250. X          start = num * 2;
  251. !         if (start <= 3 || start + 1 > ((long)fat_len * MSECTOR_SIZE))
  252. X              return(1);
  253. X  
  254. X          *(fat_buf + start + 1) =  code / 0x100;
  255. ***************
  256. *** 70,76 ****
  257. X  void
  258. X  fat_write()
  259. X  {
  260. !     int fat_start, buflen, dups;
  261. X      void disk_write();
  262. X  
  263. X      if (fd < 0)
  264. --- 70,76 ----
  265. X  void
  266. X  fat_write()
  267. X  {
  268. !     long fat_start, buflen, dups;
  269. X      void disk_write();
  270. X  
  271. X      if (fd < 0)
  272. diff -c ../mtools/mdir.c .//mdir.c
  273. *** ../mtools/mdir.c    Sat Jan  4 19:00:07 1992
  274. --- .//mdir.c    Sat Jan 11 18:12:58 1992
  275. ***************
  276. *** 78,86 ****
  277. X              if (last_drive != 'x') {
  278. X                  blocks = getfree() * MSECTOR_SIZE;
  279. X                  if (!files)
  280. !                     printf("File \"%s\" not found\n\n", newname);
  281. X                  else
  282. !                     printf("     %3d File(s)     %6ld bytes free\n\n", files, blocks);
  283. X              }
  284. X              if (init(drive, 0)) {
  285. X                  fprintf(stderr, "%s: Cannot initialize '%c:'\n", argv[0], drive);
  286. --- 78,86 ----
  287. X              if (last_drive != 'x') {
  288. X                  blocks = getfree() * MSECTOR_SIZE;
  289. X                  if (!files)
  290. !                     printf("File \"%s\" not found %8ld bytes free\n\n", newname,blocks);
  291. X                  else
  292. !                     printf("     %3d File(s)     %8ld bytes free\n\n", files, blocks);
  293. X              }
  294. X              if (init(drive, 0)) {
  295. X                  fprintf(stderr, "%s: Cannot initialize '%c:'\n", argv[0], drive);
  296. ***************
  297. *** 196,204 ****
  298. X  
  299. X      blocks = getfree() * MSECTOR_SIZE;
  300. X      if (!files)
  301. !         printf("File \"%s\" not found\n", newname);
  302. X      else
  303. !         printf("     %3d File(s)     %6ld bytes free\n", files, blocks);
  304. X      close(fd);
  305. X      exit(0);
  306. X  }
  307. --- 196,204 ----
  308. X  
  309. X      blocks = getfree() * MSECTOR_SIZE;
  310. X      if (!files)
  311. !         printf("File \"%s\" not found %8ld bytes free\n\n", newname,blocks);
  312. X      else
  313. !         printf("     %3d File(s)     %8ld bytes free\n", files, blocks);
  314. X      close(fd);
  315. X      exit(0);
  316. X  }
  317. diff -c ../mtools/msdos.h .//msdos.h
  318. *** ../mtools/msdos.h    Sat Jan  4 19:00:29 1992
  319. --- .//msdos.h    Sat Jan 11 14:56:34 1992
  320. ***************
  321. *** 2,10 ****
  322. X   * msdos common header file
  323. X   */
  324. X  
  325. ! #define MSECTOR_SIZE    512        /* MSDOS sector size in bytes */
  326. X  #define MDIR_SIZE    32        /* MSDOS directory size in bytes */
  327. ! #define MAX_CLUSTER    8192        /* largest cluster size */
  328. X  #define MAX_PATH    128        /* largest MSDOS path length */
  329. X  #define MAX_DIR_SECS    64        /* largest directory (in sectors) */
  330. X  
  331. --- 2,10 ----
  332. X   * msdos common header file
  333. X   */
  334. X  
  335. ! #define MSECTOR_SIZE    512L        /* MSDOS sector size in bytes */
  336. X  #define MDIR_SIZE    32        /* MSDOS directory size in bytes */
  337. ! #define MAX_CLUSTER    8192L        /* largest cluster size */
  338. X  #define MAX_PATH    128        /* largest MSDOS path length */
  339. X  #define MAX_DIR_SECS    64        /* largest directory (in sectors) */
  340. X  
  341. Only in ./: mtools.patch
  342. SHAR_EOF
  343. chmod 0644 mtools.patch ||
  344. echo 'restore of mtools.patch failed'
  345. Wc_c="`wc -c < 'mtools.patch'`"
  346. test 7978 -eq "$Wc_c" ||
  347.     echo 'mtools.patch: original size 7978, current size' "$Wc_c"
  348. fi
  349. exit 0
  350. -- 
  351. Hank van Cleef---The Union Institute---History of Science and Technology
  352. Unix, X11, networked systems  vancleef@netcom.com, vancleef@tmn.com  
  353.