1 /*
2 libparted - a library for manipulating disk partitions
3 Copyright (C) 2005, 2007 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /**
20 * \addtogroup PedUnit
21 * @{
22 */
23
24 /** \file unit.h */
25
26 #ifndef PED_UNIT_H_INCLUDED
27 #define PED_UNIT_H_INCLUDED
28
29 #include <parted/device.h>
30
31 #include <stdarg.h>
32 #include <stdio.h>
33
34 #define PED_SECTOR_SIZE_DEFAULT 512LL
35 #define PED_KILOBYTE_SIZE 1000LL
36 #define PED_MEGABYTE_SIZE 1000000LL
37 #define PED_GIGABYTE_SIZE 1000000000LL
38 #define PED_TERABYTE_SIZE 1000000000000LL
39 #define PED_KIBIBYTE_SIZE 1024LL
40 #define PED_MEBIBYTE_SIZE 1048576LL
41 #define PED_GIBIBYTE_SIZE 1073741824LL
42 #define PED_TEBIBYTE_SIZE 1099511627776LL
43
44 /**
45 * Human-friendly unit for representation of a location within device
46 */
47 typedef enum {
48 PED_UNIT_SECTOR,
49 PED_UNIT_BYTE,
50 PED_UNIT_KILOBYTE,
51 PED_UNIT_MEGABYTE,
52 PED_UNIT_GIGABYTE,
53 PED_UNIT_TERABYTE,
54 PED_UNIT_COMPACT,
55 PED_UNIT_CYLINDER,
56 PED_UNIT_CHS,
57 PED_UNIT_PERCENT,
58 PED_UNIT_KIBIBYTE,
59 PED_UNIT_MEBIBYTE,
60 PED_UNIT_GIBIBYTE,
61 PED_UNIT_TEBIBYTE
62 } PedUnit;
63
64 #define PED_UNIT_FIRST PED_UNIT_SECTOR
65 #define PED_UNIT_LAST PED_UNIT_TEBIBYTE
66
67 extern long long ped_unit_get_size (const PedDevice* dev, PedUnit unit);
68 extern const char* ped_unit_get_name (PedUnit unit);
69 extern PedUnit ped_unit_get_by_name (const char* unit_name);
70
71 extern void ped_unit_set_default (PedUnit unit);
72 extern PedUnit ped_unit_get_default ();
73
74 extern char* ped_unit_format_byte (const PedDevice* dev, PedSector byte);
75 extern char* ped_unit_format_custom_byte (const PedDevice* dev, PedSector byte,
76 PedUnit unit);
77
78 extern char* ped_unit_format (const PedDevice* dev, PedSector sector);
79 extern char* ped_unit_format_custom (const PedDevice* dev, PedSector sector,
80 PedUnit unit);
81
82 extern int ped_unit_parse (const char* str, const PedDevice* dev,
83 PedSector* sector,
84 PedGeometry** range);
85 extern int ped_unit_parse_custom (const char* str, const PedDevice* dev,
86 PedUnit unit, PedSector* sector,
87 PedGeometry** range);
88
89 #endif /* PED_UNIT_H_INCLUDED */
90
91 /** @} */
92
93