Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file: use own getter for the symlink size #183

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libsqsh/include/sqsh_file_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion libsqsh/src/file/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions libsqsh/src/file/inode_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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,

Expand Down
2 changes: 2 additions & 0 deletions libsqsh/src/file/inode_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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,

Expand Down
2 changes: 2 additions & 0 deletions libsqsh/src/file/inode_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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,

Expand Down
2 changes: 2 additions & 0 deletions libsqsh/src/file/inode_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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,

Expand Down
6 changes: 6 additions & 0 deletions libsqsh/src/file/inode_null.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
return NULL;
}

uint32_t
sqsh__file_inode_null_symlink_target_size(const struct SqshDataInode *inode) {

Check warning on line 98 in libsqsh/src/file/inode_null.c

View check run for this annotation

Codecov / codecov/patch

libsqsh/src/file/inode_null.c#L98

Added line #L98 was not covered by tests
(void)inode;
return 0;

Check warning on line 100 in libsqsh/src/file/inode_null.c

View check run for this annotation

Codecov / codecov/patch

libsqsh/src/file/inode_null.c#L100

Added line #L100 was not covered by tests
}

uint32_t
sqsh__file_inode_null_device_id(const struct SqshDataInode *inode) {
(void)inode;
Expand Down
29 changes: 21 additions & 8 deletions libsqsh/src/file/inode_symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,23 @@
#include <sqsh_tree_private.h>
#include <stdint.h>

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);

Check warning on line 62 in libsqsh/src/file/inode_symlink.c

View check run for this annotation

Codecov / codecov/patch

libsqsh/src/file/inode_symlink.c#L62

Added line #L62 was not covered by tests
}

/* hard_link_count */
Expand All @@ -77,14 +78,12 @@
/* 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);

Check warning on line 81 in libsqsh/src/file/inode_symlink.c

View check run for this annotation

Codecov / codecov/patch

libsqsh/src/file/inode_symlink.c#L81

Added line #L81 was not covered by tests
}

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);

Check warning on line 86 in libsqsh/src/file/inode_symlink.c

View check run for this annotation

Codecov / codecov/patch

libsqsh/src/file/inode_symlink.c#L86

Added line #L86 was not covered by tests
}

static const char *
Expand All @@ -93,6 +92,18 @@
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(

Check warning on line 97 in libsqsh/src/file/inode_symlink.c

View check run for this annotation

Codecov / codecov/patch

libsqsh/src/file/inode_symlink.c#L96-L97

Added lines #L96 - L97 were not covered by tests
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(
Expand Down Expand Up @@ -122,6 +133,7 @@
.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,

Expand All @@ -145,6 +157,7 @@
.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,

Expand Down