diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-14 02:23:43 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-14 02:23:43 +0000 |
commit | ea62077b850076c4d7dc3cf78ebd1888928c6ddf (patch) | |
tree | 37b7584ae40b99edb5583fbc4392b62ffdadf278 /miscutils/nmeter.c | |
parent | 88ca06769028e442bf873b270c176ca0e9f021f8 (diff) |
add open_read_close() and similar stuff
Diffstat (limited to 'miscutils/nmeter.c')
-rw-r--r-- | miscutils/nmeter.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/miscutils/nmeter.c b/miscutils/nmeter.c index e83de38ec..d71bd6add 100644 --- a/miscutils/nmeter.c +++ b/miscutils/nmeter.c @@ -88,12 +88,7 @@ static void put_question_marks(int count) static int readfile_z(char *buf, int sz, const char* fname) { - int fd; - fd = xopen(fname, O_RDONLY); - // We are not checking for short reads (valid only because - // we are reading /proc files) - sz = read(fd, buf, sz-1); - close(fd); + sz = open_read_close(fname, buf, sz-1); if (sz < 0) { buf[0] = '\0'; return 1; @@ -776,15 +771,12 @@ int nmeter_main(int argc, char* argv[]) s_stat *last = NULL; s_stat *s; char *cur, *prev; - int fd; if (argc != 2) bb_show_usage(); - fd = xopen("/proc/version", O_RDONLY); - if (read(fd, buf, sizeof(buf)) > 0) - is26 = (strstr(buf, "Linux version 2.4.")==NULL); - close(fd); + if (open_read_close("/proc/version", buf, sizeof(buf)) > 0) + is26 = (strstr(buf, " 2.4.")==NULL); // Can use argv[1] directly, but this will mess up // parameters as seen by e.g. ps. Making a copy... |