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

Add 64bit rdev APIs #329

Merged
merged 1 commit into from
Sep 6, 2024
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
2 changes: 1 addition & 1 deletion libcomposefs/lcfs-writer-erofs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ static int add_overlay_whiteouts(struct lcfs_node_s *root)
}

lcfs_node_set_mode(child, S_IFCHR | 0644);
lcfs_node_set_rdev(child, 0);
lcfs_node_set_rdev64(child, 0);

child->inode.st_uid = root->inode.st_uid;
child->inode.st_gid = root->inode.st_gid;
Expand Down
12 changes: 12 additions & 0 deletions libcomposefs/lcfs-writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1009,16 +1009,28 @@ void lcfs_node_set_gid(struct lcfs_node_s *node, uint32_t gid)
node->inode.st_gid = gid;
}

// Deprecated: this truncates rdev to 32 bits
cgwalters marked this conversation as resolved.
Show resolved Hide resolved
uint32_t lcfs_node_get_rdev(struct lcfs_node_s *node)
{
return (uint32_t)lcfs_node_get_rdev64(node);
}

uint64_t lcfs_node_get_rdev64(struct lcfs_node_s *node)
{
return node->inode.st_rdev;
}

// Deprecated: this truncates rdev to 32 bits
void lcfs_node_set_rdev(struct lcfs_node_s *node, uint32_t rdev)
{
node->inode.st_rdev = rdev;
}

void lcfs_node_set_rdev64(struct lcfs_node_s *node, uint64_t rdev)
{
node->inode.st_rdev = rdev;
}

uint32_t lcfs_node_get_nlink(struct lcfs_node_s *node)
{
return node->inode.st_nlink;
Expand Down
8 changes: 6 additions & 2 deletions libcomposefs/lcfs-writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ LCFS_EXTERN uint32_t lcfs_node_get_uid(struct lcfs_node_s *node);
LCFS_EXTERN void lcfs_node_set_uid(struct lcfs_node_s *node, uint32_t uid);
LCFS_EXTERN uint32_t lcfs_node_get_gid(struct lcfs_node_s *node);
LCFS_EXTERN void lcfs_node_set_gid(struct lcfs_node_s *node, uint32_t gid);
LCFS_EXTERN uint32_t lcfs_node_get_rdev(struct lcfs_node_s *node);
LCFS_EXTERN void lcfs_node_set_rdev(struct lcfs_node_s *node, uint32_t rdev);
LCFS_EXTERN uint32_t lcfs_node_get_rdev(struct lcfs_node_s *node)
__attribute__((deprecated));
LCFS_EXTERN uint64_t lcfs_node_get_rdev64(struct lcfs_node_s *node);
LCFS_EXTERN void lcfs_node_set_rdev(struct lcfs_node_s *node, uint32_t rdev)
__attribute__((deprecated));
LCFS_EXTERN void lcfs_node_set_rdev64(struct lcfs_node_s *node, uint64_t rdev);
LCFS_EXTERN uint32_t lcfs_node_get_nlink(struct lcfs_node_s *node);
LCFS_EXTERN void lcfs_node_set_nlink(struct lcfs_node_s *node, uint32_t nlink);
LCFS_EXTERN uint64_t lcfs_node_get_size(struct lcfs_node_s *node);
Expand Down
4 changes: 2 additions & 2 deletions tools/composefs-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ static void dump_node(struct lcfs_node_s *node, char *path)
uint64_t size = lcfs_node_get_size(target);

print_escaped(*path == 0 ? "/" : path, -1, ESCAPE_STANDARD);
printf(" %" PRIu64 " %s%o %u %u %u %u %" PRIi64 ".%u ", size,
printf(" %" PRIu64 " %s%o %u %u %u %" PRIu64 " %" PRIi64 ".%u ", size,
hardlink_path != NULL ? "@" : "", lcfs_node_get_mode(target),
lcfs_node_get_nlink(target), lcfs_node_get_uid(target),
lcfs_node_get_gid(target), lcfs_node_get_rdev(target),
lcfs_node_get_gid(target), lcfs_node_get_rdev64(target),
(int64_t)mtime.tv_sec, (unsigned int)mtime.tv_nsec);
print_escaped_optional(hardlink_path ? hardlink_path : payload, -1,
ESCAPE_LONE_DASH);
Expand Down
2 changes: 1 addition & 1 deletion tools/mkcomposefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ static char *tree_from_dump_line(dump_info *info, const char *line, size_t line_
lcfs_node_set_nlink(node, nlink);
lcfs_node_set_uid(node, uid);
lcfs_node_set_gid(node, gid);
lcfs_node_set_rdev(node, rdev);
lcfs_node_set_rdev64(node, rdev);
lcfs_node_set_mtime(node, &mtime);
// Validate that symlinks are non-empty
if ((mode & S_IFMT) == S_IFLNK) {
Expand Down
Loading