Source-Changes-HG archive

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

[src/trunk]: src Add external attribute dumping and restoring support from Fr...



details:   https://anonhg.NetBSD.org/src/rev/b47330f83d98
branches:  trunk
changeset: 1021813:b47330f83d98
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jun 19 13:56:34 2021 +0000

description:
Add external attribute dumping and restoring support from FreeBSD.
Does not fully work yet, attributes are being saved and restored correctly,
but don't appear in the restored files somehow.

diffstat:

 include/protocols/dumprestore.h |    6 +-
 sbin/dump/dump.h                |    4 +-
 sbin/dump/tape.c                |  252 +++++++++++++++---------------
 sbin/dump/traverse.c            |  182 ++++++++++++++++++++-
 sbin/restore/dirs.c             |  223 ++++++++++++++++++--------
 sbin/restore/extern.h           |   15 +-
 sbin/restore/interactive.c      |   53 +++---
 sbin/restore/main.c             |    8 +-
 sbin/restore/restore.c          |   30 +-
 sbin/restore/restore.h          |    3 +-
 sbin/restore/symtab.c           |   12 +-
 sbin/restore/tape.c             |  323 +++++++++++++++++++++++++++++++++++----
 sbin/restore/utilities.c        |    8 +-
 sys/sys/extattr.h               |   19 ++-
 14 files changed, 819 insertions(+), 319 deletions(-)

diffs (truncated from 2461 to 300 lines):

diff -r f0aa0c540e81 -r b47330f83d98 include/protocols/dumprestore.h
--- a/include/protocols/dumprestore.h   Sat Jun 19 13:40:00 2021 +0000
+++ b/include/protocols/dumprestore.h   Sat Jun 19 13:56:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dumprestore.h,v 1.19 2020/04/05 15:25:39 joerg Exp $   */
+/*     $NetBSD: dumprestore.h,v 1.20 2021/06/19 13:56:34 christos Exp $        */
 
 /*
  * Copyright (c) 1980, 1993
@@ -95,7 +95,8 @@
                                int64_t __uc_birthtime;
                                int64_t __uc_atime;
                                int64_t __uc_mtime;
-                               int32_t __uc_spare4[7];
+                               int32_t __uc_extsize;
+                               int32_t __uc_spare4[6];
                                uint32_t __uc_file_flags;
                                int32_t __uc_spare5[2];
                                uint32_t __uc_uid;
@@ -125,6 +126,7 @@
 #define c_mode         __c_ino.__uc_ino.__uc_mode
 #define c_spare1       __c_ino.__uc_ino.__uc_spare1
 #define c_size         __c_ino.__uc_ino.__uc_size
+#define c_extsize      __c_ino.__uc_ino.__uc_extsize
 #define c_old_atime    __c_ino.__uc_ino.__uc_old_atime
 #define c_atime                __c_ino.__uc_ino.__uc_atime
 #define c_atimensec    __c_ino.__uc_ino.__uc_atimensec
diff -r f0aa0c540e81 -r b47330f83d98 sbin/dump/dump.h
--- a/sbin/dump/dump.h  Sat Jun 19 13:40:00 2021 +0000
+++ b/sbin/dump/dump.h  Sat Jun 19 13:56:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dump.h,v 1.59 2020/12/03 08:25:57 kre Exp $    */
+/*     $NetBSD: dump.h,v 1.60 2021/06/19 13:56:34 christos Exp $       */
 
 /*-
  * Copyright (c) 1980, 1993
@@ -205,7 +205,7 @@
 
 /* file dumping routines */
 void   blksout32(int32_t *, int, ino_t);
-void   blksout64(int64_t *, int, ino_t);
+void   blksout64(union dinode *, int64_t *, int, ino_t, int);
 void   dumpino(union dinode *, ino_t);
 #ifndef RRESTORE
 void   dumpmap(char *, int, ino_t);
