implement -x by pruning fsnodes tree before building filesystem rather
than by skipping nodes while building filesystem
This commit is contained in:
parent
0e392af953
commit
d0c4ff452b
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cd9660.c,v 1.14 2006/10/08 16:25:18 dbj Exp $ */
|
||||
/* $NetBSD: cd9660.c,v 1.15 2006/10/10 01:55:45 dbj Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
|
||||
@ -101,7 +101,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(__lint)
|
||||
__RCSID("$NetBSD: cd9660.c,v 1.14 2006/10/08 16:25:18 dbj Exp $");
|
||||
__RCSID("$NetBSD: cd9660.c,v 1.15 2006/10/10 01:55:45 dbj Exp $");
|
||||
#endif /* !__lint */
|
||||
|
||||
#include <string.h>
|
||||
@ -150,7 +150,7 @@ static cd9660node *cd9660_rrip_move_directory(cd9660node *);
|
||||
static int cd9660_add_dot_records(cd9660node *);
|
||||
|
||||
static void cd9660_convert_structure(fsnode *, cd9660node *, int,
|
||||
int *, int *, fsinfo_t *);
|
||||
int *, int *);
|
||||
static void cd9660_free_structure(cd9660node *);
|
||||
static int cd9660_generate_path_table(void);
|
||||
static int cd9660_level1_convert_filename(const char *, char *, int);
|
||||
@ -490,7 +490,7 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
|
||||
real_root->type = CD9660_TYPE_DIR;
|
||||
error = 0;
|
||||
real_root->node = root;
|
||||
cd9660_convert_structure(root, real_root, 1, &numDirectories, &error, fsopts);
|
||||
cd9660_convert_structure(root, real_root, 1, &numDirectories, &error);
|
||||
|
||||
if (TAILQ_EMPTY(&real_root->cn_children)) {
|
||||
errx(1, "cd9660_makefs: converted directory is empty. "
|
||||
@ -1325,7 +1325,7 @@ cd9660_add_dot_records(cd9660node *root)
|
||||
*/
|
||||
static void
|
||||
cd9660_convert_structure(fsnode *root, cd9660node *parent_node, int level,
|
||||
int *numDirectories, int *error, fsinfo_t *fsopts)
|
||||
int *numDirectories, int *error)
|
||||
{
|
||||
fsnode *iterator = root;
|
||||
cd9660node *this_node;
|
||||
@ -1358,14 +1358,6 @@ cd9660_convert_structure(fsnode *root, cd9660node *parent_node, int level,
|
||||
* the next pointers to the right.
|
||||
*/
|
||||
while (iterator != NULL) {
|
||||
|
||||
if (FSNODE_EXCLUDE_P(fsopts, iterator)) {
|
||||
if (diskStructure.verbose_level > 0)
|
||||
printf("cd9660_makefs: excluding %s\n", iterator->name);
|
||||
iterator = iterator->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
add = 1;
|
||||
/*
|
||||
* Increment the directory count if this is a directory
|
||||
@ -1424,7 +1416,7 @@ cd9660_convert_structure(fsnode *root, cd9660node *parent_node, int level,
|
||||
cd9660_convert_structure(
|
||||
iterator->child, this_node,
|
||||
working_level,
|
||||
numDirectories, error, fsopts);
|
||||
numDirectories, error);
|
||||
|
||||
if ((*error) == 1) {
|
||||
warnx("%s: Error on recursive "
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ffs.c,v 1.39 2006/04/22 17:40:49 christos Exp $ */
|
||||
/* $NetBSD: ffs.c,v 1.40 2006/10/10 01:55:45 dbj Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||
@ -71,7 +71,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(__lint)
|
||||
__RCSID("$NetBSD: ffs.c,v 1.39 2006/04/22 17:40:49 christos Exp $");
|
||||
__RCSID("$NetBSD: ffs.c,v 1.40 2006/10/10 01:55:45 dbj Exp $");
|
||||
#endif /* !__lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -587,8 +587,6 @@ ffs_size_dir(fsnode *root, fsinfo_t *fsopts)
|
||||
curdirsize = 0;
|
||||
for (node = root; node != NULL; node = node->next) {
|
||||
ADDDIRENT(node->name);
|
||||
if (FSNODE_EXCLUDE_P(fsopts, node))
|
||||
continue;
|
||||
if (node == root) { /* we're at "." */
|
||||
assert(strcmp(node->name, ".") == 0);
|
||||
ADDDIRENT("..");
|
||||
@ -746,8 +744,6 @@ ffs_populate_dir(const char *dir, fsnode *root, fsinfo_t *fsopts)
|
||||
* pass 1: allocate inode numbers, build directory `file'
|
||||
*/
|
||||
for (cur = root; cur != NULL; cur = cur->next) {
|
||||
if (FSNODE_EXCLUDE_P(fsopts, cur))
|
||||
continue;
|
||||
if ((cur->inode->flags & FI_ALLOCATED) == 0) {
|
||||
cur->inode->flags |= FI_ALLOCATED;
|
||||
if (cur == root && cur->parent != NULL)
|
||||
@ -782,8 +778,6 @@ ffs_populate_dir(const char *dir, fsnode *root, fsinfo_t *fsopts)
|
||||
if (debug & DEBUG_FS_POPULATE)
|
||||
printf("ffs_populate_dir: PASS 2 dir %s\n", dir);
|
||||
for (cur = root; cur != NULL; cur = cur->next) {
|
||||
if (FSNODE_EXCLUDE_P(fsopts, cur))
|
||||
continue;
|
||||
if (cur->inode->flags & FI_WRITTEN)
|
||||
continue; /* skip hard-linked entries */
|
||||
cur->inode->flags |= FI_WRITTEN;
|
||||
@ -827,8 +821,6 @@ ffs_populate_dir(const char *dir, fsnode *root, fsinfo_t *fsopts)
|
||||
if (debug & DEBUG_FS_POPULATE)
|
||||
printf("ffs_populate_dir: PASS 3 dir %s\n", dir);
|
||||
for (cur = root; cur != NULL; cur = cur->next) {
|
||||
if (FSNODE_EXCLUDE_P(fsopts, cur))
|
||||
continue;
|
||||
if (cur->child == NULL)
|
||||
continue;
|
||||
if (snprintf(path, sizeof(path), "%s/%s", dir, cur->name)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: makefs.c,v 1.24 2006/10/10 01:46:49 dbj Exp $ */
|
||||
/* $NetBSD: makefs.c,v 1.25 2006/10/10 01:55:45 dbj Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Wasabi Systems, Inc.
|
||||
@ -41,7 +41,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(__lint)
|
||||
__RCSID("$NetBSD: makefs.c,v 1.24 2006/10/10 01:46:49 dbj Exp $");
|
||||
__RCSID("$NetBSD: makefs.c,v 1.25 2006/10/10 01:55:45 dbj Exp $");
|
||||
#endif /* !__lint */
|
||||
|
||||
#include <assert.h>
|
||||
@ -257,7 +257,7 @@ main(int argc, char *argv[])
|
||||
|
||||
if (specfile) { /* apply a specfile */
|
||||
TIMER_START(start);
|
||||
apply_specfile(specfile, argv[1], root);
|
||||
apply_specfile(specfile, argv[1], root, fsoptions.onlyspec);
|
||||
TIMER_RESULTS(start, "apply_specfile");
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: makefs.h,v 1.18 2006/10/10 01:46:49 dbj Exp $ */
|
||||
/* $NetBSD: makefs.h,v 1.19 2006/10/10 01:55:45 dbj Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||
@ -153,7 +153,7 @@ typedef struct {
|
||||
} option_t;
|
||||
|
||||
|
||||
void apply_specfile(const char *, const char *, fsnode *);
|
||||
void apply_specfile(const char *, const char *, fsnode *, int);
|
||||
void dump_fsnodes(const char *, fsnode *);
|
||||
const char * inode_type(mode_t);
|
||||
int set_option(option_t *, const char *, const char *);
|
||||
@ -207,6 +207,7 @@ extern struct timespec start_time;
|
||||
#define DEBUG_BUF_GETBLK 0x02000000
|
||||
#define DEBUG_APPLY_SPECFILE 0x04000000
|
||||
#define DEBUG_APPLY_SPECENTRY 0x08000000
|
||||
#define DEBUG_APPLY_SPECONLY 0x10000000
|
||||
|
||||
|
||||
#define TIMER_START(x) \
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: walk.c,v 1.22 2006/10/10 01:46:49 dbj Exp $ */
|
||||
/* $NetBSD: walk.c,v 1.23 2006/10/10 01:55:45 dbj Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||
@ -41,7 +41,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(__lint)
|
||||
__RCSID("$NetBSD: walk.c,v 1.22 2006/10/10 01:46:49 dbj Exp $");
|
||||
__RCSID("$NetBSD: walk.c,v 1.23 2006/10/10 01:55:45 dbj Exp $");
|
||||
#endif /* !__lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -59,7 +59,7 @@ __RCSID("$NetBSD: walk.c,v 1.22 2006/10/10 01:46:49 dbj Exp $");
|
||||
#include "makefs.h"
|
||||
#include "mtree.h"
|
||||
|
||||
static void apply_specdir(const char *, NODE *, fsnode *);
|
||||
static void apply_specdir(const char *, NODE *, fsnode *, int);
|
||||
static void apply_specentry(const char *, NODE *, fsnode *);
|
||||
static fsnode *create_fsnode(const char *, struct stat *);
|
||||
static fsinode *link_check(fsinode *);
|
||||
@ -228,7 +228,7 @@ free_fsnodes(fsnode *node)
|
||||
* entries will be added.
|
||||
*/
|
||||
void
|
||||
apply_specfile(const char *specfile, const char *dir, fsnode *parent)
|
||||
apply_specfile(const char *specfile, const char *dir, fsnode *parent, int speconly)
|
||||
{
|
||||
struct timeval start;
|
||||
FILE *fp;
|
||||
@ -256,13 +256,13 @@ apply_specfile(const char *specfile, const char *dir, fsnode *parent)
|
||||
assert(root->type == F_DIR);
|
||||
|
||||
/* merge in the changes */
|
||||
apply_specdir(dir, root, parent);
|
||||
apply_specdir(dir, root, parent, speconly);
|
||||
|
||||
free_nodes(root);
|
||||
}
|
||||
|
||||
static void
|
||||
apply_specdir(const char *dir, NODE *specnode, fsnode *dirnode)
|
||||
apply_specdir(const char *dir, NODE *specnode, fsnode *dirnode, int speconly)
|
||||
{
|
||||
char path[MAXPATHLEN + 1];
|
||||
NODE *curnode;
|
||||
@ -283,6 +283,30 @@ apply_specdir(const char *dir, NODE *specnode, fsnode *dirnode)
|
||||
|
||||
apply_specentry(dir, specnode, dirnode);
|
||||
|
||||
/* Remove any filesystem nodes not found in specfile */
|
||||
/* XXX inefficient. This is O^2 in each dir and it would
|
||||
* have been better never to have walked this part of the tree
|
||||
* to begin with
|
||||
*/
|
||||
if (speconly) {
|
||||
fsnode *next;
|
||||
assert(dirnode->name[0] == '.' && dirnode->name[1] == '\0');
|
||||
for (curfsnode = dirnode->next; curfsnode != NULL; curfsnode = next) {
|
||||
next = curfsnode->next;
|
||||
for (curnode = specnode->child; curnode != NULL;
|
||||
curnode = curnode->next) {
|
||||
if (strcmp(curnode->name, curfsnode->name) == 0)
|
||||
break;
|
||||
}
|
||||
if (curnode == NULL) {
|
||||
if (debug & DEBUG_APPLY_SPECONLY) {
|
||||
printf("apply_specdir: trimming %s/%s %p\n", dir, curfsnode->name, curfsnode);
|
||||
}
|
||||
free_fsnodes(curfsnode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* now walk specnode->child matching up with dirnode */
|
||||
for (curnode = specnode->child; curnode != NULL;
|
||||
curnode = curnode->next) {
|
||||
@ -366,7 +390,7 @@ apply_specdir(const char *dir, NODE *specnode, fsnode *dirnode)
|
||||
if (curfsnode->type != S_IFDIR)
|
||||
errx(1, "`%s' is not a directory", path);
|
||||
assert (curfsnode->child != NULL);
|
||||
apply_specdir(path, curnode, curfsnode->child);
|
||||
apply_specdir(path, curnode, curfsnode->child, speconly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user