aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-03 15:21:35 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-03 15:24:08 +0200
commit5e7ce8c83dd1ded633b2a1bbeea37cbb53f743f0 (patch)
tree8dcd7d96a01b9d8a49b3d977de3ffe03cb9e026f /lib/sqfs
parent1ac7243a2164796f915e0c28853a21f3927ce865 (diff)
Add a counter-part to sqfs_inode_get_xattr_index
Combines all the type depenend attribute setting and inode type promotion into a single function. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs')
-rw-r--r--lib/sqfs/inode.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/sqfs/inode.c b/lib/sqfs/inode.c
index 334ffd8..4a75e64 100644
--- a/lib/sqfs/inode.c
+++ b/lib/sqfs/inode.c
@@ -64,6 +64,55 @@ int sqfs_inode_get_xattr_index(const sqfs_inode_generic_t *inode,
return 0;
}
+int sqfs_inode_set_xattr_index(sqfs_inode_generic_t *inode, sqfs_u32 index)
+{
+ int err;
+
+ if (index != 0xFFFFFFFF) {
+ err = sqfs_inode_make_extended(inode);
+ if (err)
+ return err;
+ }
+
+ switch (inode->base.type) {
+ case SQFS_INODE_DIR:
+ case SQFS_INODE_FILE:
+ case SQFS_INODE_SLINK:
+ case SQFS_INODE_BDEV:
+ case SQFS_INODE_CDEV:
+ case SQFS_INODE_FIFO:
+ case SQFS_INODE_SOCKET:
+ break;
+ case SQFS_INODE_EXT_DIR:
+ inode->data.dir_ext.xattr_idx = index;
+ break;
+ case SQFS_INODE_EXT_FILE:
+ inode->data.file_ext.xattr_idx = index;
+ break;
+ case SQFS_INODE_EXT_SLINK:
+ inode->data.slink_ext.xattr_idx = index;
+ break;
+ case SQFS_INODE_EXT_BDEV:
+ case SQFS_INODE_EXT_CDEV:
+ inode->data.dev_ext.xattr_idx = index;
+ break;
+ case SQFS_INODE_EXT_FIFO:
+ case SQFS_INODE_EXT_SOCKET:
+ inode->data.ipc_ext.xattr_idx = index;
+ break;
+ default:
+ return SQFS_ERROR_CORRUPTED;
+ }
+
+ if (index == 0xFFFFFFFF) {
+ err = sqfs_inode_make_basic(inode);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
int sqfs_inode_make_extended(sqfs_inode_generic_t *inode)
{
switch (inode->base.type) {