libparted 3.6
Loading...
Searching...
No Matches
unit.h
Go to the documentation of this file.
1/*
2 libparted - a library for manipulating disk partitions
3 Copyright (C) 2005, 2007, 2009-2014, 2019-2023 Free Software Foundation,
4 Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
27#ifndef PED_UNIT_H_INCLUDED
28#define PED_UNIT_H_INCLUDED
29
30#include <parted/device.h>
31
32#include <stdarg.h>
33#include <stdio.h>
34
35#define PED_SECTOR_SIZE_DEFAULT 512LL
36#define PED_KILOBYTE_SIZE 1000LL
37#define PED_MEGABYTE_SIZE 1000000LL
38#define PED_GIGABYTE_SIZE 1000000000LL
39#define PED_TERABYTE_SIZE 1000000000000LL
40#define PED_KIBIBYTE_SIZE 1024LL
41#define PED_MEBIBYTE_SIZE 1048576LL
42#define PED_GIBIBYTE_SIZE 1073741824LL
43#define PED_TEBIBYTE_SIZE 1099511627776LL
44
48typedef enum {
64
65#define PED_UNIT_FIRST PED_UNIT_SECTOR
66#define PED_UNIT_LAST PED_UNIT_TEBIBYTE
67
68extern long long ped_unit_get_size (const PedDevice* dev, PedUnit unit);
69extern const char *ped_unit_get_name (PedUnit unit)
70
71#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
72 __attribute ((__const__))
73#endif
74;
75extern PedUnit ped_unit_get_by_name (const char* unit_name)
76#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
77 __attribute ((__pure__))
78#endif
79;
80
81extern void ped_unit_set_default (PedUnit unit);
83
84extern char* ped_unit_format_byte (const PedDevice* dev, PedSector byte);
85extern char* ped_unit_format_custom_byte (const PedDevice* dev, PedSector byte,
86 PedUnit unit);
87
88extern char* ped_unit_format (const PedDevice* dev, PedSector sector);
89extern char* ped_unit_format_custom (const PedDevice* dev, PedSector sector,
90 PedUnit unit);
91
92extern int ped_unit_parse (const char* str, const PedDevice* dev,
94 PedGeometry** range);
95extern int ped_unit_parse_custom (const char* str, const PedDevice* dev,
97 PedGeometry** range);
98
99#endif /* PED_UNIT_H_INCLUDED */
100
long long PedSector
We can address 2^63 sectors.
Definition: device.h:31
char * ped_unit_format_byte(const PedDevice *dev, PedSector byte)
Get a string that describes the location of the byte on device dev.
Definition: unit.c:269
const char * ped_unit_get_name(PedUnit unit)
Get a textual (non-internationalized) representation of a unit.
Definition: unit.c:156
PedUnit ped_unit_get_by_name(const char *unit_name)
Get a unit based on its textual representation: unit_name.
Definition: unit.c:167
int ped_unit_parse(const char *str, const PedDevice *dev, PedSector *sector, PedGeometry **range)
If str contains a valid description of a location on dev, then *sector is modified to describe the lo...
Definition: unit.c:315
char * ped_unit_format_custom_byte(const PedDevice *dev, PedSector byte, PedUnit unit)
Get a string that describes the location of the byte on device dev.
Definition: unit.c:196
PedUnit ped_unit_get_default()
Get the current default unit.
Definition: unit.c:107
void ped_unit_set_default(PedUnit unit)
Set the default unit used by subsequent calls to the PedUnit API.
Definition: unit.c:97
long long ped_unit_get_size(const PedDevice *dev, PedUnit unit)
Get the byte size of a given unit.
Definition: unit.c:116
PedUnit
Human-friendly unit for representation of a location within device.
Definition: unit.h:48
char * ped_unit_format_custom(const PedDevice *dev, PedSector sector, PedUnit unit)
Get a string that describes the location sector on device dev.
Definition: unit.c:282
char * ped_unit_format(const PedDevice *dev, PedSector sector)
Get a string that describes the location sector on device dev.
Definition: unit.c:296
int ped_unit_parse_custom(const char *str, const PedDevice *dev, PedUnit unit, PedSector *sector, PedGeometry **range)
If str contains a valid description of a location on dev, then *sector is modified to describe the lo...
Definition: unit.c:502
@ PED_UNIT_MEGABYTE
Definition: unit.h:52
@ PED_UNIT_TERABYTE
Definition: unit.h:54
@ PED_UNIT_GIBIBYTE
Definition: unit.h:61
@ PED_UNIT_KILOBYTE
Definition: unit.h:51
@ PED_UNIT_GIGABYTE
Definition: unit.h:53
@ PED_UNIT_BYTE
Definition: unit.h:50
@ PED_UNIT_MEBIBYTE
Definition: unit.h:60
@ PED_UNIT_COMPACT
Definition: unit.h:55
@ PED_UNIT_SECTOR
Definition: unit.h:49
@ PED_UNIT_TEBIBYTE
Definition: unit.h:62
@ PED_UNIT_CYLINDER
Definition: unit.h:56
@ PED_UNIT_CHS
Definition: unit.h:57
@ PED_UNIT_PERCENT
Definition: unit.h:58
@ PED_UNIT_KIBIBYTE
Definition: unit.h:59
#define __attribute(arg)
Definition: parted.h:32
uint8_t sector
Definition: pc98.c:7
A block device - for example, /dev/hda, not /dev/hda3.
Definition: device.h:74
Geometry of the partition.
Definition: geom.h:35