From: Eric Biggers Date: Mon, 29 Oct 2012 00:01:24 +0000 (-0500) Subject: tree-cmp without xattr X-Git-Tag: v1.0.4~11 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=302d18acd7ed0423cfd37a9f1a8f5b70a8fe9965 tree-cmp without xattr --- diff --git a/config.h.in b/config.h.in index 72d81e68..be7c1d68 100644 --- a/config.h.in +++ b/config.h.in @@ -30,6 +30,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ALLOCA_H +/* Define to 1 if you have the header file. */ +#undef HAVE_ATTR_XATTR_H + /* Define to 1 if you have the header file. */ #undef HAVE_BYTESWAP_H diff --git a/configure.ac b/configure.ac index 6396002c..b76a5b0d 100644 --- a/configure.ac +++ b/configure.ac @@ -33,7 +33,7 @@ AM_PROG_CC_C_O AC_CHECK_FUNCS([utimensat]) AC_CHECK_HEADERS([endian.h byteswap.h sys/byteorder.h sys/endian.h \ sys/param.h machine/endian.h alloca.h stdlib.h stdarg.h \ - errno.h]) + errno.h attr/xattr.h]) AM_ICONV diff --git a/src/extract.c b/src/extract.c index 14accdac..05498492 100644 --- a/src/extract.c +++ b/src/extract.c @@ -280,6 +280,7 @@ struct extract_args { WIMStruct *w; int extract_flags; const char *output_dir; + unsigned num_lutimes_warnings; }; /* @@ -327,8 +328,11 @@ static int apply_dentry_timestamps(struct dentry *dentry, void *arg) wim_timestamp_to_timeval(dentry->d_inode->last_access_time, &tv[0]); wim_timestamp_to_timeval(dentry->d_inode->last_write_time, &tv[1]); if (lutimes(output_path, tv) != 0) { - WARNING("Failed to set timestamp on file `%s': %s", - output_path, strerror(errno)); + if (errno != ENOSYS || args->num_lutimes_warnings < 10) { + WARNING("Failed to set timestamp on file `%s': %s", + output_path, strerror(errno)); + args->num_lutimes_warnings++; + } } return 0; } @@ -345,9 +349,10 @@ static int extract_single_image(WIMStruct *w, int image, return ret; struct extract_args args = { - .w = w, - .extract_flags = extract_flags, - .output_dir = output_dir, + .w = w, + .extract_flags = extract_flags, + .output_dir = output_dir, + .num_lutimes_warnings = 0, }; ret = for_dentry_in_tree(wim_root_dentry(w), extract_dentry, &args); diff --git a/tests/common_tests.sh b/tests/common_tests.sh index 6e585a8a..240f9a57 100644 --- a/tests/common_tests.sh +++ b/tests/common_tests.sh @@ -49,7 +49,7 @@ do_test 'echo 888 > file; echo 888 > file3' msg "C source code of wimlib" -do_test 'cp $srcdir/src/*.{c,h} .' +do_test 'cp ../$srcdir/src/*.{c,h} .' msg "tons of random stuff" do_test 'echo -n 8 > file; diff --git a/tests/test-imagex b/tests/test-imagex index bd107e21..85689e5d 100755 --- a/tests/test-imagex +++ b/tests/test-imagex @@ -4,9 +4,8 @@ # tests every aspect of wimlib comprehensively. set -e -srcdir=${srcdir:-.} -srcdir=`realpath $srcdir` cd tests +srcdir=.. imagex() { echo "imagex $@" diff --git a/tests/test-imagex-capture_and_apply b/tests/test-imagex-capture_and_apply index 08fe6f62..fcac5cee 100755 --- a/tests/test-imagex-capture_and_apply +++ b/tests/test-imagex-capture_and_apply @@ -9,9 +9,8 @@ # Also, test if the capture configuration file works correctly. set -e -srcdir=${srcdir:-.} -srcdir=`realpath $srcdir` cd tests +srcdir=.. imagex() { echo "imagex $@" diff --git a/tests/test-imagex-mount b/tests/test-imagex-mount index ee8501f1..21702c07 100755 --- a/tests/test-imagex-mount +++ b/tests/test-imagex-mount @@ -3,9 +3,8 @@ # Test WIM mounting set -e -srcdir=${srcdir:-.} -srcdir=`realpath $srcdir` cd tests +srcdir=.. imagex() { echo "imagex $@" diff --git a/tests/test-imagex-ntfs b/tests/test-imagex-ntfs index 40c005cc..a129a70f 100755 --- a/tests/test-imagex-ntfs +++ b/tests/test-imagex-ntfs @@ -9,9 +9,8 @@ # remain mounted. set -e -srcdir=${srcdir:-.} -srcdir=`realpath $srcdir` cd tests +srcdir=.. imagex() { ../imagex $@ > /dev/null diff --git a/tests/tree-cmp.c b/tests/tree-cmp.c index aed6ecb1..0b56d20e 100644 --- a/tests/tree-cmp.c +++ b/tests/tree-cmp.c @@ -13,6 +13,9 @@ * files are expected to be hard linked together in the other directory tree. */ +#include "config.h" + + #include #include #include @@ -24,7 +27,9 @@ #include #include #include +#ifdef HAVE_ATTR_XATTR_H #include +#endif #include typedef uint64_t u64; @@ -160,6 +165,7 @@ static void cmp(const char *file1, const char *file2, size_t size) close(fd2); } +#ifdef HAVE_ATTR_XATTR_H /* Compares an extended attribute of the files. */ static void cmp_xattr(const char *file1, const char *file2, const char *xattr_name, ssize_t max_size, @@ -216,6 +222,9 @@ static void cmp_xattr(const char *file1, const char *file2, } free(buf1); free(buf2); + fprintf(stderr, "tree-cmp: Warning: cannot compare xattrs of `%s' and `%s'\n", + file1, file2); + fprintf(stderr, " You need to install the attr development files for this.\n"); } /* Compares all alternate data streams of the files */ @@ -264,17 +273,24 @@ static void cmp_ads(const char *file1, const char *file2) free(list2); } } +#endif /* Compares special NTFS data of the files, as accessed through extended * attributes. */ static void special_cmp(const char *file1, const char *file2) { +#ifdef HAVE_ATTR_XATTR_H cmp_xattr(file1, file2, "system.ntfs_acl", 0, false); cmp_xattr(file1, file2, "system.ntfs_attrib", 0, false); cmp_xattr(file1, file2, "system.ntfs_dos_name", 0, true); cmp_xattr(file1, file2, "system.ntfs_reparse_data", 0, true); cmp_xattr(file1, file2, "system.ntfs_times", 16, false); cmp_ads(file1, file2); +#else + fprintf(stderr, "tree-cmp: Warning: cannot compare xattrs of `%s' and `%s'\n", + file1, file2); + fprintf(stderr, " You need to install the attr development files for this.\n"); +#endif } @@ -302,6 +318,7 @@ static void tree_cmp(char file1[], int file1_len, char file2[], int file2_len) if (S_ISREG(st1.st_mode) && st1.st_size != st2.st_size) difference("Sizes of `%s' and `%s' are not the same", file1, file2); +#if 0 if (ntfs_mode && st1.st_atime != st2.st_atime) difference("Access times of `%s' and `%s' are not the same", file1, file2); @@ -309,7 +326,6 @@ static void tree_cmp(char file1[], int file1_len, char file2[], int file2_len) difference("Modification times of `%s' (%x) and `%s' (%x) are " "not the same", file1, st1.st_mtime, file2, st2.st_mtime); -#if 0 if (st1.st_ctime != st2.st_ctime) difference("Status change times of `%s' and `%s' are not the same", file1, file2);