Minor cleanup

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
David Oberhollenzer 2019-05-03 00:14:48 +02:00
parent ab753a402f
commit ba034260d4
2 changed files with 11 additions and 11 deletions

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: ISC */ /* SPDX-License-Identifier: ISC */
#include "pkg2sqfs.h" #include "pkg2sqfs.h"
static int write_block(node_t *node, sqfs_info_t *info, static int write_block(file_info_t *file, sqfs_info_t *info,
compressor_stream_t *strm) compressor_stream_t *strm)
{ {
size_t idx, bs; size_t idx, bs;
@ -18,10 +18,10 @@ static int write_block(node_t *node, sqfs_info_t *info,
if (ret > 0) { if (ret > 0) {
ptr = info->scratch; ptr = info->scratch;
bs = ret; bs = ret;
node->data.file->blocksizes[idx] = bs; file->blocksizes[idx] = bs;
} else { } else {
ptr = info->block; ptr = info->block;
node->data.file->blocksizes[idx] = bs | (1 << 24); file->blocksizes[idx] = bs | (1 << 24);
} }
ret = write_retry(info->outfd, ptr, bs); ret = write_retry(info->outfd, ptr, bs);
@ -150,7 +150,7 @@ static int process_file(node_t *node, sqfs_info_t *info,
if (add_fragment(node->data.file, info, diff, strm)) if (add_fragment(node->data.file, info, diff, strm))
return -1; return -1;
} else { } else {
if (write_block(node, info, strm)) if (write_block(node->data.file, info, strm))
return -1; return -1;
} }

View File

@ -18,17 +18,17 @@ static size_t hard_link_count(node_t *node)
return 1; return 1;
} }
static int write_dir(meta_writer_t *dm, node_t *node) static int write_dir(meta_writer_t *dm, dir_info_t *dir)
{ {
sqfs_dir_header_t hdr; sqfs_dir_header_t hdr;
sqfs_dir_entry_t ent; sqfs_dir_entry_t ent;
size_t i, count; size_t i, count;
node_t *c, *d; node_t *c, *d;
c = node->data.dir->children; c = dir->children;
node->data.dir->size = 0; dir->size = 0;
node->data.dir->dref = (dm->written << 16) | dm->offset; dir->dref = (dm->written << 16) | dm->offset;
while (c != NULL) { while (c != NULL) {
count = 0; count = 0;
@ -47,7 +47,7 @@ static int write_dir(meta_writer_t *dm, node_t *node)
hdr.count = htole32(count - 1); hdr.count = htole32(count - 1);
hdr.start_block = htole32(c->inode_ref >> 16); hdr.start_block = htole32(c->inode_ref >> 16);
hdr.inode_number = htole32(c->inode_num); hdr.inode_number = htole32(c->inode_num);
node->data.dir->size += sizeof(hdr); dir->size += sizeof(hdr);
if (meta_writer_append(dm, &hdr, sizeof(hdr))) if (meta_writer_append(dm, &hdr, sizeof(hdr)))
return -1; return -1;
@ -59,7 +59,7 @@ static int write_dir(meta_writer_t *dm, node_t *node)
ent.inode_number = htole16(c->inode_num - d->inode_num); ent.inode_number = htole16(c->inode_num - d->inode_num);
ent.type = htole16(c->type); ent.type = htole16(c->type);
ent.size = htole16(strlen(c->name) - 1); ent.size = htole16(strlen(c->name) - 1);
node->data.dir->size += sizeof(ent) + strlen(c->name); dir->size += sizeof(ent) + strlen(c->name);
if (meta_writer_append(dm, &ent, sizeof(ent))) if (meta_writer_append(dm, &ent, sizeof(ent)))
return -1; return -1;
@ -93,7 +93,7 @@ static int write_inode(sqfs_info_t *info, meta_writer_t *im, meta_writer_t *dm,
case S_IFBLK: node->type = SQFS_INODE_BDEV; break; case S_IFBLK: node->type = SQFS_INODE_BDEV; break;
case S_IFCHR: node->type = SQFS_INODE_CDEV; break; case S_IFCHR: node->type = SQFS_INODE_CDEV; break;
case S_IFDIR: case S_IFDIR:
if (write_dir(dm, node)) if (write_dir(dm, node->data.dir))
return -1; return -1;
node->type = SQFS_INODE_DIR; node->type = SQFS_INODE_DIR;