summaryrefslogtreecommitdiff
path: root/cmds-fi-disk_usage.h
blob: 787b4eb56acf91979831dfffa874667713820627 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * Copyright (C) 2007 Oracle.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License v2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 021110-1307, USA.
 */

#ifndef __CMDS_FI_DISK_USAGE__
#define __CMDS_FI_DISK_USAGE__

#define DF_HUMAN_UNIT		(1<<0)

extern const char * const cmd_filesystem_usage_usage[];
int cmd_filesystem_usage(int argc, char **argv);

struct device_info {
	u64	devid;
	char	path[BTRFS_DEVICE_PATH_NAME_MAX];
	u64	size;
};

/*
 * To store the size information about the chunks:
 * the chunks info are grouped by the tuple (type, devid, num_stripes),
 * i.e. if two chunks are of the same type (RAID1, DUP...), are on the
 * same disk, have the same stripes then their sizes are grouped
 */
struct chunk_info {
	u64	type;
	u64	size;
	u64	devid;
	u64	num_stripes;
};

int load_device_info(int fd, struct device_info **device_info_ptr,
		int *device_info_count);
int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count);
char *df_pretty_sizes(u64 size, int mode);
void print_device_chunks(int fd, u64 devid, u64 total_size,
		struct chunk_info *chunks_info_ptr,
		int chunks_info_count, int mode);

#endif