diff options
author | netchild <netchild@FreeBSD.org> | 2007-01-20 11:07:41 +0000 |
---|---|---|
committer | netchild <netchild@FreeBSD.org> | 2007-01-20 11:07:41 +0000 |
commit | 22ce9c2574c61544e9f22899bcf121f2d63ee13d (patch) | |
tree | b6d599784f2929a839aed5c96f66b55a486ff899 /sys/compat | |
parent | a31f50a3fbb019e8bef333536641691ebce78066 (diff) | |
download | FreeBSD-src-22ce9c2574c61544e9f22899bcf121f2d63ee13d.zip FreeBSD-src-22ce9c2574c61544e9f22899bcf121f2d63ee13d.tar.gz |
Convert a KASSERT into a runtime warning (rate limited) + failsafe fallback.
Because of a stupid bug (also fixed with this commit) the KASSERT was
triggered when runnung the linux top.
Pointy hat to: netchild
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/linprocfs/linprocfs.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 3c21c93..d7514b6 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -121,7 +121,7 @@ __FBSDID("$FreeBSD$"); * This character array is used with ki_stati-1 as an index and tries to * map our states to suitable linux states. */ -static char *linux_state = "RRSTZDD"; +static char linux_state[] = "RRSTZDD"; /* * Filler function for proc/meminfo @@ -462,15 +462,23 @@ static int linprocfs_doprocstat(PFS_FILL_ARGS) { struct kinfo_proc kp; + char state; + static int ratelimit = 0; PROC_LOCK(p); fill_kinfo_proc(p, &kp); sbuf_printf(sb, "%d", p->p_pid); #define PS_ADD(name, fmt, arg) sbuf_printf(sb, " " fmt, arg) PS_ADD("comm", "(%s)", p->p_comm); - KASSERT(kp.ki_stat <= sizeof(linux_state), - ("linprocfs: don't know how to handle unknown FreeBSD state")); - PS_ADD("state", "%c", linux_state[kp.ki_stat - 1]); + if (kp.ki_stat > sizeof(linux_state)) { + state = 'R'; + + if (ratelimit == 0) + printf("linprocfs: don't know how to handle unknown FreeBSD state %d/%d, mapping to R\n", + kp.ki_stat, sizeof(linux_state)); + } else + state = linux_state[kp.ki_stat - 1]; + PS_ADD("state", "%c", state); PS_ADD("ppid", "%d", p->p_pptr ? p->p_pptr->p_pid : 0); PS_ADD("pgrp", "%d", p->p_pgid); PS_ADD("session", "%d", p->p_session->s_sid); |