pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/archivers/pax/files Wrap physical mt operations in SUP...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/9f61a19243e4
branches:  trunk
changeset: 470752:9f61a19243e4
user:      tv <tv%pkgsrc.org@localhost>
date:      Thu Mar 11 20:10:29 2004 +0000

description:
Wrap physical mt operations in SUPPORT_TAPE, and define that if either of
<sys/mtio.h> or <sys/tape.h> is available.

diffstat:

 archivers/pax/files/ar_io.c |  43 ++++++++++++++++++++++++++++++++++++++-----
 archivers/pax/files/pax.h   |  10 +++++++++-
 2 files changed, 47 insertions(+), 6 deletions(-)

diffs (252 lines):

diff -r 5be44dbc048b -r 9f61a19243e4 archivers/pax/files/ar_io.c
--- a/archivers/pax/files/ar_io.c       Thu Mar 11 20:08:16 2004 +0000
+++ b/archivers/pax/files/ar_io.c       Thu Mar 11 20:10:29 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ar_io.c,v 1.5 2003/12/20 04:45:04 grant Exp $  */
+/*     $NetBSD: ar_io.c,v 1.6 2004/03/11 20:10:29 tv Exp $     */
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -44,7 +44,7 @@
 #if 0
 static char sccsid[] = "@(#)ar_io.c    8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: ar_io.c,v 1.5 2003/12/20 04:45:04 grant Exp $");
+__RCSID("$NetBSD: ar_io.c,v 1.6 2004/03/11 20:10:29 tv Exp $");
 #endif
 #endif /* not lint */
 
@@ -134,7 +134,9 @@
 time_t starttime;                      /* time the run started */
 int force_one_volume;                  /* 1 if we ignore volume changes */
 
+#ifdef SUPPORT_TAPE
 static int get_phys(void);
+#endif /* SUPPORT_TAPE */
 extern sigset_t s_mask;
 static void ar_start_gzip(int, const char *, int);
 static const char *timefmt(char *, size_t, off_t, time_t);
@@ -162,7 +164,9 @@
 int
 ar_open(const char *name)
 {
+#ifdef SUPPORT_TAPE
        struct mtget mb;
+#endif /* SUPPORT_TAPE */
 
        if (arfd != -1)
                (void)close(arfd);
@@ -251,7 +255,11 @@
        }
 
        if (S_ISCHR(arsb.st_mode))
+#ifdef SUPPORT_TAPE
                artyp = ioctl(arfd, MTIOCGET, &mb) ? ISCHR : ISTAPE;
+#else
+               artyp = ISCHR;
+#endif /* SUPPORT_TAPE */
        else if (S_ISBLK(arsb.st_mode))
                artyp = ISBLK;
        else if ((lseek(arfd, (off_t)0L, SEEK_CUR) == -1) && (errno == ESPIPE))
@@ -299,6 +307,7 @@
         * stored.
         */
        switch(artyp) {
+#ifdef SUPPORT_TAPE
        case ISTAPE:
                /*
                 * Tape drives come in at least two flavors. Those that support
@@ -316,6 +325,7 @@
                 */
                blksz = rdblksz = MAXBLK;
                break;
+#endif /* SUPPORT_TAPE */
        case ISPIPE:
        case ISBLK:
        case ISCHR:
@@ -398,7 +408,7 @@
                return;
        }
 
-
+#ifdef SUPPORT_TAPE
        /*
         * Close archive file. This may take a LONG while on tapes (we may be
         * forced to wait for the rewind to complete) so tell the user what is
@@ -413,6 +423,7 @@
                        argv0);
                (void)fflush(listf);
        }
+#endif /* SUPPORT_TAPE */
 
        /*
         * if nothing was written to the archive (and we created it), we remove
@@ -442,11 +453,13 @@
        if (zpid > 0)
                waitpid(zpid, &status, 0);
 
+#ifdef SUPPORT_TAPE
        if (vflag && (artyp == ISTAPE)) {
                (void)fputs("done.\n", listf);
                vfpart = 0;
                (void)fflush(listf);
        }
+#endif /* SUPPORT_TAPE */
        arfd = -1;
 
        if (!io_ok && !did_io) {
@@ -776,6 +789,7 @@
                }
                break;
 #endif /* SUPPORT_RMT */
