Hello community, here is the log from the commit of package fnotifystat for openSUSE:Factory checked in at 2017-05-18 20:50:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/fnotifystat (Old) and /work/SRC/openSUSE:Factory/.fnotifystat.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "fnotifystat" Thu May 18 20:50:14 2017 rev:2 rq:495695 version:0.01.17 Changes: -------- --- /work/SRC/openSUSE:Factory/fnotifystat/fnotifystat.changes 2016-09-21 18:46:42.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.fnotifystat.new/fnotifystat.changes 2017-05-18 20:50:15.182893460 +0200 @@ -1,0 +2,23 @@ +Wed May 10 14:49:51 UTC 2017 - mar...@gmx.de + +- update to version 0.01.17 + * Makefile: bump version + * Manual: update copyright year and date + * Add variable pid size handling. + * Re-order declarations of mounts and mount in fnotify_event_init + * Update copyright year to source + +- update to version 0.01.16 + * Makefile: bump version + * Remove extraneous declaration of ret to fix shadowing + * constify fs1 fs2 + * Make some helper functions static + * Makefile: add PEDANTIC flags + +- update to version 0.01.15 + * Makefile: bump version + * reduce scope of ptr + * debian/control: update Standards-Version to 3.9.8 + * Update and correct copyright years + +------------------------------------------------------------------- Old: ---- fnotifystat-0.01.14.tar.gz New: ---- fnotifystat-0.01.17.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ fnotifystat.spec ++++++ --- /var/tmp/diff_new_pack.dQ7jhR/_old 2017-05-18 20:50:16.170754047 +0200 +++ /var/tmp/diff_new_pack.dQ7jhR/_new 2017-05-18 20:50:16.174753482 +0200 @@ -1,7 +1,8 @@ # # spec file for package fnotifystat # -# Copyright (c) 2015, Martin Hauke <mar...@gmx.de> +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017, Martin Hauke <mar...@gmx.de> # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +18,7 @@ Name: fnotifystat -Version: 0.01.14 +Version: 0.01.17 Release: 0 Summary: File activity monitoring tool License: GPL-2.0+ @@ -45,6 +46,6 @@ %defattr(-,root,root) %doc COPYING %{_sbindir}/fnotifystat -%{_mandir}/man8/* +%{_mandir}/man8/fnotifystat.8%{ext_man} %changelog ++++++ fnotifystat-0.01.14.tar.gz -> fnotifystat-0.01.17.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/fnotifystat-0.01.14/Makefile new/fnotifystat-0.01.17/Makefile --- old/fnotifystat-0.01.14/Makefile 2015-10-14 20:05:31.000000000 +0200 +++ new/fnotifystat-0.01.17/Makefile 2017-04-14 18:16:38.000000000 +0200 @@ -1,5 +1,5 @@ # -# Copyright (C) 2013-2015 Canonical, Ltd. +# Copyright (C) 2014-2017 Canonical, Ltd. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -16,10 +16,20 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -VERSION=0.01.14 +VERSION=0.01.17 CFLAGS += -Wall -Wextra -DVERSION='"$(VERSION)"' -O2 +# +# Pedantic flags +# +ifeq ($(PEDANTIC),1) +CFLAGS += -Wabi -Wcast-qual -Wfloat-equal -Wmissing-declarations \ + -Wmissing-format-attribute -Wno-long-long -Wpacked \ + -Wredundant-decls -Wshadow -Wno-missing-field-initializers \ + -Wno-missing-braces -Wno-sign-compare -Wno-multichar +endif + BINDIR=/usr/sbin MANDIR=/usr/share/man/man8 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/fnotifystat-0.01.14/fnotifystat.8 new/fnotifystat-0.01.17/fnotifystat.8 --- old/fnotifystat-0.01.14/fnotifystat.8 2015-10-14 20:05:31.000000000 +0200 +++ new/fnotifystat-0.01.17/fnotifystat.8 2017-04-14 18:16:38.000000000 +0200 @@ -2,7 +2,7 @@ .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) -.TH FNOTIFYSTAT 8 "May 18, 2015" +.TH FNOTIFYSTAT 8 "Apr 14, 2017" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -158,7 +158,7 @@ .PP This manual page was written by Colin King <colin.k...@canonical.com>, for the Ubuntu project (but may be used by others). .SH COPYRIGHT -Copyright \(co 2011-2015 Canonical Ltd. +Copyright \(co 2014-2017 Canonical Ltd. .br This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/fnotifystat-0.01.14/fnotifystat.c new/fnotifystat-0.01.17/fnotifystat.c --- old/fnotifystat-0.01.14/fnotifystat.c 2015-10-14 20:05:31.000000000 +0200 +++ new/fnotifystat-0.01.17/fnotifystat.c 2017-04-14 18:16:38.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2015 Canonical, Ltd. + * Copyright (C) 2014-2017 Canonical, Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -178,6 +178,42 @@ }; /* + * pid_max_digits() + * determine (or guess) maximum digits of pids + */ +static int pid_max_digits(void) +{ + static int max_digits; + ssize_t n; + int fd; + const int default_digits = 6; + const int min_digits = 5; + char buf[32]; + + if (max_digits) + goto ret; + + max_digits = default_digits; + fd = open("/proc/sys/kernel/pid_max", O_RDONLY); + if (fd < 0) + goto ret; + n = read(fd, buf, sizeof(buf) - 1); + (void)close(fd); + if (n < 0) + goto ret; + + buf[n] = '\0'; + max_digits = 0; + while (buf[max_digits] >= '0' && buf[max_digits] <= '9') + max_digits++; + if (max_digits < min_digits) + max_digits = min_digits; +ret: + return max_digits; + +} + +/* * handle_siginfo() * catch SIGUSR1, toggle verbose mode */ @@ -345,7 +381,6 @@ static char *get_pid_cmdline(const pid_t pid) { char buffer[BUFFER_SIZE]; - char *ptr; int fd; ssize_t ret = 0; @@ -374,6 +409,8 @@ if (ret < 1) { strncpy(buffer, "<unknown>", sizeof(buffer)); } else { + char *ptr; + for (ptr = buffer; *ptr && (ptr < buffer + ret); ptr++) { if (*ptr == ' ') { *ptr = '\0'; @@ -631,13 +668,12 @@ static int fnotify_event_init(void) { int fan_fd, count = 0; + FILE* mounts; + struct mntent* mount; if ((fan_fd = fanotify_init(0, 0)) < 0) pr_error("cannot initialize fanotify"); - FILE* mounts; - struct mntent* mount; - /* No paths given, do all mount points */ if ((mounts = setmntent("/proc/self/mounts", "r")) == NULL) { (void)close(fan_fd); @@ -767,6 +803,7 @@ struct tm tm; static stash_info_t previous; char str[64]; + int pid_size; if (!(opt_flags & OPT_VERBOSE)) { free(filename); @@ -804,17 +841,20 @@ return; } + pid_size = pid_max_digits(); + /* * Event for a different file and process has come in * so flush out old.. */ count_to_str((double)previous.count, str, sizeof(str)); - printf("%2.2d/%2.2d/%-2.2d %2.2d:%2.2d:%2.2d %s (%4.4s) %5d %-15.15s %s\n", + printf("%2.2d/%2.2d/%-2.2d %2.2d:%2.2d:%2.2d %s (%4.4s) %*d %-15.15s %s\n", previous.tm.tm_mday, previous.tm.tm_mon + 1, (previous.tm.tm_year+1900) % 100, previous.tm.tm_hour, previous.tm.tm_min, previous.tm.tm_sec, str, fnotify_mask_to_str(previous.mask), - previous.fs->pid, proc_info_get(previous.fs->pid)->cmdline, + pid_size, previous.fs->pid, + proc_info_get(previous.fs->pid)->cmdline, (opt_flags & OPT_DIRNAME_STRIP) ? basename(previous.filename) : previous.filename); @@ -909,10 +949,10 @@ * compare file stats, sort by total and if they are * the same, sort by pathname */ -int file_stat_cmp(const void *p1, const void *p2) +static int file_stat_cmp(const void *p1, const void *p2) { - file_stat_t **fs1 = (file_stat_t **)p1; - file_stat_t **fs2 = (file_stat_t **)p2; + file_stat_t *const *fs1 = (file_stat_t *const *)p1; + file_stat_t *const *fs2 = (file_stat_t *const *)p2; if (opt_flags & OPT_SORT_BY_PID) { if ((*fs1)->pid < (*fs2)->pid) @@ -941,6 +981,7 @@ uint64_t i, j; char ts[32]; double dur = (opt_flags & OPT_CUMULATIVE) ? 1.0 : duration; + int pid_size; if (!(opt_flags & OPT_FORCE) && !file_stats_size) return; @@ -972,20 +1013,22 @@ } else { *ts = '\0'; } - printf("Total Open Close Read Write PID Process %s%s\n", + pid_size = pid_max_digits(); + printf("Total Open Close Read Write %*.*s Process %s%s\n", + pid_size, pid_size, "PID", (opt_flags & OPT_INODE) ? "Dev (Maj:Min) Inode" : (opt_flags & OPT_DEVICE) ? "Dev (Maj:Min)" : "Pathname", ts); for (j = 0; j < file_stats_size; j++) { if (top && j <= top) { char buf[5][32]; - printf("%s %s %s %s %s %5d %-15.15s %s\n", + printf("%s %s %s %s %s %*d %-15.15s %s\n", count_to_str(sorted[j]->total / dur, buf[0], sizeof(buf[0])), count_to_str(sorted[j]->open / dur, buf[1], sizeof(buf[1])), count_to_str(sorted[j]->close / dur, buf[2], sizeof(buf[2])), count_to_str(sorted[j]->read/ dur, buf[3], sizeof(buf[3])), count_to_str(sorted[j]->write / dur, buf[4], sizeof(buf[4])), - sorted[j]->pid, + pid_size, sorted[j]->pid, proc_info_get(sorted[j]->pid)->cmdline, (opt_flags & OPT_DIRNAME_STRIP) ? basename(sorted[j]->path) : sorted[j]->path); @@ -1112,7 +1155,7 @@ * show_usage() * how to use */ -void show_usage(void) +static void show_usage(void) { printf("%s, version %s\n\n", app_name, VERSION); printf("Options are:\n" @@ -1288,7 +1331,6 @@ while(!stop_fnotifystat) { fd_set rfds; - int ret; double remaining; if (gettimeofday(&tv2, NULL) < 0)