Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102974598
D39019.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D39019.diff
View Options
diff --git a/sys/fs/tarfs/tarfs_subr.c b/sys/fs/tarfs/tarfs_subr.c
--- a/sys/fs/tarfs/tarfs_subr.c
+++ b/sys/fs/tarfs/tarfs_subr.c
@@ -384,6 +384,18 @@
tmp = tnp->tmp;
switch (tnp->type) {
+ case VREG:
+ if (tnp->nlink-- > 1)
+ return;
+ if (tnp->other != NULL)
+ tarfs_free_node(tnp->other);
+ break;
+ case VDIR:
+ if (tnp->nlink-- > 2)
+ return;
+ if (tnp->parent != NULL && tnp->parent != tnp)
+ tarfs_free_node(tnp->parent);
+ break;
case VLNK:
if (tnp->link.name)
free(tnp->link.name, M_TARFSNAME);
@@ -397,6 +409,7 @@
free(tnp->blk, M_TARFSBLK);
if (tnp->ino >= TARFS_MININO)
free_unr(tmp->ino_unr, tnp->ino);
+ TAILQ_REMOVE(&tmp->allnodes, tnp, entries);
free(tnp, M_TARFSNODE);
tmp->nfiles--;
}
diff --git a/sys/fs/tarfs/tarfs_vfsops.c b/sys/fs/tarfs/tarfs_vfsops.c
--- a/sys/fs/tarfs/tarfs_vfsops.c
+++ b/sys/fs/tarfs/tarfs_vfsops.c
@@ -406,16 +406,14 @@
tarfs_free_mount(struct tarfs_mount *tmp)
{
struct mount *mp;
- struct tarfs_node *tnp;
+ struct tarfs_node *tnp, *tnp_next;
MPASS(tmp != NULL);
TARFS_DPF(ALLOC, "%s: Freeing mount structure %p\n", __func__, tmp);
TARFS_DPF(ALLOC, "%s: freeing tarfs_node structures\n", __func__);
- while (!TAILQ_EMPTY(&tmp->allnodes)) {
- tnp = TAILQ_FIRST(&tmp->allnodes);
- TAILQ_REMOVE(&tmp->allnodes, tnp, entries);
+ TAILQ_FOREACH_SAFE(tnp, &tmp->allnodes, entries, tnp_next) {
tarfs_free_node(tnp);
}
@@ -744,6 +742,7 @@
error = EINVAL;
goto bad;
}
+ tnp->other->nlink++;
break;
case TAR_TYPE_SYMLINK:
if (link == NULL) {
diff --git a/tests/sys/fs/tarfs/tarfs_test.sh b/tests/sys/fs/tarfs/tarfs_test.sh
--- a/tests/sys/fs/tarfs/tarfs_test.sh
+++ b/tests/sys/fs/tarfs/tarfs_test.sh
@@ -59,6 +59,8 @@
atf_check_equal "$(stat -f%d,%i "${mnt}"/sparse_file)" "$(stat -L -f%d,%i "${mnt}"/short_link)"
atf_check_equal "$(stat -f%d,%i "${mnt}"/sparse_file)" "$(stat -L -f%d,%i "${mnt}"/long_link)"
atf_check_equal "$(sha256 -q "${mnt}"/sparse_file)" ${sum}
+ atf_check_equal "$(stat -f%l "${mnt}"/sparse_file)" 2
+ atf_check_equal "$(stat -f%l "${mnt}"/hard_link)" 2
}
tarfs_basic_cleanup() {
umount "${mnt}" || true
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 20, 9:28 AM (21 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14734910
Default Alt Text
D39019.diff (2 KB)
Attached To
Mode
D39019: tarfs: Correctly track link count.
Attached
Detach File
Event Timeline
Log In to Comment