[hackers] [sbase] tar: Check inode AND dev before ignoring a file. Thanks, Lars Lindqvist! || David Galos

From: <git_AT_suckless.org>
Date: Sun, 28 Jul 2013 18:11:36 +0200

commit b5b7db400905a98319c2b8978156565c68247fa5
Author: David Galos <galosd83_AT_students.rowan.edu>
Date: Sun Jul 28 12:12:03 2013 -0400

    tar: Check inode AND dev before ignoring a file. Thanks, Lars Lindqvist!

diff --git a/tar.c b/tar.c
index 0f3ce33..c1cc88d 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -48,6 +48,7 @@ static void xt(int (*)(char*, int, char[Blksiz]));
 
 static FILE *tarfile;
 static ino_t tarinode;
+static dev_t tardev;
 
 static void
 usage(void)
_AT_@ -126,6 +127,7 @@ main(int argc, char *argv[])
                 if (lstat(file, &st) < 0)
                         eprintf("tar: stat '%s':", file);
                 tarinode = st.st_ino;
+ tardev = st.st_dev;
         } else {
                 tarfile = (mode == 'c') ? stdout : stdin;
         }
_AT_@ -161,7 +163,7 @@ archive(const char* path, const struct stat* sta, int type)
         mode_t mode;
 
         lstat(path, &st);
- if (st.st_ino == tarinode) {
+ if (st.st_ino == tarinode && st.st_dev == tardev) {
                 fprintf(stderr, "ignoring '%s'
", path);
                 return 0;
         }
Received on Sun Jul 28 2013 - 18:11:36 CEST

This archive was generated by hypermail 2.3.0 : Sun Jul 28 2013 - 18:12:12 CEST