summaryrefslogtreecommitdiff
path: root/tmpfs
diff options
context:
space:
mode:
authorMaksym Planeta <mcsim.planeta@gmail.com>2012-03-21 22:43:51 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-03-27 00:04:46 +0200
commit24b07e7a3e7ff8b48033de422f27db7c0a2c690d (patch)
treea9b8c65bc89374f951da31ebc24e9bea5e900f03 /tmpfs
parent3d5ea3e4ca000383cb61eb21d408fc239f2e2247 (diff)
Fix hard links accounting in tmpfs.
* tmpfs/dir.c (diskfs_init_dir, diskfs_clear_directory): Fix hard link accounting in tmpfs for directories.
Diffstat (limited to 'tmpfs')
-rw-r--r--tmpfs/dir.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tmpfs/dir.c b/tmpfs/dir.c
index 65386e0a..4a0a60b5 100644
--- a/tmpfs/dir.c
+++ b/tmpfs/dir.c
@@ -29,6 +29,12 @@ diskfs_init_dir (struct node *dp, struct node *pdp, struct protid *cred)
{
dp->dn->u.dir.dotdot = pdp->dn;
dp->dn->u.dir.entries = 0;
+
+ /* Increase hardlink count for parent directory */
+ pdp->dn_stat.st_nlink++;
+ /* Take '.' directory into account */
+ dp->dn_stat.st_nlink++;
+
return 0;
}
@@ -40,6 +46,12 @@ diskfs_clear_directory (struct node *dp, struct node *pdp,
return ENOTEMPTY;
assert (dp->dn_stat.st_size == 0);
assert (dp->dn->u.dir.dotdot == pdp->dn);
+
+ /* Decrease hardlink count for parent directory */
+ pdp->dn_stat.st_nlink--;
+ /* Take '.' directory into account */
+ dp->dn_stat.st_nlink--;
+
return 0;
}