From 047dca15e460ab4133925fd39d0d6cc397e24ac7 Mon Sep 17 00:00:00 2001 From: YONETANI Tomokazu Date: Thu, 14 Apr 2005 10:17:23 +0000 Subject: [PATCH] Resurrect some of functions shared by rrestore. --- sbin/dump/dump.h | 13 ++++++++++--- sbin/dump/dumprmt.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/sbin/dump/dump.h b/sbin/dump/dump.h index cf2e86af27..3d1abb7469 100644 --- a/sbin/dump/dump.h +++ b/sbin/dump/dump.h @@ -33,7 +33,7 @@ * @(#)dump.h 8.2 (Berkeley) 4/28/95 * * $FreeBSD: src/sbin/dump/dump.h,v 1.7.6.4 2003/01/25 18:54:59 dillon Exp $ - * $DragonFly: src/sbin/dump/dump.h,v 1.9 2005/04/13 16:07:15 joerg Exp $ + * $DragonFly: src/sbin/dump/dump.h,v 1.10 2005/04/14 10:17:23 y0netan1 Exp $ */ #include @@ -140,12 +140,19 @@ char *rawname(char *); struct dinode *getino(ino_t); /* rdump routines */ -#ifdef RDUMP +#if defined(RDUMP) || defined(RRESTORE) void rmtclose(void); int rmthost(const char *); int rmtopen(const char *, int); int rmtwrite(const void *, int); -#endif /* RDUMP */ +#endif /* RDUMP || RRESTORE */ + +/* rrestore routines */ +#ifdef RRESTORE +int rmtread(char *, int); +int rmtseek(int, int); +int rmtioctl(int, int); +#endif /* RRESTORE */ void interrupt(int); /* in case operator bangs on console */ diff --git a/sbin/dump/dumprmt.c b/sbin/dump/dumprmt.c index 788f89893d..e91477241e 100644 --- a/sbin/dump/dumprmt.c +++ b/sbin/dump/dumprmt.c @@ -32,7 +32,7 @@ * * @(#)dumprmt.c 8.3 (Berkeley) 4/28/95 * $FreeBSD: src/sbin/dump/dumprmt.c,v 1.14.2.1 2000/07/01 06:31:52 ps Exp $ - * $DragonFly: src/sbin/dump/dumprmt.c,v 1.12 2005/04/13 16:07:15 joerg Exp $ + * $DragonFly: src/sbin/dump/dumprmt.c,v 1.13 2005/04/14 10:17:23 y0netan1 Exp $ */ #include @@ -232,6 +232,47 @@ rmtclose(void) rmtstate = TS_CLOSED; } +#ifdef RRESTORE +int +rmtread(char *buf, int count) +{ + char line[30]; + int n, i, cc; + + snprintf(line, sizeof (line), "R%d\n", count); + n = rmtcall("read", line); + if (n < 0) + /* rmtcall() properly sets errno for us on errors. */ + return (n); + for (i = 0; i < n; i += cc) { + cc = read(rmtape, buf+i, n - i); + if (cc <= 0) + rmtconnaborted(0); + } + return (n); +} + +int +rmtseek(int offset, int pos) +{ + char line[80]; + + snprintf(line, sizeof (line), "L%d\n%d\n", offset, pos); + return (rmtcall("seek", line)); +} + +int +rmtioctl(int cmd, int count) +{ + char buf[256]; + + if (count < 0) + return (-1); + snprintf(buf, sizeof (buf), "I%d\n%d\n", cmd, count); + return (rmtcall("ioctl", buf)); +} +#endif /* RRESTORE */ + int rmtwrite(const void *buf, int count) { -- 2.41.0