]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Changed default NSID in get-feature function. Fixed format of LBA range output
authorSami Waheed <slw26c@gmail.com>
Tue, 15 Sep 2015 22:29:04 +0000 (15:29 -0700)
committerSami Waheed <slw26c@gmail.com>
Tue, 15 Sep 2015 22:29:04 +0000 (15:29 -0700)
- Changed default NSID to 1 in get-feature function.   Some features
require a valid NSID (i.e. lba range type)
- Fixed format of LBA range output
- Added description to the attributes field in LBA range output
- Changed default NSID to 0xffffffff in get_log (Matches help
documentation now)

nvme.c

diff --git a/nvme.c b/nvme.c
index 3b24ef7c8c3fb750c9cc25fd48b6cb4562d05573..0e3eaf851b86bd9d651c20e11ced1586fc4f8960 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -849,13 +849,14 @@ char* nvme_feature_lba_type_to_string(__u8 type)
 static void show_lba_range(struct nvme_lba_range_type *lbrt, int nr_ranges)
 {
        int i, j;
-
+       
        for (i = 0; i <= nr_ranges; i++) {
-               printf("type       : %#x - %s\n", lbrt[i].type, nvme_feature_lba_type_to_string(lbrt[i].type));
-               printf("attributes : %#x\n", lbrt[i].attributes);
-               printf("slba       : %#"PRIx64"\n", (uint64_t)(lbrt[i].slba));
-               printf("nlb        : %#"PRIx64"\n", (uint64_t)(lbrt[i].nlb));
-               printf("guid       : ");
+               printf("\ttype       : %#x - %s\n", lbrt[i].type, nvme_feature_lba_type_to_string(lbrt[i].type));
+               printf("\tattributes : %#x - %s, %s\n", lbrt[i].attributes, (lbrt[i].attributes & 0x0001) ? "LBA range may be overwritten":"LBA range should not be overwritten",
+                       ((lbrt[i].attributes & 0x0002) >> 1) ? "LBA range should be hidden from the OS/EFI/BIOS":"LBA range should be visible from the OS/EFI/BIOS");
+               printf("\tslba       : %#"PRIx64"\n", (uint64_t)(lbrt[i].slba));
+               printf("\tnlb        : %#"PRIx64"\n", (uint64_t)(lbrt[i].nlb));
+               printf("\tguid       : ");
                for (j = 0; j < 16; j++)
                        printf("%02x", lbrt[i].guid[j]);
                printf("\n");
@@ -1290,7 +1291,7 @@ static int get_log(int argc, char **argv)
        struct config cfg;
 
        const struct config defaults = {
-               .namespace_id = 0,
+               .namespace_id = 0xffffffff,
                .log_id       = 0,
                .log_len      = 0,
        };
@@ -1322,7 +1323,7 @@ static int get_log(int argc, char **argv)
                                   cfg.namespace_id);
                if (!err) {
                        if (!cfg.raw_binary) {
-                               printf("Device:%s log-id:%d namespace-id:%#x",
+                               printf("Device:%s log-id:%d namespace-id:%#x\n",
                                       devicename, cfg.log_id,
                                       cfg.namespace_id);
                                d(log, cfg.log_len, 16, 1);
@@ -2151,7 +2152,7 @@ static int get_feature(int argc, char **argv)
        struct config cfg;
 
        const struct config defaults = {
-               .namespace_id = 0,
+               .namespace_id = 1,
                .feature_id   = 0,
                .sel          = 0,
                .cdw11        = 0,