File src/io.c changed (mode: 100644) (index 7f299a8..6dad447) |
... |
... |
enum { |
32 |
32 |
static int max_line_len; |
static int max_line_len; |
33 |
33 |
static struct pwatch_proc *head; |
static struct pwatch_proc *head; |
34 |
34 |
static unsigned int view = VIEW_NORMAL; |
static unsigned int view = VIEW_NORMAL; |
35 |
|
static unsigned int cells = 0; |
|
36 |
|
static unsigned int selected_line = 0, last_line = 0, useful_lines = 0; |
|
37 |
|
static unsigned int max_pages = 1, page = 0; |
|
|
35 |
|
static int cells = 0; |
|
36 |
|
static int selected_line = 0, last_line = 0, useful_lines = 0; |
|
37 |
|
static int max_pages = 1, page = 0; |
38 |
38 |
static pid_t selected_pid = 0; |
static pid_t selected_pid = 0; |
39 |
39 |
|
|
40 |
40 |
|
|
|
... |
... |
static void usage(void) |
53 |
53 |
static void iotop_show_help(void) |
static void iotop_show_help(void) |
54 |
54 |
{ |
{ |
55 |
55 |
char buf[256]; |
char buf[256]; |
56 |
|
int ch, max; |
|
|
56 |
|
int buf_len; |
|
57 |
|
int ch; |
|
58 |
|
int max; |
|
59 |
|
|
|
60 |
|
buf_len = sizeof(buf); |
57 |
61 |
|
|
58 |
62 |
max = max_line_len; |
max = max_line_len; |
59 |
|
if (max > sizeof(buf)) |
|
60 |
|
max = sizeof(buf); |
|
|
63 |
|
if (max > buf_len) |
|
64 |
|
max = buf_len; |
61 |
65 |
|
|
62 |
66 |
/* wait for a key when calling getch */ |
/* wait for a key when calling getch */ |
63 |
67 |
nodelay(stdscr, FALSE); |
nodelay(stdscr, FALSE); |
|
... |
... |
static void iotop_show_cells(const unsigned int page, |
118 |
122 |
{ |
{ |
119 |
123 |
struct pwatch_proc *p; |
struct pwatch_proc *p; |
120 |
124 |
char buf[256]; |
char buf[256]; |
121 |
|
int max, line, skip; |
|
|
125 |
|
int buf_len; |
|
126 |
|
int line, skip, max; |
122 |
127 |
char rb[16], wb[16]; |
char rb[16], wb[16]; |
123 |
128 |
char rs[16], ws[16]; |
char rs[16], ws[16]; |
124 |
129 |
|
|
|
130 |
|
buf_len = sizeof(buf); |
|
131 |
|
|
125 |
132 |
max = max_line_len; |
max = max_line_len; |
126 |
|
if (max > sizeof(buf)) |
|
127 |
|
max = sizeof(buf); |
|
|
133 |
|
if (max > buf_len) |
|
134 |
|
max = buf_len; |
128 |
135 |
|
|
129 |
136 |
/* skip is the number of entries we have to skip */ |
/* skip is the number of entries we have to skip */ |
130 |
137 |
skip = useful_lines * page; |
skip = useful_lines * page; |
|
... |
... |
static void iotop_show_cells(const unsigned int page, |
176 |
183 |
static void iotop_show_process(void) |
static void iotop_show_process(void) |
177 |
184 |
{ |
{ |
178 |
185 |
struct pwatch_fd *ifd; |
struct pwatch_fd *ifd; |
179 |
|
unsigned int lines_per_page, line, max; |
|
|
186 |
|
int lines_per_page, line, max; |
180 |
187 |
char buf[4096], flags[32]; |
char buf[4096], flags[32]; |
|
188 |
|
int buf_len; |
181 |
189 |
struct pwatch_proc *proc; |
struct pwatch_proc *proc; |
182 |
190 |
|
|
|
191 |
|
buf_len = sizeof(buf); |
|
192 |
|
|
183 |
193 |
max = max_line_len; |
max = max_line_len; |
184 |
|
if (max > sizeof(buf)) |
|
185 |
|
max = sizeof(buf); |
|
|
194 |
|
if (max > buf_len) |
|
195 |
|
max = buf_len; |
186 |
196 |
|
|
187 |
197 |
proc = pwatch_proc_get(head, selected_pid); |
proc = pwatch_proc_get(head, selected_pid); |
188 |
198 |
if (!proc) { |
if (!proc) { |
|
... |
... |
int main(int argc, char *argv[]) |
291 |
301 |
unsigned int re_sort = 0, force_sort; |
unsigned int re_sort = 0, force_sort; |
292 |
302 |
char s_sort[256]; |
char s_sort[256]; |
293 |
303 |
char status[256]; |
char status[256]; |
|
304 |
|
int status_len; |
294 |
305 |
int c; |
int c; |
295 |
306 |
unsigned long refresh_rate = 1; |
unsigned long refresh_rate = 1; |
296 |
307 |
unsigned int refresh_count = 0, refresh_steps; |
unsigned int refresh_count = 0, refresh_steps; |
|
... |
... |
int main(int argc, char *argv[]) |
342 |
353 |
strcpy(error, ""); |
strcpy(error, ""); |
343 |
354 |
errcode = 0; |
errcode = 0; |
344 |
355 |
|
|
|
356 |
|
status_len = sizeof(status); |
345 |
357 |
while (1) { |
while (1) { |
346 |
358 |
max_line_len = COLS + 1; |
max_line_len = COLS + 1; |
347 |
|
if (max_line_len > sizeof(status)) |
|
348 |
|
max_line_len = sizeof(status); |
|
|
359 |
|
if (max_line_len > status_len) |
|
360 |
|
max_line_len = status_len; |
349 |
361 |
|
|
350 |
362 |
if ((ch = getch()) != ERR) { |
if ((ch = getch()) != ERR) { |
351 |
363 |
re_sort = 0; |
re_sort = 0; |