btrfs-progs: Print more info about device sizes
[platform/upstream/btrfs-progs.git] / cmds-fi-disk_usage.h
1 /*
2  * Copyright (C) 2007 Oracle.  All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public
6  * License v2 as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public
14  * License along with this program; if not, write to the
15  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16  * Boston, MA 021110-1307, USA.
17  */
18
19 #ifndef __CMDS_FI_DISK_USAGE__
20 #define __CMDS_FI_DISK_USAGE__
21
22 #define DF_HUMAN_UNIT           (1<<0)
23
24 extern const char * const cmd_filesystem_usage_usage[];
25 int cmd_filesystem_usage(int argc, char **argv);
26
27 struct device_info {
28         u64     devid;
29         char    path[BTRFS_DEVICE_PATH_NAME_MAX];
30         /* Size of the block device */
31         u64     device_size;
32         /* Size that's occupied by the filesystem, can be changed via resize */
33         u64     size;
34 };
35
36 /*
37  * To store the size information about the chunks:
38  * the chunks info are grouped by the tuple (type, devid, num_stripes),
39  * i.e. if two chunks are of the same type (RAID1, DUP...), are on the
40  * same disk, have the same stripes then their sizes are grouped
41  */
42 struct chunk_info {
43         u64     type;
44         u64     size;
45         u64     devid;
46         u64     num_stripes;
47 };
48
49 int load_device_info(int fd, struct device_info **device_info_ptr,
50                 int *device_info_count);
51 int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count);
52 char *df_pretty_sizes(u64 size, int mode);
53 void print_device_chunks(int fd, u64 devid, u64 total_size,
54                 struct chunk_info *chunks_info_ptr,
55                 int chunks_info_count, int mode);
56 void print_device_sizes(int fd, struct device_info *devinfo, int mode);
57
58 #endif