diff --git a/libsqsh/include/sqsh_file_private.h b/libsqsh/include/sqsh_file_private.h index 88efc157..3c68a1f2 100644 --- a/libsqsh/include/sqsh_file_private.h +++ b/libsqsh/include/sqsh_file_private.h @@ -230,6 +230,7 @@ struct SqshInodeImpl { uint32_t (*directory_parent_inode)(const struct SqshDataInode *inode); const char *(*symlink_target_path)(const struct SqshDataInode *inode); + uint32_t (*symlink_target_size)(const struct SqshDataInode *inode); uint32_t (*device_id)(const struct SqshDataInode *inode); diff --git a/libsqsh/src/file/file.c b/libsqsh/src/file/file.c index 0a202653..1a6078d5 100644 --- a/libsqsh/src/file/file.c +++ b/libsqsh/src/file/file.c @@ -330,7 +330,7 @@ sqsh_file_symlink_dup(const struct SqshFile *inode) { uint32_t sqsh_file_symlink_size(const struct SqshFile *context) { - return (uint32_t)sqsh_file_size(context); + return context->impl->symlink_target_size(get_inode(context)); } uint32_t diff --git a/libsqsh/src/file/inode_device.c b/libsqsh/src/file/inode_device.c index 75b926e7..883e460f 100644 --- a/libsqsh/src/file/inode_device.c +++ b/libsqsh/src/file/inode_device.c @@ -103,6 +103,7 @@ const struct SqshInodeImpl sqsh__inode_device_impl = { .directory_parent_inode = sqsh__file_inode_null_directory_parent_inode, .symlink_target_path = sqsh__file_inode_null_symlink_target_path, + .symlink_target_size = sqsh__file_inode_null_symlink_target_size, .device_id = inode_device_id, @@ -126,6 +127,7 @@ const struct SqshInodeImpl sqsh__inode_device_ext_impl = { .directory_parent_inode = sqsh__file_inode_null_directory_parent_inode, .symlink_target_path = sqsh__file_inode_null_symlink_target_path, + .symlink_target_size = sqsh__file_inode_null_symlink_target_size, .device_id = inode_device_ext_id, diff --git a/libsqsh/src/file/inode_directory.c b/libsqsh/src/file/inode_directory.c index 14202ddc..a098404f 100644 --- a/libsqsh/src/file/inode_directory.c +++ b/libsqsh/src/file/inode_directory.c @@ -141,6 +141,7 @@ const struct SqshInodeImpl sqsh__inode_directory_impl = { .directory_parent_inode = inode_directory_parent_inode, .symlink_target_path = sqsh__file_inode_null_symlink_target_path, + .symlink_target_size = sqsh__file_inode_null_symlink_target_size, .device_id = sqsh__file_inode_null_device_id, @@ -164,6 +165,7 @@ const struct SqshInodeImpl sqsh__inode_directory_ext_impl = { .directory_parent_inode = inode_directory_ext_parent_inode, .symlink_target_path = sqsh__file_inode_null_symlink_target_path, + .symlink_target_size = sqsh__file_inode_null_symlink_target_size, .device_id = sqsh__file_inode_null_device_id, diff --git a/libsqsh/src/file/inode_file.c b/libsqsh/src/file/inode_file.c index 283003c2..6ea6459f 100644 --- a/libsqsh/src/file/inode_file.c +++ b/libsqsh/src/file/inode_file.c @@ -175,6 +175,7 @@ const struct SqshInodeImpl sqsh__inode_file_impl = { .directory_parent_inode = sqsh__file_inode_null_directory_parent_inode, .symlink_target_path = sqsh__file_inode_null_symlink_target_path, + .symlink_target_size = sqsh__file_inode_null_symlink_target_size, .device_id = sqsh__file_inode_null_device_id, @@ -198,6 +199,7 @@ const struct SqshInodeImpl sqsh__inode_file_ext_impl = { .directory_parent_inode = sqsh__file_inode_null_directory_parent_inode, .symlink_target_path = sqsh__file_inode_null_symlink_target_path, + .symlink_target_size = sqsh__file_inode_null_symlink_target_size, .device_id = sqsh__file_inode_null_device_id, diff --git a/libsqsh/src/file/inode_ipc.c b/libsqsh/src/file/inode_ipc.c index 1f7ffecc..88188b46 100644 --- a/libsqsh/src/file/inode_ipc.c +++ b/libsqsh/src/file/inode_ipc.c @@ -89,6 +89,7 @@ const struct SqshInodeImpl sqsh__inode_ipc_impl = { .directory_parent_inode = sqsh__file_inode_null_directory_parent_inode, .symlink_target_path = sqsh__file_inode_null_symlink_target_path, + .symlink_target_size = sqsh__file_inode_null_symlink_target_size, .device_id = sqsh__file_inode_null_device_id, @@ -112,6 +113,7 @@ const struct SqshInodeImpl sqsh__inode_ipc_ext_impl = { .directory_parent_inode = sqsh__file_inode_null_directory_parent_inode, .symlink_target_path = sqsh__file_inode_null_symlink_target_path, + .symlink_target_size = sqsh__file_inode_null_symlink_target_size, .device_id = sqsh__file_inode_null_device_id, diff --git a/libsqsh/src/file/inode_null.c b/libsqsh/src/file/inode_null.c index 1c7defab..30c1dbf3 100644 --- a/libsqsh/src/file/inode_null.c +++ b/libsqsh/src/file/inode_null.c @@ -94,6 +94,12 @@ sqsh__file_inode_null_symlink_target_path(const struct SqshDataInode *inode) { return NULL; } +uint32_t +sqsh__file_inode_null_symlink_target_size(const struct SqshDataInode *inode) { + (void)inode; + return 0; +} + uint32_t sqsh__file_inode_null_device_id(const struct SqshDataInode *inode) { (void)inode; diff --git a/libsqsh/src/file/inode_symlink.c b/libsqsh/src/file/inode_symlink.c index 57176ac0..de8b644b 100644 --- a/libsqsh/src/file/inode_symlink.c +++ b/libsqsh/src/file/inode_symlink.c @@ -43,22 +43,23 @@ #include #include -static uint64_t inode_symlink_size(const struct SqshDataInode *inode); -static uint64_t inode_symlink_ext_size(const struct SqshDataInode *inode); +static uint32_t inode_symlink_target_size(const struct SqshDataInode *inode); +static uint32_t +inode_symlink_ext_target_size(const struct SqshDataInode *inode); /* payload_size */ static size_t inode_symlink_payload_size( const struct SqshDataInode *inode, const struct SqshArchive *archive) { (void)archive; - return inode_symlink_size(inode); + return inode_symlink_target_size(inode); } static size_t inode_symlink_ext_payload_size( const struct SqshDataInode *inode, const struct SqshArchive *archive) { (void)archive; - return inode_symlink_ext_size(inode); + return inode_symlink_ext_target_size(inode); } /* hard_link_count */ @@ -77,14 +78,12 @@ inode_symlink_ext_hard_link_count(const struct SqshDataInode *inode) { /* size */ static uint64_t inode_symlink_size(const struct SqshDataInode *inode) { - return sqsh__data_inode_symlink_target_size( - sqsh__data_inode_symlink(inode)); + return inode_symlink_target_size(inode); } static uint64_t inode_symlink_ext_size(const struct SqshDataInode *inode) { - return sqsh__data_inode_symlink_ext_target_size( - sqsh__data_inode_symlink_ext(inode)); + return inode_symlink_ext_target_size(inode); } static const char * @@ -93,6 +92,18 @@ inode_symlink_target_path(const struct SqshDataInode *inode) { sqsh__data_inode_symlink_ext(inode)); } +static uint32_t +inode_symlink_ext_target_size(const struct SqshDataInode *inode) { + return sqsh__data_inode_symlink_ext_target_size( + sqsh__data_inode_symlink_ext(inode)); +} + +static uint32_t +inode_symlink_target_size(const struct SqshDataInode *inode) { + return sqsh__data_inode_symlink_target_size( + sqsh__data_inode_symlink(inode)); +} + static const char * inode_symlink_ext_target_path(const struct SqshDataInode *inode) { return (const char *)sqsh__data_inode_symlink_ext_target_path( @@ -122,6 +133,7 @@ const struct SqshInodeImpl sqsh__inode_symlink_impl = { .directory_parent_inode = sqsh__file_inode_null_directory_parent_inode, .symlink_target_path = inode_symlink_target_path, + .symlink_target_size = inode_symlink_target_size, .device_id = sqsh__file_inode_null_device_id, @@ -145,6 +157,7 @@ const struct SqshInodeImpl sqsh__inode_symlink_ext_impl = { .directory_parent_inode = sqsh__file_inode_null_directory_parent_inode, .symlink_target_path = inode_symlink_ext_target_path, + .symlink_target_size = inode_symlink_ext_target_size, .device_id = sqsh__file_inode_null_device_id,