+#ifdef SUPPORT_TAPE
        case ISTAPE:
                if ((res = read_with_restart(arfd, buf, cnt)) > 0) {
                        /*
@@ -803,6 +817,7 @@
                        return(res);
                }
                break;
+#endif
        case ISREG:
        case ISBLK:
        case ISCHR:
@@ -895,7 +910,9 @@
                if ((errno == ENOSPC) || (errno == EFBIG) || (errno == EDQUOT))
                        res = lstrval = 0;
                break;
+#ifdef SUPPORT_TAPE
        case ISTAPE:
+#endif /* SUPPORT_TAPE */
        case ISCHR:
        case ISBLK:
 #ifdef SUPPORT_RMT
@@ -974,7 +991,9 @@
        long fsbz;
        off_t cpos;
        off_t mpos;
+#ifdef SUPPORT_TAPE
        struct mtop mb;
+#endif /* SUPPORT_TAPE */
 
        /*
         * Fail resync attempts at user request (done) or if this is going to be
@@ -995,6 +1014,7 @@
 #ifdef SUPPORT_RMT
        case ISRMT:
 #endif /* SUPPORT_RMT */
+#ifdef SUPPORT_TAPE
        case ISTAPE:
                /*
                 * if the last i/o was a successful data transfer, we assume
@@ -1024,6 +1044,7 @@
 #endif /* SUPPORT_RMT */
                lstrval = 1;
                break;
+#endif /* SUPPORT_TAPE */
        case ISREG:
        case ISCHR:
        case ISBLK:
@@ -1088,7 +1109,10 @@
         * number of physical blocks to skip (we do not know physical block
         * size at this point), so we must only read forward on tapes!
         */
-       if (artyp == ISTAPE || artyp == ISPIPE
+       if (artyp == ISPIPE
+#ifdef SUPPORT_TAPE
+           || artyp == ISTAPE
+#endif /* SUPPORT_TAPE */
 #ifdef SUPPORT_RMT
            || artyp == ISRMT
 #endif /* SUPPORT_RMT */
@@ -1136,7 +1160,9 @@
 ar_rev(off_t sksz)
 {
        off_t cpos;
+#ifdef SUPPORT_TAPE
        struct mtop mb;
+#endif /* SUPPORT_TAPE */
        int phyblk;
 
        /*
@@ -1201,6 +1227,7 @@
                        return(-1);
                }
                break;
+#ifdef SUPPORT_TAPE
        case ISTAPE:
 #ifdef SUPPORT_RMT
        case ISRMT:
@@ -1258,11 +1285,13 @@
                        return(-1);
                }
                break;
+#endif /* SUPPORT_TAPE */
        }
        lstrval = 1;
        return(0);
 }
 
+#ifdef SUPPORT_TAPE
 /*
  * get_phys()
  *     Determine the physical block size on a tape drive. We need the physical
@@ -1419,6 +1448,7 @@
        }
        return(phyblk);
 }
+#endif /* SUPPORT_TAPE */
 
 /*
  * ar_next()
@@ -1461,6 +1491,7 @@
         */
        if (strcmp(arcname, STDO) && strcmp(arcname, STDN) && (artyp != ISREG)
            && (artyp != ISPIPE)) {
+#ifdef SUPPORT_TAPE
                if (artyp == ISTAPE
 #ifdef SUPPORT_RMT
                    || artyp == ISRMT
@@ -1469,7 +1500,9 @@
                        tty_prnt("%s ready for archive tape volume: %d\n",
                                arcname, arvol);
                        tty_prnt("Load the NEXT TAPE on the tape drive");
-               } else {
+               } else
+#endif /* SUPPORT_TAPE */
+               {
                        tty_prnt("%s ready for archive volume: %d\n",
                                arcname, arvol);
                        tty_prnt("Load the NEXT STORAGE MEDIA (if required)");
diff -r 5be44dbc048b -r 9f61a19243e4 archivers/pax/files/pax.h
--- a/archivers/pax/files/pax.h Thu Mar 11 20:08:16 2004 +0000
+++ b/archivers/pax/files/pax.h Thu Mar 11 20:10:29 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pax.h,v 1.4 2003/12/20 04:45:04 grant Exp $    */
+/*     $NetBSD: pax.h,v 1.5 2004/03/11 20:10:29 tv Exp $       */
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -40,6 +40,12 @@
 #else
 #define HAVE_LUTIMES 1
 #define HAVE_STRUCT_STAT_ST_FLAGS 1
+#define HAVE_SYS_MTIO_H 1
+#endif
+
+/* Tape support only available if one of the following is available. */
+#if HAVE_SYS_MTIO_H || HAVE_SYS_TAPE_H
+#define SUPPORT_TAPE 1
 #endif
 
 /*
@@ -72,7 +78,9 @@
 #define ISREG          0       /* regular file */
 #define ISCHR          1       /* character device */
 #define ISBLK          2       /* block device */
+#ifdef SUPPORT_TAPE
 #define ISTAPE         3       /* tape drive */
+#endif
 #define ISPIPE         4       /* pipe/socket */
 #ifdef SUPPORT_RMT
 #define        ISRMT           5       /* rmt */



Home | Main Index | Thread Index | Old Index