aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfs')
-rw-r--r--lib/sqfs/src/dir_reader.c9
-rw-r--r--lib/sqfs/src/readdir.c42
2 files changed, 23 insertions, 28 deletions
diff --git a/lib/sqfs/src/dir_reader.c b/lib/sqfs/src/dir_reader.c
index 2b6d0e8..fdb5976 100644
--- a/lib/sqfs/src/dir_reader.c
+++ b/lib/sqfs/src/dir_reader.c
@@ -210,11 +210,11 @@ int sqfs_dir_reader_open_dir(sqfs_dir_reader_t *rd,
parent = inode->data.dir.parent_inode;
}
- if (dcache_find(rd, inode->base.inode_number, &state->cur_ref))
+ if (dcache_find(rd, inode->base.inode_number, &state->dir_ref))
return SQFS_ERROR_NO_ENTRY;
- if (state->cur_ref == rd->super.root_inode_ref) {
- state->parent_ref = state->cur_ref;
+ if (state->dir_ref == rd->super.root_inode_ref) {
+ state->parent_ref = state->dir_ref;
} else if (dcache_find(rd, parent, &state->parent_ref)) {
return SQFS_ERROR_NO_ENTRY;
}
@@ -224,7 +224,6 @@ int sqfs_dir_reader_open_dir(sqfs_dir_reader_t *rd,
state->state = DIR_STATE_ENTRIES;
}
- state->start_state = state->state;
return 0;
}
@@ -256,7 +255,7 @@ int sqfs_dir_reader_read(sqfs_dir_reader_t *rd, sqfs_dir_reader_state_t *state,
err = mk_dummy_entry(".", out);
if (err == 0) {
state->state = DIR_STATE_DOT;
- state->ent_ref = state->cur_ref;
+ state->ent_ref = state->dir_ref;
}
return err;
case DIR_STATE_DOT:
diff --git a/lib/sqfs/src/readdir.c b/lib/sqfs/src/readdir.c
index 9feaf22..1e5dd0f 100644
--- a/lib/sqfs/src/readdir.c
+++ b/lib/sqfs/src/readdir.c
@@ -73,19 +73,18 @@ int sqfs_readdir_state_init(sqfs_readdir_state_t *s, const sqfs_super_t *super,
memset(s, 0, sizeof(*s));
if (inode->base.type == SQFS_INODE_DIR) {
- s->init.block = inode->data.dir.start_block;
- s->init.offset = inode->data.dir.offset;
- s->init.size = inode->data.dir.size;
+ s->block = inode->data.dir.start_block;
+ s->offset = inode->data.dir.offset;
+ s->size = inode->data.dir.size;
} else if (inode->base.type == SQFS_INODE_EXT_DIR) {
- s->init.block = inode->data.dir_ext.start_block;
- s->init.offset = inode->data.dir_ext.offset;
- s->init.size = inode->data.dir_ext.size;
+ s->block = inode->data.dir_ext.start_block;
+ s->offset = inode->data.dir_ext.offset;
+ s->size = inode->data.dir_ext.size;
} else {
return SQFS_ERROR_NOT_DIR;
}
- s->init.block += super->directory_table_start;
- s->current = s->init;
+ s->block += super->directory_table_start;
return 0;
}
@@ -99,11 +98,10 @@ int sqfs_meta_reader_readdir(sqfs_meta_reader_t *m, sqfs_readdir_state_t *it,
if (it->entries == 0) {
sqfs_dir_header_t hdr;
- if (it->current.size <= sizeof(hdr))
+ if (it->size <= sizeof(hdr))
goto out_eof;
- ret = sqfs_meta_reader_seek(m, it->current.block,
- it->current.offset);
+ ret = sqfs_meta_reader_seek(m, it->block, it->offset);
if (ret != 0)
return ret;
@@ -111,19 +109,18 @@ int sqfs_meta_reader_readdir(sqfs_meta_reader_t *m, sqfs_readdir_state_t *it,
if (ret != 0)
return ret;
- sqfs_meta_reader_get_position(m, &it->current.block,
- &it->current.offset);
+ sqfs_meta_reader_get_position(m, &it->block, &it->offset);
- it->current.size -= sizeof(hdr);
+ it->size -= sizeof(hdr);
it->entries = hdr.count + 1;
it->inum_base = hdr.inode_number;
it->inode_block = hdr.start_block;
}
- if (it->current.size <= sizeof(**ent))
+ if (it->size <= sizeof(**ent))
goto out_eof;
- ret = sqfs_meta_reader_seek(m, it->current.block, it->current.offset);
+ ret = sqfs_meta_reader_seek(m, it->block, it->offset);
if (ret != 0)
return ret;
@@ -131,18 +128,17 @@ int sqfs_meta_reader_readdir(sqfs_meta_reader_t *m, sqfs_readdir_state_t *it,
if (ret)
return ret;
- sqfs_meta_reader_get_position(m, &it->current.block,
- &it->current.offset);
+ sqfs_meta_reader_get_position(m, &it->block, &it->offset);
- it->current.size -= sizeof(**ent);
+ it->size -= sizeof(**ent);
it->entries -= 1;
count = (*ent)->size + 1;
- if (count >= it->current.size) {
- it->current.size = 0;
+ if (count >= it->size) {
+ it->size = 0;
} else {
- it->current.size -= count;
+ it->size -= count;
}
if (inum != NULL)
@@ -155,7 +151,7 @@ int sqfs_meta_reader_readdir(sqfs_meta_reader_t *m, sqfs_readdir_state_t *it,
return 0;
out_eof:
- it->current.size = 0;
+ it->size = 0;
it->entries = 0;
return 1;
}