[Added Oren Sela, the originator of the PR]

On Tue, 1 Feb 2000 23:28:17 -0800 (PST),
  Matthew Jacob <[EMAIL PROTECTED]> said:

>> rmt(8) returns the result of MTIOCGET filled into struct mtget in
>> response to the 'S' command, issued by dump(8) of some certain OSs
>> including Solaris. (FreeBSD's one seems to not issue the 'S' command)
>> Due to the extention made to struct mtget in FreeBSD, remote dump
>> from, eg Solaris to FreeBSD fails to establish rmt connection.
>> 
>> Maybe we would have to provide something like struct mtget_org for
>> compatibility with other OSs. Also, if we were to issue 'S' in our
>> dump(8), some command extention may be required. (any plans?)
>> 
>> Any comments?

Matthew> Yes. This is definitely an issue. Didn't this come up before and was a PR
Matthew> filed that I somehow forgot to own? After all, I probably broke things.

You mean this one? I saw exactly the same message.

On Wed, 17 Nov 1999 05:50:13 -0800 (PST),
  [EMAIL PROTECTED] said:

>> Number:         14946
>> Category:       i386
>> Synopsis:       rmt - remote magtape protocol
(snip)
>> Description:
osela> I want to use the rmt on bsd vs. solaris 2.7.
osela> When I use ufsdump from the solaris machine to the BSD I get following output:
osela>   DUMP: Writing 32 Kilobyte records
osela>   DUMP: Date of this level 0 dump: Wed Nov 17 15:23:38 1999
osela>   DUMP: Date of last level 0 dump: the epoch
osela>   DUMP: Dumping /dev/rdsk/c0t0d0s7 (hope:/export/home) to
osela> alice:/dev/nrsa0.
osela>   DUMP: Mapping (Pass I) [regular files]
osela>   DUMP: Mapping (Pass II) [directories]
osela>   DUMP: Estimated 436 blocks (218KB).
osela>   DUMP: rmtstatus: expected response size 24, got 76
osela>   DUMP: This means the remote rmt daemon is not compatible.
osela>   DUMP: Lost connection to remote host.
osela>   DUMP: Bad return code from dump: 1
osela> The rmt on Solaris is not compatible with the one on BSD.
osela> I need a solution - can any one help :->

The following patch change mtget to mtget_org, and performs necessary
conversion.

diff -urN --exclude=CVS src.org/sbin/dump/dumprmt.c src/sbin/dump/dumprmt.c
--- src.org/sbin/dump/dumprmt.c Sat Aug 28 09:12:37 1999
+++ src/sbin/dump/dumprmt.c     Wed Feb  2 17:08:54 2000
@@ -320,12 +320,28 @@
 {
        register int i;
        register char *cp;
+#if defined(__FreeBSD__)
+       struct mtget_org mtsorg;
+#endif /* __FreeBSD__ */
 
        if (rmtstate != TS_OPEN)
                return (NULL);
        rmtcall("status", "S\n");
+#if defined(__FreeBSD__)
+       for (i = 0, cp = (char *)&mtsorg; i < sizeof(mtsorg); i++)
+               *cp++ = rmtgetb();
+       /* Convert the compatible struct into FreeBSD's one. */
+       bzero(&mts, sizeof(mts));
+       mts->mt_type = mtsorg->mt_type;
+       mts->mt_dsreg = mtsorg->mt_dsreg;
+       mts->mt_erreg = mtsorg->mt_erreg;
+       mts->mt_resid = mtsorg->mt_resid;
+       mts->mt_fileno = mtsorg->mt_fileno;
+       mts->mt_blkno = mtsorg->mt_blkno;
+#else
        for (i = 0, cp = (char *)&mts; i < sizeof(mts); i++)
                *cp++ = rmtgetb();
+#endif /* __FreeBSD__ */
        return (&mts);
 }
 
diff -urN --exclude=CVS src.org/sys/sys/mtio.h src/sys/sys/mtio.h
--- src.org/sys/sys/mtio.h      Mon Jan 24 11:34:17 2000
+++ src/sys/sys/mtio.h  Wed Feb  2 17:08:11 2000
@@ -136,6 +136,38 @@
        u_int32_t mt_comp2;     /* compression type for mode 2 */
        u_int32_t mt_comp3;     /* compression type for mode 3 */
 /* end not yet implemented */
+#endif /* __FreeBSD__ */
+       daddr_t mt_fileno;      /* relative file number of current position */
+       daddr_t mt_blkno;       /* relative block number of current position */
+};
+
+/* The original struct mtget for compatibility of rmt(8) with other OSs */
+
+struct mtget_org {
+       short   mt_type;        /* type of magtape device */
+/* the following two registers are grossly device dependent */
+       short   mt_dsreg;       /* ``drive status'' register */
+       short   mt_erreg;       /* ``error'' register */
+/* end device-dependent registers */
+       short   mt_resid;       /* residual count */
+#if notdef /* FreeBSD extention */
+       daddr_t mt_blksiz;      /* presently operating blocksize */
+       daddr_t mt_density;     /* presently operating density */
+       u_int32_t mt_comp;      /* presently operating compression */
+       daddr_t mt_blksiz0;     /* blocksize for mode 0 */
+       daddr_t mt_blksiz1;     /* blocksize for mode 1 */
+       daddr_t mt_blksiz2;     /* blocksize for mode 2 */
+       daddr_t mt_blksiz3;     /* blocksize for mode 3 */
+       daddr_t mt_density0;    /* density for mode 0 */
+       daddr_t mt_density1;    /* density for mode 1 */
+       daddr_t mt_density2;    /* density for mode 2 */
+       daddr_t mt_density3;    /* density for mode 3 */
+/* the following are not yet implemented */
+       u_int32_t mt_comp0;     /* compression type for mode 0 */
+       u_int32_t mt_comp1;     /* compression type for mode 1 */
+       u_int32_t mt_comp2;     /* compression type for mode 2 */
+       u_int32_t mt_comp3;     /* compression type for mode 3 */
+/* end not yet implemented */
 #endif
        daddr_t mt_fileno;      /* relative file number of current position */
        daddr_t mt_blkno;       /* relative block number of current position */
diff -urN --exclude=CVS src.org/usr.sbin/rmt/rmt.c src/usr.sbin/rmt/rmt.c
--- src.org/usr.sbin/rmt/rmt.c  Sat Aug 28 10:19:32 1999
+++ src/usr.sbin/rmt/rmt.c      Wed Feb  2 17:01:51 2000
@@ -181,12 +181,30 @@
        case 'S':               /* status */
                DEBUG("rmtd: S\n");
                { struct mtget mtget;
+#if defined(__FreeBSD__)
+                 struct mtget_org mtgetorg;
+#endif /* __FreeBSD__ */
                  if (ioctl(tape, MTIOCGET, (char *)&mtget) < 0)
                        goto ioerror;
+#if defined(__FreeBSD__)
+                 /* Convert FreeBSD's mtget to the compatible one. */
+                 mtgetorg.mt_type = mtget.mt_type;
+                 mtgetorg.mt_dsreg = mtget.mt_dsreg;
+                 mtgetorg.mt_erreg = mtget.mt_erreg;
+                 mtgetorg.mt_resid = mtget.mt_resid;
+                 mtgetorg.mt_fileno = mtget.mt_fileno;
+                 mtgetorg.mt_blkno = mtget.mt_blkno;
+                 rval = sizeof (mtgetorg);
+#else
                  rval = sizeof (mtget);
+#endif /* __FreeBSD__ */
                  (void)sprintf(resp, "A%d\n", rval);
                  (void)write(1, resp, strlen(resp));
+#if defined(__FreeBSD__)
+                 (void)write(1, (char *)&mtgetorg, sizeof (mtgetorg));
+#else
                  (void)write(1, (char *)&mtget, sizeof (mtget));
+#endif /* __FreeBSD__ */
                  goto top;
                }
 


-- 
Seigo Tanimura <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>

Reply via email to