1/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License as
4 * published by the Free Software Foundation; either version 2 of
5 * the License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
15 * MA 02111-1307 USA
16 */
17#ifndef _DISK_INITIAL_
18#define _DISK_INITIAL_
19
20#include "disk_io_tools.h"
21
22#define PARTITION_FILE "/proc/partitions"
23#define MOUNT_FILE "/proc/mounts"
24
25#define USB_DISK_MAJOR 8
26#define DEFAULT_USB_TAG "USB disk"
27
28#ifdef BCM_MMC
29#define MMC_DISK_MAJOR 179
30#define DEFAULT_MMC_TAG "SD card"
31#endif
32
33#define PARTITION_TYPE_UNKNOWN "unknown"
34
35typedef struct disk_info disk_info_t;
36typedef struct partition_info partition_info_t;
37
38#pragma pack(1) // let struct be neat by byte.
39struct disk_info{
40	char *tag;
41	char *vendor;
42	char *model;
43	char *device;
44	u32 major;
45	u32 minor;
46	char *port;
47	u32 partition_number;
48	u32 mounted_number;
49	u64 size_in_kilobytes;
50	partition_info_t *partitions;
51	disk_info_t *next;
52} ;
53
54struct partition_info{
55	char *device;
56	char *label;
57	u32 partition_order;
58	char *mount_point;
59	char *file_system;
60	char *permission;
61	u64 size_in_kilobytes;
62	u64 used_kilobytes;
63	disk_info_t *disk;
64	partition_info_t *next;
65} ;
66#pragma pack() // End.
67
68extern disk_info_t *read_disk_data();
69extern int is_disk_name(const char *device_name);
70extern disk_info_t *create_disk(const char *device_name, disk_info_t **new_disk_info);
71extern disk_info_t *initial_disk_data(disk_info_t **disk_info_list);
72extern void free_disk_data(disk_info_t **disk_info_list);
73
74extern int get_disk_major_minor(const char *disk_name, u32 *major, u32 *minor);
75extern int get_disk_size(const char *disk_name, u64 *size_in_kilobytes);
76extern char *get_disk_vendor(const char *disk_name, char *buf, const int buf_size);
77extern char *get_disk_model(const char *disk_name, char *buf, const int buf_size);
78extern int get_disk_partitionnumber(const char *string, u32 *partition_number, u32 *mounted_number);
79
80extern int is_partition_name(const char *device_name, u32 *partition_order);
81extern partition_info_t *create_partition(const char *device_name, partition_info_t **new_part_info);
82extern partition_info_t *initial_part_data(partition_info_t **part_info_list);
83extern void free_partition_data(partition_info_t **partition_info_list);
84
85extern int get_partition_size(const char *partition_name, u64 *size_in_kilobytes);
86extern int read_mount_data(const char *device_name
87		, char *mount_point, int mount_len
88		, char *type, int type_len
89		, char *right, int right_len
90		);
91extern int get_mount_path(const char *const pool, char *mount_path, int mount_len);
92extern int get_mount_size(const char *mount_point, u64 *total_kilobytes, u64 *used_kilobytes);
93
94extern char *get_disk_name(const char *string, char *buf, const int buf_size);
95
96extern void print_disk(const disk_info_t *const disk_info);
97extern void print_disks(const disk_info_t *const disk_list);
98extern void print_partition(const partition_info_t *const partition_info);
99extern void print_partitions(const partition_info_t *const partition_list);
100#endif // _DISK_INITIAL_
101