From 26a59eea43dc243da38068ae847a5d7541ea9c43 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Fri, 17 Mar 2006 13:34:40 +0000 Subject: [PATCH] readlink(); check bounds top: add 'system' cpu time to 'kernel', 'idle' and 'user' --- commands/simple/top.c | 13 +++++++++---- man/man1/top.1 | 9 ++++----- servers/fs/stadir.c | 8 ++++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/commands/simple/top.c b/commands/simple/top.c index 4b37bfdda..e17137895 100644 --- a/commands/simple/top.c +++ b/commands/simple/top.c @@ -110,7 +110,7 @@ void print_procs(int maxlines, struct mproc *mproc) { int p, nprocs; - int idleticks = 0, kernelticks = 0; + int idleticks = 0, kernelticks = 0, systemticks = 0, userticks = 0; for(p = nprocs = 0; p < PROCS; p++) { if(proc2[p].p_rts_flags & SLOT_FREE) @@ -131,14 +131,19 @@ void print_procs(int maxlines, /* Kernel task time, not counting IDLE */ if(proc2[p].p_nr < 0) kernelticks += tick_procs[nprocs].ticks; + else if(mproc[proc2[p].p_nr].mp_procgrp == 0) + systemticks += tick_procs[nprocs].ticks; + else + userticks += tick_procs[nprocs].ticks; nprocs++; } qsort(tick_procs, nprocs, sizeof(tick_procs[0]), cmp_ticks); - printf("CPU states: %5.2f%% user, %5.2f%% kernel, %5.2f%% idle\n\n", - 100.0*(dt-idleticks-kernelticks)/dt, - 100.0*(kernelticks)/dt, + printf("CPU states: %5.2f%% user, %5.2f%% system, %5.2f%% kernel, %5.2f%% idle\n\n", + 100.0*userticks/dt, + 100.0*systemticks/dt, + 100.0*kernelticks/dt, 100.0*idleticks/dt); maxlines -= 2; diff --git a/man/man1/top.1 b/man/man1/top.1 index 6f6abbb07..904ab9faa 100644 --- a/man/man1/top.1 +++ b/man/man1/top.1 @@ -13,11 +13,10 @@ At the top of the screen, top shows the current system load averages in the last 1-minute, 5-minute and 15-minute intervals. Then, over the last top interval it displays: the number of alive, active, and sleeping processes; memory free; and CPU usage. CPU usage is split into -user, kernel and idle time. Kernel time is time spent by kernel tasks, -that is tasks that run in kernel mode in kernel address space. User -time is all other CPU time, including system processes such as servers -and drivers, as top can't see the difference between a user process and -a server or driver. +user, kernel, system and idle time. Kernel time is time spent by kernel tasks, +that is tasks that run in kernel mode in kernel address space. System +time are system user processes, such as drivers and servers. User +time is all other CPU time. Then it displays all the alive processes sorted by CPU usage in the last interval, with a number of fields for every process. Currently the diff --git a/servers/fs/stadir.c b/servers/fs/stadir.c index 6fa0bcbb9..c84b5ec9e 100644 --- a/servers/fs/stadir.c +++ b/servers/fs/stadir.c @@ -274,6 +274,9 @@ PUBLIC int do_rdlink() block_t b; /* block containing link text */ struct buf *bp; /* buffer containing link text */ register struct inode *rip; /* target inode */ + int copylen; + copylen = m_in.m1_i2; + if(copylen < 0) return EINVAL; if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); if ((rip = parse_path(user_path, (char *) 0, EAT_PATH_OPAQUE)) == NIL_INODE) @@ -284,11 +287,12 @@ PUBLIC int do_rdlink() if (m_in.name2_length <= 0) r = EINVAL; else if (m_in.name2_length < rip->i_size) r = ERANGE; else { + if(rip->i_size < copylen) copylen = rip->i_size; bp = get_block(rip->i_dev, b, NORMAL); r = sys_vircopy(SELF, D, (vir_bytes) bp->b_data, - who_e, D, (vir_bytes) m_in.name2, (vir_bytes) rip->i_size); + who_e, D, (vir_bytes) m_in.name2, (vir_bytes) copylen); - if (r == OK) r = rip->i_size; + if (r == OK) r = copylen; put_block(bp, DIRECTORY_BLOCK); } } -- 2.44.0