From aee6fa6825b0c50e66693af1efa7af1828192218 Mon Sep 17 00:00:00 2001 From: Alex Hornung Date: Fri, 11 Sep 2009 09:59:30 +0100 Subject: [PATCH] devfs - populate statfs f_files properly * Now we set statfs f_files to the total number of currently allocated devfs_nodes. Reported-by: Sascha Wildner --- sys/sys/devfs.h | 1 + sys/vfs/devfs/devfs_core.c | 4 ++++ sys/vfs/devfs/devfs_vfsops.c | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/sys/devfs.h b/sys/sys/devfs.h index cd2815937d..0d6565638c 100644 --- a/sys/sys/devfs.h +++ b/sys/sys/devfs.h @@ -127,6 +127,7 @@ struct devfs_mnt_data { struct mount *mp; uint32_t mnt_type; long leak_count; + long file_count; int jailed; size_t mntonnamelen; }; diff --git a/sys/vfs/devfs/devfs_core.c b/sys/vfs/devfs/devfs_core.c index 7230e644e5..347da7e46b 100644 --- a/sys/vfs/devfs/devfs_core.c +++ b/sys/vfs/devfs/devfs_core.c @@ -269,6 +269,8 @@ devfs_allocp(devfs_nodetype devfsnodetype, char *name, ++mp->mnt_namecache_gen; } + ++DEVFS_MNTDATA(mp)->file_count; + return node; } @@ -413,6 +415,8 @@ devfs_freep(struct devfs_node *node) } node->flags |= DEVFS_DESTROYED; + --DEVFS_MNTDATA(node->mp)->file_count; + objcache_put(devfs_node_cache, node); return 0; diff --git a/sys/vfs/devfs/devfs_vfsops.c b/sys/vfs/devfs/devfs_vfsops.c index 20793433ea..e365280ab7 100644 --- a/sys/vfs/devfs/devfs_vfsops.c +++ b/sys/vfs/devfs/devfs_vfsops.c @@ -109,6 +109,7 @@ devfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) mnt->jailed = jailed(cred); mnt->leak_count = 0; + mnt->file_count = 0; mnt->mp = mp; TAILQ_INIT(&mnt->orphan_list); mnt->root_node = devfs_allocp(Proot, "", NULL, mp, NULL); @@ -176,7 +177,7 @@ devfs_statfs(struct mount *mp, struct statfs *sbp, struct ucred *cred) sbp->f_blocks = 2; /* avoid divide by zero in some df's */ sbp->f_bfree = 0; sbp->f_bavail = 0; - sbp->f_files = 0; + sbp->f_files = (DEVFS_MNTDATA(mp))?(DEVFS_MNTDATA(mp)->file_count):0; sbp->f_ffree = 0; if (sbp != &mp->mnt_stat) { -- 2.11.4.GIT