Subject: Re: mtools-2.0.7
To: None <che5ari@sun.leeds.ac.uk>
From: Rob Windsor <windsor@ksu.ksu.edu>
List: netbsd-help
Date: 12/07/1994 03:01:16
Verily did che5ari@sun.leeds.ac.uk write:
> I've tried to compile mtools-2.0.7 under NetBSD-1.0 (i386). Compilation
> works fine, but the programs do not work. I get 'Cannot initialize A:'.
> I've added to the device database the following:
 
> struct device devices[] = {
> 	{'A', "/dev/rfd0c", 0L, 12, 0, (int (*) ()) 0, 80, 2, 18},
> };
 
> Anyone who has got mtools working, could you please help.

The following is my install notes on mtools.  I had the same problem
and decided to take a peek at the FreeBSD port/patch.

If the install notes look a tad odd (or "different"), here's my
basic outline (to explain myself): 

1>  untar into /usr/local/src/blah
1a> change perms to a-w on everything in /usr/local/src/blah
2>  symlink everything (with ``lndir'') to /usr/local/build/blah
3>  edit/compile/link/etc as needed
       If there's a file that needs editing, I remove the link and
       copy it over.
4>  install it in /usr/local/install/blah/{bin,man/*,lib,info}
5>  symlink up to /usr/local/{bin,man/*,lib,info}
6>  polish off install notes, update /etc/motd and /etc/history

------------- snip (PUNK.notes.mtools-2.0.7) --------------
##########################################################################
##                                                                      ##
##  Installation notes for programs compiled on punk                    ##
##                                                                      ##
##  punk is a 486Dx/50 running NetBSD-1.0                               ##
##                                                                      ##
##  These notes should work for any Intel 386-class machine running     ##
##  NetBSD-1.0 (or -current).  Also highly likely to work for other     ##
##  non-Intel machines running NetBSD-1.0 (or -current).                ##
##                                                                      ##
##  If you have any questions, e-mail the sysadmin or catch him (me)    ##
##  on irc.  e-mail:  windsor@m-net.arbornet.org  irc: Windsor or ugly  ##
##                                                                      ##
##########################################################################

Installation notes for mtools-2.0.7

#1  Fetched ftp://prep.ai.mit.edu/pub/gnu/mtools-2.0.7.tar.gz

windsor@punk:/usr/local/src>tar -zxvf /dnload/gnu/mtools-2.0.7.tar.gz     
windsor@punk:/usr/local/src/mtools-2.0.7>chmod -R a-w *
windsor@punk:/usr/local/build/mtools-2.0.7>lndir /usr/local/src/mtools-2.0.7

edited ./Makefile
windsor@punk:/usr/local/build/mtools-2.0.7>diff -c ../../src/mtools-2.0.7/Makefile ./Makefile
*** ../../src/mtools-2.0.7/Makefile     Thu Sep 10 10:10:46 1992
--- ./Makefile  Fri Nov 18 08:39:41 1994
***************
*** 14,28 ****
  #CFLAGS = -O -M2e -DINT16 -DXENIX -DLOCKF
  #LDFLAGS = -s -M2e -i -f 5000
  
! CFLAGS        = -O -DSPARC -DBSD
  LDFLAGS       = -s
  LD    = $(CC)
  LINT  = lint
  SHLIB =
  SHAR  = shar -a
! BINDIR        = ${DESTDIR}/usr/local/mtools
  MANEXT        = 1
! MANDIR        = ${DESTDIR}/usr/share/local/man/man$(MANEXT)
  #
  # for AT&T Unix PC 7300/3b1 style shared libraries.
  #SHOBJ        = /lib/crt0s.o /lib/shlib.ifile
--- 14,29 ----
  #CFLAGS = -O -M2e -DINT16 -DXENIX -DLOCKF
  #LDFLAGS = -s -M2e -i -f 5000
  
! CC    = gcc
! CFLAGS        = -O -DBSD -DNETBSD
  LDFLAGS       = -s
  LD    = $(CC)
  LINT  = lint
  SHLIB =
  SHAR  = shar -a
! BINDIR        = /usr/local/install/mtools-2.0.7/bin
  MANEXT        = 1
! MANDIR        = /usr/local/install/mtools-2.0.7/man/man$(MANEXT)
  #
  # for AT&T Unix PC 7300/3b1 style shared libraries.
  #SHOBJ        = /lib/crt0s.o /lib/shlib.ifile
***************
*** 107,113 ****
  
  install: all
        -mkdir $(BINDIR)
!       for prog in $(PROGS); do install $$prog $(BINDIR)/$$prog; gln -sf ../mtools/$$prog ${DESTDIR}/usr/local/bin; done
        install -c -m 644 Mattrib.1 $(MANDIR)/mattrib.$(MANEXT)
        install -c -m 644 Mcd.1 $(MANDIR)/mcd.$(MANEXT)
        install -c -m 644 Mcopy.1 $(MANDIR)/mcopy.$(MANEXT)
--- 108,114 ----
  
  install: all
        -mkdir $(BINDIR)
!       for prog in $(PROGS); do install $$prog $(BINDIR)/$$prog; done
        install -c -m 644 Mattrib.1 $(MANDIR)/mattrib.$(MANEXT)
        install -c -m 644 Mcd.1 $(MANDIR)/mcd.$(MANEXT)
        install -c -m 644 Mcopy.1 $(MANDIR)/mcopy.$(MANEXT)
***************
*** 125,131 ****
        install -c -m 644 Mkmanifest.1 $(MANDIR)/mkmanifest.$(MANEXT)
  
  clean:
!       rm $(PROGS) *.o core a.out tags TAGS
  
  lint:
        $(LINT) mattrib.c buf_read.c buf_write.c devices.c dir_read.c \
--- 126,132 ----
        install -c -m 644 Mkmanifest.1 $(MANDIR)/mkmanifest.$(MANEXT)
  
  clean:
!       rm -f $(PROGS) *.o core a.out tags TAGS
  
  lint:
        $(LINT) mattrib.c buf_read.c buf_write.c devices.c dir_read.c \


edited ./msdos.h
windsor@punk:/usr/local/build/mtools-2.0.7>diff -c ../../src/mtools-2.0.7/msdos.h ./msdos.h
*** ../../src/mtools-2.0.7/msdos.h      Thu Sep 10 09:59:13 1992
--- ./msdos.h   Fri Nov 18 08:49:04 1994
***************
*** 49,55 ****
        unsigned char nheads[2];        /* Heads */
        unsigned char nhs[4];           /* number of hidden sectors */
        unsigned char bigsect[4];       /* big total sectors */
!       unsigned char junk[476];        /* who cares? */
  };
  
  typedef void SIG_TYPE;
