pull: changes to various utils
Subsystems (2)
cover pull: changes to various utils
Hello,
Here is collection of patches that hit various utilities all around source tree, and do not have any particular theme. These changes are also available from my github remote repository.
git://github.com/kerolasa/lelux-utiliteetit.git various
Sami Kerola (16):
whereis: tell when mandatory option is missing
flock: add --verbose option
flock: improve timeout handling
prlimit: tell in --verbose output which pid got the new limit
tunelp: remove get_val() in favour of strtol_or_err()
tunelp: remove unnecessary preprocessor directives lib/strutils: move parse_switch() from setterm(1) to library
tunelp: use parse_switch()
eject: use parse_switch()
rpmatch: use symbolic value when evaluation return codes
tailf: check printing criteria more carefully
tailf: count last lines correctly at initial print out
tailf: do not allow minus signed last lines argument
tailf: ensure file argument really is a file
logger: move /dev/log to pathnames.h
logger: fix -i argument parsing regression
disk-utils/fdisk.c | 2 +- disk-utils/fsck.minix.c | 6 +-- disk-utils/sfdisk.c | 2 +- include/Makemodule.am | 1 - include/pathnames.h | 3 ++ include/rpmatch.h | 4 ++ include/strutils.h | 2 + include/timer.h | 31 ----------- lib/strutils.c | 8 +++ login-utils/vipw.c | 2 +- misc-utils/logger.1 | 5 +- misc-utils/logger.c | 16 ++++-- misc-utils/whereis.c | 8 ++- sys-utils/Makemodule.am | 5 +- sys-utils/eject.c | 14 +---- sys-utils/flock.1 | 4 ++ sys-utils/flock.c | 82 +++++++++++++++++++++++++---- sys-utils/prlimit.c | 3 +- sys-utils/tunelp.c | 51 +++++------------- term-utils/mesg.c | 6 +-- term-utils/setterm.c | 14 ----- text-utils/tailf.c | 135 ++++++++++++++++++++++++++++-------------------- 22 files changed, 224 insertions(+), 180 deletions(-) delete mode 100644 include/timer.h
Signature · 1 line
2.3.0
PATCH 1/16 whereis: tell when mandatory option is missing
--- misc-utils/whereis.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
misc-utils/whereis.c +7 -1
@@ -495,7 +495,7 @@ int main(int argc, char **argv) {struct wh_dirlist *ls =NULL ;int want =ALL_DIRS ; -int i, want_resetable =0 ; +int i, want_resetable =0 , opt_f_missing =0 ;setlocale (LC_ALL ,"" );bindtextdomain (PACKAGE ,LOCALEDIR );
@@ -540,6 +540,7 @@ int main(int argc, char **argv)switch (*arg) {case 'f' : + opt_f_missing =0 ;break ;case 'u' : uflag =1 ;
@@ -551,6 +552,7 @@ int main(int argc, char **argv)free_dirlist (&ls,BIN_DIR );construct_dirlist_from_argv ( &ls, &i, argc, argv,BIN_DIR ); + opt_f_missing =1 ;break ;case 'M' :if (*(arg +1 ))
@@ -559,6 +561,7 @@ int main(int argc, char **argv)free_dirlist (&ls,MAN_DIR );construct_dirlist_from_argv ( &ls, &i, argc, argv,MAN_DIR ); + opt_f_missing =1 ;break ;case 'S' :if (*(arg +1 ))
@@ -567,6 +570,7 @@ int main(int argc, char **argv)free_dirlist (&ls,SRC_DIR );construct_dirlist_from_argv ( &ls, &i, argc, argv,SRC_DIR ); + opt_f_missing =1 ;break ;case 'b' :if (want_resetable) {
@@ -607,5 +611,7 @@ int main(int argc, char **argv) }free_dirlist (&ls,ALL_DIRS ); +if (opt_f_missing) +errx (EXIT_FAILURE ,_ ("option -f missing" ));return EXIT_SUCCESS ; }
Signature · 1 line
2.3.0
Re: [PATCH 01/16] whereis: tell when mandatory option is missing
Quoted 2 lines · Sami Kerola
misc-utils/whereis.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
But whereis works fine with a missing -f when some other option is given after -B or -M or -S. Example:
$ whereis -B /crap -bm when where whereis when: where: whereis: /usr/share/man/man1/whereis.1.gz
To break that with a complaint about a missing -f... Better not.
But when there's no intervening option, then it's good to report a missing -f -- at least, when there is more than one argument after the -B or -M or -S.
misc-utils/whereis.c int main(int argc, char **argv) · line 615
Quoted 2 lines
misc-utils/whereis.c +2
-0+if (opt_f_missing) +errx (EXIT_FAILURE ,_ ("option -f missing" ));
s/missing/is missing/
Benno
Signature · 1 line
http://www.fastmail.com - Send your email first class
Karel Zak
maintainerRe: [PATCH 01/16] whereis: tell when mandatory option is missing
In reply to Sami KerolaQuoted 2 lines · Sami Kerola
misc-utils/whereis.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Benno is right, see construct_dirlist_from_argv(), the dir list is terminated by arbitrary option, it checks for '-'.
The expected use-case is "<dirlist> <search-restriction> <pattern>", for example:
whereis -M /usr/share/man/man1 -m ls
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 01/16] whereis: tell when mandatory option is missing
Quoted 11 lines · Karel Zak
Quoted 2 lines · Sami Kerola
misc-utils/whereis.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)Benno is right, see
construct_dirlist_from_argv(), the dir list is terminated by arbitrary option, it checks for '-'.The expected use-case is "<dirlist> <search-restriction> <pattern>", for example:
whereis -M
/usr/share/man/man1-m ls
Hi Benno & Karel,
I see, most of the options has to flick the opt_f_missing. Here is updated version of the change.
https://github.com/kerolasa/lelux-utiliteetit/commit/ada8f7f0b253a031936519f7953629d701832444
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
Karel Zak
maintainerRe: [PATCH 01/16] whereis: tell when mandatory option is missing
Quoted 12 lines · Sami Kerola
Quoted 10 lines · Karel Zak
Quoted 2 lines · Sami Kerola
misc-utils/whereis.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)Benno is right, see
construct_dirlist_from_argv(), the dir list is terminated by arbitrary option, it checks for '-'.The expected use-case is "<dirlist> <search-restriction> <pattern>", for example:
Quoted 8 lines
Quoted 1 line
whereis -M
/usr/share/man/man1-m lsHi Benno & Karel,
I see, most of the options has to flick the
opt_f_missing. Here is updated version of the change.https://github.com/kerolasa/lelux-utiliteetit/commit/ada8f7f0b253a031936519f7953629d701832444
Did you update your "various" branch? I still see old patches on github. (And I'd like to "git pull" :-)
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 01/16] whereis: tell when mandatory option is missing
Quoted 2 lines · Karel Zak
Did you update your "various" branch? I still see old patches on github. (And I'd like to "git pull" :-)
I left the original branches as-is. Now when all has had enough time to have look of my github commits I'll rewrite the history where needed, and send update pull as various2, script2, more2, and so on branches. Since that's not a lot of work I assume to do the submission at evening (work is distracting hobbies).
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
Re: [PATCH 01/16] whereis: tell when mandatory option is missing
Quoted 9 lines · Sami Kerola
Quoted 2 lines · Karel Zak
Did you update your "various" branch? I still see old patches on github. (And I'd like to "git pull" :-)
I left the original branches as-is. Now when all has had enough time to have look of my github commits I'll rewrite the history where needed, and send update pull as various2, script2, more2, and so on branches. Since that's not a lot of work I assume to do the submission at evening (work is distracting hobbies).
The second versions of the four branches are available.
Fix to comment Benno mentioned is here. And of course I removed the earlier mistake addition to unrelated commit.
https://github.com/kerolasa/lelux-utiliteetit/commit/fc5097c31b7e5eb43e92e577b2b66c6fe66de240
Karel, your proposal to avoid unnecessary fopen() && fclose() pairs resulted to new commit
https://github.com/kerolasa/lelux-utiliteetit/commit/2a6f4ec60281bf69f1ac2d72d06752c376b78053
that is also below, but does not make the script2 branch quite ready. The HAVE_LIBUTEMPTER problem is still present.
Summary: the following two branches ought to be ready for merge:
git://github.com/kerolasa/lelux-utiliteetit.git rtcwake2
git://github.com/kerolasa/lelux-utiliteetit.git various2
p.s. Here's mail list review copy of commit 2a6f4ec6.
--->8----
From: Sami Kerola <[email protected]>
Date: Tue, 3 Mar 2015 22:06:01 +0000
Subject: [PATCH] script: move timing file opening close to use of it
This allows removing almost immediate closure of file handle in the doshell() function that does not use the file.
--- term-utils/script.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
term-utils/script.c +1 -0
@@ -90,6 +90,7 @@ struct script_control {char *cflg;/* command to be executed */ char *fname;/* output file path */ FILE *typescriptfp;/* output file pointer */ +char *tname;/* timing file path */ FILE *timingfp;/* timing file pointer */ struct timeval oldtime;/* previous write or command start time */ int master;/* pseudoterminal master file descriptor */
@@ -169,6 +170,9 @@ static void __attribute__((__noreturn__))
done(struct script_control *ctl)
else
exit(WEXITSTATUS(ctl->childstatus));
}
+ if (ctl->timingfp)
+ fclose(ctl->timingfp);
+ fclose(ctl->typescriptfp);
exit(EXIT_SUCCESS);}
@@ -271,8 +275,17 @@ static void do_io(struct script_control *ctl)
time_t tvec = time((time_t *)NULL);
char buf[128];- if (ctl->tflg && !ctl->timingfp)
- ctl->timingfp = fdopen(STDERR_FILENO, "w");
+ if ((ctl->typescriptfp = fopen(ctl->fname, ctl->aflg ? "a" :
"w")) == NULL) {
+ warn(_("cannot open %s"), ctl->fname);
+ fail(ctl);
+ }
+ if (ctl->tflg) {
+ if (!ctl->tname) {
+ if (!(ctl->timingfp = fopen("/dev/stderr", "w")))
+ err(EXIT_FAILURE, _("cannot open %s"), "/dev/stderr");
+ } else if (!(ctl->timingfp = fopen(ctl->tname, "w")))
+ err(EXIT_FAILURE, _("cannot open %s"), ctl->tname);
+ }
pfd[0].fd = STDIN_FILENO;
pfd[0].events = POLLIN;@@ -344,11 +357,6 @@ static void __attribute__((__noreturn__)) doshell(struct script_control *ctl)
/* close things irrelevant for this process */
close(ctl->master);- if (ctl->typescriptfp)
- fclose(ctl->typescriptfp);
- if (ctl->timingfp)
- fclose(ctl->timingfp);
- ctl->typescriptfp = ctl->timingfp = NULL;
dup2(ctl->slave, STDIN_FILENO);
dup2(ctl->slave, STDOUT_FILENO);
@@ -522,8 +530,8 @@ int main(int argc, char **argv)
ctl.qflg = 1;
break;
case 't':
- if (optarg && !(ctl.timingfp = fopen(optarg, "w")))
- err(EXIT_FAILURE, _("cannot open %s"), optarg);
+ if (optarg)
+ ctl.tname = optarg;
ctl.tflg = 1;
break;
case 'V':
@@ -546,11 +554,6 @@ int main(int argc, char **argv)
die_if_link(&ctl);
}- if ((ctl.typescriptfp = fopen(ctl.fname, ctl.aflg ? "a" : "w")) == NULL) {
- warn(_("cannot open %s"), ctl.fname);
- fail(&ctl);
- }
-
ctl.shell = getenv("SHELL");
if (ctl.shell == NULL)
ctl.shell = _PATH_BSHELL;Signature · 1 line
2.3.1
PATCH 2/16 flock: add --verbose option
In reply to Sami KerolaJenkins script jobs using flock are a great example of a situation in which one may want an automation to be verbose, so that when unexpected events happen there is more hints in logs.
--- sys-utils/Makemodule.am | 4 ++-- sys-utils/flock.1 | 4 ++++ sys-utils/flock.c | 33 ++++++++++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 5 deletions(-)
sys-utils/Makemodule.am +2 -2
@@ -1,8 +1,8 @@ if BUILD_FLOCK usrbin_exec_PROGRAMS += flock dist_man_MANS += sys-utils/flock.1 -flock_SOURCES = sys-utils/flock.c -flock_LDADD = $(LDADD) libcommon.la +flock_SOURCES = sys-utils/flock.c lib/monotonic.c +flock_LDADD = $(LDADD) libcommon.la $(CLOCKGETTIME_LIBS) endif if BUILD_IPCMK
sys-utils/flock.1 +4 -0
@@ -107,6 +107,10 @@ option for the exit code used. The zero number of .IR seconds is interpreted as \fB\-\-nonblock\fR. .TP +.B \-\-verbose +Tell why lock could not be got, and when it can be how long did it take +to acquire the lock. +.TP .BR \-V , " \-\-version" Display version information and exit. .TP
sys-utils/flock.c +30 -3
@@ -44,6 +44,7 @@#include "strutils.h" #include "closestream.h" #include "timer.h" +#include "monotonic.h" static void __attribute__((__noreturn__))usage (int ex) {
@@ -66,6 +67,7 @@ static void __attribute__((__noreturn__)) usage(int ex)fputs (_ (" -E, --conflict-exit-code <number> exit code after conflict or timeout\n" ), stderr);fputs (_ (" -o, --close close file descriptor before running command\n" ), stderr);fputs (_ (" -c, --command <command> run a single command string through the shell\n" ), stderr); +fputs (_ (" --verbose increase verbosity\n" ), stderr);fprintf (stderr,USAGE_SEPARATOR );fprintf (stderr,USAGE_HELP );fprintf (stderr,USAGE_VERSION );
@@ -120,6 +122,8 @@ int main(int argc, char *argv[])int opt, ix;int do_close =0 ;int status; +int verbose =0 ; +struct timeval time_start, time_done;/* * The default exit code for lock conflict or timeout * is specified in man flock.1
@@ -128,7 +132,9 @@ int main(int argc, char *argv[])char **cmd_argv =NULL , *sh_c_argv[4 ];const char *filename =NULL ;struct sigaction old_sa; - +enum { +OPT_VERBOSE =CHAR_MAX +1 + };static const struct option long_options[] = { {"shared" , no_argument,NULL ,'s' }, {"exclusive" , no_argument,NULL ,'x' },
@@ -139,8 +145,9 @@ int main(int argc, char *argv[]) {"wait", required_argument, NULL, 'w'}, {"conflict-exit-code", required_argument, NULL, 'E'}, {"close", no_argument, NULL, 'o'}, + {"verbose", no_argument, NULL, OPT_VERBOSE}, {"help", no_argument, NULL, 'h'}, - {"version", no_argument, NULL, 'V'}, + {"version", required_argument, NULL, 'V'}, {NULL, 0, NULL, 0} };
@@ -184,6 +191,9 @@ int main(int argc, char *argv[]) conflict_exit_code =strtos32_or_err (optarg,_ ("invalid exit code" ));break ; +case OPT_VERBOSE : + verbose =1 ; +break ;case 'V' :printf (UTIL_LINUX_VERSION );exit (EX_OK );
@@ -239,16 +249,23 @@ int main(int argc, char *argv[])setup_timer (&timeout, &old_timer, &old_sa, timeout_handler); } +if (verbose) +gettime_monotonic (&time_start);while (flock (fd, type | block)) {switch (errno) {case EWOULDBLOCK :/* -n option set and failed to lock. */ +if (verbose) +warnx (_ ("failed to get lock" ));exit (conflict_exit_code);case EINTR :/* Signal received */ -if (timeout_expired) +if (timeout_expired) {/* -w option set and failed to lock. */ +if (verbose) +warnx (_ ("timeout while waiting to get lock" ));exit (conflict_exit_code); + }/* otherwise try again */ continue ;case EIO :
@@ -282,13 +299,23 @@ int main(int argc, char *argv[])if (have_timeout)cancel_timer (&old_timer, &old_sa); +if (verbose) { +struct timeval delta; +gettime_monotonic (&time_done); +timersub (&time_done, &time_start, &delta); +printf (_ ("%s: getting lock took %ld.%06ld seconds\n" ), + program_invocation_short_name, delta.tv_sec, + delta.tv_usec); + } status =EX_OK ;if (cmd_argv) {pid_t w, f;/* Clear any inherited settings */ signal (SIGCHLD ,SIG_DFL ); +if (verbose) +printf (_ ("%s: executing %s\n" ), program_invocation_short_name, cmd_argv[2 ]); f =fork ();if (f <0 ) {
Signature · 1 line
2.3.0
Re: [PATCH 02/16] flock: add --verbose option
sys-utils/flock.1 option for the exit code used. The zero number of · line 112
Quoted 3 lines · Sami Kerola
+.B \-\-verbose
sys-utils/flock.1 +2
-0+Tell why lock could not be got, and when it can be how long did it take +to acquire the lock.
Better: "Report how long it took to acquire the lock, or why the lock could not be obtained."
sys-utils/flock.c int main(int argc, char *argv[]) · line 150
Quoted 2 lines
sys-utils/flock.c +1
-1- {"version", no_argument, NULL, 'V'}, + {"version", required_argument, NULL, 'V'},
Huh?
Benno
Signature · 1 line
http://www.fastmail.com - mmm... Fastmail...
Re: [PATCH 02/16] flock: add --verbose option
Quoted 8 lines · Benno Schulenberg
sys-utils/flock.1 option for the exit code used. The zero number of · line 112
Quoted 3 lines · Sami Kerola
+.B \-\-verbose
sys-utils/flock.1 +2
-0+Tell why lock could not be got, and when it can be how long did it take +to acquire the lock.Better: "Report how long it took to acquire the lock, or why the lock could not be obtained."
Quoted 4 lines
sys-utils/flock.c int main(int argc, char *argv[]) · line 150
Quoted 2 lines
sys-utils/flock.c +1
-1- {"version", no_argument, NULL, 'V'}, + {"version", required_argument, NULL, 'V'},Huh?
Thanks Benno,
Wording is updated, and --version option argument reuirement reverted. To be honest I have no idea how that error slipped to change, excellent you noticed it.
https://github.com/kerolasa/lelux-utiliteetit/commit/f1cb67206af5e6b46ba10b482d3c315c484082d6
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
PATCH 3/16 flock: improve timeout handling
In reply to Sami KerolaSignal ALRM raised by the timer, and the timer only, will be considered as a timeout criteria.
Secondly time interval is made to use monotonic clock. Documentation of ITIMER_REAL is unclear whether that time is affected various sources of clock skew, or does it even tick when system is suspended.
This code is moved from libcommon.la to flock.c because of two reasons. This is the only utility using the function, and setup_timer() along with cancel_timer() need to be linked with -lrt option.
--- include/Makemodule.am | 1 - include/timer.h | 31 ------------------------------- sys-utils/Makemodule.am | 2 +- sys-utils/flock.c | 49 ++++++++++++++++++++++++++++++++++++++++++------- 4 files changed, 43 insertions(+), 40 deletions(-) delete mode 100644 include/timer.h
include/Makemodule.am +0 -1
@@ -44,7 +44,6 @@ dist_noinst_HEADERS += \ include/swapprober.h \ include/swapheader.h \ include/sysfs.h \ - include/timer.h \ include/timeutils.h \ include/ttyutils.h \ include/widechar.h \
include/timer.h deleted +0 -31
@@ -1,31 +0,0 @@ -#ifndef UTIL_LINUX_TIMER_H -#define UTIL_LINUX_TIMER_H - -#include <signal.h> -#include <sys/time.h> - -static inline int setup_timer ( -struct itimerval *timer, -struct itimerval *old_timer, -struct sigaction *old_sa, -void (*timeout_handler)(int )) -{ -struct sigaction sa; - -memset (&sa,0 ,sizeof sa); - sa.sa_handler = timeout_handler; - sa.sa_flags =SA_RESETHAND ; -sigaction (SIGALRM , &sa, old_sa); - -return setitimer (ITIMER_REAL , timer, old_timer); -} - -static inline void cancel_timer ( -struct itimerval *old_timer, -struct sigaction *old_sa) -{ -setitimer (ITIMER_REAL , old_timer,NULL ); -sigaction (SIGALRM , old_sa,NULL ); -} - -#endif
sys-utils/Makemodule.am +1 -1
@@ -2,7 +2,7 @@ if BUILD_FLOCK usrbin_exec_PROGRAMS += flock dist_man_MANS += sys-utils/flock.1 flock_SOURCES = sys-utils/flock.c lib/monotonic.c -flock_LDADD = $(LDADD) libcommon.la $(CLOCKGETTIME_LIBS) +flock_LDADD = $(LDADD) libcommon.la -lrt endif if BUILD_IPCMK
sys-utils/flock.c +42 -7
88 lines not on this page · raw message
Signature · 1 line
2.3.0
Karel Zak
maintainerRe: [PATCH 03/16] flock: improve timeout handling
Quoted 6 lines · Sami Kerola
Signal ALRM raised by the timer, and the timer only, will be considered as a timeout criteria.
Secondly time interval is made to use monotonic clock. Documentation of
ITIMER_REALis unclear whether that time is affected various sources of clock skew, or does it even tick when system is suspended.
I agree, setitimer() API is also obsolete.
Quoted 3 lines
This code is moved from libcommon.la to
flock.cbecause of two reasons. This is the only utility using the function, andsetup_timer()along withcancel_timer()need to be linked with -lrt option.
Hmm... yes, it's used by flock only, but I still think it would be better to keep it in common lib/ code. Maybe we can use the timers on another places later (uuidd, login, sulogin, ...).
What about to keep all -lrt stuff in lib/monotonic.c?
sys-utils/Makemodule.am if BUILD_FLOCK · line 5
Quoted 8 lines
sys-utils/Makemodule.am +1
-1@@ -2,7 +2,7 @@ if BUILD_FLOCK usrbin_exec_PROGRAMS += flock dist_man_MANS += sys-utils/flock.1 flock_SOURCES = sys-utils/flock.c lib/monotonic.c -flock_LDADD = $(LDADD) libcommon.la $(CLOCKGETTIME_LIBS) +flock_LDADD = $(LDADD) libcommon.la -lrt
Don't use -l<foo> in Makefiles, always use $(FOO) and initialize the variable in ./configure, $(CLOCKGETTIME_LIBS) is fine (although the name of the variable is not perfect in this context).
sys-utils/Makemodule.am if BUILD_FLOCK
Quoted 8 lines
sys-utils/Makemodule.am +5
-1+static void timeout_handler(int sig __attribute__((__unused__)), + siginfo_t *info, + void *context __attribute__((__unused__))) { - timeout_expired = 1; + if (info->si_code == SI_TIMER) + timeout_expired = 1; }
BTW, it mean that "kill -ALRM" does not force the program to set timeout_expired, right? Nice.
Quoted 1 line
+static int
setup_timer(timer_t *t_id, struct itimerval *timeout)
if you move it to lib/ than add a pointer to timeout_handler() too
Anyway, it seems more elegant than the previous implementation.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 03/16] flock: improve timeout handling
Quoted 14 lines · Karel Zak
Quoted 6 lines · Sami Kerola
Signal ALRM raised by the timer, and the timer only, will be considered as a timeout criteria.
Secondly time interval is made to use monotonic clock. Documentation of
ITIMER_REALis unclear whether that time is affected various sources of clock skew, or does it even tick when system is suspended.I agree,
setitimer()API is also obsolete.Quoted 3 lines
This code is moved from libcommon.la to
flock.cbecause of two reasons. This is the only utility using the function, andsetup_timer()along withcancel_timer()need to be linked with -lrt option.
Quoted 5 lines
Hmm... yes, it's used by flock only, but I still think it would be better to keep it in common
lib/code. Maybe we can use the timers on another places later (uuidd, login, sulogin, ...).What about to keep all -lrt stuff in
lib/monotonic.c?
Thanks Karel,
Moving to monotonic sounds good to me. Notice that there is linking change in configure.ac making monotonic.c to be linked with -lrt even when clock_gettime() would not require it. The timer_create() requires -lrt at last for now.
https://github.com/kerolasa/lelux-utiliteetit/commit/50425160a825986abb4e9c22ef8acee8e7b34834
Quoted 4 lines
Quoted 4 lines
sys-utils/Makemodule.am +0
-0@@ -2,7 +2,7 @@ if BUILD_FLOCK usrbin_exec_PROGRAMS += flock
Quoted 8 lines
sys-utils/Makemodule.am if BUILD_FLOCK · line 5
Quoted 4 lines
sys-utils/Makemodule.am +1
-1dist_man_MANS += sys-utils/flock.1 flock_SOURCES = sys-utils/flock.c lib/monotonic.c -flock_LDADD = $(LDADD) libcommon.la $(CLOCKGETTIME_LIBS) +flock_LDADD = $(LDADD) libcommon.la -lrtDon't use -l<foo> in Makefiles, always use $(FOO) and initialize the variable in ./configure, $(CLOCKGETTIME_LIBS) is fine (although the name of the variable is not perfect in this context).
TODO:
s/CLOCKGETTIME_LIBS/UL_REALTIME_LIBS/
Better?
Quoted 11 lines
sys-utils/Makemodule.am if BUILD_FLOCK
Quoted 8 lines
sys-utils/Makemodule.am +5
-1+static void timeout_handler(int sig __attribute__((__unused__)), + siginfo_t *info, + void *context __attribute__((__unused__))) { - timeout_expired = 1; + if (info->si_code == SI_TIMER) + timeout_expired = 1; }BTW, it mean that "kill -ALRM" does not force the program to set
timeout_expired, right? Nice.
Correct. After the change flock(1) cannot be forced to timeout by sending an ALRM signal. Is that good, bad, or possible regression is debatable. I think allowing external signals to cause timeout is unintented behavior. If someone requires external timeouts then adding an option to allow them is justified.
Quoted 5 lines
Quoted 1 line
+static int
setup_timer(timer_t *t_id, struct itimerval *timeout)if you move it to
lib/than add a pointer totimeout_handler()tooAnyway, it seems more elegant than the previous implementation.
Function pointer is added.
https://github.com/kerolasa/lelux-utiliteetit/commit/50425160a825986abb4e9c22ef8acee8e7b34834
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
Karel Zak
maintainerRe: [PATCH 03/16] flock: improve timeout handling
Quoted 6 lines · Sami Kerola
Moving to monotonic sounds good to me. Notice that there is linking change in configure.ac making
monotonic.cto be linked with -lrt even whenclock_gettime()would not require it. Thetimer_create()requires -lrt at last for now.https://github.com/kerolasa/lelux-utiliteetit/commit/50425160a825986abb4e9c22ef8acee8e7b34834
OK.
Quoted 3 lines
s/CLOCKGETTIME_LIBS/UL_REALTIME_LIBS/
Better?
Yeah.
Quoted 3 lines
Correct. After the change flock(1) cannot be forced to timeout by sending an ALRM signal. Is that good, bad, or possible regression is debatable. I think allowing external signals to cause timeout is unintented behavior.
I think it's better to split signals and timers.
Quoted 3 lines
Function pointer is added.
https://github.com/kerolasa/lelux-utiliteetit/commit/50425160a825986abb4e9c22ef8acee8e7b34834
You forgot to update commit message ("This code is moved ...").
Anyway, looks good.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Karel Zak
maintainerRe: [PATCH 03/16] flock: improve timeout handling
In reply to Sami Kerolasys-utils/flock.c static int open_file(const char *filename, int *flags) · line 133
Quoted 2 lines · Sami Kerola
sys-utils/flock.c +2
-0+ sig_a.sa_flags =SA_SIGINFO ; + sig_a.sa_handler = (void (*)(int ))timeout_handler;
man sigaction:
If SA_SIGINFO is specified in sa_flags, then sa_sigaction (instead of sa_handler) specifies the signal-handling function for signum.
I'll fix it...
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 4/16 prlimit: tell in --verbose output which pid got the new limit
In reply to Sami Kerola--- sys-utils/prlimit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sys-utils/prlimit.c +2 -1
@@ -360,7 +360,8 @@ static void do_prlimit(struct list_head *lims) old = &lim->rlim;if (verbose && new) { -printf (_ ("New %s limit: " ), lim->desc->name); +printf (_ ("New %s limit for pid %d: " ), lim->desc->name, + pid ? pid :getpid ());if (new->rlim_cur ==RLIM_INFINITY )printf ("<%s" ,_ ("unlimited" ));else
Signature · 1 line
2.3.0
Re: [PATCH 04/16] prlimit: tell in --verbose output which pid got the new limit
Quoted 2 lines · Sami Kerola
sys-utils/prlimit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 5/16 tunelp: remove get_val() in favour of strtol_or_err()
In reply to Sami Kerola--- sys-utils/Makemodule.am | 1 + sys-utils/tunelp.c | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-)
sys-utils/Makemodule.am +1 -0
@@ -50,6 +50,7 @@ if BUILD_TUNELP usrsbin_exec_PROGRAMS += tunelp dist_man_MANS += sys-utils/tunelp.8 tunelp_SOURCES = sys-utils/tunelp.c sys-utils/lp.h +tunelp_LDADD = $(LDADD) libcommon.la endif if BUILD_FSTRIM
sys-utils/tunelp.c +8 -14
@@ -74,8 +74,10 @@#include "xalloc.h" #include "closestream.h" -#define EXIT_BAD_VALUE 3 -#define EXIT_LP_IO_ERR 4 +#define STRTOXX_EXIT_CODE 3 +#define EXIT_LP_IO_ERR 4 + +#include "strutils.h" struct command {long op;
@@ -114,14 +116,6 @@ static void __attribute__((__noreturn__)) print_usage(FILE *out)exit (out == stderr ?EXIT_FAILURE :EXIT_SUCCESS ); } -static long get_val (char *val) -{ -long ret; -if (!(sscanf (val,"%ld" , &ret) ==1 )) -errx (EXIT_BAD_VALUE ,_ ("bad value" )); -return ret; -} -static long get_onoff (char *val) {if (!strncasecmp ("on" , val,2 ))
@@ -171,28 +165,28 @@ int main(int argc, char **argv)break ;case 'i' : cmds->op =LPSETIRQ ; - cmds->val =get_val (optarg); + cmds->val =strtol_or_err (optarg,_ ("argument error" )); cmds->next =xmalloc (sizeof (struct command )); cmds = cmds->next; cmds->next =0 ;break ;case 't' : cmds->op =LPTIME ; - cmds->val =get_val (optarg); + cmds->val =strtol_or_err (optarg,_ ("argument error" )); cmds->next =xmalloc (sizeof (struct command )); cmds = cmds->next; cmds->next =0 ;break ;case 'c' : cmds->op =LPCHAR ; - cmds->val =get_val (optarg); + cmds->val =strtol_or_err (optarg,_ ("argument error" )); cmds->next =xmalloc (sizeof (struct command )); cmds = cmds->next; cmds->next =0 ;break ;case 'w' : cmds->op =LPWAIT ; - cmds->val =get_val (optarg); + cmds->val =strtol_or_err (optarg,_ ("argument error" )); cmds->next =xmalloc (sizeof (struct command )); cmds = cmds->next; cmds->next =0 ;
Signature · 1 line
2.3.0
Re: [PATCH 05/16] tunelp: remove get_val() in favour of strtol_or_err()
Quoted 3 lines · Sami Kerola
sys-utils/Makemodule.am | 1 + sys-utils/tunelp.c | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 6/16 tunelp: remove unnecessary preprocessor directives
In reply to Sami KerolaThe lp.h included earlier in the tunelp.c has the definitions that were checked, so these statements could have not been false and such impossible conditions does not need to be checked.
--- sys-utils/tunelp.c | 8 -------- 1 file changed, 8 deletions(-)
sys-utils/tunelp.c +0 -8
@@ -205,7 +205,6 @@ int main(int argc, char **argv) show_irq =0 ; }break ; -#ifdef LPGETSTATUS case 'o' : cmds->op =LPABORTOPEN ; cmds->val =get_onoff (optarg);
@@ -228,8 +227,6 @@ int main(int argc, char **argv) cmds = cmds->next; cmds->next =0 ;break ; -#endif -#ifdef LPRESET case 'r' : cmds->op =LPRESET ; cmds->val =0 ;
@@ -237,8 +234,6 @@ int main(int argc, char **argv) cmds = cmds->next; cmds->next =0 ;break ; -#endif -#ifdef LPTRUSTIRQ case 'T' :/* Note: this will do the wrong thing on * 2.0.36 when compiled under 2.2.x
@@ -249,7 +244,6 @@ int main(int argc, char **argv) cmds = cmds->next; cmds->next =0 ;break ; -#endif case 'v' :case 'V' :printf (UTIL_LINUX_VERSION );
@@ -290,7 +284,6 @@ int main(int argc, char **argv) cmds = cmdst;while (cmds->next) { -#ifdef LPGETSTATUS if (cmds->op ==LPGETSTATUS ) { status =0xdeadbeef ; retval =ioctl (fd,LPGETSTATUS - offset, &status);
@@ -314,7 +307,6 @@ int main(int argc, char **argv)printf ("\n" ); } }else -#endif /* LPGETSTATUS */ if (ioctl (fd, cmds->op - offset, cmds->val) <0 )warn (_ ("ioctl failed" )); cmdst = cmds;
Signature · 1 line
2.3.0
PATCH 7/16 lib/strutils: move parse_switch() from setterm(1) to library
In reply to Sami KerolaTo allow sharing the code with other utilities.
--- include/strutils.h | 2 ++ lib/strutils.c | 8 ++++++++ term-utils/setterm.c | 14 -------------- 3 files changed, 10 insertions(+), 14 deletions(-)
include/strutils.h +2 -0
@@ -36,6 +36,8 @@ extern void strtotimeval_or_err(const char *str, struct timeval *tv,extern int isdigit_string (const char *str); +extern int parse_switch (const char *arg,const char *a,const char *b); +#ifndef HAVE_MEMPCPY extern void *mempcpy (void *restrict dest,const void *restrict src,size_t n);#endif
lib/strutils.c +8 -0
@@ -181,6 +181,14 @@ int isdigit_string(const char *str)return p && p > str && !*p; } +int parse_switch (const char *arg,const char *a,const char *b) +{ +if (strcmp (arg, a) ==0 ) +return 1 ; +else if (strcmp (arg, b) ==0 ) +return 0 ; +errx (STRTOXX_EXIT_CODE ,_ ("argument error: %s" ), arg); +}#ifndef HAVE_MEMPCPY void *mempcpy (void *restrict dest,const void *restrict src,size_t n)
term-utils/setterm.c +0 -14
@@ -178,20 +178,6 @@ struct setterm_control { opt_powerdown:1, opt_blength:1, opt_bfreq:1; }; -/* Command line parsing routines. -* -* Note that it is an error for a given option to be invoked more than once. -*/ - -static int parse_switch (const char *arg,const char *t,const char *f) -{ -if (strcmp (arg, t) ==0 ) -return 1 ; -else if (strcmp (arg, f) ==0 ) -return 0 ; -errx (EXIT_FAILURE ,_ ("argument error: %s" ), arg); -} -static int parse_febg_color (const char *arg) {int color;
Signature · 1 line
2.3.0
Re: [PATCH 07/16] lib/strutils: move parse_switch() from setterm(1) to library
Quoted 2 lines · Sami Kerola
-/* Command line parsing routines.
- *
When removing this comment, please also remove its companion:
/* End of command line parsing routines. */
(It would have been needed anyway, since the usage() routine has intruded.)
Benno
Signature · 1 line
http://www.fastmail.com - Access your email from home and the web
Karel Zak
maintainerRe: [PATCH 07/16] lib/strutils: move parse_switch() from setterm(1) to library
In reply to Sami KerolaQuoted 4 lines · Sami Kerola
include/strutils.h | 2 ++ lib/strutils.c | 8 ++++++++ term-utils/setterm.c | 14 -------------- 3 files changed, 10 insertions(+), 14 deletions(-)
Applied (and removed the extra comment as suggested by Benno), thanks.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 8/16 tunelp: use parse_switch()
In reply to Sami Kerola--- sys-utils/tunelp.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
sys-utils/tunelp.c +5 -16
@@ -116,13 +116,6 @@ static void __attribute__((__noreturn__)) print_usage(FILE *out)exit (out == stderr ?EXIT_FAILURE :EXIT_SUCCESS ); } -static long get_onoff (char *val) -{ -if (!strncasecmp ("on" , val,2 )) -return 1 ; -return 0 ; -} -int main (int argc,char **argv) {int c, fd, irq, status, show_irq, offset =0 , retval;
@@ -193,28 +186,24 @@ int main(int argc, char **argv)break ;case 'a' : cmds->op =LPABORT ; - cmds->val =get_onoff (optarg); + cmds->val =parse_switch (optarg,"on" ,"off" ); cmds->next =xmalloc (sizeof (struct command )); cmds = cmds->next; cmds->next =0 ;break ;case 'q' : -if (get_onoff (optarg)) { - show_irq =1 ; - }else { - show_irq =0 ; - } + show_irq =parse_switch (optarg,"on" ,"off" );break ;case 'o' : cmds->op =LPABORTOPEN ; - cmds->val =get_onoff (optarg); + cmds->val =parse_switch (optarg,"on" ,"off" ); cmds->next =xmalloc (sizeof (struct command )); cmds = cmds->next; cmds->next =0 ;break ;case 'C' : cmds->op =LPCAREFUL ; - cmds->val =get_onoff (optarg); + cmds->val =parse_switch (optarg,"on" ,"off" ); cmds->next =xmalloc (sizeof (struct command )); cmds = cmds->next; cmds->next =0 ;
@@ -239,7 +228,7 @@ int main(int argc, char **argv)* 2.0.36 when compiled under 2.2.x */ cmds->op =LPTRUSTIRQ ; - cmds->val =get_onoff (optarg); + cmds->val =parse_switch (optarg,"on" ,"off" ); cmds->next =xmalloc (sizeof (struct command )); cmds = cmds->next; cmds->next =0 ;
Signature · 1 line
2.3.0
Re: [PATCH 08/16] tunelp: use parse_switch()
Quoted 2 lines · Sami Kerola
sys-utils/tunelp.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
Applied, thanks.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 9/16 eject: use parse_switch()
In reply to Sami Kerola--- sys-utils/eject.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
sys-utils/eject.c +2 -12
@@ -202,12 +202,7 @@ static void parse_args(struct eject_control *ctl, int argc, char **argv)switch (c) {case 'a' : ctl->a_option =1 ; -if (!strcmp (optarg,"0" ) || !strcmp (optarg,"off" )) - ctl->a_arg =0 ; -else if (!strcmp (optarg,"1" ) || !strcmp (optarg,"on" )) - ctl->a_arg =1 ; -else -errx (EXIT_FAILURE ,_ ("invalid argument to --auto/-a option" )); + ctl->a_arg =parse_switch (optarg,"on" ,"off" );break ;case 'c' : ctl->c_option =1 ;
@@ -231,12 +226,7 @@ static void parse_args(struct eject_control *ctl, int argc, char **argv)break ;case 'i' : ctl->i_option =1 ; -if (!strcmp (optarg,"0" ) || !strcmp (optarg,"off" )) - ctl->i_arg =0 ; -else if (!strcmp (optarg,"1" ) || !strcmp (optarg,"on" )) - ctl->i_arg =1 ; -else -errx (EXIT_FAILURE ,_ ("invalid argument to --manualeject/-i option" )); + ctl->i_arg =parse_switch (optarg,"on" ,"off" );break ;case 'm' : ctl->m_option =1 ;
Signature · 1 line
2.3.0
Karel Zak
maintainerRe: [PATCH 09/16] eject: use parse_switch()
sys-utils/eject.c static void parse_args(struct eject_control *ctl, int argc, char **argv) · line 205
Quoted 9 lines · Sami Kerola
sys-utils/eject.c +1
-6case 'a' : ctl->a_option =1 ; -if (!strcmp (optarg,"0" ) || !strcmp (optarg,"off" )) - ctl->a_arg =0 ; -else if (!strcmp (optarg,"1" ) || !strcmp (optarg,"on" )) - ctl->a_arg =1 ; -else -errx (EXIT_FAILURE ,_ ("invalid argument to --auto/-a option" )); + ctl->a_arg =parse_switch (optarg,"on" ,"off" );
I have extended parse_switch() to accept arbitrary number of 1|0 pairs and also error message, so:
ctl->a_arg = parse_switch(optarg, _("argument error"),
"on", "off", "1", "0", NULL);
Idea: maybe we can remove all the _("argument error") strings from all strtoxxx_ functions and use some global function to generate proper user friendly error messages from longopts[], something like:
while ((c = getopt_long(argc, argv, "a:b:", longopts, NULL)) != -1) {
err_strtoxxx_set_options(c, longopts); <--- !!!
switch (c) {
case 'a':
foo = strtol_or_err(optarg);
break;
case 'b':
bar = parse_switch(optarg, "on", "off", NULL);
break;
}
}where err_strtoxxx_set_options() sets in strutils.c static
ul_cur_option = c;
ul_lonfopts = longopts;then on error strtol_or_err() and parse_switch() will use the ul_ variables to print
"invalid argument to --auto/-a: %s", optarg
and if ul_* are not initialized then something generic ("argument error"). The result will be less code in main(), better error messages, and code independent on the names of the options.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 09/16] eject: use parse_switch()
Quoted 43 lines · Karel Zak
sys-utils/eject.c static void parse_args(struct eject_control *ctl, int argc, char **argv) · line 205
Quoted 9 lines · Sami Kerola
sys-utils/eject.c +1
-6case 'a' : ctl->a_option =1 ; -if (!strcmp (optarg,"0" ) || !strcmp (optarg,"off" )) - ctl->a_arg =0 ; -else if (!strcmp (optarg,"1" ) || !strcmp (optarg,"on" )) - ctl->a_arg =1 ; -else -errx (EXIT_FAILURE ,_ ("invalid argument to --auto/-a option" )); + ctl->a_arg =parse_switch (optarg,"on" ,"off" );I have extended
parse_switch()to accept arbitrary number of 1|0 pairs and also error message, so:
ctl->a_arg= parse_switch(optarg,_("argument error"),"on", "off", "1", "0", NULL);Idea: maybe we can remove all the
_("argument error")strings from allstrtoxxx_functions and use some global function to generate proper user friendly error messages from longopts[], something like:while ((c =
getopt_long(argc, argv, "a:b:", longopts, NULL)) != -1) {err_strtoxxx_set_options(c, longopts); <--- !!! switch (c) { case 'a': foo = strtol_or_err(optarg); break; case 'b': bar = parse_switch(optarg, "on", "off", NULL); break; } }where
err_strtoxxx_set_options()sets instrutils.cstaticul_cur_option = c; ul_lonfopts = longopts;
Quoted 8 lines
then on error
strtol_or_err()andparse_switch()will use theul_variables to print"invalid argument to --auto/-a: %s", optargand if ul_* are not initialized then something generic ("argument error"). The result will be less code in
main(), better error messages, and code independent on the names of the options.
Thanks Karel,
Updated version of parse_switch() is now in use in 'tunelp: use parse_switch()' change.
https://github.com/kerolasa/lelux-utiliteetit/commit/d5ea22b18085c8a16621bc2e2cf45200afe3fe9c
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
PATCH 10/16 rpmatch: use symbolic value when evaluation return codes
In reply to Sami Kerola--- disk-utils/fdisk.c | 2 +- disk-utils/fsck.minix.c | 6 +++--- disk-utils/sfdisk.c | 2 +- include/rpmatch.h | 4 ++++ login-utils/vipw.c | 2 +- term-utils/mesg.c | 6 +++--- 6 files changed, 13 insertions(+), 9 deletions(-)
disk-utils/fdisk.c +1 -1
@@ -347,7 +347,7 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask,if (rc)break ; x =rpmatch (buf); -if (x ==1 || x ==0 ) { +if (x ==RPMATCH_YES || x ==RPMATCH_NO ) {fdisk_ask_yesno_set_result (ask, x);break ; }
disk-utils/fsck.minix.c +3 -3
@@ -269,11 +269,11 @@ ask(const char *string, int def) {ignore_result (fgets (input,YESNO_LENGTH , stdin) ); resp =rpmatch (input);switch (resp) { -case -1 : +case RPMATCH_INVALID :/* def = def */ break ; -case 0 : -case 1 : +case RPMATCH_NO : +case RPMATCH_YES : def = resp;break ;default :
disk-utils/sfdisk.c +1 -1
@@ -167,7 +167,7 @@ static int ask_callback(struct fdisk_context *cxt,if (rc)break ; x =rpmatch (buf); -if (x ==1 || x ==0 ) { +if (x ==RPMATCH_YES || x ==RPMATCH_NO ) {fdisk_ask_yesno_set_result (ask, x);break ; }
include/rpmatch.h +4 -0
@@ -6,4 +6,8 @@ (*r == 'y' || *r == 'Y' ? 1 : *r == 'n' || *r == 'N' ? 0 : -1)#endif +#define RPMATCH_YES 1 +#define RPMATCH_NO 0 +#define RPMATCH_INVALID -1 +#endif /* UTIL_LINUX_RPMATCH_H */
login-utils/vipw.c +1 -1
@@ -352,7 +352,7 @@ int main(int argc, char *argv[])printf (_ ("Would you like to edit %s now [y/n]? " ), orig_file);if (fgets (response,sizeof (response), stdin)) { -if (rpmatch (response) ==1 ) +if (rpmatch (response) ==RPMATCH_YES )edit_file (1 ); } }
term-utils/mesg.c +3 -3
@@ -137,7 +137,7 @@ int main(int argc, char *argv[]) }switch (rpmatch (argv[0 ])) { -case 1 : +case RPMATCH_YES :#ifdef USE_TTY_GROUP if (chmod (tty, sb.st_mode |S_IWGRP ) <0 ) #else
@@ -147,13 +147,13 @@ int main(int argc, char *argv[])if (verbose)puts (_ ("write access to your terminal is allowed" ));return IS_ALLOWED ; -case 0 : +case RPMATCH_NO :if (chmod (tty, sb.st_mode & ~(S_IWGRP |S_IWOTH )) <0 )err (MESG_EXIT_FAILURE ,_ ("change %s mode failed" ), tty);if (verbose)puts (_ ("write access to your terminal is denied" ));return IS_NOT_ALLOWED ; -case -1 : +case RPMATCH_INVALID :warnx (_ ("invalid argument: %s" ), argv[0 ]);usage (stderr);default :
Signature · 1 line
2.3.0
Re: [PATCH 10/16] rpmatch: use symbolic value when evaluation return codes
Quoted 7 lines · Sami Kerola
disk-utils/fdisk.c | 2 +- disk-utils/fsck.minix.c | 6 +++--- disk-utils/sfdisk.c | 2 +- include/rpmatch.h | 4 ++++ login-utils/vipw.c | 2 +- term-utils/mesg.c | 6 +++--- 6 files changed, 13 insertions(+), 9 deletions(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 11/16 tailf: check printing criteria more carefully
In reply to Sami KerolaEarlier size check did not print out contents of a file if it happen to be same size as last time roll_file() function ran. The earlier buggy behavior was easy to reproduce with two terminal windows. Contents of the second echo were not visible.
term1> tailf /tmp/tailf-test
terminal2> echo 1 >| /tmp/tailf-test
terminal2> echo 2 >| /tmp/tailf-test
In this commit also a mount point and a file changes are detected, leading to full printout of a file in such cases.
--- text-utils/tailf.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
text-utils/tailf.c +17 -14
@@ -86,7 +86,7 @@ tailf(const char *filename, int lines) }static void -roll_file (const char *filename,off_t *size) +roll_file (const char *filename,struct stat *old) {char buf[BUFSIZ ];int fd;
@@ -100,12 +100,17 @@ roll_file(const char *filename, off_t *size)if (fstat (fd, &st) ==-1 )err (EXIT_FAILURE ,_ ("stat of %s failed" ), filename); -if (st.st_size == *size) { +if (st.st_size == old->st_size && st.st_mtime == old->st_mtime && + st.st_ino == old->st_ino && st.st_dev == old->st_dev) {close (fd);return ; } -if (lseek (fd, *size,SEEK_SET ) != (off_t)-1 ) { +if (st.st_ino != old->st_ino || st.st_dev != old->st_dev + || (old->st_mtime < st.st_mtime && st.st_size <= old->st_size)) + old->st_size =0 ; + +if (lseek (fd, old->st_size,SEEK_SET ) != (off_t)-1 ) {ssize_t rc, wc;while ((rc =read (fd, buf,sizeof (buf))) >0 ) {
@@ -123,16 +128,16 @@ roll_file(const char *filename, off_t *size)* avoids data duplication. If we read nothing or hit an error, reset * to the reported size, this handles truncated files. */ - *size = (pos !=-1 && pos != *size) ? pos : st.st_size; + old->st_size = (pos !=-1 && pos != old->st_size) ? pos :0 ;close (fd); }static void -watch_file (const char *filename,off_t *size) +watch_file (const char *filename,struct stat *old) {do { -roll_file (filename, size); +roll_file (filename, old);xusleep (250000 ); }while (1 ); }
@@ -144,7 +149,7 @@ watch_file(const char *filename, off_t *size)#define NEVENTS 4static int -watch_file_inotify (const char *filename,off_t *size) +watch_file_inotify (const char *filename,struct stat *old) {char buf[NEVENTS *sizeof (struct inotify_event ) ];int fd, ffd, e;
@@ -176,7 +181,7 @@ watch_file_inotify(const char *filename, off_t *size)struct inotify_event *ev = (struct inotify_event *) &buf[e];if (ev->mask &IN_MODIFY ) -roll_file (filename, size); +roll_file (filename, old);else {close (ffd); ffd =-1 ;
@@ -237,8 +242,7 @@ int main(int argc, char **argv)const char *filename;long lines;int ch; -struct stat st; -off_t size =0 ; +struct stat old;static const struct option longopts[] = { {"lines" , required_argument,0 ,'n' },
@@ -277,16 +281,15 @@ int main(int argc, char **argv) filename = argv[optind]; -if (stat (filename, &st) !=0 ) +if (stat (filename, &old) !=0 )err (EXIT_FAILURE ,_ ("stat of %s failed" ), filename); - size = st.st_size;;tailf (filename, lines);#ifdef HAVE_INOTIFY_INIT - if (!watch_file_inotify(filename, &size)) + if (!watch_file_inotify(filename, &old))#endif -watch_file (filename, &size); +watch_file (filename, &old);return EXIT_SUCCESS ; }
Signature · 1 line
2.3.0
Karel Zak
maintainerRe: [PATCH 11/16] tailf: check printing criteria more carefully
text-utils/tailf.c roll_file(const char *filename, off_t *size) · line 111
Quoted 4 lines · Sami Kerola
text-utils/tailf.c +3
-1-if (lseek (fd, *size,SEEK_SET ) != (off_t)-1 ) { +if (st.st_ino != old->st_ino || st.st_dev != old->st_dev + || (old->st_mtime < st.st_mtime && st.st_size <= old->st_size)) + old->st_size =0 ;
So.. if I remove (truncate) last line from 1GiB file then tailf will print all the file *again*? Would be better to reset to st.st_size if the size is smaller than old->st_size?
Or maybe if you want to support "echo 1 >| file" use case than add a new option (--rewind) or so.
text-utils/tailf.c roll_file(const char *filename, off_t *size) · line 131
Quoted 10 lines
text-utils/tailf.c +2
-1+if (lseek (fd, old->st_size,SEEK_SET ) != (off_t)-1 ) {ssize_t rc, wc;while ((rc =read (fd, buf,sizeof (buf))) >0 ) {@@ -123,16 +128,16 @@ roll_file(const char *filename, off_t *size)* avoids data duplication. If we read nothing or hit an error, reset * to the reported size, this handles truncated files. */ - *size = (pos !=-1 && pos != *size) ? pos : st.st_size; + old->st_size = (pos !=-1 && pos != old->st_size) ? pos :0 ;
This way how to reset seems better.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 11/16] tailf: check printing criteria more carefully
Quoted 10 lines · Karel Zak
text-utils/tailf.c roll_file(const char *filename, off_t *size) · line 111
Quoted 4 lines · Sami Kerola
text-utils/tailf.c +3
-1-if (lseek (fd, *size,SEEK_SET ) != (off_t)-1 ) { +if (st.st_ino != old->st_ino || st.st_dev != old->st_dev + || (old->st_mtime < st.st_mtime && st.st_size <= old->st_size)) + old->st_size =0 ;So.. if I remove (truncate) last line from 1GiB file then tailf will print all the file *again*? Would be better to reset to st.st_size if the size is smaller than
old->st_size?
Quoted 2 lines
Or maybe if you want to support "echo 1 >| file" use case than add a new option (--rewind) or so.
Thanks Karel,
The 1GiB file last line truncation is such strong argument against the change that I removed it from my remote branch. Maybe the tailf.1 manual page should mention truncations are not handled always correctly, and that's as good the command is ever going to be.
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
PATCH 12/16 tailf: count last lines correctly at initial print out
In reply to Sami KerolaWhen last lines happen to be greater than string buffer size for fgets() the number of printed lines resulted to too few.
--- text-utils/tailf.c | 56 +++++++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 30 deletions(-)
text-utils/tailf.c +26 -30
@@ -36,6 +36,8 @@#include <ctype.h> #include <errno.h> #include <getopt.h> +#include <sys/mman.h> +#ifdef HAVE_INOTIFY_INIT #include <sys/inotify.h> #endif
@@ -49,40 +51,34 @@#define DEFAULT_LINES 10static void -tailf (const char *filename,int lines) +tailf (const char *filename,unsigned long lines,struct stat *old) { -char *buf, *p; -int head =0 ; -int tail =0 ; -FILE *str; -int i; +int fd; +size_t i; +char *data; -if (!(str =fopen (filename,"r" ))) +if (!(fd =open (filename,O_RDONLY )))err (EXIT_FAILURE ,_ ("cannot open %s" ), filename); - - buf =xmalloc ((lines ? lines :1 ) *BUFSIZ ); - p = buf; -while (fgets (p,BUFSIZ , str)) { -if (++tail >= lines) { - tail =0 ; - head =1 ; + data =mmap (0 , old->st_size,PROT_READ ,MAP_SHARED , fd,0 ); + i = (size_t )old->st_size -1 ; +/* humans do not think last new line in a file should be counted, +* in that case do off by one from counter point of view */ +if (data[i] =='\n' ) + lines++; +while (i) { +if (data[i] =='\n' ) { +if (--lines ==0 ) { + i++; +break ; + } } - p = buf + (tail *BUFSIZ ); + i--; } - -if (head) { -for (i = tail; i < lines; i++) -fputs (buf + (i *BUFSIZ ), stdout); -for (i =0 ; i < tail; i++) -fputs (buf + (i *BUFSIZ ), stdout); - }else { -for (i = head; i < tail; i++) -fputs (buf + (i *BUFSIZ ), stdout); - } - +while (i < (size_t )old->st_size) +putchar (data[i++]); +munmap (data, old->st_size); +close (fd);fflush (stdout); -free (buf); -fclose (str); } static void
@@ -283,8 +279,8 @@ int main(int argc, char **argv)if (stat (filename, &old) !=0 )err (EXIT_FAILURE ,_ ("stat of %s failed" ), filename); - -tailf (filename, lines); +if (lines && old.st_size) +tailf (filename, lines, &old);#ifdef HAVE_INOTIFY_INIT if (!watch_file_inotify (filename, &old))
Signature · 1 line
2.3.0
Karel Zak
maintainerRe: [PATCH 12/16] tailf: count last lines correctly at initial print out
Quoted 2 lines · Sami Kerola
When last lines happen to be greater than string buffer size for
fgets()the number of printed lines resulted to too few.
Maybe add a note about mmap() to commit message ?!
text-utils/tailf.c line 62
Quoted 11 lines
text-utils/tailf.c +2
-8-if (!(str =fopen (filename,"r" ))) +if (!(fd =open (filename,O_RDONLY )))err (EXIT_FAILURE ,_ ("cannot open %s" ), filename); - - buf =xmalloc ((lines ? lines :1 ) *BUFSIZ ); - p = buf; -while (fgets (p,BUFSIZ , str)) { -if (++tail >= lines) { - tail =0 ; - head =1 ; + data =mmap (0 , old->st_size,PROT_READ ,MAP_SHARED , fd,0 );
It would be nice to compare this it with original implementation on large files. I guess mmap will be more effective and faster.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 12/16] tailf: count last lines correctly at initial print out
Quoted 5 lines · Karel Zak
Quoted 2 lines · Sami Kerola
When last lines happen to be greater than string buffer size for
fgets()the number of printed lines resulted to too few.Maybe add a note about
mmap()to commit message ?!
Thanks Karel,
Done.
https://github.com/kerolasa/lelux-utiliteetit/commit/537f3b197f3c6af307997ebd103becbf44f529c1
Quoted 6 lines
Quoted 6 lines
text-utils/tailf.c +1
-4-if (!(str =fopen (filename,"r" ))) +if (!(fd =open (filename,O_RDONLY )))err (EXIT_FAILURE ,_ ("cannot open %s" ), filename); - - buf =xmalloc ((lines ? lines :1 ) *BUFSIZ ); - p = buf;
Quoted 8 lines
text-utils/tailf.c line 62
Quoted 5 lines
text-utils/tailf.c +1
-4-while (fgets (p,BUFSIZ , str)) { -if (++tail >= lines) { - tail =0 ; - head =1 ; + data =mmap (0 , old->st_size,PROT_READ ,MAP_SHARED , fd,0 );It would be nice to compare this it with original implementation on large files. I guess mmap will be more effective and faster.
My motivation to do this change had less to do with speed than correcness. Earlier version did not print requested number or lines when tail read buffer was insufficient. That probably did not happen too often as 8K is a lot of text.
The reason I chose mmap() is simple. It provides easy interface to read a file backwards. And a potential speed gain is a nice side effect.
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
PATCH 13/16 tailf: do not allow minus signed last lines argument
In reply to Sami KerolaBefore mmap() the command behavior was not completely correct, as demonstrated below, and after the mmap() it tried to print some eighteen quintillion lines.
$ tailf -n-1 x tailf: cannot allocate 18446744073709543424 bytes: Cannot allocate memory
--- text-utils/tailf.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
text-utils/tailf.c +13 -11
@@ -213,16 +213,16 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out) }/* parses -N option */ -static long old_style_option (int *argc,char **argv) +static long old_style_option (int *argc,char **argv,unsigned long *lines) { -int i =1 , nargs = *argc; -long lines =-1 ; +int i =1 , nargs = *argc, ret =0 ;while (i < nargs) {if (argv[i][0 ] =='-' &&isdigit (argv[i][1 ])) { - lines =strtol_or_err (argv[i] +1 , + *lines =strtoul_or_err (argv[i] +1 ,_ ("failed to parse number of lines" )); nargs--; + ret =1 ;if (nargs - i)memmove (argv + i, argv + i +1 ,sizeof (char *) * (nargs - i));
@@ -230,13 +230,13 @@ static long old_style_option(int *argc, char **argv) i++; } *argc = nargs; -return lines; +return ret; }int main (int argc,char **argv) {const char *filename; -long lines; +unsigned long lines;int ch;struct stat old;
@@ -252,16 +252,18 @@ int main(int argc, char **argv)textdomain (PACKAGE );atexit (close_stdout); - lines =old_style_option (&argc, argv); -if (lines <0 ) +if (!old_style_option (&argc, argv, &lines)) lines =DEFAULT_LINES ;while ((ch =getopt_long (argc, argv,"n:N:Vh" , longopts,NULL )) !=-1 ) -switch ((char )ch) { +switch ((char )ch) {case 'n' :case 'N' : - lines =strtol_or_err (optarg, -_ ("failed to parse number of lines" )); +if (optarg[0 ] =='-' ) +errx (EXIT_FAILURE ,"%s: %s" , +_ ("failed to parse number of lines" ), optarg); + lines = +strtoul_or_err (optarg,_ ("failed to parse number of lines" ));break ;case 'V' :printf (UTIL_LINUX_VERSION );
Signature · 1 line
2.3.0
PATCH 14/16 tailf: ensure file argument really is a file
In reply to Sami KerolaThe tailf(1) never worked very well with block or character devices, sockets, fifos and such. Now after mmap() is used to find last lines even the little command used to work is broken, so test the tailf is asked to follow a file and when not fail. That said symlinks are OK, as long they point to a file.
--- text-utils/tailf.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
text-utils/tailf.c +24 -0
@@ -233,6 +233,28 @@ static long old_style_option(int *argc, char **argv, unsigned long *lines)return ret; } +static int is_file (const char *filename,const struct stat sb) +{ +switch (sb.st_mode &S_IFMT ) { +case S_IFREG : +return 0 ; +case S_IFLNK : + { +char *resolved_path =NULL ; +struct stat follow; +int ret; + +if (realpath (filename, resolved_path)) { +stat (resolved_path, &follow); + ret =is_file (resolved_path, follow); +free (resolved_path); +return ret; + } + } + } +return 1 ; +} +int main (int argc,char **argv) {const char *filename;
@@ -281,6 +303,8 @@ int main(int argc, char **argv)if (stat (filename, &old) !=0 )err (EXIT_FAILURE ,_ ("stat of %s failed" ), filename); +if (is_file (filename, old)) +errx (EXIT_FAILURE ,_ ("%s: is not a file" ), filename);if (lines && old.st_size)tailf (filename, lines, &old);
Signature · 1 line
2.3.0
Karel Zak
maintainerRe: [PATCH 14/16] tailf: ensure file argument really is a file
Quoted 19 lines · Sami Kerola
text-utils/tailf.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)text-utils/tailf.c +8
-0@@ -233,6 +233,28 @@ static long old_style_option(int *argc, char **argv, unsigned long *lines)return ret; } +static int is_file (const char *filename,const struct stat sb) +{ +switch (sb.st_mode &S_IFMT ) { +case S_IFREG : +return 0 ; +case S_IFLNK : + { +char *resolved_path =NULL ;
text-utils/tailf.c static long old_style_option(int *argc, char **argv, unsigned long *lines) · line 253
Quoted 10 lines
text-utils/tailf.c +10
-0+struct stat follow; +int ret; + +if (realpath (filename, resolved_path)) { +stat (resolved_path, &follow); + ret =is_file (resolved_path, follow); +free (resolved_path); +return ret; + } + }
but you use stat() and no lstat(), so you don't have to care about symlinks, right? :-)
text-utils/tailf.c int main(int argc, char **argv) · line 305
Quoted 2 lines
text-utils/tailf.c +0
-0if (stat (filename, &old) !=0 )err (EXIT_FAILURE ,_ ("stat of %s failed" ), filename);
if (IS_REG(old.st_mode))
errx(EXIT_FAILURE, _("%s: is not a file"), filename);text-utils/tailf.c int main(int argc, char **argv) · line 309
Quoted 4 lines
text-utils/tailf.c +2
-0+if (is_file (filename, old)) +errx (EXIT_FAILURE ,_ ("%s: is not a file" ), filename);if (lines && old.st_size)tailf (filename, lines, &old);
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 14/16] tailf: ensure file argument really is a file
Quoted 34 lines · Karel Zak
Quoted 19 lines · Sami Kerola
text-utils/tailf.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)text-utils/tailf.c +8
-0@@ -233,6 +233,28 @@ static long old_style_option(int *argc, char **argv, unsigned long *lines)return ret; } +static int is_file (const char *filename,const struct stat sb) +{ +switch (sb.st_mode &S_IFMT ) { +case S_IFREG : +return 0 ; +case S_IFLNK : + { +char *resolved_path =NULL ;text-utils/tailf.c static long old_style_option(int *argc, char **argv, unsigned long *lines) · line 253
Quoted 10 lines
text-utils/tailf.c +10
-0+struct stat follow; +int ret; + +if (realpath (filename, resolved_path)) { +stat (resolved_path, &follow); + ret =is_file (resolved_path, follow); +free (resolved_path); +return ret; + } + }but you use
stat()and nolstat(), so you don't have to care about symlinks, right? :-)
Quoted 5 lines
text-utils/tailf.c int main(int argc, char **argv) · line 305
Quoted 2 lines
text-utils/tailf.c +0
-0if (stat (filename, &old) !=0 )err (EXIT_FAILURE ,_ ("stat of %s failed" ), filename);if (
IS_REG(old.st_mode))errx(EXIT_FAILURE, _("%s: is not a file"), filename);
Thanks Karel,
Change is made a lot nicer, and I found what got side lined;
((st.st_mode & S_IFMT) == S_IFREG) != S_ISREG(st.st_mode)
Let's hope I will never forget that in future.
https://github.com/kerolasa/lelux-utiliteetit/commit/a7a3440221e74408ef7727b6c3c83ed68e6e4936
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
PATCH 15/16 logger: move /dev/log to pathnames.h
In reply to Sami Kerola--- include/pathnames.h | 3 +++ misc-utils/logger.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-)
include/pathnames.h +3 -0
@@ -193,5 +193,8 @@/* kernel command line */ #define _PATH_PROC_CMDLINE "/proc/cmdline" +/* logger paths */ +#define _PATH_DEVLOG "/dev/log" +#endif /* PATHNAMES_H */
misc-utils/logger.c +2 -1
@@ -56,6 +56,7 @@#include "c.h" #include "closestream.h" #include "nls.h" +#include "pathnames.h" #include "strutils.h" #include "xalloc.h"
@@ -481,7 +482,7 @@ static void logger_open(struct logger_ctl *ctl) ctl->syslogfp = syslog_rfc5424;return ; } - ctl->fd =unix_socket (ctl,"/dev/log" , ctl->socket_type); + ctl->fd =unix_socket (ctl, _PATH_DEVLOG, ctl->socket_type); ctl->syslogfp = syslog_local; }
Signature · 1 line
2.3.0
Re: [PATCH 15/16] logger: move /dev/log to pathnames.h
Quoted 3 lines · Sami Kerola
include/pathnames.h | 3 +++ misc-utils/logger.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 16/16 logger: fix -i argument parsing regression
In reply to Sami KerolaWith earlier logger it's possible to combine the option -i with other options, such as -s. But currently:
$:~> logger -is
logger: failed to parse id: 's'
The changed behaviour breaks existing scripts like dhcpcd-run-hooks from dhcpcd.
Broken-since: aab5b44405b9a6ada92e419e5a84cc0d1d4afee9
Reference: http://comments.gmane.org/gmane.linux.utilities.util-linux-ng/9683
--- misc-utils/logger.1 | 5 ++++- misc-utils/logger.c | 13 +++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-)
misc-utils/logger.1 +4 -1
@@ -58,7 +58,10 @@ syslog port defined in /etc/services, which is often 514 . Log the contents of the specified \fIfile\fR. This option cannot be combined with a command-line message. .TP -.BR \-i , " \-\-id" [ = \fIid ] +.BR \-i +Log the PID of the logger process with each line. +.TP +.BR "\-\-id" [ = \fIid ] Log the PID of the logger process with each line. When the optional argument \fIid\fR is specified, then it is used instead of the logger command's PID. The use of \fB\-\-id=$$\fR
misc-utils/logger.c +9 -4
@@ -89,7 +89,8 @@ enum {OPT_JOURNALD ,OPT_RFC3164 ,OPT_RFC5424 , -OPT_SOCKET_ERRORS +OPT_SOCKET_ERRORS , +OPT_ID }; struct logger_ctl {
@@ -548,7 +549,8 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out)fputs (_ ("Enter messages into the system log.\n" ), out);fputs (USAGE_OPTIONS , out); -fputs (_ (" -i, --id[=<id>] log <id> (default is PID)\n" ), out); +fputs (_ (" -i log logger command PID\n" ), out); +fputs (_ (" --id[=<id>] log <id> (default is PID)\n" ), out);fputs (_ (" -f, --file <file> log the contents of this file\n" ), out);fputs (_ (" -p, --priority <prio> mark given message with this priority\n" ), out);fputs (_ (" --prio-prefix look for a prefix on every line read from stdin\n" ), out);
@@ -606,7 +608,7 @@ int main(int argc, char **argv)FILE *jfd =NULL ;#endif static const struct option longopts[] = { - {"id" , optional_argument,0 ,'i' }, + {"id" , optional_argument,0 ,OPT_ID }, {"stderr" , no_argument,0 ,'s' }, {"file" , required_argument,0 ,'f' }, {"priority" , required_argument,0 ,'p' },
@@ -633,7 +635,7 @@ int main(int argc, char **argv)textdomain (PACKAGE );atexit (close_stdout); -while ((ch =getopt_long (argc, argv,"f:i::p:st:u:dTn:P:Vh" , +while ((ch =getopt_long (argc, argv,"f:ip:st:u:dTn:P:Vh" , longopts,NULL )) !=-1 ) {switch (ch) {case 'f' :/* file to log */
@@ -642,6 +644,9 @@ int main(int argc, char **argv) stdout_reopened =1 ;break ;case 'i' :/* log process id also */ + ctl.pid =getpid (); +break ; +case OPT_ID :if (optarg) {const char *p = optarg;
Signature · 1 line
2.3.0
Re: [PATCH 16/16] logger: fix -i argument parsing regression
Quoted 1 line · Sami Kerola
Reviewed-by Benno Schulenberg <[email protected]>
Please use my justemail address (the current one) here instead. The vertaalt one I use just for translations.
Quoted 1 line
+.BR \-i
s/BR/B/ (since there is just one argument)
Quoted 1 line
+.BR "\-\-id" [ = \fIid ]
s/= /=/ (to fix my own mistake)
misc-utils/logger.c static void __attribute__ ((__noreturn__)) usage(FILE *out) · line 552
Quoted 2 lines
misc-utils/logger.c +1
-1-fputs (_ (" -i, --id[=<id>] log <id> (default is PID)\n" ), out); +fputs (_ (" -i log logger command PID\n" ), out);
Better: "log the logger command's PID" -- there is room enough to avoid telegram style.
misc-utils/logger.c static void __attribute__ ((__noreturn__)) usage(FILE *out) · line 553
Quoted 1 line
misc-utils/logger.c +1
-0+fputs (_ (" --id[=<id>] log <id> (default is PID)\n" ), out);
Better: "log the given <id>, or otherwise the PID"
Benno
Signature · 2 lines
http://www.fastmail.com - Access all of your messages and folders
wherever you areRe: [PATCH 16/16] logger: fix -i argument parsing regression
Quoted 12 lines · Benno Schulenberg
Quoted 1 line · Sami Kerola
Reviewed-by Benno Schulenberg <[email protected]>Please use my justemail address (the current one) here instead. The vertaalt one I use just for translations.
Quoted 1 line
+.BR \-i
s/BR/B/ (since there is just one argument)
Quoted 1 line
+.BR "\-\-id" [ = \fIid ]
Quoted 7 lines
s/= /=/ (to fix my own mistake)
misc-utils/logger.c static void __attribute__ ((__noreturn__)) usage(FILE *out) · line 552
Quoted 2 lines
misc-utils/logger.c +1
-1-fputs (_ (" -i, --id[=<id>] log <id> (default is PID)\n" ), out); +fputs (_ (" -i log logger command PID\n" ), out);Better: "log the logger command's PID" -- there is room enough to avoid telegram style.
Nalime Benno,
Quoted 3 lines
misc-utils/logger.c static void __attribute__ ((__noreturn__)) usage(FILE *out) · line 553
Quoted 1 line
misc-utils/logger.c +1
-0+fputs (_ (" --id[=<id>] log <id> (default is PID)\n" ), out);Better: "log the given <id>, or otherwise the PID"
Here is updated version of the change.
https://github.com/kerolasa/lelux-utiliteetit/commit/7dbe2082a9d87316d7aed7d1c8a7f94a8a80b1f0
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
Re: [PATCH 11/62] pull: ...
In reply to Sami KerolaQuoted 1 line · Sami Kerola
Here is collection of patches [...]
Oh mayday, mayday, m... Where's the panic button?
:)
Benno
Signature · 1 line
http://www.fastmail.com - Send your email first class
Karel Zak
maintainerQuoted 1 line · Sami Kerola
git://github.com/kerolasa/lelux-utiliteetit.gitvarious
Merged (various2), thanks.
Look forward to see regression tests for flock, logger and whereis.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com