Loading...
Searching...
No Matches
unit.h
Go to the documentation of this file.
/*
libparted - a library for manipulating disk partitions
Copyright (C) 2005, 2007, 2009-2014, 2019-2023, 2026 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
*/
#ifndef PED_UNIT_H_INCLUDED
#define PED_UNIT_H_INCLUDED
#include <parted/device.h>
#include <stdarg.h>
#include <stdio.h>
#define PED_SECTOR_SIZE_DEFAULT 512LL
#define PED_KILOBYTE_SIZE 1000LL
#define PED_MEGABYTE_SIZE 1000000LL
#define PED_GIGABYTE_SIZE 1000000000LL
#define PED_TERABYTE_SIZE 1000000000000LL
#define PED_KIBIBYTE_SIZE 1024LL
#define PED_MEBIBYTE_SIZE 1048576LL
#define PED_GIBIBYTE_SIZE 1073741824LL
#define PED_TEBIBYTE_SIZE 1099511627776LL
typedef enum {
PED_UNIT_SECTOR,
PED_UNIT_BYTE,
PED_UNIT_KILOBYTE,
PED_UNIT_MEGABYTE,
PED_UNIT_GIGABYTE,
PED_UNIT_TERABYTE,
PED_UNIT_COMPACT,
PED_UNIT_CYLINDER,
PED_UNIT_CHS,
PED_UNIT_PERCENT,
PED_UNIT_KIBIBYTE,
PED_UNIT_MEBIBYTE,
PED_UNIT_GIBIBYTE,
PED_UNIT_TEBIBYTE
} PedUnit;
#define PED_UNIT_FIRST PED_UNIT_SECTOR
#define PED_UNIT_LAST PED_UNIT_TEBIBYTE
extern long long ped_unit_get_size (const PedDevice* dev, PedUnit unit);
extern const char *ped_unit_get_name (PedUnit unit)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__const__))
#endif
;
extern PedUnit ped_unit_get_by_name (const char* unit_name)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern void ped_unit_set_default (PedUnit unit);
extern PedUnit ped_unit_get_default ();
extern char* ped_unit_format_byte (const PedDevice* dev, PedSector byte);
extern char* ped_unit_format_custom_byte (const PedDevice* dev, PedSector byte,
PedUnit unit);
extern char* ped_unit_format (const PedDevice* dev, PedSector sector);
extern char* ped_unit_format_custom (const PedDevice* dev, PedSector sector,
PedUnit unit);
extern int ped_unit_parse (const char* str, const PedDevice* dev,
PedSector* sector,
PedGeometry** range);
extern int ped_unit_parse_custom (const char* str, const PedDevice* dev,
PedUnit unit, PedSector* sector,
PedGeometry** range);
#endif /* PED_UNIT_H_INCLUDED */
device.h
PedSector
long long PedSector
We can address 2^63 sectors.
Definition device.h:31
PedDevice
struct _PedDevice PedDevice
Definition device.h:58
PedGeometry
struct _PedGeometry PedGeometry
Definition geom.h:30
ped_unit_format_byte
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
ped_unit_get_name
const char * ped_unit_get_name(PedUnit unit)
Get a textual (non-internationalized) representation of a unit.
Definition unit.c:156
ped_unit_get_by_name
PedUnit ped_unit_get_by_name(const char *unit_name)
Get a unit based on its textual representation: unit_name.
Definition unit.c:167
ped_unit_parse
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
ped_unit_format_custom_byte
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
ped_unit_get_default
PedUnit ped_unit_get_default()
Get the current default unit.
Definition unit.c:107
ped_unit_set_default
void ped_unit_set_default(PedUnit unit)
Set the default unit used by subsequent calls to the PedUnit API.
Definition unit.c:97
ped_unit_get_size
long long ped_unit_get_size(const PedDevice *dev, PedUnit unit)
Get the byte size of a given unit.
Definition unit.c:116
PedUnit
PedUnit
Human-friendly unit for representation of a location within device.
Definition unit.h:48
ped_unit_format_custom
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
ped_unit_format
char * ped_unit_format(const PedDevice *dev, PedSector sector)
Get a string that describes the location sector on device dev.
Definition unit.c:296
ped_unit_parse_custom
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
@ PED_UNIT_MEGABYTE
Definition unit.h:52
PED_UNIT_TERABYTE
@ PED_UNIT_TERABYTE
Definition unit.h:54
PED_UNIT_GIBIBYTE
@ PED_UNIT_GIBIBYTE
Definition unit.h:61
PED_UNIT_KILOBYTE
@ PED_UNIT_KILOBYTE
Definition unit.h:51
PED_UNIT_GIGABYTE
@ PED_UNIT_GIGABYTE
Definition unit.h:53
PED_UNIT_BYTE
@ PED_UNIT_BYTE
Definition unit.h:50
PED_UNIT_MEBIBYTE
@ PED_UNIT_MEBIBYTE
Definition unit.h:60
PED_UNIT_COMPACT
@ PED_UNIT_COMPACT
Definition unit.h:55
PED_UNIT_SECTOR
@ PED_UNIT_SECTOR
Definition unit.h:49
PED_UNIT_TEBIBYTE
@ PED_UNIT_TEBIBYTE
Definition unit.h:62
PED_UNIT_CYLINDER
@ PED_UNIT_CYLINDER
Definition unit.h:56
PED_UNIT_CHS
@ PED_UNIT_CHS
Definition unit.h:57
PED_UNIT_PERCENT
@ PED_UNIT_PERCENT
Definition unit.h:58
PED_UNIT_KIBIBYTE
@ PED_UNIT_KIBIBYTE
Definition unit.h:59
__attribute
#define __attribute(arg)
Definition parted.h:32
sector
uint8_t sector
Definition pc98.c:7