Page MenuHomeFreeBSD

D39019.diff
No OneTemporary

D39019.diff

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

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)

Event Timeline