#ifndef lint
static const char rcsid[] =
- "$Id: dirs.c,v 1.29 2004/12/15 11:00:01 stelian Exp $";
+ "$Id: dirs.c,v 1.35 2008/04/17 15:16:47 stelian Exp $";
#endif /* not lint */
#include <config.h>
uid_t uid;
gid_t gid;
unsigned int flags;
+ char xattr;
};
/*
#if defined(__linux__) || defined(sunos)
static struct inotab *allocinotab __P((dump_ino_t, OFF_T));
-static void savemodeinfo __P((dump_ino_t, struct new_bsd_inode *));
+static void savemodeinfo __P((dump_ino_t, struct new_bsd_inode *, char *));
#else
static struct inotab *allocinotab __P((dump_ino_t, OFF_T));
-static void savemodeinfo __P((dump_ino_t, struct dinode *));
+static void savemodeinfo __P((dump_ino_t, struct dinode *, char *));
#endif
static void dcvt __P((struct odirect *, struct direct *));
static void flushent __P((void));
struct inotab *itp;
struct direct nulldir;
int fd;
+ char xattr[XATTR_MAXSIZE];
+ int xattr_found = 0;
dump_ino_t ino;
Vprintf(stdout, "Extract directories from tape\n");
memcpy(&ip, curfile.dip, sizeof(ip));
itp = allocinotab(ino, seekpt);
getfile(putdir, xtrnull);
+ xattr_found = 0;
while (spcl.c_flags & DR_EXTATTRIBUTES) {
switch (spcl.c_extattributes) {
case EXT_MACOSFNDRINFO:
skipfile();
break;
case EXT_XATTR:
- msg("EA/ACLs attributes not supported, skipping\n");
- skipfile();
+ if (readxattr(xattr) == GOOD)
+ xattr_found = 1;
break;
}
}
- savemodeinfo(ino, &ip);
+ if (xattr_found)
+ savemodeinfo(ino, &ip, xattr);
+ else
+ savemodeinfo(ino, &ip, NULL);
putent(&nulldir);
flushent();
itp->t_size = seekpt - itp->t_seekpt;
fprintf(stderr, "directory mode, owner, and times not set\n");
return;
}
- mf = fopen(modefile, "r");
+ mf = FOPEN(modefile, "r");
if (mf == NULL) {
warn("fopen");
fprintf(stderr, "cannot open mode file %s\n", modefile);
}
clearerr(mf);
for (;;) {
+ char xattr[XATTR_MAXSIZE];
(void) fread((char *)&node, 1, sizeof(struct modeinfo), mf);
if (feof(mf))
break;
+ if (node.xattr) {
+ (void) fread(xattr, 1, XATTR_MAXSIZE, mf);
+ if (feof(mf))
+ break;
+ }
ep = lookupino(node.ino);
if (command == 'i' || command == 'x') {
if (ep == NULL)
cp = myname(ep);
(void) chown(cp, node.uid, node.gid);
(void) chmod(cp, node.mode);
+ utimes(cp, node.timep);
+ if (node.xattr)
+ xattr_extract(cp, xattr);
+ ep->e_flags &= ~NEW;
if (node.flags)
#ifdef __linux__
(void) lsetflags(cp, node.flags);
(void) chflags(cp, node.flags);
#endif
#endif
- utimes(cp, node.timep);
- ep->e_flags &= ~NEW;
}
}
if (ferror(mf))
fprintf(stderr, "directory mode, owner, and times not set\n");
return;
}
- mf = fopen(modefile, "r");
+ mf = FOPEN(modefile, "r");
if (mf == NULL) {
warn("fopen");
fprintf(stderr, "cannot open mode file %s\n", modefile);
}
clearerr(mf);
for (;;) {
+ char xattr[XATTR_MAXSIZE];
(void) fread((char *)&node, 1, sizeof(struct modeinfo), mf);
if (feof(mf))
break;
+ if (node.xattr) {
+ (void) fread(xattr, 1, XATTR_MAXSIZE, mf);
+ if (feof(mf))
+ break;
+ }
ep = lookupino(node.ino);
if (ep == NULL) {
panic("cannot find directory inode %d\n", node.ino);
} else {
- cp = myname(ep);
struct STAT sb;
unsigned long newflags;
+ cp = myname(ep);
if (LSTAT(cp, &sb) < 0) {
- warn("%s: does not exist", cp);
+ warn("unable to stat %s", cp);
do_compare_error;
continue;
}
}
#ifdef __linux__
if (lgetflags(cp, &newflags) < 0) {
- warn("%s: lgetflags failed", cp);
- do_compare_error;
+ if (node.flags != 0) {
+ warn("%s: lgetflags failed", cp);
+ do_compare_error;
+ }
}
else {
if (newflags != node.flags) {
}
}
#endif
+ if (node.xattr) {
+ if (xattr_compare(cp, xattr) == FAIL)
+ do_compare_error;
+ }
+ else {
+ if (xattr_compare(cp, NULL) == FAIL)
+ do_compare_error;
+ }
ep->e_flags &= ~NEW;
}
}
static void
#if defined(__linux__) || defined(sunos)
-savemodeinfo(dump_ino_t ino, struct new_bsd_inode *dip) {
+savemodeinfo(dump_ino_t ino, struct new_bsd_inode *dip, char *xattr) {
#else
-savemodeinfo(dump_ino_t ino, struct dinode *dip) {
+savemodeinfo(dump_ino_t ino, struct dinode *dip, char *xattr) {
#endif
struct modeinfo node;
node.flags = dip->di_flags;
node.uid = dip->di_uid;
node.gid = dip->di_gid;
+ node.xattr = xattr ? 1 : 0;
if ( fwrite((char *)&node, 1, sizeof(struct modeinfo), mf) != sizeof(struct modeinfo) )
err(1,"cannot write to file %s", modefile);
+ if (xattr)
+ if ( fwrite(xattr, 1, XATTR_MAXSIZE, mf) != XATTR_MAXSIZE)
+ err(1,"cannot write to file %s", modefile);
}
/*