tar: add verbose flag (-v)

This commit is contained in:
Hiltjo Posthuma 2015-05-08 12:28:51 +02:00 committed by sin
parent f5f43dbd5b
commit 7dff7d4c83

9
tar.c
View File

@ -65,7 +65,7 @@ static int tarfd;
static ino_t tarinode; static ino_t tarinode;
static dev_t tardev; static dev_t tardev;
static int mflag; static int mflag, vflag;
static int filtermode; static int filtermode;
static void static void
@ -326,6 +326,8 @@ static void
c(const char *path, struct stat *st, void *data, struct recursor *r) c(const char *path, struct stat *st, void *data, struct recursor *r)
{ {
archive(path); archive(path);
if (vflag)
puts(path);
if (st && S_ISDIR(st->st_mode)) if (st && S_ISDIR(st->st_mode))
recurse(path, NULL, r); recurse(path, NULL, r);
@ -429,6 +431,8 @@ xt(int argc, char *argv[], int (*fn)(char *, ssize_t, char[BLKSIZ]))
} }
fn(fname, size, b); fn(fname, size, b);
if (vflag && mode != 't')
puts(fname);
} }
if (!mflag) { if (!mflag) {
@ -482,6 +486,9 @@ main(int argc, char *argv[])
case 'h': case 'h':
r.follow = 'L'; r.follow = 'L';
break; break;
case 'v':
vflag = 1;
break;
default: default:
usage(); usage();
} ARGEND; } ARGEND;