X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=restore%2Ftape.c;h=c74e3909f10e46cf1f1ae026573f5d9cfab56bde;hp=c4c50c0cc750d5af689358a9052e611ccf95e740;hb=cb6d3f79501e3c03637ca49f4b980288771eabd3;hpb=b43981b3544000a3683e6a53ea1cf8412f09e4d5 diff --git a/restore/tape.c b/restore/tape.c index c4c50c0..c74e390 100644 --- a/restore/tape.c +++ b/restore/tape.c @@ -42,7 +42,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.85 2005/01/14 13:01:34 stelian Exp $"; + "$Id: tape.c,v 1.90 2005/06/08 13:24:11 stelian Exp $"; #endif /* not lint */ #include @@ -167,6 +167,7 @@ static void xtrlnkskip __P((char *, size_t)); static void xtrmap __P((char *, size_t)); static void xtrmapskip __P((char *, size_t)); static void xtrskip __P((char *, size_t)); +static void xtrxattr __P((char *, size_t)); static void setmagtapein __P((void)); static int extractattr __P((char *)); static void compareattr __P((char *)); @@ -196,6 +197,9 @@ static void xtrcmpskip __P((char *, size_t)); static int readmapflag; static int readingmaps; /* set to 1 while reading the maps */ +static char xattrbuf[XATTR_MAXSIZE]; +static int xattrlen; + #ifdef DUMP_MACOSX static DumpFinderInfo gFndrInfo; #endif @@ -342,6 +346,7 @@ setup(void) #endif FLUSHTAPEBUF(); findtapeblksize(); + cvtflag = 0; if (gethead(&spcl) == FAIL) { blkcnt--; /* push back this block */ blksread--; @@ -1029,10 +1034,14 @@ extractattr(char *path) skipfile(); #endif break; - case EXT_XATTR: - msg("EA/ACLs not supported in this version, skipping\n"); - skipfile(); - break; + case EXT_XATTR: { + char xattr[XATTR_MAXSIZE]; + + if (readxattr(xattr) == GOOD) { + xattr_extract(path, xattr); + break; + } + } default: msg("unexpected inode extension %ld, skipping\n", spcl.c_extattributes); skipfile(); @@ -1054,7 +1063,6 @@ extractfinderinfoufs(char *name) u_int32_t uid; u_int32_t gid; char path[MAXPATHLEN], fname[MAXPATHLEN]; - int toto; curfile.name = name; curfile.action = USING; @@ -1214,6 +1222,29 @@ extractresourceufs(char *name) } #endif /* DUMP_MACOSX */ +int +readxattr(char *buffer) +{ + if (dflag) + msg("reading EA data for inode %lu\n", curfile.ino); + + curfile.name = "EA block"; + if (curfile.dip->di_size > XATTR_MAXSIZE) { + fprintf(stderr, "EA size too big (%ld)", (long)curfile.dip->di_size); + skipfile(); + return (FAIL); + } + + memset(xattrbuf, 0, XATTR_MAXSIZE); + xattrlen = 0; + + getfile(xtrxattr, xtrnull); + + memcpy(buffer, xattrbuf, XATTR_MAXSIZE); + + return (GOOD); +} + /* * skip over bit maps on the tape */ @@ -1346,8 +1377,6 @@ xtrfile(char *buf, size_t size) static void xtrfilefinderinfo(char *buf, size_t size) { - if (Nflag) - return; bcopy(buf, &gFndrInfo, size); } #endif /* DUMP_MACOSX */ @@ -1483,6 +1512,17 @@ xtrcmpskip(UNUSED(char *buf), size_t size) } #endif /* COMPARE_ONTHEFLY */ +static void +xtrxattr(char *buf, size_t size) +{ + if (xattrlen + size > XATTR_MAXSIZE) { + fprintf(stderr, "EA size too big (%ld)", (long)xattrlen + size); + return; + } + memcpy(xattrbuf + xattrlen, buf, size); + xattrlen += size; +} + #if !COMPARE_ONTHEFLY static int do_cmpfiles(int fd_tape, int fd_disk, OFF_T size) @@ -1527,7 +1567,7 @@ cmpfiles(char *tapefile, char *diskfile, struct STAT *sbuf_disk) int fd_tape, fd_disk; if (STAT(tapefile, &sbuf_tape) != 0) { - panic("Can't lstat tmp file %s: %s\n", tapefile, + panic("can't lstat tmp file %s: %s\n", tapefile, strerror(errno)); do_compare_error; } @@ -1545,12 +1585,12 @@ cmpfiles(char *tapefile, char *diskfile, struct STAT *sbuf_disk) } if ((fd_tape = OPEN(tapefile, O_RDONLY)) < 0) { - panic("Can't open %s: %s\n", tapefile, strerror(errno)); + panic("can't open %s: %s\n", tapefile, strerror(errno)); do_compare_error; } if ((fd_disk = OPEN(diskfile, O_RDONLY)) < 0) { close(fd_tape); - panic("Can't open %s: %s\n", diskfile, strerror(errno)); + panic("can't open %s: %s\n", diskfile, strerror(errno)); do_compare_error; } @@ -1598,6 +1638,8 @@ cmpfiles(char *tapefile, char *diskfile, struct STAT *sbuf_disk) static void compareattr(char *name) { + int xattr_done = 0; + while (spcl.c_flags & DR_EXTATTRIBUTES) { switch (spcl.c_extattributes) { case EXT_MACOSFNDRINFO: @@ -1608,16 +1650,26 @@ compareattr(char *name) msg("MacOSX not supported for comparision in this version, skipping\n"); skipfile(); break; - case EXT_XATTR: - msg("EA/ACLs not supported for comparision in this version, skipping\n"); - skipxattr(); + case EXT_XATTR: { + char xattr[XATTR_MAXSIZE]; + + if (readxattr(xattr) == GOOD) { + if (xattr_compare(name, xattr) == FAIL) + do_compare_error; + xattr_done = 1; + } + else + do_compare_error; break; + } default: msg("unexpected inode extension %ld, skipping\n", spcl.c_extattributes); skipfile(); break; } } + if (!xattr_done && xattr_compare(name, NULL) == FAIL) + do_compare_error; } #if !COMPARE_ONTHEFLY @@ -1652,7 +1704,7 @@ comparefile(char *name) } if ((r = LSTAT(name, &sb)) != 0) { - warn("%s: does not exist (%d)", name, r); + warn("unable to stat %s", name); do_compare_error; skipfile(); return; @@ -1730,7 +1782,7 @@ comparefile(char *name) return; } if ((lsize = readlink(name, lbuf, MAXPATHLEN)) < 0) { - panic("readlink of %s failed: %s", name, + panic("readlink of %s failed: %s\n", name, strerror(errno)); do_compare_error; } @@ -1773,7 +1825,7 @@ comparefile(char *name) case IFREG: #if COMPARE_ONTHEFLY if ((ifile = OPEN(name, O_RDONLY)) < 0) { - panic("Can't open %s: %s\n", name, strerror(errno)); + warn("can't open %s", name); skipfile(); do_compare_error; } @@ -2361,6 +2413,7 @@ findtapeblksize(void) errx(1, "Tape read error on first record"); memcpy(&spclpt, tapebuf, TP_BSIZE); + cvtflag = 0; if (converthead(&spclpt) == FAIL) { cvtflag++; if (converthead(&spclpt) == FAIL) { @@ -2571,7 +2624,7 @@ converthead(struct s_spcl *buf) if (checksum((int *)buf) == FAIL) return (FAIL); if (Bcvt) - swabst((u_char *)"8i4s31i528bi192b3i", (u_char *)buf); + swabst((u_char *)"8i4s1l29i528bi192b4i", (u_char *)buf); goto good; } memcpy(&u_ospcl.s_ospcl, buf, TP_BSIZE);