diff options
author | Toomas Soome <tsoome@me.com> | 2015-03-02 01:42:42 +0200 |
---|---|---|
committer | Dan McDonald <danmcd@omniti.com> | 2015-03-06 15:30:16 -0500 |
commit | 4adca7e7219d20c7ca20933b5006222e781ff0e9 (patch) | |
tree | 161536fb59557290240d40b95aec19038927db02 /usr/src/cmd | |
parent | 409430af79aac96ef996a8fa0af6ca929d0faad5 (diff) | |
download | illumos-gate-4adca7e7219d20c7ca20933b5006222e781ff0e9.tar.gz |
2930 beadm should sort by creation date
Reviewed by: Marcel Telka <marcel@telka.sk>
Reviewed by: Josef ‘Jeff’ Sipek <jeffpc@josefsipek.net>
Reviewed by: Gary Mills <gary_mills@fastmail.fm>
Approved by: Dan McDonald <danmcd@omniti.com>
Diffstat (limited to 'usr/src/cmd')
-rw-r--r-- | usr/src/cmd/beadm/beadm.c | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/usr/src/cmd/beadm/beadm.c b/usr/src/cmd/beadm/beadm.c index 4fb22b9bcc..e290b745cd 100644 --- a/usr/src/cmd/beadm/beadm.c +++ b/usr/src/cmd/beadm/beadm.c @@ -25,6 +25,7 @@ /* * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2015 Toomas Soome <tsoome@me.com> */ /* @@ -131,7 +132,8 @@ usage(void) "\t\t[-o property=value] ... [-p zpool] [-v] beName@snapshot\n" "\tbeadm destroy [-Ffsv] beName \n" "\tbeadm destroy [-Fv] beName@snapshot \n" - "\tbeadm list [[-a] | [-d] [-s]] [-H] [-v] [beName]\n" + "\tbeadm list [[-a] | [-d] [-s]] [-H]\n" + "\t\t[-k|-K date | name | space] [-v] [beName]\n" "\tbeadm mount [-s ro|rw] [-v] beName [mountpoint]\n" "\tbeadm unmount [-fv] beName | mountpoint\n" "\tbeadm umount [-fv] beName | mountpoint\n" @@ -1085,8 +1087,9 @@ be_do_list(int argc, char **argv) int err = 1; int c = 0; char *be_name = NULL; + be_sort_t order = BE_SORT_UNSPECIFIED; - while ((c = getopt(argc, argv, "adsvH")) != -1) { + while ((c = getopt(argc, argv, "adk:svHK:")) != -1) { switch (c) { case 'a': all = B_TRUE; @@ -1094,6 +1097,39 @@ be_do_list(int argc, char **argv) case 'd': dsets = B_TRUE; break; + case 'k': + case 'K': + if (order != BE_SORT_UNSPECIFIED) { + (void) fprintf(stderr, _("Sort key can be " + "specified only once.\n")); + usage(); + return (1); + } + if (strcmp(optarg, "date") == 0) { + if (c == 'k') + order = BE_SORT_DATE; + else + order = BE_SORT_DATE_REV; + break; + } + if (strcmp(optarg, "name") == 0) { + if (c == 'k') + order = BE_SORT_NAME; + else + order = BE_SORT_NAME_REV; + break; + } + if (strcmp(optarg, "space") == 0) { + if (c == 'k') + order = BE_SORT_SPACE; + else + order = BE_SORT_SPACE_REV; + break; + } + (void) fprintf(stderr, _("Unknown sort key: %s\n"), + optarg); + usage(); + return (1); case 's': snaps = B_TRUE; break; @@ -1138,6 +1174,13 @@ be_do_list(int argc, char **argv) switch (err) { case BE_SUCCESS: + /* the default sort is ascending date, no need to sort twice */ + if (order == BE_SORT_UNSPECIFIED) + order = BE_SORT_DATE; + + if (order != BE_SORT_DATE) + be_sort(&be_nodes, order); + print_nodes(be_name, dsets, snaps, parsable, be_nodes); break; case BE_ERR_BE_NOENT: |