diff options
author | Karel Zak | 2006-12-07 00:25:49 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:25:49 +0100 |
commit | e8f2641919de90b488ce3788a7795b88311750b5 (patch) | |
tree | 68f3732da38ff1b21ec49780d7c830250329fec9 /sys-utils | |
parent | Imported from util-linux-2.11f tarball. (diff) | |
download | kernel-qcow2-util-linux-e8f2641919de90b488ce3788a7795b88311750b5.tar.gz kernel-qcow2-util-linux-e8f2641919de90b488ce3788a7795b88311750b5.tar.xz kernel-qcow2-util-linux-e8f2641919de90b488ce3788a7795b88311750b5.zip |
Imported from util-linux-2.11m tarball.
Diffstat (limited to 'sys-utils')
-rw-r--r-- | sys-utils/cytune.c | 28 | ||||
-rw-r--r-- | sys-utils/ipcrm.8 | 4 | ||||
-rw-r--r-- | sys-utils/ipcs.c | 4 | ||||
-rw-r--r-- | sys-utils/rdev.c | 1 | ||||
-rw-r--r-- | sys-utils/readprofile.c | 32 | ||||
-rw-r--r-- | sys-utils/renice.c | 24 |
6 files changed, 64 insertions, 29 deletions
diff --git a/sys-utils/cytune.c b/sys-utils/cytune.c index dfa276e9b..5a13c4de8 100644 --- a/sys-utils/cytune.c +++ b/sys-utils/cytune.c @@ -250,7 +250,7 @@ int main(int argc, char *argv[]) { global_optind = optind; /* For signal routine. */ if (set || set_def) { - for(i = optind;i < argc;i ++) { + for(i = optind; i < argc; i++) { file = open(argv[i],O_RDONLY); if(file == -1) { int errsv = errno; @@ -265,10 +265,11 @@ int main(int argc, char *argv[]) { argv[i],set?set_val:set_def_val,strerror(errsv)); exit(1); } + close(file); } } if (set_time || set_def_time) { - for(i = optind;i < argc;i ++) { + for(i = optind; i < argc; i++) { file = open(argv[i],O_RDONLY); if(file == -1) { int errsv = errno; @@ -283,11 +284,12 @@ int main(int argc, char *argv[]) { argv[i],set_time?set_time_val:set_def_time_val,strerror(errsv)); exit(1); } + close(file); } } if (get || get_def) { - for(i = optind;i < argc;i ++) { + for(i = optind; i < argc; i++) { file = open(argv[i],O_RDONLY); if(file == -1) { int errsv = errno; @@ -306,11 +308,13 @@ int main(int argc, char *argv[]) { argv[i],strerror(errsv)); exit(1); } - printf(_("%s: %ld %s threshold and %ld %s timeout\n"), - argv[i], threshold_value, - get?_("current"):_("default"), - timeout_value, - get?_("current"):_("default")); + close(file); + if (get) + printf(_("%s: %ld current threshold and %ld current timeout\n"), + argv[i], threshold_value, timeout_value); + else + printf(_("%s: %ld default threshold and %ld default timeout\n"), + argv[i], threshold_value, timeout_value); } } @@ -418,9 +422,8 @@ int main(int argc, char *argv[]) { } #ifdef XMIT - printf(_("%s: %lu ints, %lu/%lu chars; ") - _("fifo: %lu thresh, %lu tmout, ") - _("%lu max, %lu now\n"), + printf(_("%s: %lu ints, %lu/%lu chars; fifo: %lu thresh, %lu tmout, " + "%lu max, %lu now\n"), argv[i], cywork.int_count,cywork.char_count,cywork.send_count, threshold_value,timeout_value, @@ -430,7 +433,8 @@ int main(int argc, char *argv[]) { xfer_rate, xmit_rate); #else - printf(_("%s: %lu ints, %lu chars; fifo: %lu thresh, %lu tmout, %lu max, %lu now\n"), + printf(_("%s: %lu ints, %lu chars; fifo: %lu thresh, %lu tmout, " + "%lu max, %lu now\n"), argv[i], cywork.int_count,cywork.char_count, threshold_value,timeout_value, diff --git a/sys-utils/ipcrm.8 b/sys-utils/ipcrm.8 index ef2facb92..1a0107d7c 100644 --- a/sys-utils/ipcrm.8 +++ b/sys-utils/ipcrm.8 @@ -4,10 +4,10 @@ .SH NAME ipcs \- provide information on ipc facilities .SH SYNOPSIS -.BI "ipcrm [ shm | msg | sem ] " id +.BI "ipcrm [ shm | msg | sem ] " id ... .SH DESCRIPTION .B ipcrm -will remove the resource speccified by +will remove the resource(s) specified by .IR id . .SH SEE ALSO .BR ipcs (8) diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c index 60dcb319d..0673be564 100644 --- a/sys-utils/ipcs.c +++ b/sys-utils/ipcs.c @@ -127,8 +127,8 @@ usage(void) { static void help (void) { - printf (_("%s provides information on ipc facilities for"), progname); - printf (_(" which you have read access.\n")); + printf (_("%s provides information on ipc facilities for" + " which you have read access.\n"), progname); printf (_("Resource Specification:\n\t-m : shared_mem\n\t-q : messages\n")); printf (_("\t-s : semaphores\n\t-a : all (default)\n")); printf (_("Output Format:\n\t-t : time\n\t-p : pid\n\t-c : creator\n")); diff --git a/sys-utils/rdev.c b/sys-utils/rdev.c index e2b23aee0..1710a2010 100644 --- a/sys-utils/rdev.c +++ b/sys-utils/rdev.c @@ -131,6 +131,7 @@ find_dev_recursive(char *dirnamebuf, int number) { return 1; } dirnamebuf[dirnamelen] = 0; + closedir(dp); return 0; } diff --git a/sys-utils/readprofile.c b/sys-utils/readprofile.c index eee8634fe..117a53072 100644 --- a/sys-utils/readprofile.c +++ b/sys-utils/readprofile.c @@ -64,16 +64,36 @@ usage(void) { exit(1); } +static void * +xmalloc (size_t size) { + void *t; + + if (size == 0) + return NULL; + + t = malloc (size); + if (t == NULL) { + fprintf(stderr, _("out of memory")); + exit(1); + } + + return t; +} + static FILE * myopen(char *name, char *mode, int *flag) { - static char cmdline[S_LEN]; + int len = strlen(name); - if (!strcmp(name+strlen(name)-3,".gz")) { - *flag=1; - sprintf(cmdline,"zcat %s", name); - return popen(cmdline,mode); + if (!strcmp(name+len-3,".gz")) { + FILE *res; + char *cmdline = xmalloc(len+6); + sprintf(cmdline, "zcat %s", name); + res = popen(cmdline,mode); + free(cmdline); + *flag = 1; + return res; } - *flag=0; + *flag = 0; return fopen(name,mode); } diff --git a/sys-utils/renice.c b/sys-utils/renice.c index f04f69f13..2807ae3bc 100644 --- a/sys-utils/renice.c +++ b/sys-utils/renice.c @@ -71,10 +71,12 @@ main(int argc, char **argv) } prio = atoi(*argv); argc--, argv++; +#if 0 if (prio > PRIO_MAX) prio = PRIO_MAX; if (prio < PRIO_MIN) prio = PRIO_MIN; +#endif for (; argc > 0; argc--, argv++) { if (strcmp(*argv, "-g") == 0) { which = PRIO_PGRP; @@ -111,12 +113,11 @@ main(int argc, char **argv) } int -donice(which, who, prio) - int which, who, prio; -{ - int oldprio; +donice(int which, int who, int prio) { + int oldprio, newprio; - errno = 0, oldprio = getpriority(which, who); + errno = 0; + oldprio = getpriority(which, who); if (oldprio == -1 && errno) { fprintf(stderr, "renice: %d: ", who); perror(_("getpriority")); @@ -127,6 +128,15 @@ donice(which, who, prio) perror(_("setpriority")); return (1); } - printf(_("%d: old priority %d, new priority %d\n"), who, oldprio, prio); - return (0); + errno = 0; + newprio = getpriority(which, who); + if (newprio == -1 && errno) { + fprintf(stderr, "renice: %d: ", who); + perror(_("getpriority")); + return (1); + } + + printf(_("%d: old priority %d, new priority %d\n"), + who, oldprio, newprio); + return 0; } |