aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2022-10-20 14:30:00 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2022-12-09 12:15:37 +0000
commit83aff0f08c525ea3c394f3dd6598665cd369d53c (patch)
tree85260671e72554c5f5c12f6c9d1f71d4a0840609
parente77f2f9dc683bb5ac725c5844fc36c831138e841 (diff)
downloadsrc-83aff0f08c525ea3c394f3dd6598665cd369d53c.tar.gz
src-83aff0f08c525ea3c394f3dd6598665cd369d53c.zip
Add 'show tmpfs' ddb command
Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37097
-rw-r--r--sys/fs/tmpfs/tmpfs_vfsops.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c
index 7bd44decd830..51a16ae6f5cf 100644
--- a/sys/fs/tmpfs/tmpfs_vfsops.c
+++ b/sys/fs/tmpfs/tmpfs_vfsops.c
@@ -43,6 +43,7 @@
* allocate and release resources.
*/
+#include "opt_ddb.h"
#include "opt_tmpfs.h"
#include <sys/cdefs.h>
@@ -696,3 +697,44 @@ struct vfsops tmpfs_vfsops = {
.vfs_uninit = tmpfs_uninit,
};
VFS_SET(tmpfs_vfsops, tmpfs, VFCF_JAIL);
+
+#ifdef DDB
+#include <ddb/ddb.h>
+
+static void
+db_print_tmpfs(struct mount *mp, struct tmpfs_mount *tmp)
+{
+ db_printf("mp %p (%s) tmp %p\n", mp,
+ mp->mnt_stat.f_mntonname, tmp);
+ db_printf(
+ "\tsize max %ju pages max %lu pages used %lu\n"
+ "\tinodes max %ju inodes inuse %ju refcount %ju\n"
+ "\tmaxfilesize %ju r%c %snamecache %smtime\n",
+ (uintmax_t)tmp->tm_size_max, tmp->tm_pages_max, tmp->tm_pages_used,
+ (uintmax_t)tmp->tm_nodes_max, (uintmax_t)tmp->tm_nodes_inuse,
+ (uintmax_t)tmp->tm_refcount, (uintmax_t)tmp->tm_maxfilesize,
+ tmp->tm_ronly ? 'o' : 'w', tmp->tm_nonc ? "no" : "",
+ tmp->tm_nomtime ? "no" : "");
+}
+
+DB_SHOW_COMMAND(tmpfs, db_show_tmpfs)
+{
+ struct mount *mp;
+ struct tmpfs_mount *tmp;
+
+ if (have_addr) {
+ mp = (struct mount *)addr;
+ tmp = VFS_TO_TMPFS(mp);
+ db_print_tmpfs(mp, tmp);
+ return;
+ }
+
+ TAILQ_FOREACH(mp, &mountlist, mnt_list) {
+ if (strcmp(mp->mnt_stat.f_fstypename, tmpfs_vfsconf.vfc_name) ==
+ 0) {
+ tmp = VFS_TO_TMPFS(mp);
+ db_print_tmpfs(mp, tmp);
+ }
+ }
+}
+#endif /* DDB */