Refactor enmasse() and recurse() to reflect depth
The HLP-changes to sbase have been a great addition of functionality, but they kind of "polluted" the enmasse() and recurse() prototypes. As this will come in handy in the future, knowing at which "depth" you are inside a recursing function is an important functionality. Instead of having a special HLP-flag passed to enmasse, each sub- function needs to provide it on its own and can calculate results based on the current depth (for instance, 'H' implies 'P' at depth > 0). A special case is recurse(), because it actually depends on the follow-type. A new flag "recurse_follow" brings consistency into what used to be spread across different naming conventions (fflag, HLP_flag, ...). This also fixes numerous bugs with the behaviour of HLP in the tools using it.
This commit is contained in:
11
tar.c
11
tar.c
@@ -42,7 +42,6 @@ static ino_t tarinode;
|
||||
static dev_t tardev;
|
||||
|
||||
static int mflag;
|
||||
static int fflag = 'P';
|
||||
static char filtermode;
|
||||
|
||||
static FILE *
|
||||
@@ -234,14 +233,14 @@ print(char * fname, int l, char b[BLKSIZ])
|
||||
}
|
||||
|
||||
static void
|
||||
c(const char * path, int fflag)
|
||||
c(const char *path, int depth)
|
||||
{
|
||||
archive(path);
|
||||
recurse(path, c, fflag);
|
||||
recurse(path, c, depth);
|
||||
}
|
||||
|
||||
static void
|
||||
xt(int (*fn)(char*, int, char[BLKSIZ]))
|
||||
xt(int (*fn)(char *, int, char[BLKSIZ]))
|
||||
{
|
||||
char b[BLKSIZ], fname[257], *s;
|
||||
struct header *h = (void*)b;
|
||||
@@ -293,7 +292,7 @@ main(int argc, char *argv[])
|
||||
filtermode = ARGC();
|
||||
break;
|
||||
case 'h':
|
||||
fflag = 'L';
|
||||
recurse_follow = 'L';
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
@@ -316,7 +315,7 @@ main(int argc, char *argv[])
|
||||
tarfile = stdout;
|
||||
}
|
||||
chdir(dir);
|
||||
c(argv[0], fflag);
|
||||
c(argv[0], 0);
|
||||
break;
|
||||
case 't':
|
||||
case 'x':
|
||||
|
Reference in New Issue
Block a user