diff -r f0aa0c540e81 -r b47330f83d98 sbin/dump/tape.c
--- a/sbin/dump/tape.c  Sat Jun 19 13:40:00 2021 +0000
+++ b/sbin/dump/tape.c  Sat Jun 19 13:56:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tape.c,v 1.56 2021/06/07 14:07:32 hannken Exp $        */
+/*     $NetBSD: tape.c,v 1.57 2021/06/19 13:56:34 christos Exp $       */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)tape.c     8.4 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: tape.c,v 1.56 2021/06/07 14:07:32 hannken Exp $");
+__RCSID("$NetBSD: tape.c,v 1.57 2021/06/19 13:56:34 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -69,8 +69,8 @@
 
 static ssize_t atomic_read(int, void *, int);
 static ssize_t atomic_write(int, const void *, int);
-static void doslave(int, int);
-static void enslave(void);
+static void doworker(int, int);
+static void create_workers(void);
 static void flushtape(void);
 static void killall(void);
 static void proceed(int);
@@ -80,11 +80,11 @@
 
 /*
  * Concurrent dump mods (Caltech) - disk block reading and tape writing
- * are exported to several slave processes.  While one slave writes the
+ * are exported to several worker processes.  While one worker writes the
  * tape, the others read disk blocks; they pass control of the tape in
  * a ring via signals. The parent process traverses the file system and
- * sends writeheader()'s and lists of daddr's to the slaves via pipes.
- * The following structure defines the instruction packets sent to slaves.
+ * sends writeheader()'s and lists of daddr's to the workers via pipes.
+ * The following structure defines the instruction packets sent to workers.
  */
 struct req {
        daddr_t dblk;
@@ -92,20 +92,20 @@
 };
 int reqsiz;
 
-#define SLAVES 3               /* 1 slave writing, 1 reading, 1 for slack */
-struct slave {
+#define WORKERS 3              /* 1 worker writing, 1 reading, 1 for slack */
+struct worker {
        int64_t tapea;          /* header number at start of this chunk */
        int64_t firstrec;       /* record number of this block */
        int count;              /* count to next header (used for TS_TAPE */
                                /* after EOT) */
        int inode;              /* inode that we are currently dealing with */
-       int fd;                 /* FD for this slave */
-       int pid;                /* PID for this slave */
-       int sent;               /* 1 == we've sent this slave requests */
+       int fd;                 /* FD for this worker */
+       int pid;                /* PID for this worker */
+       int sent;               /* 1 == we've sent this worker requests */
        char (*tblock)[TP_BSIZE]; /* buffer for data blocks */
        struct req *req;        /* buffer for requests */
-} slaves[SLAVES+1];
-struct slave *slp;
+} workers[WORKERS+1];
+struct worker *wp;
 
 char   (*nextblock)[TP_BSIZE];
 
@@ -138,18 +138,18 @@
         * packets, so flushtape() can write them together with one write().
         * Align tape buffer on page boundary to speed up tape write().
         */
-       for (i = 0; i <= SLAVES; i++) {
+       for (i = 0; i <= WORKERS; i++) {
                buf = (char *)
                    xmalloc((unsigned)(reqsiz + writesize + pgoff + TP_BSIZE));
-               slaves[i].tblock = (char (*)[TP_BSIZE])
+               workers[i].tblock = (char (*)[TP_BSIZE])
                    (((long)&buf[ntrec + 1] + pgoff) &~ pgoff);
-               slaves[i].req = (struct req *)slaves[i].tblock - ntrec - 1;
+               workers[i].req = (struct req *)workers[i].tblock - ntrec - 1;
        }
-       slp = &slaves[0];
-       slp->count = 1;
-       slp->tapea = 0;
-       slp->firstrec = 0;
-       nextblock = slp->tblock;
+       wp = &workers[0];
+       wp->count = 1;
+       wp->tapea = 0;
+       wp->firstrec = 0;
+       nextblock = wp->tblock;
        return(1);
 }
 
@@ -157,8 +157,8 @@
 writerec(const char *dp, int isspcl)
 {
 
-       slp->req[trecno].dblk = (daddr_t)0;
-       slp->req[trecno].count = 1;
+       wp->req[trecno].dblk = (daddr_t)0;
+       wp->req[trecno].count = 1;
        *(union u_spcl *)(*(nextblock)++) = *(const union u_spcl *)dp;
        if (isspcl)
                lastspclrec = iswap64(spcl.c_tapea);
@@ -177,8 +177,8 @@
        dblkno = fsatoda(ufsib, blkno);
        tpblks = size >> tp_bshift;
        while ((avail = MIN(tpblks, ntrec - trecno)) > 0) {
-               slp->req[trecno].dblk = dblkno;
-               slp->req[trecno].count = avail;
+               wp->req[trecno].dblk = dblkno;
+               wp->req[trecno].count = avail;
                trecno += avail;
                spcl.c_tapea = iswap64(iswap64(spcl.c_tapea) + avail);
                if (trecno >= ntrec)
@@ -279,27 +279,27 @@
        int i, blks, got;
        int64_t lastfirstrec;
 
-       int siz = (char *)nextblock - (char *)slp->req;
+       int siz = (char *)nextblock - (char *)wp->req;
 
-       slp->req[trecno].count = 0;                     /* Sentinel */
+       wp->req[trecno].count = 0;                      /* Sentinel */
 
-       if (atomic_write(slp->fd, slp->req, siz) != siz)
+       if (atomic_write(wp->fd, wp->req, siz) != siz)
                quite(errno, "error writing command pipe");
-       slp->sent = 1; /* we sent a request, read the response later */
+       wp->sent = 1; /* we sent a request, read the response later */
 
-       lastfirstrec = slp->firstrec;
+       lastfirstrec = wp->firstrec;
 
-       if (++slp >= &slaves[SLAVES])
-               slp = &slaves[0];
+       if (++wp >= &workers[WORKERS])
+               wp = &workers[0];
 
-       /* Read results back from next slave */
-       if (slp->sent) {
-               if (atomic_read(slp->fd, &got, sizeof got)
+       /* Read results back from next worker */
+       if (wp->sent) {
+               if (atomic_read(wp->fd, &got, sizeof got)
                    != sizeof got) {
                        perror("  DUMP: error reading command pipe in master");
                        dumpabort(0);
                }
-               slp->sent = 0;
+               wp->sent = 0;
 
                /* Check for end of tape */
                if (got < writesize) {
@@ -309,15 +309,15 @@
                         * Drain the results, don't care what the values were.
                         * If we read them here then trewind won't...
                         */
-                       for (i = 0; i < SLAVES; i++) {
-                               if (slaves[i].sent) {
-                                       if (atomic_read(slaves[i].fd,
+                       for (i = 0; i < WORKERS; i++) {
+                               if (workers[i].sent) {
+                                       if (atomic_read(workers[i].fd,
                                            &got, sizeof got)
                                            != sizeof got) {
                                                perror("  DUMP: error reading command pipe in master");
                                                dumpabort(0);
                                        }
-                                       slaves[i].sent = 0;
+                                       workers[i].sent = 0;
                                }
                        }
 
@@ -334,11 +334,11 @@
                        if (spcl.c_addr[i] != 0)
                                blks++;
        }
-       slp->count = lastspclrec + blks + 1 - iswap64(spcl.c_tapea);
-       slp->tapea = iswap64(spcl.c_tapea);
-       slp->firstrec = lastfirstrec + ntrec;
-       slp->inode = curino;
-       nextblock = slp->tblock;
+       wp->count = lastspclrec + blks + 1 - iswap64(spcl.c_tapea);
+       wp->tapea = iswap64(spcl.c_tapea);
+       wp->firstrec = lastfirstrec + ntrec;
+       wp->inode = curino;
+       nextblock = wp->tblock;
        trecno = 0;
        asize += tenths;
        blockswritten += ntrec;
@@ -357,7 +357,7 @@
        int f;
        int got;
 
-       for (f = 0; f < SLAVES; f++) {
+       for (f = 0; f < WORKERS; f++) {
                /*
                 * Drain the results, but unlike EOT we DO (or should) care
                 * what the return values were, since if we detect EOT after
@@ -366,22 +366,22 @@
                 *
                 * fixme: punt for now.
                 */
-               if (slaves[f].sent) {
-                       if (atomic_read(slaves[f].fd, &got, sizeof got)
+               if (workers[f].sent) {
+                       if (atomic_read(workers[f].fd, &got, sizeof got)
                            != sizeof got) {
                                perror("  DUMP: error reading command pipe in master");
                                dumpabort(0);
                        }
-                       slaves[f].sent = 0;
+                       workers[f].sent = 0;
                        if (got != writesize) {
                                msg("EOT detected in last 2 tape records!\n");
                                msg("Use a longer tape, decrease the size estimate\n");
                                quit("or use no size estimate at all");
                        }
                }
-               (void) close(slaves[f].fd);
+               (void) close(workers[f].fd);
        }
-       while (wait(NULL) >= 0) /* wait for any signals from slaves */
+       while (wait(NULL) >= 0) /* wait for any signals from workers */
                /* void */;
 
        if (pipeout)
@@ -457,29 +457,29 @@
 rollforward(void)
 {
        struct req *p, *q, *prev;
-       struct slave *tslp;
+       struct worker *twp;
        int i, size, got;
        int64_t savedtapea;
        union u_spcl *ntb, *otb;
-       tslp = &slaves[SLAVES];
-       ntb = (union u_spcl *)tslp->tblock[1];
+       twp = &workers[WORKERS];
+       ntb = (union u_spcl *)twp->tblock[1];
 
        /*
-        * Each of the N slaves should have requests that need to
-        * be replayed on the next tape.  Use the extra slave buffers
-        * (slaves[SLAVES]) to construct request lists to be sent to
-        * each slave in turn.
+        * Each of the N workers should have requests that need to
+        * be replayed on the next tape.  Use the extra worker buffers



Home | Main Index | Thread Index | Old Index