]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
super-show: Print label
authorGabriel <g2p.code@gmail.com>
Fri, 5 Jul 2013 21:59:21 +0000 (23:59 +0200)
committerGabriel <g2p.code@gmail.com>
Thu, 3 Oct 2013 11:48:50 +0000 (13:48 +0200)
Makefile
bcache-super-show.c
bcache.h

index efeac036406e5b86b01265f67840649c5f0b94b6..1f3caa48f6fdbadc29d920ad7fdaa4a3cb698d47 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -22,4 +22,5 @@ make-bcache: CFLAGS += `pkg-config --cflags uuid blkid`
 make-bcache: bcache.o
 probe-bcache: LDLIBS += `pkg-config --libs uuid`
 bcache-super-show: LDLIBS += `pkg-config --libs uuid`
+bcache-super-show: CFLAGS += -std=gnu99
 bcache-super-show: bcache.o
index c00d22e1c9c38704ec8d3957fc2cb7f687f93434..26cc40ed0a099f6607c5e9e27bf72a7a477156e8 100644 (file)
@@ -4,6 +4,7 @@
  * GPLv2
  */
 
+
 #define _FILE_OFFSET_BITS      64
 #define __USE_FILE_OFFSET64
 #define _XOPEN_SOURCE 500
@@ -32,6 +33,29 @@ static void usage()
 }
 
 
+static bool accepted_char(char c)
+{
+       if ('0' <= c && c <= '9')
+               return true;
+       if ('A' <= c && c <= 'Z')
+               return true;
+       if ('a' <= c && c <= 'z')
+               return true;
+       if (strchr(".-_", c))
+               return true;
+       return false;
+}
+
+static void print_encode(char* in)
+{
+       for (char* pos = in; *pos; pos++)
+               if (accepted_char(*pos))
+                       putchar(*pos);
+               else
+                       printf("%%%x", *pos);
+}
+
+
 int main(int argc, char **argv)
 {
        bool force_csum = false;
@@ -123,6 +147,16 @@ int main(int argc, char **argv)
 
        putchar('\n');
 
+       char label[SB_LABEL_SIZE + 1];
+       strncpy(label, (char*)sb.label, SB_LABEL_SIZE);
+       label[SB_LABEL_SIZE] = '\0';
+       printf("dev.label\t\t");
+       if (*label)
+               print_encode(label);
+       else
+               printf("(empty)");
+       putchar('\n');
+
        uuid_unparse(sb.uuid, uuid);
        printf("dev.uuid\t\t%s\n", uuid);
 
index 1d78da3be1c0e3c4bef35fdfbac5c3067143edde..61e4252432d5cced8710cff6e57bccf500c8d9a6 100644 (file)
--- a/bcache.h
+++ b/bcache.h
@@ -115,7 +115,7 @@ BITMASK(BDEV_STATE,         struct cache_sb, flags, 61, 2);
 #define BDEV_STATE_DIRTY       2U
 #define BDEV_STATE_STALE       3U
 
-inline uint64_t crc64(const void *_data, size_t len);
+uint64_t crc64(const void *_data, size_t len);
 
 #define node(i, j)             ((void *) ((i)->d + (j)))
 #define end(i)                 node(i, (i)->keys)