aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-07-08 17:08:34 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-07-08 19:17:31 +0200
commitaed35c78c6a51a4b4c37ebda5643d2246842fb74 (patch)
treebcca46d34146c117005a3c4b58588613fec3206e
parentfd0b2e7a242568f5b11f8a22ce0c3f639e6bbbfc (diff)
Fix: libfstree: actually use a full 32 bit hard link counter
The squashfs on-disk format uses 32 bit link counters, but the fstree used 16 bit ones. Because the link count also includes child nodes, this artificially limited the number of entries in a directory to ~64k files. This patch removes the limit by switching libfstree to 32 bit counters. Reported-by: Marvin Renich <mrvn@renich.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--include/fstree.h2
-rw-r--r--lib/fstree/hardlink.c2
-rw-r--r--lib/fstree/mknode.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/include/fstree.h b/include/fstree.h
index aa8efd5..58936d7 100644
--- a/include/fstree.h
+++ b/include/fstree.h
@@ -98,8 +98,8 @@ struct tree_node_t {
sqfs_u32 gid;
sqfs_u32 inode_num;
sqfs_u32 mod_time;
+ sqfs_u32 link_count;
sqfs_u16 mode;
- sqfs_u16 link_count;
/* SquashFS inode refernce number. 32 bit offset of the meta data
block start (relative to inode table start), shifted left by 16
diff --git a/lib/fstree/hardlink.c b/lib/fstree/hardlink.c
index 11ab566..f45acf7 100644
--- a/lib/fstree/hardlink.c
+++ b/lib/fstree/hardlink.c
@@ -62,7 +62,7 @@ int fstree_resolve_hard_link(fstree_t *fs, tree_node_t *node)
return -1;
}
- if (node->link_count == 0x0FFFF) {
+ if (node->link_count == 0xFFFFFFFF) {
errno = EMLINK;
return -1;
}
diff --git a/lib/fstree/mknode.c b/lib/fstree/mknode.c
index 11026f6..2b1f89d 100644
--- a/lib/fstree/mknode.c
+++ b/lib/fstree/mknode.c
@@ -88,7 +88,7 @@ tree_node_t *fstree_mknode(tree_node_t *parent, const char *name,
}
if (parent != NULL) {
- if (parent->link_count == 0x0FFFF) {
+ if (parent->link_count == 0xFFFFFFFF) {
free(n);
errno = EMLINK;
return NULL;