summaryrefslogtreecommitdiff
path: root/lib/sqfshelper/serialize_fstree.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-03 17:03:25 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-03 17:03:25 +0200
commit3c0f5ca9757b80b2065e429091e3021f3d2f87d5 (patch)
tree06379bffccf9c448703dc1b5ace797b35ea7f63f /lib/sqfshelper/serialize_fstree.c
parenta7a14d776496fac631f05ccaf25ea0c9e764cde9 (diff)
Cleanup: simplify tree_node_to_inode
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfshelper/serialize_fstree.c')
-rw-r--r--lib/sqfshelper/serialize_fstree.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/lib/sqfshelper/serialize_fstree.c b/lib/sqfshelper/serialize_fstree.c
index 7a03dc9..9efcb04 100644
--- a/lib/sqfshelper/serialize_fstree.c
+++ b/lib/sqfshelper/serialize_fstree.c
@@ -19,18 +19,6 @@
#include <string.h>
#include <stdio.h>
-static int get_type(tree_node_t *node)
-{
- switch (node->mode & S_IFMT) {
- case S_IFSOCK: return SQFS_INODE_SOCKET;
- case S_IFIFO: return SQFS_INODE_FIFO;
- case S_IFLNK: return SQFS_INODE_SLINK;
- case S_IFBLK: return SQFS_INODE_BDEV;
- case S_IFCHR: return SQFS_INODE_CDEV;
- }
- assert(0);
-}
-
static sqfs_inode_generic_t *tree_node_to_inode(tree_node_t *node)
{
sqfs_inode_generic_t *inode;
@@ -45,27 +33,34 @@ static sqfs_inode_generic_t *tree_node_to_inode(tree_node_t *node)
return NULL;
}
- if (S_ISLNK(node->mode)) {
- inode->slink_target = (char *)inode->extra;
- memcpy(inode->extra, node->data.slink_target, extra);
- }
-
- inode->base.type = get_type(node);
-
- switch (inode->base.type) {
- case SQFS_INODE_FIFO:
- case SQFS_INODE_SOCKET:
+ switch (node->mode & S_IFMT) {
+ case S_IFSOCK:
+ inode->base.type = SQFS_INODE_SOCKET;
inode->data.ipc.nlink = 1;
break;
- case SQFS_INODE_SLINK:
+ case S_IFIFO:
+ inode->base.type = SQFS_INODE_FIFO;
+ inode->data.ipc.nlink = 1;
+ break;
+ case S_IFLNK:
+ inode->base.type = SQFS_INODE_SLINK;
inode->data.slink.nlink = 1;
inode->data.slink.target_size = extra;
+ inode->slink_target = (char *)inode->extra;
+ memcpy(inode->extra, node->data.slink_target, extra);
+ break;
+ case S_IFBLK:
+ inode->base.type = SQFS_INODE_BDEV;
+ inode->data.dev.nlink = 1;
+ inode->data.dev.devno = node->data.devno;
break;
- case SQFS_INODE_BDEV:
- case SQFS_INODE_CDEV:
+ case S_IFCHR:
+ inode->base.type = SQFS_INODE_CDEV;
inode->data.dev.nlink = 1;
inode->data.dev.devno = node->data.devno;
break;
+ default:
+ assert(0);
}
return inode;