From: Shakur Shams Mullick <shakursmullick@gmail.com>
To: util-linux@vger.kernel.org
Cc: Shakur Shams Mullick <shakursmullick@gmail.com>
Subject: [PATCH 7/8] misc-utils/lslocks.c: add sorting support for lslocks command
Date: Sat, 3 May 2014 23:41:27 +0600 [thread overview]
Message-ID: <1399138888-7554-7-git-send-email-shakursmullick@gmail.com> (raw)
In-Reply-To: <1399138888-7554-1-git-send-email-shakursmullick@gmail.com>
usage is similar to that of lsblk.
Signed-off-by: Shakur Shams Mullick <shakursmullick@gmail.com>
---
misc-utils/lslocks.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c
index 1495bd4..0d6aa16 100644
--- a/misc-utils/lslocks.c
+++ b/misc-utils/lslocks.c
@@ -89,6 +89,8 @@ static struct libmnt_table *tab; /* /proc/self/mountinfo */
/* basic output flags */
static int no_headings;
static int raw;
+static int nsort;
+static int szsort;
struct lock {
struct list_head locks;
@@ -462,6 +464,8 @@ static int show_locks(struct list_head *locks)
}
scols_table_enable_raw(table, raw);
scols_table_enable_noheadings(table, no_headings);
+ scols_table_enable_namesort(table, nsort);
+ scols_table_enable_sizesort(table, szsort);
for (i = 0; i < ncolumns; i++) {
struct colinfo *col = get_column_info(i);
@@ -511,6 +515,10 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)
" -n, --noheadings don't print headings\n"
" -r, --raw use the raw output format\n"
" -u, --notruncate don't truncate text in columns\n"
+ " -z, show list sorted by size\n"
+ " -c, show list sorted by name\n"
+ " -q --sort WORD sort by WORD: size -z, name -c\n"
+ " e.g. --sort size\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n"), out);
@@ -534,6 +542,9 @@ int main(int argc, char *argv[])
{ "help", no_argument, NULL, 'h' },
{ "output", required_argument, NULL, 'o' },
{ "notruncate", no_argument, NULL, 'u' },
+ { "sort", 1, NULL, 'q' },
+ { NULL, no_argument, NULL, 'z' },
+ { NULL, no_argument, NULL, 'c' },
{ "version", no_argument, NULL, 'V' },
{ "noheadings", no_argument, NULL, 'n' },
{ "raw", no_argument, NULL, 'r' },
@@ -546,7 +557,7 @@ int main(int argc, char *argv[])
atexit(close_stdout);
while ((c = getopt_long(argc, argv,
- "p:o:nruhV", long_opts, NULL)) != -1) {
+ "p:o:nruhVq:zc", long_opts, NULL)) != -1) {
switch(c) {
case 'p':
@@ -566,6 +577,18 @@ int main(int argc, char *argv[])
case 'r':
raw = 1;
break;
+ case 'q':
+ if(strncasecmp(optarg, "size", 4) == 0)
+ szsort = 1;
+ else if(strncasecmp(optarg, "name", 4) == 0)
+ nsort = 1;
+ break;
+ case 'c':
+ nsort = 1;
+ break;
+ case 'z':
+ szsort = 1;
+ break;
case 'u':
disable_columns_truncate();
break;
--
1.8.3.2
next prev parent reply other threads:[~2014-05-03 17:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-03 17:41 [PATCH 1/8] libsmartcols/src/libsmartcols.h.in: add function name Shakur Shams Mullick
2014-05-03 17:41 ` [PATCH 2/8] libsmartcols/src/libsmartcols.sym: add function symbol Shakur Shams Mullick
2014-05-03 17:41 ` [PATCH 3/8] libsmartcols/src/smartcolsP.h: add sort flag and related enum Shakur Shams Mullick
2014-05-03 17:41 ` [PATCH 4/8] libsmartcols/src/table.c: implementation of 4 newly added functions Shakur Shams Mullick
2014-05-03 17:41 ` [PATCH 5/8] libsmartcols/src/table_print.c: sort table before printing Shakur Shams Mullick
2014-05-03 17:41 ` [PATCH 6/8] misc-utils/lsblk.c: add sorting support for lsblk command Shakur Shams Mullick
2014-05-06 10:43 ` Karel Zak
2014-05-03 17:41 ` Shakur Shams Mullick [this message]
2014-05-03 17:41 ` [PATCH 8/8] disk-utils/partx.c: add sorting support for partx command Shakur Shams Mullick
2014-05-06 10:33 ` [PATCH 1/8] libsmartcols/src/libsmartcols.h.in: add function name Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399138888-7554-7-git-send-email-shakursmullick@gmail.com \
--to=shakursmullick@gmail.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox