Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- sys-utils/cytune.c | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/sys-utils/cytune.c b/sys-utils/cytune.c index 4cc7db6..bdaad2e 100644 --- a/sys-utils/cytune.c +++ b/sys-utils/cytune.c @@ -135,6 +135,17 @@ static void summary(int sig) cc->timeout_value = 0; } +static void cyg_get_mon(int fd, struct cyclades_monitor *mon, char *file, + unsigned long *threshold_value, unsigned long *timeout_value) +{ + if (ioctl(fd, CYGETMON, &mon)) + err(EXIT_FAILURE, _("cannot issue CYGETMON on %s"), file); + if (ioctl(fd, CYGETTHRESH, &threshold_value)) + err(EXIT_FAILURE, _("cannot get threshold for %s"), file); + if (ioctl(fd, CYGETTIMEOUT, &timeout_value)) + err(EXIT_FAILURE, _("cannot get timeout for %s"), file); +} + static void query_tty_stats(int argc, char **argv, unsigned int interval, int numfiles, unsigned long *threshold_value, unsigned long *timeout_value) @@ -164,18 +175,8 @@ static void query_tty_stats(int argc, char **argv, unsigned int interval, int nu cmon[cmon_index].cfile = open(argv[i], O_RDONLY); if (cmon[cmon_index].cfile == -1) err(EXIT_FAILURE, _("cannot open %s"), argv[i]); - if (ioctl - (cmon[cmon_index].cfile, CYGETMON, &cmon[cmon_index].c)) - err(EXIT_FAILURE, _("cannot issue CYGETMON on %s"), - argv[i]); + cyg_get_mon(cmon[cmon_index].cfile, &cmon[cmon_index].c, argv[i], threshold_value, timeout_value); summary(-1); - if (ioctl - (cmon[cmon_index].cfile, CYGETTHRESH, &threshold_value)) - err(EXIT_FAILURE, _("cannot get threshold for %s"), - argv[i]); - if (ioctl(cmon[cmon_index].cfile, CYGETTIMEOUT, &timeout_value)) - err(EXIT_FAILURE, _("cannot get timeout for %s"), - argv[i]); } while (1) { sleep(interval); @@ -188,21 +189,9 @@ static void query_tty_stats(int argc, char **argv, unsigned int interval, int nu for (i = optind; i < argc; i++) { cmon_index = i - optind; - if (ioctl(cmon[cmon_index].cfile, CYGETMON, &cywork)) - err(EXIT_FAILURE, - _("cannot issue CYGETMON on %s"), argv[i]); - if (ioctl - (cmon[cmon_index].cfile, CYGETTHRESH, - &threshold_value)) - err(EXIT_FAILURE, - _("cannot get threshold for %s"), argv[i]); - if (ioctl - (cmon[cmon_index].cfile, CYGETTIMEOUT, - &timeout_value)) - err(EXIT_FAILURE, - _("cannot get timeout for %s"), argv[i]); - + cyg_get_mon(cmon[cmon_index].cfile, &cywork, argv[i], threshold_value, timeout_value); xfer_rate = cywork.char_count / diff; + if ((*threshold_value) != cmon[cmon_index].threshold_value || (*timeout_value) != -- 1.9.2 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html