egray@osiris.cso.uiuc.edu (Emmet P. Gray) (04/16/91)
This is patch #4 to the Mtools v2.0 distribution package. This patch will fix a bug in the mmd command where directories inherited the file name extension of the parent directory. It also adds a feature that will allow the copying of zero length files. Mtools was posted to the unix-pc.sources news group (and mailed to Rich Salz, the moderator of comp.sources.unix) on the 17th of September 1990. Since then, patches 1-3 have been posted to unix-pc.sources, comp.sources.bugs, and emailed to Rich Salz. The "always current" version of Mtools and all the patches are available via anonymous ftp from cerl.cecer.army.mil (129.229.1.101). I've also uploaded the files to the ~ftp/tmp/mtools directory on uunet.uu.net. Emmet P. Gray US Army, HQ III Corps & Fort Hood ...!uunet!uiucuxc!fthood!egray Attn: AFZF-DE-ENV fthood!egray@uxc.cso.uiuc.edu Directorate of Engineering & Housing Environmental Management Office Fort Hood, TX 76544-5057 ----------------------------------------------------------------------------- Prereq: 2.0.3 *** old/patchlevel.h Thu Apr 11 19:09:32 1991 --- patchlevel.h Thu Apr 11 19:21:42 1991 *************** *** 1 **** ! #define VERSION 2.0.3 --- 1,17 ---- ! #define VERSION "2.0.4" ! #define DATE "11 Apr 91" ! ! /* ! * Version 1.0 13 Oct 86 ! * Version 1.1 11 Jan 87 ! * Version 1.2 11 Jun 87 ! * Version 1.3 15 Jun 88 ! * Version 1.4 28 Sep 88 ! * Version 1.5 9 Oct 88 ! * Version 1.6 3 May 89 ! * Version 2.0 8 Sep 90 ! * patch #1 12 Oct 90 ! * patch #2 21 Nov 90 ! * patch #3 28 Nov 90 ! * patch #4 11 Apr 91 ! */ *** old/Configure Thu Apr 11 19:09:31 1991 --- Configure Sun Apr 14 14:14:03 1991 *************** *** 21,26 **** 2) The Makefile and msdos.h files ! The following pre-processor variables are used throughout ! Mtools: BSD for systems without System V style strings functions --- 21,26 ---- 2) The Makefile and msdos.h files ! The following pre-processor variables are used in Mtools. They ! should be set with "-Dvariable" in CFLAGS in the Makefile. BSD for systems without System V style strings functions *************** *** 27,35 **** and System V style utime(). ! UNIXPC for users of AT&T Unix PC 7300/3B1 ! There are a few more pre-processor variables in devices.c to select ! some standard device options. There is a variable in msdos.h called SIG_TYPE which should be configured to the "base" return type of signal(); --- 27,36 ---- and System V style utime(). ! ISC default devices for ISC's Unix V. ! UNIXPC default devices for AT&T Unix PC 7300/3B1 + SPARC default devices for SunOS 4.1 on a SPARCstation + There is a variable in msdos.h called SIG_TYPE which should be configured to the "base" return type of signal(); *************** *** 37,40 **** --- 38,45 ---- 3) The devices "database" in devices.c + WARNING: The devices.c file, as distributed, has *NO* devices + defined. You *MUST* select from one of the examples or edit the + devices database yourself. + struct device { char drive; /* the drive letter */ *************** *** 79,86 **** ! If a device supports more than one disk capacity (1.2m and ! 360k), then you should place the most frequently used capacity ! first. You may get an error message from the device driver when ! the disk capacity doesn't match the device, but these can be safely ignored. --- 84,91 ---- ! If a device supports more than one disk capacity (1.2m and ! 360k), then you should place the most frequently used capacity ! first. You may get an error message from the device driver when ! the disk capacity doesn't match the device, but these can be safely ignored. *************** *** 121,125 **** {'\0', (char *) NULL, 0L, 0, 0, (int (*)()) 0, 0, 0, 0} ! Note that the two devices are actually the same physical ! device, and that only the number of sectors are ! different. --- 126,130 ---- {'\0', (char *) NULL, 0L, 0, 0, (int (*)()) 0, 0, 0, 0} ! Note that the two devices are actually the same physical ! device, and that only the number of sectors are ! different. *** old/Makefile Thu Apr 11 19:10:27 1991 --- Makefile Thu Apr 11 19:21:42 1991 *************** *** 178,193 **** init.o: msdos.h is_dir.o: msdos.h ! mattrib.o: msdos.h ! mcd.o: msdos.h ! mdel.o: msdos.h ! mdir.o: msdos.h ! mformat.o: msdos.h ! mlabel.o: msdos.h ! mmd.o: msdos.h ! mrd.o: msdos.h ! mread.o: msdos.h ! mren.o: msdos.h ! mtype.o: msdos.h ! mwrite.o: msdos.h parse.o: msdos.h subdir.o: msdos.h --- 178,194 ---- init.o: msdos.h is_dir.o: msdos.h ! mattrib.o: msdos.h patchlevel.h ! mcd.o: msdos.h patchlevel.h ! mcopy.o: patchlevel.h ! mdel.o: msdos.h patchlevel.h ! mdir.o: msdos.h patchlevel.h ! mformat.o: msdos.h patchlevel.h ! mlabel.o: msdos.h patchlevel.h ! mmd.o: msdos.h patchlevel.h ! mrd.o: msdos.h patchlevel.h ! mread.o: msdos.h patchlevel.h ! mren.o: msdos.h patchlevel.h ! mtype.o: msdos.h patchlevel.h ! mwrite.o: msdos.h patchlevel.h parse.o: msdos.h subdir.o: msdos.h *** old/Mformat.1 Thu Apr 11 19:09:31 1991 --- Mformat.1 Thu Apr 11 19:21:43 1991 *************** *** 31,34 **** --- 31,38 ---- .B l An optional volume label. + .PP + To format a diskette at a density other than the default, you must supply + (at least) those command line parameters that are different from the + default. .SH SEE ALSO mlabel(1) *** old/Mformat.out Thu Apr 11 19:09:31 1991 --- Mformat.out Thu Apr 11 19:21:43 1991 *************** *** 29,32 **** --- 29,36 ---- l An optional volume label. + To format a diskette at a density other than the default, + you must supply (at least) those command line parameters + that are different from the the default. + SEE ALSO mlabel(1) *** old/Readme Thu Apr 11 19:09:31 1991 --- Readme Thu Apr 11 19:34:36 1991 *************** *** 1,4 **** MTOOLS ! version 2.0.0 - 8 Sep 90 Mtools is a public domain collection of programs to allow Unix systems --- 1,4 ---- MTOOLS ! version 2.0 Mtools is a public domain collection of programs to allow Unix systems *** old/Release.notes Thu Apr 11 19:09:31 1991 --- Release.notes Sun Apr 14 14:12:39 1991 *************** *** 1,5 **** New in the v2.0 release.... ! 1) Support for multiple devices. Mtools now supports: multiple floppy disks (A:, B:, etc) DOS partitions on a hard disk --- 1,5 ---- New in the v2.0 release.... ! 1) Support for multiple devices. Mtools now supports: multiple floppy disks (A:, B:, etc) DOS partitions on a hard disk *************** *** 20,25 **** get clobbered by MSDOS file name restrictions. ! 7) The mkdfs program of the "fast-mtools" release for the Sun SparcStation can be replaced with mformat. Many thanks to Viktor Dukhovni (viktor@math.princeton.edu) for --- 20,28 ---- get clobbered by MSDOS file name restrictions. ! 7) The mkdfs program of the "fast-mtools" release for the Sun SparcStation can be replaced with mformat. + + 8) The Configure file has been included to help those who must add + devices to the devices.c file. Many thanks to Viktor Dukhovni (viktor@math.princeton.edu) for *** old/buf_write.c Thu Apr 11 19:09:31 1991 --- buf_write.c Thu Apr 11 19:43:51 1991 *************** *** 11,14 **** --- 11,15 ---- extern long disk_offset, disk_current; extern unsigned char *disk_buf; + static int blank_cyl(); void *** old/dir_make.c Thu Apr 11 19:09:31 1991 --- dir_make.c Thu Apr 11 19:55:24 1991 *************** *** 29,32 **** --- 29,33 ---- return(1); + /* CONSTCOND */ while (1) { next = fat_decode(fat); *** old/dir_read.c Thu Apr 11 19:09:31 1991 --- dir_read.c Thu Apr 11 19:46:34 1991 *************** *** 42,45 **** --- 42,46 ---- length = 0; + /* CONSTCOND */ while (1) { dir_chain[length] = (long) (num - 2) * clus_size + dir_start + dir_len; *************** *** 96,100 **** register int i; char *malloc(); ! void free(), disk_read(), dir_flush(); if (dir_dirty) --- 97,101 ---- register int i; char *malloc(); ! void free(), disk_read(), dir_flush(), exit(), perror(); if (dir_dirty) *** old/dir_write.c Thu Apr 11 19:09:31 1991 --- dir_write.c Thu Apr 11 19:21:44 1991 *************** *** 66,70 **** char *s, buf[MAX_PATH], *name, *ext, *strcpy(), *strpbrk(), *strrchr(); static unsigned char ans[13]; ! int dot, modified; register int i; --- 66,70 ---- char *s, buf[MAX_PATH], *name, *ext, *strcpy(), *strpbrk(), *strrchr(); static unsigned char ans[13]; ! int dot, modified, len; register int i; *************** *** 82,93 **** ext = ""; dot = 0; ! for (i = strlen(buf) - 1; i >= 0; i--) { ! if (buf[i] == '.' && !dot) { dot = 1; ! buf[i] = '\0'; ! ext = &buf[i + 1]; } ! if (islower(buf[i])) ! buf[i] = toupper(buf[i]); } if (*name == '\0') { --- 82,95 ---- ext = ""; dot = 0; ! len = strlen(name); ! for (i = 0; i < len; i++) { ! s = name + len -i -1; ! if (*s == '.' && !dot) { dot = 1; ! *s = '\0'; ! ext = s +1; } ! if (islower(*s)) ! *s = toupper(*s); } if (*name == '\0') { *** old/fat_free.c Thu Apr 11 19:09:31 1991 --- fat_free.c Thu Apr 11 19:54:25 1991 *************** *** 16,20 **** --- 16,24 ---- { unsigned int next, fat_decode(); + /* a zero length file? */ + if (fat == 0) + return(0); + /* CONSTCOND */ while (1) { /* get next cluster number */ *** old/file_read.c Thu Apr 11 19:09:31 1991 --- file_read.c Thu Apr 11 19:57:00 1991 *************** *** 21,29 **** long current, start; unsigned char in_buf[MAX_CLUSTER], out_buf[MAX_CLUSTER]; ! void disk_read(); current = 0L; in_len = clus_size * MSECTOR_SIZE; while (1) { start = (long) (fat - 2) * clus_size + dir_start + dir_len; --- 21,33 ---- long current, start; unsigned char in_buf[MAX_CLUSTER], out_buf[MAX_CLUSTER]; ! void disk_read(), perror(); current = 0L; in_len = clus_size * MSECTOR_SIZE; + /* a zero length file? */ + if (fat == 0) + return(0); + /* CONSTCOND */ while (1) { start = (long) (fat - 2) * clus_size + dir_start + dir_len; *************** *** 47,51 **** } /* write it */ ! fwrite((char *) out_buf, sizeof(*out_buf), out_len, fp); } /* much easier... */ --- 51,58 ---- } /* write it */ ! if (fwrite((char *) out_buf, sizeof(*out_buf), out_len, fp) == 0) { ! perror("file_write: fwrite"); ! return(-1); ! } } /* much easier... */ *************** *** 52,56 **** else { out_len = (size - current > in_len) ? in_len : size - current; ! fwrite((char *) in_buf, sizeof(*in_buf), out_len, fp); current += out_len; --- 59,66 ---- else { out_len = (size - current > in_len) ? in_len : size - current; ! if (fwrite((char *) in_buf, sizeof(*in_buf), out_len, fp) == 0) { ! perror("file_write: fwrite"); ! return(-1); ! } current += out_len; *** old/file_write.c Thu Apr 11 19:09:31 1991 --- file_write.c Sun Apr 14 19:39:19 1991 *************** *** 5,9 **** extern unsigned end_fat; ! static int need_nl; /* --- 5,9 ---- extern unsigned end_fat; ! static int need_nl, put_cluster(); /* *************** *** 28,31 **** --- 28,32 ---- size = 0L; + /* CONSTCOND */ while (1) { if ((i = put_cluster(fp, fat, &filesize, textmode)) < 0) { *************** *** 104,108 **** } } ! tbuf[i++] = c; } } --- 105,109 ---- } } ! tbuf[i++] = (unsigned char) c; } } *** old/init.c Thu Apr 11 19:09:31 1991 --- init.c Sun Apr 14 13:59:58 1991 *************** *** 9,12 **** --- 9,13 ---- #include "msdos.h" + #define FULL_CYL #define WORD(x) ((boot->x)[0] + ((boot->x)[1] << 8)) *************** *** 22,25 **** --- 23,27 ---- extern unsigned char *fat_buf, *disk_buf, *dir_buf; extern struct device devices[]; + static struct bootsector *read_boot(); int *************** *** 31,35 **** char *malloc(), *name, *expand(); void perror(), exit(), reset_chain(), free(), fat_read(); ! struct bootsector *boot, *read_boot(); struct device *dev; --- 33,37 ---- char *malloc(), *name, *expand(); void perror(), exit(), reset_chain(), free(), fat_read(); ! struct bootsector *boot; struct device *dev; *************** *** 74,78 **** sectors = WORD(nsect); if (heads && sectors) ! tracks = WORD(psect) / (heads * sectors); /* sanity checking */ --- 76,80 ---- sectors = WORD(nsect); if (heads && sectors) ! tracks = WORD(psect) / (unsigned) (heads * sectors); /* sanity checking */ *************** *** 175,179 **** fat_len = WORD(fatlen); dir_start = fat_start + (boot->nfat * fat_len); ! dir_len = WORD(dirents) * MDIR_SIZE / MSECTOR_SIZE; num_clus = (unsigned int) (WORD(psect) - dir_start - dir_len) / clus_size; num_fat = boot->nfat; --- 177,181 ---- fat_len = WORD(fatlen); dir_start = fat_start + (boot->nfat * fat_len); ! dir_len = WORD(dirents) * MDIR_SIZE / (unsigned) MSECTOR_SIZE; num_clus = (unsigned int) (WORD(psect) - dir_start - dir_len) / clus_size; num_fat = boot->nfat; *************** *** 194,198 **** --- 196,205 ---- } /* full cylinder buffering */ + #ifdef FULL_CYL disk_size = (dev->tracks) ? (sectors * heads) : 1; + #else /* FULL_CYL */ + disk_size = (dev->tracks) ? sectors : 1; + #endif /* FULL_CYL */ + disk_buf = (unsigned char *) malloc((unsigned int) disk_size * MSECTOR_SIZE); if (disk_buf == NULL) { *************** *** 223,227 **** FILE *fp; char *s, *strcpy(), *strcat(), *mcwd_path, *getenv(), *strncpy(); ! char buf[BUFSIZ], *memset(); static char ans[MAX_PATH]; --- 230,234 ---- FILE *fp; char *s, *strcpy(), *strcat(), *mcwd_path, *getenv(), *strncpy(); ! char buf[BUFSIZ], *expand(); static char ans[MAX_PATH]; *** old/mattrib.c Thu Apr 11 19:09:31 1991 --- mattrib.c Thu Apr 11 19:21:45 1991 *************** *** 7,14 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ --- 7,10 ---- *************** *** 15,18 **** --- 11,15 ---- #include <stdio.h> #include "msdos.h" + #include "patchlevel.h" int fd = -1; /* the file descriptor for the device */ *************** *** 86,89 **** --- 83,87 ---- } if (argc < 3 || argv[fargn][0] == '\0' || oops) { + fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s [-a|+a] [-h|+h] [-r|+r] [-s|+s] msdosfile [msdosfiles...]\n", argv[0]); exit(1); *** old/mcd.c Thu Apr 11 19:09:31 1991 --- mcd.c Thu Apr 11 19:21:45 1991 *************** *** 7,14 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ --- 7,10 ---- *************** *** 15,18 **** --- 11,15 ---- #include <stdio.h> #include "msdos.h" + #include "patchlevel.h" int fd = -1; /* the file descriptor for the device */ *************** *** 35,38 **** --- 32,36 ---- if (argc > 2) { + fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s: msdosdirectory\n", argv[0]); exit(1); *************** *** 58,63 **** * search to see if filename is also a directory. */ ! if (subdir(drive, pathname)) exit(1); /* is filename really a subdirectory? */ strcpy(newpath, pathname); --- 56,63 ---- * search to see if filename is also a directory. */ ! if (subdir(drive, pathname)) { ! fprintf(stderr, "%s: Directory not found\n", argv[0]); exit(1); + } /* is filename really a subdirectory? */ strcpy(newpath, pathname); *************** *** 68,73 **** /* move to real subdirectory */ ! if (subdir(drive, newpath)) exit(1); } /* it checked out ok, so save it */ --- 68,75 ---- /* move to real subdirectory */ ! if (subdir(drive, newpath)) { ! fprintf(stderr, "%s: Directory not found\n", argv[0]); exit(1); + } } /* it checked out ok, so save it */ *************** *** 77,81 **** if (!(fp = fopen(expand(mcwd_path), "w"))) { ! fprintf(stderr, "Can't open '%s' for write\n", expand(mcwd_path)); exit(1); } --- 79,83 ---- if (!(fp = fopen(expand(mcwd_path), "w"))) { ! fprintf(stderr, "%s: Can't open '%s' for write\n", argv[0], expand(mcwd_path)); exit(1); } *** old/mcopy.c Thu Apr 11 19:09:31 1991 --- mcopy.c Sun Apr 14 19:41:55 1991 *************** *** 7,17 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ #include <stdio.h> #define NONE 0 --- 7,14 ---- * Environmental Management Office * Fort Hood, TX 76544-5057 */ #include <stdio.h> + #include "patchlevel.h" #define NONE 0 *************** *** 26,30 **** extern char *optarg; int i, oops, msdos_args, unix_args, destination; ! char **nargv, *strcpy(), *malloc(); void exit(); /* get command line options */ --- 23,27 ---- extern char *optarg; int i, oops, msdos_args, unix_args, destination; ! char **nargv, **malloc(); void exit(); /* get command line options */ *************** *** 46,49 **** --- 43,47 ---- if (oops || (argc - optind) < 2) { + fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s [-tnvm] msdosfile unixfile\n", argv[0]); fprintf(stderr, " %s [-tnvm] msdosfile [msdosfiles...] unixdirectory\n", argv[0]); *************** *** 62,66 **** if (destination == NONE) { ! fprintf(stderr, "%s: no drive letter designation specified\n", argv[0]); exit(1); } --- 60,64 ---- if (destination == NONE) { ! fprintf(stderr, "%s: No drive letter designation specified\n", argv[0]); exit(1); } *************** *** 74,82 **** /* sanity checking */ if (!msdos_args || !unix_args) { ! fprintf(stderr, "%s: unresolved destination\n", argv[0]); exit(1); } if ((destination == MWRITE && msdos_args > 1) || (destination == MREAD && unix_args > 1)) { ! fprintf(stderr, "%s: duplicate destination files\n", argv[0]); exit(1); } --- 72,80 ---- /* sanity checking */ if (!msdos_args || !unix_args) { ! fprintf(stderr, "%s: Unresolved destination\n", argv[0]); exit(1); } if ((destination == MWRITE && msdos_args > 1) || (destination == MREAD && unix_args > 1)) { ! fprintf(stderr, "%s: Duplicate destination files\n", argv[0]); exit(1); } *** old/mdel.c Thu Apr 11 19:09:31 1991 --- mdel.c Thu Apr 11 19:52:17 1991 *************** *** 7,14 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ --- 7,10 ---- *************** *** 16,19 **** --- 12,16 ---- #include <signal.h> #include "msdos.h" + #include "patchlevel.h" int fd = -1; /* the file descriptor for the device */ *************** *** 25,28 **** --- 22,27 ---- int fat_error; /* FAT error detected? */ + static int got_signal(); + main(argc, argv) int argc; *************** *** 29,33 **** char *argv[]; { ! int i, ismatch, entry, nogo, verbose, fargn, got_signal(); unsigned int start; char *filename, *newfile, *get_name(), *unix_name(), *get_path(); --- 28,32 ---- char *argv[]; { ! int i, ismatch, entry, nogo, verbose, fargn; unsigned int start; char *filename, *newfile, *get_name(), *unix_name(), *get_path(); *************** *** 49,52 **** --- 48,52 ---- } if (argc < 2 || (argv[1][0] == '-' && !verbose)) { + fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s [-v] msdosfile [msdosfiles...]\n", argv[0]); exit(1); *** old/mdir.c Thu Apr 11 19:09:31 1991 --- mdir.c Thu Apr 11 21:31:35 1991 *************** *** 7,14 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ --- 7,10 ---- *************** *** 15,18 **** --- 11,15 ---- #include <stdio.h> #include "msdos.h" + #include "patchlevel.h" int fd = -1; /* the file descriptor for the device */ *************** *** 24,27 **** --- 21,27 ---- int fat_error; /* FAT error detected? */ + static long getfree(); + static char *conv_date(), *conv_time(); + main(argc, argv) int argc; *************** *** 29,34 **** { int i, entry, files, fargn, wide, faked; ! long size, blocks, getfree(); ! char *date, *time, *conv_date(), *conv_time(), last_drive, *fix_mcwd(); char *strncpy(), newpath[MAX_PATH], *get_name(), *get_path(), *pathname; char *newfile, *filename, *unix_name(), volume[12], drive, *strpbrk(); --- 29,34 ---- { int i, entry, files, fargn, wide, faked; ! long size, blocks; ! char *date, *time, last_drive, *fix_mcwd(); char *strncpy(), newpath[MAX_PATH], *get_name(), *get_path(), *pathname; char *newfile, *filename, *unix_name(), volume[12], drive, *strpbrk(); *************** *** 47,50 **** --- 47,52 ---- } if (argv[1][0] == '-' && !wide) { + fprintf(stderr, "%s: illegal option -- %c\n", argv[0], argv[1][1]); + fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s: [-w] msdosdirectory\n", argv[0]); fprintf(stderr, " %s: [-w] msdosfile [msdosfiles...]\n", argv[0]); *************** *** 185,189 **** printf("%-8.8s %-3.3s ", dir->name, dir->ext); else ! printf("%-8.8s %-3.3s %8d %s %s\n", dir->name, dir->ext, size, date, time); } if (argc > 2) --- 187,191 ---- printf("%-8.8s %-3.3s ", dir->name, dir->ext); else ! printf("%-8.8s %-3.3s %8ld %s %s\n", dir->name, dir->ext, size, date, time); } if (argc > 2) *** old/mformat.c Thu Apr 11 19:09:31 1991 --- mformat.c Sun Apr 14 19:36:27 1991 *************** *** 7,14 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ --- 7,10 ---- *************** *** 16,19 **** --- 12,16 ---- #include <ctype.h> #include "msdos.h" + #include "patchlevel.h" int fd, dir_dirty, dir_entries; *************** *** 32,38 **** int tot_sectors, num_clus, fat_guess; long time(), now, lseek(); ! char drive, *name, *expand(), tname[9], text[4]; char *strncpy(), *memset(), *memcpy(); ! unsigned char media, *label, *dos_name(), buf[MSECTOR_SIZE]; struct device *dev; struct directory *dir, *mk_entry(); --- 29,35 ---- int tot_sectors, num_clus, fat_guess; long time(), now, lseek(); ! char drive, *name, *expand(); char *strncpy(), *memset(), *memcpy(); ! unsigned char media, label[12], buf[MSECTOR_SIZE]; struct device *dev; struct directory *dir, *mk_entry(); *************** *** 43,47 **** heads = 0; sectors = 0; ! label = NULL; /* get command line options */ while ((c = getopt(argc, argv, "t:h:s:l:")) != EOF) { --- 40,44 ---- heads = 0; sectors = 0; ! label[0] = '\0'; /* get command line options */ while ((c = getopt(argc, argv, "t:h:s:l:")) != EOF) { *************** *** 57,70 **** break; case 'l': ! if (strlen(optarg) > 8) { ! strncpy(tname, optarg, 8); ! tname[8] = '\0'; ! strncpy(text, optarg + 8, 3); ! text[3] = '\0'; ! sprintf((char *) buf, "%s.%s", tname, text); ! label = dos_name((char *) buf, 0); ! } ! else ! label = dos_name(optarg, 0); break; default: --- 54,58 ---- break; case 'l': ! sprintf((char *) label, "%-11.11s", optarg); break; default: *************** *** 75,78 **** --- 63,67 ---- if (oops || (argc - optind) != 1) { + fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s [-t tracks] [-h heads] [-s sectors] [-l label] device\n", argv[0]); exit(1); *************** *** 110,114 **** exit(1); } ! /* open the port */ name = expand(dev->name); if ((fd = open(name, 2 | dev->mode)) < 0) { --- 99,103 ---- exit(1); } ! /* open the device */ name = expand(dev->name); if ((fd = open(name, 2 | dev->mode)) < 0) { *************** *** 206,210 **** boot.secsiz[0] = 512 % 0x100; boot.secsiz[1] = 512 / 0x100; ! boot.clsiz = clus_size; boot.nrsvsect[0] = 1; boot.nrsvsect[1] = 0; --- 195,199 ---- boot.secsiz[0] = 512 % 0x100; boot.secsiz[1] = 512 / 0x100; ! boot.clsiz = (unsigned char) clus_size; boot.nrsvsect[0] = 1; boot.nrsvsect[1] = 0; *************** *** 243,247 **** write(fd, (char *) buf, MSECTOR_SIZE); /* the root directory */ ! if (label != NULL && *label != '\0') { time(&now); dir = mk_entry(label, 0x08, 0, 0L, now); --- 232,236 ---- write(fd, (char *) buf, MSECTOR_SIZE); /* the root directory */ ! if (label[0] != '\0') { time(&now); dir = mk_entry(label, 0x08, 0, 0L, now); *** old/mkmanifest.c Thu Apr 11 19:09:32 1991 --- mkmanifest.c Thu Apr 11 21:28:28 1991 *************** *** 48,52 **** static char *dev[9] = {"con", "aux", "com1", "com2", "lpt1", "prn", "lpt2", "lpt3", "nul"}; ! char *s, *temp, *ext, *malloc(), *strcpy(), *strpbrk(), *strcat(); char buf[15]; int i, dot; --- 48,52 ---- static char *dev[9] = {"con", "aux", "com1", "com2", "lpt1", "prn", "lpt2", "lpt3", "nul"}; ! char *s, *temp, *ext, *strcpy(), *strpbrk(), *strcat(); char buf[15]; int i, dot; *** old/mlabel.c Thu Apr 11 19:09:32 1991 --- mlabel.c Sun Apr 14 14:35:16 1991 *************** *** 7,14 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ --- 7,10 ---- *************** *** 16,19 **** --- 12,16 ---- #include <ctype.h> #include "msdos.h" + #include "patchlevel.h" int fd = -1; /* the file descriptor for the device */ *************** *** 30,36 **** { int entry, slot, fargn, verbose, oops; ! char filename[13], *strncpy(), drive, ans[10], vol[13], *strncat(); ! char tname[9], text[4], *fix_mcwd(); ! unsigned char *fixed, *dos_name(); void exit(), dir_write(), dir_flush(), disk_flush(); struct directory *dir, *dir_read(), *mk_entry(); --- 27,33 ---- { int entry, slot, fargn, verbose, oops; ! char filename[30], *strncpy(), drive, ans[10], *strncat(); ! char *strcpy(), *fix_mcwd(); ! unsigned char fixed[12], vol[12]; void exit(), dir_write(), dir_flush(), disk_flush(); struct directory *dir, *dir_read(), *mk_entry(); *************** *** 49,52 **** --- 46,50 ---- } if (argc < 2 || argv[fargn][1] != ':' || oops) { + fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s [-v] drive:\n", argv[0]); exit(1); *************** *** 84,90 **** slot = entry; ! strncpy(vol, (char *) dir->name, 8); vol[8] = '\0'; ! strncat(vol, (char *) dir->ext, 3); vol[11] = '\0'; --- 82,88 ---- slot = entry; ! strncpy((char *) vol, (char *) dir->name, 8); vol[8] = '\0'; ! strncat((char *) vol, (char *) dir->ext, 3); vol[11] = '\0'; *************** *** 103,115 **** gets(filename); if (filename[0] != '\0') { ! /* add a '.' at column 9 */ ! if (strlen(filename) > 8) { ! strncpy(tname, filename, 8); ! tname[8] = '\0'; ! strncpy(text, &filename[8], 3); ! text[3] = '\0'; ! sprintf(filename, "%s.%s", tname, text); ! } ! fixed = dos_name(filename, verbose); } else { --- 101,107 ---- gets(filename); if (filename[0] != '\0') { ! sprintf((char *) fixed, "%-11.11s", filename); ! if (strlen(filename) > 11 && verbose) ! printf("New label is \"%s\"\n", fixed); } else { *************** *** 120,125 **** gets(ans); if (ans[0] == 'y' || ans[0] == 'Y') { ! fixed = (unsigned char *) vol; ! *fixed = 0xe5; } else --- 112,117 ---- gets(ans); if (ans[0] == 'y' || ans[0] == 'Y') { ! strcpy((char *) fixed, (char *) vol); ! fixed[0] = 0xe5; } else *** old/mmd.c Thu Apr 11 19:09:32 1991 --- mmd.c Thu Apr 11 20:04:46 1991 *************** *** 7,14 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ --- 7,10 ---- *************** *** 16,19 **** --- 12,16 ---- #include <signal.h> #include "msdos.h" + #include "patchlevel.h" int fd = -1; /* the file descriptor for the device */ *************** *** 25,28 **** --- 22,28 ---- int fat_error; /* FAT error detected? */ + static int got_signal(); + static void empty_dir(); + main(argc, argv) int argc; *************** *** 29,33 **** char *argv[]; { ! int i, entry, slot, fargn, verbose, oops, got_signal(); extern unsigned int end_fat; unsigned int fat, dot, next_fat(); --- 29,33 ---- char *argv[]; { ! int i, entry, slot, fargn, verbose, oops; extern unsigned int end_fat; unsigned int fat, dot, next_fat(); *************** *** 35,40 **** char *strcpy(), *fix_mcwd(), *pathname, *unix_name(), last_drive; unsigned char *fixed, *dos_name(); ! void exit(), fat_write(), empty_dir(), dir_write(), disk_flush(); ! void dir_flush(); struct directory *dir, *dir_read(), *mk_entry(); long time(), now; --- 35,39 ---- char *strcpy(), *fix_mcwd(), *pathname, *unix_name(), last_drive; unsigned char *fixed, *dos_name(); ! void exit(), fat_write(), dir_write(), disk_flush(), dir_flush(); struct directory *dir, *dir_read(), *mk_entry(); long time(), now; *************** *** 55,59 **** oops++; } ! if (!argc || oops) { fprintf(stderr, "Usage: %s [-v] msdosdirectory [msdosdirectories...]\n", argv[0]); exit(1); --- 54,59 ---- oops++; } ! if (argc == 1 || oops) { ! fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s [-v] msdosdirectory [msdosdirectories...]\n", argv[0]); exit(1); *** old/mrd.c Thu Apr 11 19:09:32 1991 --- mrd.c Thu Apr 11 21:26:03 1991 *************** *** 7,14 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ --- 7,10 ---- *************** *** 16,19 **** --- 12,16 ---- #include <signal.h> #include "msdos.h" + #include "patchlevel.h" int fd = -1; /* the file descriptor for the device */ *************** *** 25,28 **** --- 22,27 ---- int fat_error; /* FAT error detected? */ + static int got_signal(), is_empty(); + main(argc, argv) int argc; *************** *** 29,33 **** char *argv[]; { ! int i, ismatch, entry, oops, empty, got_signal(); unsigned int start; char *filename, *newfile, *get_name(), drive, *pathname, *get_path(); --- 28,32 ---- char *argv[]; { ! int i, ismatch, entry, oops, empty; unsigned int start; char *filename, *newfile, *get_name(), drive, *pathname, *get_path(); *************** *** 40,44 **** signal(SIGQUIT, (SIG_TYPE(*) ()) got_signal); ! if (argc == 0) { fprintf(stderr, "Usage: %s mdsosdirectory [msdosdirectories...]\n", argv[0]); exit(1); --- 39,44 ---- signal(SIGQUIT, (SIG_TYPE(*) ()) got_signal); ! if (argc == 1) { ! fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s mdsosdirectory [msdosdirectories...]\n", argv[0]); exit(1); *************** *** 138,141 **** --- 138,142 ---- void disk_read(); + /* CONSTCOND */ while (1) { sector = (long) (fat - 2) * clus_size + dir_start + dir_len; *** old/mread.c Thu Apr 11 19:09:32 1991 --- mread.c Thu Apr 11 21:27:29 1991 *************** *** 7,14 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ --- 7,10 ---- *************** *** 25,28 **** --- 21,25 ---- #endif /* BSD */ #include "msdos.h" + #include "patchlevel.h" int fd = -1; /* the file descriptor for the device */ *************** *** 34,37 **** --- 31,38 ---- int fat_error; /* FAT error detected? */ + static void set_mtime(); + static FILE *open_file(); + static long conv_stamp(); + main(argc, argv) int argc; *************** *** 38,42 **** char *argv[]; { ! FILE *fp, *open_file(); extern int optind; extern char *optarg; --- 39,43 ---- char *argv[]; { ! FILE *fp; extern int optind; extern char *optarg; *************** *** 43,51 **** int i, ismatch, entry, single, c, oops, preserve, nowarn, textmode; unsigned int fat; ! long size, mtime, conv_stamp(); char *filename, *newfile, *get_name(), *unix_name(), *pathname; char *get_path(), *target, tmp[MAX_PATH], *strcat(), *strcpy(), drive; char get_drive(), last_drive, *fix_mcwd(), *s; ! void exit(), set_mtime(); struct directory *dir, *dir_read(); struct stat stbuf; --- 44,52 ---- int i, ismatch, entry, single, c, oops, preserve, nowarn, textmode; unsigned int fat; ! long size, mtime; char *filename, *newfile, *get_name(), *unix_name(), *pathname; char *get_path(), *target, tmp[MAX_PATH], *strcat(), *strcpy(), drive; char get_drive(), last_drive, *fix_mcwd(), *s; ! void exit(); struct directory *dir, *dir_read(); struct stat stbuf; *************** *** 74,77 **** --- 75,79 ---- if (oops || (argc - optind) < 2) { + fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s [-tnm] msdosfile unixfile\n", argv[0]); fprintf(stderr, " %s [-tnm] msdosfile [msdosfiles...] unixdirectory\n", argv[0]); *************** *** 90,94 **** /* too many arguments */ if (single && (argc - optind) != 2) { ! fprintf(stderr, "%s: too many arguments or destination directory omitted\n", argv[0]); exit(1); } --- 92,96 ---- /* too many arguments */ if (single && (argc - optind) != 2) { ! fprintf(stderr, "%s: Too many arguments or destination directory omitted\n", argv[0]); exit(1); } *************** *** 202,205 **** --- 204,208 ---- if (!nowarn) { if (!access(target, 0)) { + /* CONSTCOND */ while (1) { printf("File \"%s\" exists, overwrite (y/n) ? ", target); *************** *** 240,243 **** --- 243,247 ---- #else /* BSD */ extern long timezone; + void tzset(); #endif /* BSD */ struct tm *tmbuf, *localtime(); *** old/mren.c Thu Apr 11 19:09:32 1991 --- mren.c Thu Apr 11 19:21:49 1991 *************** *** 7,14 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ --- 7,10 ---- *************** *** 15,18 **** --- 11,15 ---- #include <stdio.h> #include "msdos.h" + #include "patchlevel.h" int fd = -1; /* the file descriptor for the device */ *************** *** 45,48 **** --- 42,46 ---- } if (argc != fargn + 2) { + fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s [-v] sourcefile targetfile\n", argv[0]); exit(1); *** old/mtype.c Thu Apr 11 19:09:32 1991 --- mtype.c Thu Apr 11 19:21:49 1991 *************** *** 7,14 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ --- 7,10 ---- *************** *** 15,18 **** --- 11,15 ---- #include <stdio.h> #include "msdos.h" + #include "patchlevel.h" int fd = -1; /* the file descriptor for the device */ *************** *** 57,60 **** --- 54,58 ---- if (oops || (argc - optind) < 1) { + fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s [-st] msdosfile [msdosfiles...]\n", argv[0]); exit(1); *** old/mwrite.c Thu Apr 11 19:09:32 1991 --- mwrite.c Thu Apr 11 21:25:17 1991 *************** *** 7,14 **** * Environmental Management Office * Fort Hood, TX 76544-5057 - * Version 2.0.0 8 Sep 90 - * patch #1 12 Oct 90 - * patch #2 21 Nov 90 - * patch #3 28 Nov 90 */ --- 7,10 ---- *************** *** 18,21 **** --- 14,18 ---- #include <sys/stat.h> #include "msdos.h" + #include "patchlevel.h" int fd = -1; /* the file descriptor for the device */ *************** *** 30,33 **** --- 27,33 ---- int textmode = 0; int nowarn = 0; + static int got_signal(); + static struct directory *writeit(); + static long free_space(); main(argc, argv) *************** *** 38,42 **** extern char *optarg; int i, entry, ismatch, nogo, slot, single; ! int c, oops, verbose, first, mod_time, got_signal(); unsigned int dot, start; char *filename, *newfile, *get_name(), get_drive(); --- 38,42 ---- extern char *optarg; int i, entry, ismatch, nogo, slot, single; ! int c, oops, verbose, first, mod_time; unsigned int dot, start; char *filename, *newfile, *get_name(), get_drive(); *************** *** 45,49 **** unsigned char *fixed, *dos_name(); void exit(), fat_write(), dir_write(), disk_flush(), dir_flush(); ! struct directory *dir, *dir_read(), *writeit(); /* catch signals */ signal(SIGINT, (SIG_TYPE(*) ()) got_signal); --- 45,49 ---- unsigned char *fixed, *dos_name(); void exit(), fat_write(), dir_write(), disk_flush(), dir_flush(); ! struct directory *dir, *dir_read(); /* catch signals */ signal(SIGINT, (SIG_TYPE(*) ()) got_signal); *************** *** 75,78 **** --- 75,79 ---- if (oops || (argc - optind) < 2) { + fprintf(stderr, "Mtools version %s, dated %s\n", VERSION, DATE); fprintf(stderr, "Usage: %s [-tnvm] unixfile msdosfile\n", argv[0]); fprintf(stderr, " %s [-tnvm] unixfile [unixfiles...] msdosdirectory\n", argv[0]); *************** *** 113,117 **** /* too many arguments */ if ((argc - optind) != 2) { ! fprintf(stderr, "%s: too many arguments or destination directory omitted\n", argv[0]); exit(1); } --- 114,118 ---- /* too many arguments */ if ((argc - optind) != 2) { ! fprintf(stderr, "%s: Too many arguments or destination directory omitted\n", argv[0]); exit(1); } *************** *** 172,175 **** --- 173,177 ---- } else { + /* CONSTCOND */ while (1) { printf("File \"%s\" exists, overwrite (y/n) ? ", target); *************** *** 213,225 **** slot = entry; } - if (!single) - printf("Copying %s\n", target); - /* write the file */ ! if (dir = writeit(fixed, argv[i], verbose, mod_time)) dir_write(slot, dir); if (full) { ! fprintf(stderr, "%s: Disk Full\n", argv[0]); break; } --- 215,224 ---- slot = entry; } /* write the file */ ! if (dir = writeit(fixed, argv[i], verbose, mod_time, single, target)) dir_write(slot, dir); if (full) { ! fprintf(stderr, "%s: Disk full\n", argv[0]); break; } *************** *** 241,252 **** static struct directory * ! writeit(fixed, path, verbose, mod_time) unsigned char *fixed; char *path; ! int verbose, mod_time; { FILE *fp; unsigned int fat, next_fat(); ! long filesize, file_write(), size, time(), now, free_space(); struct directory *dir, *mk_entry(); struct stat stbuf; --- 240,252 ---- static struct directory * ! writeit(fixed, path, verbose, mod_time, single, target) unsigned char *fixed; char *path; ! int verbose, mod_time, single; ! char *target; { FILE *fp; unsigned int fat, next_fat(); ! long filesize, file_write(), size, time(), now; struct directory *dir, *mk_entry(); struct stat stbuf; *************** *** 264,270 **** if ((stbuf.st_mode & S_IFREG) != S_IFREG) { ! fprintf(stderr, "\"%s\" is not a regular file\n", path); return(NULL); } /* will it fit? */ filesize = stbuf.st_size; --- 264,280 ---- if ((stbuf.st_mode & S_IFREG) != S_IFREG) { ! if (verbose) ! fprintf(stderr, "\"%s\" is not a regular file\n", path); return(NULL); } + + if (!(fp = fopen(path, "r"))) { + fprintf(stderr, "Can't open \"%s\" for read\n", path); + return(NULL); + } + + if (!single) + printf("Copying %s\n", target); + /* will it fit? */ filesize = stbuf.st_size; *************** *** 279,285 **** time(&now); ! if (!(fp = fopen(path, "r"))) { ! fprintf(stderr, "Can't open \"%s\" for read\n", path); ! return(NULL); } --- 289,296 ---- time(&now); ! /* if a zero length file */ ! if (filesize == 0L) { ! dir = mk_entry(fixed, 0x20, 0, 0L, now); ! return(dir); } *** old/subdir.c Thu Apr 11 19:09:32 1991 --- subdir.c Thu Apr 11 19:48:31 1991 *************** *** 3,6 **** --- 3,7 ---- extern int dir_entries; + static int descend(); /* *************** *** 14,18 **** char *pathname; { ! char *s, *tmp, tbuf[MAX_PATH], *path, *strcpy(), *strcat(); static char last_drive, lastpath[MAX_PATH]; int code; --- 15,19 ---- char *pathname; { ! char *s, *tmp, tbuf[MAX_PATH], *path, *strcpy(); static char last_drive, lastpath[MAX_PATH]; int code; End of Patch