btrfs-progs: move device usage to cmds-device, more cleanups
[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         u64     size;
31 };
32
33 /*
34  * To store the size information about the chunks:
35  * the chunks info are grouped by the tuple (type, devid, num_stripes),
36  * i.e. if two chunks are of the same type (RAID1, DUP...), are on the
37  * same disk, have the same stripes then their sizes are grouped
38  */
39 struct chunk_info {
40         u64     type;
41         u64     size;
42         u64     devid;
43         u64     num_stripes;
44 };
45
46 int load_device_info(int fd, struct device_info **device_info_ptr,
47                 int *device_info_count);
48 int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count);
49 char *df_pretty_sizes(u64 size, int mode);
50 void print_device_chunks(int fd, u64 devid, u64 total_size,
51                 struct chunk_info *chunks_info_ptr,
52                 int chunks_info_count, int mode);
53
54 #endif