From: Karel Zak Date: Wed, 29 Feb 2012 13:26:46 +0000 (+0100) Subject: lslocks: add --notruncate, minor fixes in man page X-Git-Tag: v2.22-rc1~734 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4137d397ce5af61054ae046db511a90f9c38055;p=thirdparty%2Futil-linux.git lslocks: add --notruncate, minor fixes in man page Signed-off-by: Karel Zak --- diff --git a/misc-utils/lslocks.8 b/misc-utils/lslocks.8 index f4160ff87b..3257d79522 100644 --- a/misc-utils/lslocks.8 +++ b/misc-utils/lslocks.8 @@ -23,10 +23,11 @@ Print a help text and exit. Specify which output columns to print. Use .B "--help" to get a list of all supported columns. -.IP "\fB\-\-noheadings\fP" +.IP "\fB\-n, \-\-noheadings\fP" Do not print a header line. - -.IP "\fB\-\-raw\fP" +.IP "\fB\-u, \-\-notruncate\fP" +Do not truncate text in columns. +.IP "\fB\-r, \-\-raw\fP" Use the raw output format. .SH OUTPUT @@ -53,7 +54,9 @@ Ending offset of the lock. .IP "PATH" Full path of the lock - if none is found or no permissions to read the path it -will fallback to the device's mountpoint. +will fallback to the device's mountpoint. The path might be truncated, use +.B "--notruncate" +to get the full path. .SH NOTES .nf diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c index 9a23d35431..39ab18d596 100644 --- a/misc-utils/lslocks.c +++ b/misc-utils/lslocks.c @@ -62,7 +62,7 @@ struct colinfo { }; /* columns descriptions */ -struct colinfo infos[] = { +static struct colinfo infos[] = { [COL_SRC] = { "COMMAND", 15, 0, N_("command of the process holding the lock") }, [COL_PID] = { "PID", 5, TT_FL_RIGHT, N_("PID of the process holding the lock") }, [COL_SIZE] = { "SIZE", 4, TT_FL_RIGHT, N_("size of the lock") }, @@ -91,6 +91,14 @@ struct lock { char *size; }; +static void disable_columns_truncate(void) +{ + size_t i; + + for (i = 0; i < NCOLS; i++) + infos[i].flags &= ~TT_FL_TRUNC; +} + /* * Return a PID's command name */ @@ -465,6 +473,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) " -o, --output define which output columns to use\n" " -n, --noheadings don't print headings\n" " -r --raw use the raw output format\n" + " -u, --notruncate don't truncate text in columns\n" " -h, --help display this help and exit\n" " -V, --version output version information and exit\n"), out); @@ -486,6 +495,7 @@ int main(int argc, char *argv[]) { "pid", required_argument, NULL, 'p' }, { "help", no_argument, NULL, 'h' }, { "output", required_argument, NULL, 'o' }, + { "notruncate", no_argument, NULL, 'u' }, { "version", no_argument, NULL, 'V' }, { "noheadings", no_argument, NULL, 'n' }, { "raw", no_argument, NULL, 'r' }, @@ -497,7 +507,7 @@ int main(int argc, char *argv[]) textdomain(PACKAGE); while ((c = getopt_long(argc, argv, - "p:o:nrhV", long_opts, NULL)) != -1) { + "p:o:nruhV", long_opts, NULL)) != -1) { switch(c) { case 'p': @@ -521,6 +531,9 @@ int main(int argc, char *argv[]) case 'r': tt_flags |= TT_FL_RAW; break; + case 'u': + disable_columns_truncate(); + break; case '?': default: usage(stderr);