aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhillip Lougher <phillip@squashfs.org.uk>2014-08-08 02:55:33 +0100
committerPhillip Lougher <phillip@squashfs.org.uk>2014-08-08 02:55:33 +0100
commitc000873f337772cfdb8a844144d940c09c019c3e (patch)
tree5df3ea2dced72cc7f16cec43f9b3ff6c0b88cd12
parent401c5785a8a7c0e5dddcb8ac31ae15304c3edf33 (diff)
downloadsquashfs-tools-c000873f337772cfdb8a844144d940c09c019c3e.tar.gz
mksquashfs/actions: make the root of the in-core directory structure available
to various action test operations. Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
-rw-r--r--squashfs-tools/action.c13
-rw-r--r--squashfs-tools/action.h9
-rw-r--r--squashfs-tools/mksquashfs.c49
3 files changed, 40 insertions, 31 deletions
diff --git a/squashfs-tools/action.c b/squashfs-tools/action.c
index d776179..ed1601e 100644
--- a/squashfs-tools/action.c
+++ b/squashfs-tools/action.c
@@ -668,7 +668,7 @@ int actions()
}
-void eval_actions(struct dir_ent *dir_ent)
+void eval_actions(struct dir_info *root, struct dir_ent *dir_ent)
{
int i, match;
struct action_data action_data;
@@ -680,6 +680,7 @@ void eval_actions(struct dir_ent *dir_ent)
action_data.buf = &dir_ent->inode->buf;
action_data.depth = dir_ent->our_dir->depth;
action_data.dir_ent = dir_ent;
+ action_data.root = root;
for (i = 0; i < other_count; i++) {
struct action *action = &other_spec[i];
@@ -699,7 +700,7 @@ void eval_actions(struct dir_ent *dir_ent)
/*
* Fragment specific action code
*/
-void *eval_frag_actions(struct dir_ent *dir_ent)
+void *eval_frag_actions(struct dir_info *root, struct dir_ent *dir_ent)
{
int i, match;
struct action_data action_data;
@@ -710,6 +711,7 @@ void *eval_frag_actions(struct dir_ent *dir_ent)
action_data.buf = &dir_ent->inode->buf;
action_data.depth = dir_ent->our_dir->depth;
action_data.dir_ent = dir_ent;
+ action_data.root = root;
for (i = 0; i < fragment_count; i++) {
match = eval_expr(fragment_spec[i].expr, &action_data);
@@ -1265,7 +1267,7 @@ static int parse_empty_args(struct action_entry *action, int args,
}
-int eval_empty_actions(struct dir_ent *dir_ent)
+int eval_empty_actions(struct dir_info *root, struct dir_ent *dir_ent)
{
int i, match = 0;
struct action_data action_data;
@@ -1284,6 +1286,7 @@ int eval_empty_actions(struct dir_ent *dir_ent)
action_data.buf = &dir_ent->inode->buf;
action_data.depth = dir_ent->our_dir->depth;
action_data.dir_ent = dir_ent;
+ action_data.root = root;
for (i = 0; i < empty_count && !match; i++) {
data = empty_spec[i].data;
@@ -1524,6 +1527,7 @@ void eval_move_actions(struct dir_info *root, struct dir_ent *dir_ent)
action_data.buf = &dir_ent->inode->buf;
action_data.depth = dir_ent->our_dir->depth;
action_data.dir_ent = dir_ent;
+ action_data.root = root;
/*
* Evaluate each move action against the current file. For any
@@ -1732,7 +1736,7 @@ int prune_actions()
}
-int eval_prune_actions(struct dir_ent *dir_ent)
+int eval_prune_actions(struct dir_info *root, struct dir_ent *dir_ent)
{
int i, match = 0;
struct action_data action_data;
@@ -1743,6 +1747,7 @@ int eval_prune_actions(struct dir_ent *dir_ent)
action_data.buf = &dir_ent->inode->buf;
action_data.depth = dir_ent->our_dir->depth;
action_data.dir_ent = dir_ent;
+ action_data.root = root;
for (i = 0; i < prune_count && !match; i++)
match = eval_expr(prune_spec[i].expr, &action_data);
diff --git a/squashfs-tools/action.h b/squashfs-tools/action.h
index 835ce91..6b9e4dd 100644
--- a/squashfs-tools/action.h
+++ b/squashfs-tools/action.h
@@ -201,6 +201,7 @@ struct action_data {
char *subpath;
struct stat *buf;
struct dir_ent *dir_ent;
+ struct dir_info *root;
};
@@ -280,14 +281,14 @@ struct move_ent {
*/
extern int parse_action(char *);
extern void dump_actions();
-extern void *eval_frag_actions(struct dir_ent *);
+extern void *eval_frag_actions(struct dir_info *, struct dir_ent *);
extern void *get_frag_action(void *);
extern int eval_exclude_actions(char *, char *, char *, struct stat *, int,
struct dir_ent *);
-extern void eval_actions(struct dir_ent *);
-extern int eval_empty_actions(struct dir_ent *dir_ent);
+extern void eval_actions(struct dir_info *, struct dir_ent *);
+extern int eval_empty_actions(struct dir_info *, struct dir_ent *dir_ent);
extern void eval_move_actions(struct dir_info *, struct dir_ent *);
-extern int eval_prune_actions(struct dir_ent *);
+extern int eval_prune_actions(struct dir_info *, struct dir_ent *);
extern void do_move_actions();
extern int read_bytes(int, void *, int);
extern int actions();
diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
index 321726f..c6aa05f 100644
--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -281,6 +281,9 @@ unsigned int xattr_bytes = 0, total_xattr_bytes = 0;
int append_fragments = 0;
struct append_file **file_mapping;
+/* root of the in-core directory structure */
+struct dir_info *root_dir;
+
static char *read_from_disk(long long start, unsigned int avail_bytes);
void add_old_root_entry(char *name, squashfs_inode inode, int inode_number,
int type);
@@ -291,7 +294,7 @@ struct file_info *duplicate(long long file_size, long long bytes,
struct dir_info *dir_scan1(char *, char *, struct pathnames *,
struct dir_ent *(_readdir)(struct dir_info *), int);
void dir_scan2(struct dir_info *dir, struct pseudo *pseudo);
-void dir_scan3(struct dir_info *root, struct dir_info *dir);
+void dir_scan3(struct dir_info *dir);
void dir_scan4(struct dir_info *dir);
void dir_scan5(struct dir_info *dir);
void dir_scan6(struct dir_info *dir);
@@ -1566,7 +1569,7 @@ struct fragment *get_and_fill_fragment(struct file_buffer *file_buffer,
if(file_buffer == NULL || file_buffer->size == 0)
return &empty_fragment;
- fragment = eval_frag_actions(dir_ent);
+ fragment = eval_frag_actions(root_dir, dir_ent);
if((*fragment) && (*fragment)->size + file_buffer->size > block_size) {
write_fragment(*fragment);
@@ -3087,10 +3090,10 @@ void dir_scan(squashfs_inode *inode, char *pathname,
struct dir_ent *(_readdir)(struct dir_info *), int progress)
{
struct stat buf;
- struct dir_info *dir_info = dir_scan1(pathname, "", paths, _readdir, 1);
struct dir_ent *dir_ent;
- if(dir_info == NULL)
+ root_dir = dir_scan1(pathname, "", paths, _readdir, 1);
+ if(root_dir == NULL)
return;
/* Create root directory dir_ent and associated inode, and connect
@@ -3119,20 +3122,20 @@ void dir_scan(squashfs_inode *inode, char *pathname,
dir_ent->inode = lookup_inode(&buf);
}
- dir_ent->dir = dir_info;
- dir_info->dir_ent = dir_ent;
+ dir_ent->dir = root_dir;
+ root_dir->dir_ent = dir_ent;
/*
* Process most actions and any pseudo files
*/
if(actions() || get_pseudo())
- dir_scan2(dir_info, get_pseudo());
+ dir_scan2(root_dir, get_pseudo());
/*
* Process move actions
*/
if(move_actions()) {
- dir_scan3(dir_info, dir_info);
+ dir_scan3(root_dir);
do_move_actions();
}
@@ -3140,26 +3143,26 @@ void dir_scan(squashfs_inode *inode, char *pathname,
* Process prune actions
*/
if(prune_actions())
- dir_scan4(dir_info);
+ dir_scan4(root_dir);
/*
* Process empty actions
*/
if(empty_actions())
- dir_scan5(dir_info);
+ dir_scan5(root_dir);
/*
* Sort directories and compute the inode numbers
*/
- dir_scan6(dir_info);
+ dir_scan6(root_dir);
alloc_inode_no(dir_ent->inode, root_inode_number);
- eval_actions(dir_ent);
+ eval_actions(root_dir, dir_ent);
if(sorted)
- generate_file_priorities(dir_info, 0,
- &dir_info->dir_ent->inode->buf);
+ generate_file_priorities(root_dir, 0,
+ &root_dir->dir_ent->inode->buf);
if(appending) {
sigset_t sigmask;
@@ -3174,13 +3177,13 @@ void dir_scan(squashfs_inode *inode, char *pathname,
write_destination(fd, SQUASHFS_START, 4, "\0\0\0\0");
}
- queue_put(to_reader, dir_info);
+ queue_put(to_reader, root_dir);
if(sorted)
- sort_files_and_write(dir_info);
+ sort_files_and_write(root_dir);
set_progressbar_state(progress);
- dir_scan7(inode, dir_info);
+ dir_scan7(inode, root_dir);
dir_ent->inode->inode = *inode;
dir_ent->inode->type = SQUASHFS_DIR_TYPE;
}
@@ -3492,7 +3495,7 @@ void dir_scan2(struct dir_info *dir, struct pseudo *pseudo)
struct stat *buf = &inode_info->buf;
char *name = dir_ent->name;
- eval_actions(dir_ent);
+ eval_actions(root_dir, dir_ent);
if((buf->st_mode & S_IFMT) == S_IFDIR)
dir_scan2(dir_ent->dir, pseudo_subdir(name, pseudo));
@@ -3589,16 +3592,16 @@ void dir_scan2(struct dir_info *dir, struct pseudo *pseudo)
* dir_scan3 routines...
* This processes the move action
*/
-void dir_scan3(struct dir_info *root, struct dir_info *dir)
+void dir_scan3(struct dir_info *dir)
{
struct dir_ent *dir_ent = NULL;
while((dir_ent = scan2_readdir(dir, dir_ent)) != NULL) {
- eval_move_actions(root, dir_ent);
+ eval_move_actions(root_dir, dir_ent);
if((dir_ent->inode->buf.st_mode & S_IFMT) == S_IFDIR)
- dir_scan3(root, dir_ent->dir);
+ dir_scan3(dir_ent->dir);
}
}
@@ -3645,7 +3648,7 @@ void dir_scan4(struct dir_info *dir)
if((dir_ent->inode->buf.st_mode & S_IFMT) == S_IFDIR)
dir_scan4(dir_ent->dir);
- if(eval_prune_actions(dir_ent)) {
+ if(eval_prune_actions(root_dir, dir_ent)) {
struct dir_ent *tmp = dir_ent;
if((dir_ent->inode->buf.st_mode & S_IFMT) == S_IFDIR) {
@@ -3695,7 +3698,7 @@ void dir_scan5(struct dir_info *dir)
if((dir_ent->inode->buf.st_mode & S_IFMT) == S_IFDIR) {
dir_scan5(dir_ent->dir);
- if(eval_empty_actions(dir_ent)) {
+ if(eval_empty_actions(root_dir, dir_ent)) {
struct dir_ent *tmp = dir_ent;
/*