mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-22 00:00:03 +03:00
super-show: Print label
This commit is contained in:
parent
decab73814
commit
866e21a35d
1
Makefile
1
Makefile
@ -22,4 +22,5 @@ make-bcache: CFLAGS += `pkg-config --cflags uuid blkid`
|
|||||||
make-bcache: bcache.o
|
make-bcache: bcache.o
|
||||||
probe-bcache: LDLIBS += `pkg-config --libs uuid`
|
probe-bcache: LDLIBS += `pkg-config --libs uuid`
|
||||||
bcache-super-show: LDLIBS += `pkg-config --libs uuid`
|
bcache-super-show: LDLIBS += `pkg-config --libs uuid`
|
||||||
|
bcache-super-show: CFLAGS += -std=gnu99
|
||||||
bcache-super-show: bcache.o
|
bcache-super-show: bcache.o
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
* GPLv2
|
* GPLv2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
#define __USE_FILE_OFFSET64
|
#define __USE_FILE_OFFSET64
|
||||||
#define _XOPEN_SOURCE 500
|
#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)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
bool force_csum = false;
|
bool force_csum = false;
|
||||||
@ -123,6 +147,16 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
putchar('\n');
|
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);
|
uuid_unparse(sb.uuid, uuid);
|
||||||
printf("dev.uuid\t\t%s\n", uuid);
|
printf("dev.uuid\t\t%s\n", uuid);
|
||||||
|
|
||||||
|
2
bcache.h
2
bcache.h
@ -115,7 +115,7 @@ BITMASK(BDEV_STATE, struct cache_sb, flags, 61, 2);
|
|||||||
#define BDEV_STATE_DIRTY 2U
|
#define BDEV_STATE_DIRTY 2U
|
||||||
#define BDEV_STATE_STALE 3U
|
#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 node(i, j) ((void *) ((i)->d + (j)))
|
||||||
#define end(i) node(i, (i)->keys)
|
#define end(i) node(i, (i)->keys)
|
||||||
|
Loading…
Reference in New Issue
Block a user