--- 49,56 ----
        unsigned char nheads[2];        /* Heads */
        unsigned char nhs[4];           /* number of hidden sectors */
        unsigned char bigsect[4];       /* big total sectors */
!       unsigned char junk[474];        /* who cares? */
!       unsigned char signat[2];        /* 0xaa55 */
  };
  
  typedef void SIG_TYPE;


edited ./devices.c
windsor@punk:/usr/local/build/mtools-2.0.7>diff -c ../../src/mtools-2.0.7/devices.c ./devices.c
*** ../../src/mtools-2.0.7/devices.c    Thu Sep 10 10:11:17 1992
--- ./devices.c Thu Nov  3 04:43:57 1994
***************
*** 5,10 ****
--- 5,23 ----
  #include <stdio.h>
  #include "msdos.h"
  
+ #ifdef NETBSD
+ struct device devices[] = {
+       {'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 18},
+       {'A', "/dev/rfd0a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 9},
+       {'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 80, 2, 15},
+       {'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},
+       {'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 40, 2, 8},
+       {'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 40, 1, 9},
+       {'B', "/dev/rfd1a", 0L, 12, 0, (int (*) ()) 0, 40, 1, 8},
+       {'\0', (char *) NULL, 0L, 0, 0, (int (*) ()) 0, 0, 0, 0}
+ };
+ #endif /* NETBSD */
+ 
  #ifdef DELL
  struct device devices[] = {
        {'A', "/dev/rdsk/f0d9dt", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},


edited ./buf_read.c
windsor@punk:/usr/local/build/mtools-2.0.7>diff -c ../../src/mtools-2.0.7/buf_read.c ./buf_read.c
*** ../../src/mtools-2.0.7/buf_read.c   Thu Sep 10 09:59:11 1992
--- ./buf_read.c        Fri Nov 18 08:42:59 1994
***************
*** 24,36 ****
        int length;
        unsigned char *buf_ptr, *disk_ptr;
        char *memcpy();
!       long where, tail, lseek();
        void perror(), exit(), disk_flush();
  
                                        /* don't use cache? */
        if (disk_size == 1) {
                where = (start * MSECTOR_SIZE) + disk_offset;
!               if (lseek(fd, where, 0) < 0) {
                        perror("disk_read: lseek");
                        exit(1);
                }
--- 24,37 ----
        int length;
        unsigned char *buf_ptr, *disk_ptr;
        char *memcpy();
!       long where, tail;
!       off_t lseek();
        void perror(), exit(), disk_flush();
  
                                        /* don't use cache? */
        if (disk_size == 1) {
                where = (start * MSECTOR_SIZE) + disk_offset;
!               if (lseek(fd, (off_t) where, 0) < 0) {
                        perror("disk_read: lseek");
                        exit(1);
                }
***************
*** 55,61 ****
                        length = disk_size * MSECTOR_SIZE;
  
                                        /* move to next location */
!                       if (lseek(fd, where, 0) < 0) {
                                perror("disk_read: lseek");
                                exit(1);
                        }
--- 56,62 ----
                        length = disk_size * MSECTOR_SIZE;
  
                                        /* move to next location */
!                       if (lseek(fd, (off_t) where, 0) < 0) {
                                perror("disk_read: lseek");
                                exit(1);
                        }


edited ./buf_write.c
windsor@punk:/usr/local/build/mtools-2.0.7>diff -c ../../src/mtools-2.0.7/buf_write.c ./buf_write.c
*** ../../src/mtools-2.0.7/buf_write.c  Thu Sep 10 09:59:47 1992
--- ./buf_write.c       Fri Nov 18 08:44:39 1994
***************
*** 23,34 ****
        unsigned char *buf_ptr, *disk_ptr;
        char *memcpy();
        void perror(), exit(), disk_flush();
!       long where, tail, lseek();
  
                                        /* don't use cache? */
        if (disk_size == 1) {
                where = (start * MSECTOR_SIZE) + disk_offset;
!               if (lseek(fd, where, 0) < 0) {
                        perror("disk_write: lseek");
                        exit(1);
                }
--- 23,35 ----
        unsigned char *buf_ptr, *disk_ptr;
        char *memcpy();
        void perror(), exit(), disk_flush();
!       long where, tail;
!       off_t lseek();
  
                                        /* don't use cache? */
        if (disk_size == 1) {
                where = (start * MSECTOR_SIZE) + disk_offset;
!               if (lseek(fd, (off_t) where, 0) < 0) {
                        perror("disk_write: lseek");
                        exit(1);
                }
***************
*** 59,65 ****
                                length = disk_size * MSECTOR_SIZE;
  
                                        /* move to next location */
!                               if (lseek(fd, where, 0) < 0) {
                                        perror("disk_write: lseek");
                                        exit(1);
                                }
--- 60,66 ----
                                length = disk_size * MSECTOR_SIZE;
  
                                        /* move to next location */
!                               if (lseek(fd, (off_t) where, 0) < 0) {
                                        perror("disk_write: lseek");
                                        exit(1);
                                }
***************
*** 88,101 ****
  disk_flush()
  {
        int len;
!       long where, lseek();
        void perror(), exit();
  
        if (fd < 0 || disk_current < 0L || !disk_dirty)
                return;
  
        where = (disk_current * MSECTOR_SIZE) + disk_offset;
!       if (lseek(fd, where, 0) < 0) {
                perror("disk_flush: lseek");
                exit(1);
        }
--- 89,103 ----
  disk_flush()
  {
        int len;
!       long where;
!       off_t lseek();
        void perror(), exit();
  
        if (fd < 0 || disk_current < 0L || !disk_dirty)
                return;
  
        where = (disk_current * MSECTOR_SIZE) + disk_offset;
!       if (lseek(fd, (off_t) where, 0) < 0) {
                perror("disk_flush: lseek");
                exit(1);
        }


edited ./init.c
windsor@punk:/usr/local/build/mtools-2.0.7>diff -c ../../src/mtools-2.0.7/init.c ./init.c
*** ../../src/mtools-2.0.7/init.c       Thu Sep 10 09:59:47 1992
--- ./init.c    Fri Nov 18 08:46:53 1994
***************
*** 311,320 ****
  static struct bootsector *
  read_boot()
  {
!       long lseek();
        static struct bootsector boot;
  
!       if (lseek(fd, disk_offset, 0) < 0)
                return(NULL);
                                        /* read the first sector */
        if (read(fd, (char *) &boot, MSECTOR_SIZE) != MSECTOR_SIZE)
--- 311,320 ----
  static struct bootsector *
  read_boot()
  {
!       off_t lseek();
        static struct bootsector boot;
  
!       if (lseek(fd, (off_t) disk_offset, 0) < 0)
                return(NULL);
                                        /* read the first sector */
        if (read(fd, (char *) &boot, MSECTOR_SIZE) != MSECTOR_SIZE)


edited ./mformat.c
windsor@punk:/usr/local/build/mtools-2.0.7>diff -c ../../src/mtools-2.0.7/mformat.c ./mformat.c
*** ../../src/mtools-2.0.7/mformat.c    Thu Sep 10 09:59:16 1992
--- ./mformat.c Fri Nov 18 08:50:08 1994
***************
*** 27,33 ****
        struct bootsector boot;
        int i, c, oops, tracks, heads, sectors, fat_len, dir_len, clus_size;
        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];
--- 27,34 ----
        struct bootsector boot;
        int i, c, oops, tracks, heads, sectors, fat_len, dir_len, clus_size;
        int tot_sectors, num_clus, fat_guess;
!       long time(), now;
!       off_t lseek();
        char drive, *name, *expand();
        char *strncpy(), *memset(), *memcpy();
        unsigned char media, label[12], buf[MSECTOR_SIZE];
***************
*** 209,217 ****
        boot.nsect[1] = sectors / 0x100;
        boot.nheads[0] = heads % 0x100;
        boot.nheads[1] = heads / 0x100;
  
                                        /* write the boot */
!       lseek(fd, 0L, 0);
        write(fd, (char *) &boot, MSECTOR_SIZE);
                                        /* first fat */
        memset((char *) buf, '\0', MSECTOR_SIZE);
--- 210,220 ----
        boot.nsect[1] = sectors / 0x100;
        boot.nheads[0] = heads % 0x100;
        boot.nheads[1] = heads / 0x100;
+       boot.signat[0] = 0x55;
+       boot.signat[1] = 0xaa;
  
                                        /* write the boot */
!       lseek(fd, (off_t) 0, 0);
        write(fd, (char *) &boot, MSECTOR_SIZE);
                                        /* first fat */
        memset((char *) buf, '\0', MSECTOR_SIZE);


windsor@punk:/usr/local/install>mkdir mtools-2.0.7
windsor@punk:/usr/local/install>cd mtools-2.0.7/
windsor@punk:/usr/local/install/mtools-2.0.7>mkdir bin
windsor@punk:/usr/local/install/mtools-2.0.7>mkdir man
windsor@punk:/usr/local/install/mtools-2.0.7>cd man
windsor@punk:/usr/local/install/mtools-2.0.7/man>mkdir man1
windsor@punk:/usr/local/build/mtools-2.0.7>make
windsor@punk:/usr/local/build/mtools-2.0.7>make install


Here's a cut of the semi-nasty error messages...
buf_read.c: In function `disk_read':
buf_read.c:26: warning: extern declaration of `memcpy' doesn't match global one
buf_write.c: In function `disk_write':
buf_write.c:24: warning: extern declaration of `memcpy' doesn't match global one
dir_read.c: In function `dir_read':
dir_read.c:19: warning: extern declaration of `memcpy' doesn't match global one
dir_write.c: In function `dir_write':
dir_write.c:21: warning: extern declaration of `memcpy' doesn't match global one
init.c:334: warning: `lock_dev' was declared implicitly `extern' and later `static'
mdel.o: warning: this program uses gets(), which is unsafe.
mformat.c: In function `main':
mformat.c:33: warning: extern declaration of `memcpy' doesn't match global one
mmd.c: In function `empty_dir':
mmd.c:183: warning: extern declaration of `memcpy' doesn't match global one
mread.o: warning: this program uses gets(), which is unsafe.
mren.o: warning: this program uses gets(), which is unsafe.
mwrite.o: warning: this program uses gets(), which is unsafe.

------------- snip (PUNK.notes.mtools-2.0.7) --------------

Hope this helps.

-- Rob
----------------------------------------
Internet: windsor@ksu.ksu.edu      Life: Rob@Manhattan.Kansas.USA.Earth

"Life's a journey, not a destination."  -- Aerosmith (1993), 'Amazing'