summaryrefslogtreecommitdiff
path: root/lib/sqfs/id_table_read.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-25 14:16:10 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-25 14:20:48 +0200
commitf8346498604f417415c131e3c6dbf66e6643254e (patch)
tree8f9de79c9d4d59bfa9481a632064afde5afa2d39 /lib/sqfs/id_table_read.c
parentdb9187c8d21e9f08b20899e3e14c1938db7b79fb (diff)
Replace reads in squashfs with positional reads
In most cases, we know exactely where the data that we want to read is on disk, so instead of using read() on the squashfs (or lseek + read), the code can in many places be cleaned up to use the pread wrapper read_data_at instead. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/id_table_read.c')
-rw-r--r--lib/sqfs/id_table_read.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/sqfs/id_table_read.c b/lib/sqfs/id_table_read.c
index 7147f2e..1e92f75 100644
--- a/lib/sqfs/id_table_read.c
+++ b/lib/sqfs/id_table_read.c
@@ -38,15 +38,12 @@ int id_table_read(id_table_t *tbl, int fd, sqfs_super_t *super,
tbl->num_ids = super->id_count;
tbl->max_ids = super->id_count;
- if (lseek(fd, super->id_table_start, SEEK_SET) == (off_t)-1)
- goto fail_seek;
-
block_count = super->id_count / 2048;
if (super->id_count % 2048)
++block_count;
- if (read_data("reading ID table", fd, blocks,
- sizeof(blocks[0]) * block_count)) {
+ if (read_data_at("reading ID table", super->id_table_start, fd,
+ blocks, sizeof(blocks[0]) * block_count)) {
return -1;
}
@@ -82,7 +79,4 @@ int id_table_read(id_table_t *tbl, int fd, sqfs_super_t *super,
fail_meta:
meta_reader_destroy(m);
return -1;
-fail_seek:
- perror("seeking to ID table");
- return -1;
}