libparted 3.6
Loading...
Searching...
No Matches
unit.in.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 _GL_ATTRIBUTE_CONST;
71extern PedUnit ped_unit_get_by_name (const char* unit_name) _GL_ATTRIBUTE_PURE;
72
73extern void ped_unit_set_default (PedUnit unit);
75
76extern char* ped_unit_format_byte (const PedDevice* dev, PedSector byte);
77extern char* ped_unit_format_custom_byte (const PedDevice* dev, PedSector byte,
78 PedUnit unit);
79
80extern char* ped_unit_format (const PedDevice* dev, PedSector sector);
81extern char* ped_unit_format_custom (const PedDevice* dev, PedSector sector,
82 PedUnit unit);
83
84extern int ped_unit_parse (const char* str, const PedDevice* dev,
86 PedGeometry** range);
87extern int ped_unit_parse_custom (const char* str, const PedDevice* dev,
89 PedGeometry** range);
90
91#endif /* PED_UNIT_H_INCLUDED */
92
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.in.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.in.h:52
@ PED_UNIT_TERABYTE
Definition: unit.in.h:54
@ PED_UNIT_GIBIBYTE
Definition: unit.in.h:61
@ PED_UNIT_KILOBYTE
Definition: unit.in.h:51
@ PED_UNIT_GIGABYTE
Definition: unit.in.h:53
@ PED_UNIT_BYTE
Definition: unit.in.h:50
@ PED_UNIT_MEBIBYTE
Definition: unit.in.h:60
@ PED_UNIT_COMPACT
Definition: unit.in.h:55
@ PED_UNIT_SECTOR
Definition: unit.in.h:49
@ PED_UNIT_TEBIBYTE
Definition: unit.in.h:62
@ PED_UNIT_CYLINDER
Definition: unit.in.h:56
@ PED_UNIT_CHS
Definition: unit.in.h:57
@ PED_UNIT_PERCENT
Definition: unit.in.h:58
@ PED_UNIT_KIBIBYTE
Definition: unit.in.h:59
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