From owner-freebsd-hackers Wed Feb 2 0:38: 4 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from rina.r.dl.itc.u-tokyo.ac.jp (rina.r.dl.itc.u-tokyo.ac.jp [133.11.199.247]) by builder.freebsd.org (Postfix) with ESMTP id DD4233F03 for ; Wed, 2 Feb 2000 00:37:40 -0800 (PST) Received: from rina.r.dl.itc.u-tokyo.ac.jp (tanimura@localhost.r.dl.itc.u-tokyo.ac.jp [127.0.0.1]) by rina.r.dl.itc.u-tokyo.ac.jp (8.9.3+3.2W/3.7W-rina.r-0.1-11.01.2000) with ESMTP id RAA98959; Wed, 2 Feb 2000 17:37:26 +0900 (JST) Date: Wed, 02 Feb 2000 17:37:26 +0900 Message-ID: <14487.60613.970438.81928B@rina.r.dl.itc.u-tokyo.ac.jp> From: Seigo Tanimura To: mjacob@feral.com, osela@tactline.co.il Cc: tanimura@r.dl.itc.u-tokyo.ac.jp, hackers@FreeBSD.ORG Subject: Re: FreeBSD-specific extension of struct mtget breaks dump(8) from Solaris In-Reply-To: In your message of "Tue, 1 Feb 2000 23:28:17 -0800 (PST)" References: <14487.55497.261038.68187Y@rina.r.dl.itc.u-tokyo.ac.jp> User-Agent: Wanderlust/1.0.3 (Notorious) SEMI/1.13.4 (Terai) FLIM/1.12.7 (=?ISO-8859-4?Q?Y=FEzaki?=) MULE XEmacs/21.1 (patch 8) (Bryce Canyon) (i386--freebsd) Organization: Digital Library Research Division, Information Techinology Centre, The University of Tokyo MIME-Version: 1.0 (generated by SEMI 1.13.4 - "Terai") Content-Type: multipart/mixed; boundary="Multipart_Wed_Feb__2_17:37:25_2000-1" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --Multipart_Wed_Feb__2_17:37:25_2000-1 Content-Type: text/plain; charset=US-ASCII [Added Oren Sela, the originator of the PR] On Tue, 1 Feb 2000 23:28:17 -0800 (PST), Matthew Jacob 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), osela@tactline.co.il 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. --Multipart_Wed_Feb__2_17:37:25_2000-1 Content-Type: text/plain; type=patch; charset=US-ASCII Content-Disposition: attachment; filename="mtget.diff" Content-Transfer-Encoding: 7bit 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; } --Multipart_Wed_Feb__2_17:37:25_2000-1 Content-Type: text/plain; charset=US-ASCII -- Seigo Tanimura --Multipart_Wed_Feb__2_17:37:25_2000-1-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message