@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <sys/types.h>
#include <uuid/uuid.h>
#include <ctype.h>
#include "kerncompat.h"
@@ -2108,3 +2109,73 @@ void btrfs_print_superblock(struct btrfs_super_block *sb, int full)
print_backup_roots(sb);
}
}
+
+#define BPSL 256
+
+#define BTRFS_SEQ_PRINT(plist, arg) \
+ do { \
+ snprintf(str, BPSL, plist, arg); \
+ printf("%s", str); \
+ } while (0)
+
+static void print_a_device(struct btrfs_device *device)
+{
+ char str[BPSL];
+ char uuidstr[BTRFS_UUID_UNPARSED_SIZE];
+
+ uuid_unparse(device->uuid, uuidstr);
+ BTRFS_SEQ_PRINT("\t[[UUID: %s]]\n", uuidstr);
+ BTRFS_SEQ_PRINT("\t\tdev_addr:\t%p\n", device);
+ BTRFS_SEQ_PRINT("\t\tdevice:\t\t%s\n", device->name);
+ BTRFS_SEQ_PRINT("\t\tdevid:\t\t%llu\n", device->devid);
+ BTRFS_SEQ_PRINT("\t\tgeneration:\t%llu\n", device->generation);
+ BTRFS_SEQ_PRINT("\t\ttotal_bytes:\t%llu\n", device->total_bytes);
+ BTRFS_SEQ_PRINT("\t\tbytes_used:\t%llu\n", device->bytes_used);
+ BTRFS_SEQ_PRINT("\t\ttype:\t\t%llu\n", device->type);
+ BTRFS_SEQ_PRINT("\t\tio_align:\t%u\n", device->io_align);
+ BTRFS_SEQ_PRINT("\t\tio_width:\t%u\n", device->io_width);
+ BTRFS_SEQ_PRINT("\t\tsector_size:\t%u\n", device->sector_size);
+}
+
+static void print_a_fs_device(struct btrfs_fs_devices *fs_devices)
+{
+ char str[BPSL];
+ char uuidstr[BTRFS_UUID_UNPARSED_SIZE];
+ struct btrfs_device *device = NULL;
+ size_t sz = sizeof(*fs_devices);
+
+ uuid_unparse(fs_devices->fsid, uuidstr);
+ BTRFS_SEQ_PRINT("[fsid: %s]\n", uuidstr);
+
+ BTRFS_SEQ_PRINT("\tsize:\t\t\t%ld\n", sz);
+
+ uuid_unparse(fs_devices->metadata_uuid, uuidstr);
+ BTRFS_SEQ_PRINT("\tmetadata_uuid:\t\t%s\n", uuidstr);
+
+ BTRFS_SEQ_PRINT("\tfs_devs_addr:\t\t%p\n", fs_devices);
+ BTRFS_SEQ_PRINT("\ttotal_rw_bytes:\t\t%llu\n", fs_devices->total_rw_bytes);
+
+ list_for_each_entry(device, &fs_devices->devices, dev_list) {
+ print_a_device(device);
+ }
+}
+
+
+void btrfs_print_devlist(struct btrfs_fs_devices *the_fs_devices)
+{
+ struct list_head *fs_uuids = btrfs_get_fs_uuids();
+ struct list_head *cur_uuid;
+
+ list_for_each(cur_uuid, fs_uuids) {
+ struct btrfs_fs_devices *fs_devices;
+
+ fs_devices = list_entry(cur_uuid, struct btrfs_fs_devices, list);
+ if (the_fs_devices) {
+ if (the_fs_devices == fs_devices)
+ print_a_fs_device(fs_devices);
+ } else {
+ print_a_fs_device(fs_devices);
+ }
+ printf("\n");
+ }
+}
@@ -42,5 +42,6 @@ void print_extent_item(struct extent_buffer *eb, int slot, int metadata);
void print_objectid(FILE *stream, u64 objectid, u8 type);
void print_key_type(FILE *stream, u64 objectid, u8 type);
void btrfs_print_superblock(struct btrfs_super_block *sb, int full);
+void btrfs_print_devlist(struct btrfs_fs_devices *the_fs_devices);
#endif
Provides the boilerplate code to print the device list. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- kernel-shared/print-tree.c | 71 ++++++++++++++++++++++++++++++++++++++ kernel-shared/print-tree.h | 1 + 2 files changed, 72 insertions(+)