From 5e7ce8c83dd1ded633b2a1bbeea37cbb53f743f0 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 3 Oct 2019 15:21:35 +0200 Subject: 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 --- lib/sqfs/inode.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'lib/sqfs') 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) { -- cgit v1.2.3