aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-07-02 21:14:45 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-07-08 19:17:35 +0200
commit8c0aa2504199036eaaa09673ea93dcdcd79606ef (patch)
treea27807d97cb7c390cbba15c063b07650803de620 /bin
parent10ab81a0de97513d82d05945c12bff87b02ede27 (diff)
Cleanup: move inode_stat to sqfs2tar
After trying removing many instances of `struct stat`, there is only one user of inode_stat left, so move the function there. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin')
-rw-r--r--bin/sqfs2tar/write_tree.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/bin/sqfs2tar/write_tree.c b/bin/sqfs2tar/write_tree.c
index e460481..5fa08e8 100644
--- a/bin/sqfs2tar/write_tree.c
+++ b/bin/sqfs2tar/write_tree.c
@@ -24,6 +24,47 @@ static sqfs_hard_link_t *find_hard_link(const char *name, sqfs_u32 inum)
return lnk;
}
+static void inode_stat(const sqfs_tree_node_t *node, struct stat *sb)
+{
+ memset(sb, 0, sizeof(*sb));
+
+ sb->st_mode = node->inode->base.mode;
+ sb->st_uid = node->uid;
+ sb->st_gid = node->gid;
+ sb->st_mtime = node->inode->base.mod_time;
+
+ switch (node->inode->base.type) {
+ case SQFS_INODE_BDEV:
+ case SQFS_INODE_CDEV:
+ sb->st_rdev = node->inode->data.dev.devno;
+ break;
+ case SQFS_INODE_EXT_BDEV:
+ case SQFS_INODE_EXT_CDEV:
+ sb->st_rdev = node->inode->data.dev_ext.devno;
+ break;
+ case SQFS_INODE_SLINK:
+ sb->st_size = node->inode->data.slink.target_size;
+ break;
+ case SQFS_INODE_EXT_SLINK:
+ sb->st_size = node->inode->data.slink_ext.target_size;
+ break;
+ case SQFS_INODE_FILE:
+ sb->st_size = node->inode->data.file.file_size;
+ break;
+ case SQFS_INODE_EXT_FILE:
+ sb->st_size = node->inode->data.file_ext.file_size;
+ break;
+ case SQFS_INODE_DIR:
+ sb->st_size = node->inode->data.dir.size;
+ break;
+ case SQFS_INODE_EXT_DIR:
+ sb->st_size = node->inode->data.dir_ext.size;
+ break;
+ default:
+ break;
+ }
+}
+
static int write_tree_dfs(const sqfs_tree_node_t *n)
{
sqfs_hard_link_t *lnk = NULL;