pmt: initial 3.0.2 update

This commit is contained in:
2024-12-14 10:25:23 +03:00
parent 686ef38598
commit 7f8090bb1f
1292 changed files with 500876 additions and 2823 deletions

101
include/parted/constraint.h Executable file
View File

@@ -0,0 +1,101 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1998-2000, 2007, 2009-2014, 2019-2023 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_CONSTRAINT_H_INCLUDED
#define PED_CONSTRAINT_H_INCLUDED
typedef struct _PedConstraint PedConstraint;
#include <parted/device.h>
#include <parted/geom.h>
#include <parted/natmath.h>
struct _PedConstraint {
PedAlignment* start_align;
PedAlignment* end_align;
PedGeometry* start_range;
PedGeometry* end_range;
PedSector min_size;
PedSector max_size;
};
extern int
ped_constraint_init (
PedConstraint* constraint,
const PedAlignment* start_align,
const PedAlignment* end_align,
const PedGeometry* start_range,
const PedGeometry* end_range,
PedSector min_size,
PedSector max_size);
extern PedConstraint*
ped_constraint_new (
const PedAlignment* start_align,
const PedAlignment* end_align,
const PedGeometry* start_range,
const PedGeometry* end_range,
PedSector min_size,
PedSector max_size);
extern PedConstraint*
ped_constraint_new_from_min_max (
const PedGeometry* min,
const PedGeometry* max);
extern PedConstraint*
ped_constraint_new_from_min (const PedGeometry* min);
extern PedConstraint*
ped_constraint_new_from_max (const PedGeometry* max);
extern PedConstraint*
ped_constraint_duplicate (const PedConstraint* constraint);
extern void
ped_constraint_done (PedConstraint* constraint);
extern void
ped_constraint_destroy (PedConstraint* constraint);
extern PedConstraint*
ped_constraint_intersect (const PedConstraint* a, const PedConstraint* b);
extern PedGeometry*
ped_constraint_solve_max (const PedConstraint* constraint);
extern PedGeometry*
ped_constraint_solve_nearest (
const PedConstraint* constraint, const PedGeometry* geom);
extern int
ped_constraint_is_solution (const PedConstraint* constraint,
const PedGeometry* geom)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern PedConstraint*
ped_constraint_any (const PedDevice* dev);
extern PedConstraint*
ped_constraint_exact (const PedGeometry* geom);
#endif /* PED_CONSTRAINT_H_INCLUDED */

39
include/parted/crc32.h Executable file
View File

@@ -0,0 +1,39 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1998-2000, 2007, 2009-2014, 2019-2023 Free Software
Foundation, Inc.
crc32.h
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 _CRC32_H
#define _CRC32_H
#include <stdint.h>
/*
* This computes a 32 bit CRC of the data in the buffer, and returns the CRC.
* The polynomial used is 0xedb88320.
*/
extern uint32_t __efi_crc32 (const void *buf, unsigned long len,
uint32_t seed)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
#endif /* _CRC32_H */

88
include/parted/debug.h Executable file
View File

@@ -0,0 +1,88 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1998-2000, 2002, 2007, 2009-2014, 2019-2023 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_DEBUG_H_INCLUDED
#define PED_DEBUG_H_INCLUDED
#include <stdarg.h>
#ifdef DEBUG
typedef void (PedDebugHandler) ( const int level, const char* file, int line,
const char* function, const char* msg );
extern void ped_debug_set_handler (PedDebugHandler* handler);
extern void ped_debug ( const int level, const char* file, int line,
const char* function, const char* msg, ... );
extern void __attribute__((__noreturn__))
ped_assert ( const char* cond_text,
const char* file, int line, const char* function );
#if defined __GNUC__ && !defined __JSFTRACE__
#define PED_DEBUG(level, ...) \
ped_debug ( level, __FILE__, __LINE__, __PRETTY_FUNCTION__, \
__VA_ARGS__ )
#define PED_ASSERT(cond) \
do { \
if (!(cond)) { \
ped_assert ( \
#cond, \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__ ); \
} \
} while (0)
#else /* !__GNUC__ */
/* function because variadic macros are C99 */
static void PED_DEBUG (int level, ...)
{
va_list va_args;
va_start (va_args, level);
ped_debug ( level, "unknown file", 0, "unknown function", va_args );
va_end (va_args);
}
#define PED_ASSERT(cond) \
do { \
if (!(cond)) { \
ped_assert ( \
#cond, \
"unknown", \
0, \
"unknown"); \
} \
} while (0)
#endif /* __GNUC__ */
#else /* !DEBUG */
#define PED_ASSERT(cond) do {} while (0)
#define PED_DEBUG(level, ...) do {} while (0)
#endif /* DEBUG */
#endif /* PED_DEBUG_H_INCLUDED */

172
include/parted/device.h Executable file
View File

@@ -0,0 +1,172 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1998-2001, 2005, 2007-2008, 2011-2014, 2019-2023 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/>.
*/
/**
* \addtogroup PedDevice
* @{
*/
/** \file device.h */
#ifndef PED_DEVICE_H_INCLUDED
#define PED_DEVICE_H_INCLUDED
/** We can address 2^63 sectors */
typedef long long PedSector;
typedef enum {
PED_DEVICE_UNKNOWN = 0,
PED_DEVICE_SCSI = 1,
PED_DEVICE_IDE = 2,
PED_DEVICE_DAC960 = 3,
PED_DEVICE_CPQARRAY = 4,
PED_DEVICE_FILE = 5,
PED_DEVICE_ATARAID = 6,
PED_DEVICE_I2O = 7,
PED_DEVICE_UBD = 8,
PED_DEVICE_DASD = 9,
PED_DEVICE_VIODASD = 10,
PED_DEVICE_SX8 = 11,
PED_DEVICE_DM = 12,
PED_DEVICE_XVD = 13,
PED_DEVICE_SDMMC = 14,
PED_DEVICE_VIRTBLK = 15,
PED_DEVICE_AOE = 16,
PED_DEVICE_MD = 17,
PED_DEVICE_LOOP = 18,
PED_DEVICE_NVME = 19,
PED_DEVICE_RAM = 20,
PED_DEVICE_PMEM = 21
} PedDeviceType;
typedef struct _PedDevice PedDevice;
typedef struct _PedDeviceArchOps PedDeviceArchOps;
typedef struct _PedCHSGeometry PedCHSGeometry;
/**
* A cylinder-head-sector "old-style" geometry.
*
* A device addressed in this way has C*H*S sectors.
*/
struct _PedCHSGeometry {
int cylinders;
int heads;
int sectors;
};
/** A block device - for example, /dev/hda, not /dev/hda3 */
struct _PedDevice {
PedDevice* next;
char* model; /**< \brief description of hardware
(manufacturer, model) */
char* path; /**< device /dev entry */
PedDeviceType type; /**< SCSI, IDE, etc. \sa PedDeviceType */
long long sector_size; /**< logical sector size */
long long phys_sector_size; /**< physical sector size */
PedSector length; /**< device length (LBA) */
int open_count; /**< the number of times this device has
been opened with ped_device_open(). */
int read_only;
int external_mode;
int dirty;
int boot_dirty;
PedCHSGeometry hw_geom;
PedCHSGeometry bios_geom;
short host, did;
void* arch_specific;
};
#include <parted/natmath.h>
/**
* List of functions implementing architecture-specific operations.
*/
struct _PedDeviceArchOps {
PedDevice* (*_new) (const char* path);
void (*destroy) (PedDevice* dev);
int (*is_busy) (PedDevice* dev);
int (*open) (PedDevice* dev);
int (*refresh_open) (PedDevice* dev);
int (*close) (PedDevice* dev);
int (*refresh_close) (PedDevice* dev);
int (*read) (const PedDevice* dev, void* buffer,
PedSector start, PedSector count);
int (*write) (PedDevice* dev, const void* buffer,
PedSector start, PedSector count);
int (*sync) (PedDevice* dev);
int (*sync_fast) (PedDevice* dev);
PedSector (*check) (PedDevice* dev, void* buffer,
PedSector start, PedSector count);
void (*probe_all) ();
/* These functions are optional */
PedAlignment *(*get_minimum_alignment)(const PedDevice *dev);
PedAlignment *(*get_optimum_alignment)(const PedDevice *dev);
};
#include <parted/constraint.h>
#include <parted/timer.h>
extern void ped_device_probe_all ();
extern void ped_device_free_all ();
extern PedDevice* ped_device_get (const char* name);
extern PedDevice* ped_device_get_next (const PedDevice* dev)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern int ped_device_is_busy (PedDevice* dev);
extern int ped_device_open (PedDevice* dev);
extern int ped_device_close (PedDevice* dev);
extern void ped_device_destroy (PedDevice* dev);
extern void ped_device_cache_remove (PedDevice* dev);
extern int ped_device_begin_external_access (PedDevice* dev);
extern int ped_device_end_external_access (PedDevice* dev);
extern int ped_device_read (const PedDevice* dev, void* buffer,
PedSector start, PedSector count);
extern int ped_device_write (PedDevice* dev, const void* buffer,
PedSector start, PedSector count);
extern int ped_device_sync (PedDevice* dev);
extern int ped_device_sync_fast (PedDevice* dev);
extern PedSector ped_device_check (PedDevice* dev, void* buffer,
PedSector start, PedSector count);
extern PedConstraint* ped_device_get_constraint (const PedDevice* dev);
extern PedConstraint *ped_device_get_minimal_aligned_constraint(
const PedDevice *dev);
extern PedConstraint *ped_device_get_optimal_aligned_constraint(
const PedDevice *dev);
extern PedAlignment *ped_device_get_minimum_alignment(const PedDevice *dev);
extern PedAlignment *ped_device_get_optimum_alignment(const PedDevice *dev);
/* private stuff ;-) */
extern void _ped_device_probe (const char* path);
#endif /* PED_DEVICE_H_INCLUDED */
/** @} */

503
include/parted/disk.h Executable file
View File

@@ -0,0 +1,503 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1999-2002, 2007-2014, 2019-2023 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/>.
*/
/**
* \addtogroup PedDisk
* @{
*/
/** \file disk.h */
#ifndef PED_DISK_H_INCLUDED
#define PED_DISK_H_INCLUDED
/* Include these to work around gnulib redefining free, read, etc. which causes problems
* with pt-common.h
*/
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
/**
* Disk flags
*/
enum _PedDiskFlag {
/* This flag (which defaults to true) controls if disk types for
which cylinder alignment is optional do cylinder alignment when a
new partition gets added.
This flag is available for msdos and sun disklabels (for sun labels
it only controls the aligning of the end of the partition) */
PED_DISK_CYLINDER_ALIGNMENT=1,
/* This flag controls whether the boot flag of a GPT PMBR is set */
PED_DISK_GPT_PMBR_BOOT=2,
};
// NOTE: DO NOT define using enums
#define PED_DISK_FIRST_FLAG 1 // PED_DISK_CYLINDER_ALIGNMENT
#define PED_DISK_LAST_FLAG 2 // PED_DISK_GPT_PMBR_BOOT
/**
* Partition types
*/
enum _PedPartitionType {
PED_PARTITION_NORMAL = 0x00,
PED_PARTITION_LOGICAL = 0x01,
PED_PARTITION_EXTENDED = 0x02,
PED_PARTITION_FREESPACE = 0x04,
PED_PARTITION_METADATA = 0x08,
PED_PARTITION_PROTECTED = 0x10
};
/**
* Partition flags.
*/
enum _PedPartitionFlag {
PED_PARTITION_BOOT=1,
PED_PARTITION_ROOT=2,
PED_PARTITION_SWAP=3,
PED_PARTITION_HIDDEN=4,
PED_PARTITION_RAID=5,
PED_PARTITION_LVM=6,
PED_PARTITION_LBA=7,
PED_PARTITION_HPSERVICE=8,
PED_PARTITION_PALO=9,
PED_PARTITION_PREP=10,
PED_PARTITION_MSFT_RESERVED=11,
PED_PARTITION_BIOS_GRUB=12,
PED_PARTITION_APPLE_TV_RECOVERY=13,
PED_PARTITION_DIAG=14,
PED_PARTITION_LEGACY_BOOT=15,
PED_PARTITION_MSFT_DATA=16,
PED_PARTITION_IRST=17,
PED_PARTITION_ESP=18,
PED_PARTITION_CHROMEOS_KERNEL=19,
PED_PARTITION_BLS_BOOT=20,
PED_PARTITION_LINUX_HOME=21,
PED_PARTITION_NO_AUTOMOUNT=22,
};
// NOTE: DO NOT define using enums
#define PED_PARTITION_FIRST_FLAG 1 // PED_PARTITION_BOOT
#define PED_PARTITION_LAST_FLAG 22 // PED_PARTITION_NO_AUTOMOUNT
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
PED_DISK_TYPE_PARTITION_NAME=2, /**< supports partition names */
PED_DISK_TYPE_PARTITION_TYPE_ID=4, /**< supports partition type-ids */
PED_DISK_TYPE_PARTITION_TYPE_UUID=8, /**< supports partition type-uuids */
PED_DISK_TYPE_DISK_UUID=16, /**< supports disk uuids */
PED_DISK_TYPE_PARTITION_UUID=32, /**< supports partition uuids */
};
// NOTE: DO NOT define using enums
#define PED_DISK_TYPE_FIRST_FEATURE 1 // PED_DISK_TYPE_EXTENDED
#define PED_DISK_TYPE_LAST_FEATURE 32 // PED_DISK_TYPE_PARTITION_UUID
struct _PedDisk;
struct _PedPartition;
struct _PedDiskOps;
struct _PedDiskType;
struct _PedDiskArchOps;
typedef enum _PedDiskFlag PedDiskFlag;
typedef enum _PedPartitionType PedPartitionType;
typedef enum _PedPartitionFlag PedPartitionFlag;
typedef enum _PedDiskTypeFeature PedDiskTypeFeature;
typedef struct _PedDisk PedDisk;
typedef struct _PedPartition PedPartition;
typedef const struct _PedDiskOps PedDiskOps;
typedef struct _PedDiskType PedDiskType;
typedef const struct _PedDiskArchOps PedDiskArchOps;
#include <parted/device.h>
#include <parted/filesys.h>
#include <parted/natmath.h>
#include <parted/geom.h>
#include <stdbool.h>
/** @} */
/**
* \addtogroup PedPartition
*
* @{
*/
/** \file disk.h */
/**
* PedPartition structure represents a partition.
*/
struct _PedPartition {
PedPartition* prev;
PedPartition* next;
/**< the partition table of the partition */
PedDisk* disk;
PedGeometry geom; /**< geometry of the partition */
/**< the partition number: In Linux, this is the
same as the minor number. No assumption
should be made about "num" and "type"
- different disk labels have different rules. */
int num;
PedPartitionType type; /**< the type of partition: a bit field of
PED_PARTITION_LOGICAL, PED_PARTITION_EXTENDED,
PED_PARTITION_METADATA
and PED_PARTITION_FREESPACE.
Both the first two, and the last two are
mutually exclusive.
An extended partition is a primary
partition that may contain logical partitions.
There is at most one extended partition on
a disk.
A logical partition is like a primary
partition, except it's inside an extended
partition. Internally, pseudo partitions are
allocated to represent free space, or disk
label meta-data. These have the
PED_PARTITION_FREESPACE or
PED_PARTITION_METADATA bit set. */
/**< The type of file system on the partition. NULL if unknown. */
const PedFileSystemType* fs_type;
/**< Only used for an extended partition. The list of logical
partitions (and free space and metadata within the extended
partition). */
PedPartition* part_list;
void* disk_specific;
};
/** @} */
/**
* \addtogroup PedDisk
* @{
*/
/**
* Represents a disk label (partition table).
*/
struct _PedDisk {
PedDevice* dev; /**< the device where the
partition table lies */
const PedDiskType* type; /**< type of disk label */
const int* block_sizes; /**< block sizes supported
by this label */
PedPartition* part_list; /**< list of partitions. Access with
ped_disk_next_partition() */
void* disk_specific;
/* office use only ;-) */
int needs_clobber; /**< clobber before write? */
int update_mode; /**< mode without free/metadata
partitions, for easier
update */
};
struct _PedDiskOps {
/* disk label operations */
int (*probe) (const PedDevice *dev);
int (*clobber) (PedDevice* dev);
PedDisk* (*alloc) (const PedDevice* dev);
PedDisk* (*duplicate) (const PedDisk* disk);
void (*free) (PedDisk* disk);
int (*read) (PedDisk* disk);
int (*write) (const PedDisk* disk);
int (*disk_set_flag) (
PedDisk *disk,
PedDiskFlag flag,
int state);
int (*disk_get_flag) (
const PedDisk *disk,
PedDiskFlag flag);
int (*disk_is_flag_available) (
const PedDisk *disk,
PedDiskFlag flag);
uint8_t* (*disk_get_uuid) (const PedDisk* disk);
/** \todo add label guessing op here */
/* partition operations */
PedPartition* (*partition_new) (
const PedDisk* disk,
PedPartitionType part_type,
const PedFileSystemType* fs_type,
PedSector start,
PedSector end);
PedPartition* (*partition_duplicate) (const PedPartition* part);
void (*partition_destroy) (PedPartition* part);
int (*partition_set_system) (PedPartition* part,
const PedFileSystemType* fs_type);
int (*partition_set_flag) (
PedPartition* part,
PedPartitionFlag flag,
int state);
int (*partition_get_flag) (
const PedPartition* part,
PedPartitionFlag flag);
int (*partition_is_flag_available) (
const PedPartition* part,
PedPartitionFlag flag);
void (*partition_set_name) (PedPartition* part, const char* name);
const char* (*partition_get_name) (const PedPartition* part);
int (*partition_set_type_id) (PedPartition* part, uint8_t id);
uint8_t (*partition_get_type_id) (const PedPartition* part);
int (*partition_set_type_uuid) (PedPartition* part, const uint8_t* uuid);
uint8_t* (*partition_get_type_uuid) (const PedPartition* part);
uint8_t* (*partition_get_uuid) (const PedPartition* part);
int (*partition_align) (PedPartition* part,
const PedConstraint* constraint);
int (*partition_enumerate) (PedPartition* part);
bool (*partition_check) (const PedPartition* part);
/* other */
int (*alloc_metadata) (PedDisk* disk);
int (*get_max_primary_partition_count) (const PedDisk* disk);
bool (*get_max_supported_partition_count) (const PedDisk* disk,
int* supported);
PedAlignment *(*get_partition_alignment)(const PedDisk *disk);
PedSector (*max_length) (void);
PedSector (*max_start_sector) (void);
};
struct _PedDiskType {
PedDiskType* next;
const char* name; /**< the name of the partition table type.
\todo not very intuitive name */
PedDiskOps* const ops;
PedDiskTypeFeature features; /**< bitmap of supported features */
};
/**
* Architecture-specific operations. i.e. communication with kernel (or
* whatever) about changes, etc.
*/
struct _PedDiskArchOps {
char* (*partition_get_path) (const PedPartition* part);
int (*partition_is_busy) (const PedPartition* part);
int (*disk_commit) (PedDisk* disk);
};
extern void ped_disk_type_register (PedDiskType* type);
extern void ped_disk_type_unregister (PedDiskType* type);
extern PedDiskType* ped_disk_type_get_next (PedDiskType const *type)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern PedDiskType* ped_disk_type_get (const char* name)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern int ped_disk_type_check_feature (const PedDiskType* disk_type,
PedDiskTypeFeature feature)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern PedDiskType* ped_disk_probe (PedDevice* dev);
extern int ped_disk_clobber (PedDevice* dev);
extern PedDisk* ped_disk_new (PedDevice* dev);
extern PedDisk* ped_disk_new_fresh (PedDevice* dev,
const PedDiskType* disk_type);
extern PedDisk* ped_disk_duplicate (const PedDisk* old_disk);
extern void ped_disk_destroy (PedDisk* disk);
extern int ped_disk_commit (PedDisk* disk);
extern int ped_disk_commit_to_dev (PedDisk* disk);
extern int ped_disk_commit_to_os (PedDisk* disk);
extern int ped_disk_check (const PedDisk* disk);
extern void ped_disk_print (const PedDisk* disk);
extern int ped_disk_get_primary_partition_count (const PedDisk* disk)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern int ped_disk_get_last_partition_num (const PedDisk* disk)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern int ped_disk_get_max_primary_partition_count (const PedDisk* disk);
extern bool ped_disk_get_max_supported_partition_count(const PedDisk* disk,
int* supported);
extern PedAlignment *ped_disk_get_partition_alignment(const PedDisk *disk);
extern int ped_disk_set_flag(PedDisk *disk, PedDiskFlag flag, int state);
extern int ped_disk_get_flag(const PedDisk *disk, PedDiskFlag flag);
extern int ped_disk_is_flag_available(const PedDisk *disk, PedDiskFlag flag);
extern uint8_t* ped_disk_get_uuid (const PedDisk* disk);
extern const char *ped_disk_flag_get_name(PedDiskFlag flag);
extern PedDiskFlag ped_disk_flag_get_by_name(const char *name);
extern PedDiskFlag ped_disk_flag_next(PedDiskFlag flag)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__const__))
#endif
;
/** @} */
/**
* \addtogroup PedPartition
*
* @{
*/
extern PedPartition* ped_partition_new (const PedDisk* disk,
PedPartitionType type,
const PedFileSystemType* fs_type,
PedSector start,
PedSector end);
extern void ped_partition_destroy (PedPartition* part);
extern int ped_partition_is_active (const PedPartition* part)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern int ped_partition_set_flag (PedPartition* part, PedPartitionFlag flag,
int state);
extern int ped_partition_get_flag (const PedPartition* part,
PedPartitionFlag flag);
extern int ped_partition_is_flag_available (const PedPartition* part,
PedPartitionFlag flag);
extern int ped_partition_set_system (PedPartition* part,
const PedFileSystemType* fs_type);
extern int ped_partition_set_name (PedPartition* part, const char* name);
extern const char* ped_partition_get_name (const PedPartition* part);
extern int ped_partition_set_type_id (PedPartition* part, uint8_t id);
extern uint8_t ped_partition_get_type_id (const PedPartition* part);
extern int ped_partition_set_type_uuid (PedPartition* part, const uint8_t* uuid);
extern uint8_t* ped_partition_get_type_uuid (const PedPartition* part);
extern uint8_t* ped_partition_get_uuid (const PedPartition* part);
extern int ped_partition_is_busy (const PedPartition* part);
extern char* ped_partition_get_path (const PedPartition* part);
extern const char* ped_partition_type_get_name (PedPartitionType part_type)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__const__))
#endif
;
extern const char* ped_partition_flag_get_name (PedPartitionFlag flag);
extern PedPartitionFlag ped_partition_flag_get_by_name (const char* name);
extern PedPartitionFlag ped_partition_flag_next (PedPartitionFlag flag)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__const__))
#endif
;
/** @} */
/**
* \addtogroup PedDisk
* @{
*/
extern int ped_disk_add_partition (PedDisk* disk, PedPartition* part,
const PedConstraint* constraint);
extern int ped_disk_remove_partition (PedDisk* disk, PedPartition* part);
extern int ped_disk_delete_partition (PedDisk* disk, PedPartition* part);
extern int ped_disk_delete_all (PedDisk* disk);
extern int ped_disk_set_partition_geom (PedDisk* disk, PedPartition* part,
const PedConstraint* constraint,
PedSector start, PedSector end);
extern int ped_disk_maximize_partition (PedDisk* disk, PedPartition* part,
const PedConstraint* constraint);
extern PedGeometry* ped_disk_get_max_partition_geometry (PedDisk* disk,
PedPartition* part, const PedConstraint* constraint);
extern int ped_disk_minimize_extended_partition (PedDisk* disk);
extern PedPartition* ped_disk_next_partition (const PedDisk* disk,
const PedPartition* part)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern PedPartition* ped_disk_get_partition (const PedDisk* disk, int num)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern PedPartition* ped_disk_get_partition_by_sector (const PedDisk* disk,
PedSector sect)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern PedPartition* ped_disk_extended_partition (const PedDisk* disk)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern PedSector ped_disk_max_partition_length (const PedDisk *disk);
extern PedSector ped_disk_max_partition_start_sector (const PedDisk *disk);
/* internal functions */
extern PedDisk* _ped_disk_alloc (const PedDevice* dev, const PedDiskType* type);
extern void _ped_disk_free (PedDisk* disk);
/** @} */
/**
* \addtogroup PedPartition
*
* @{
*/
extern PedPartition* _ped_partition_alloc (const PedDisk* disk,
PedPartitionType type,
const PedFileSystemType* fs_type,
PedSector start,
PedSector end);
extern void _ped_partition_free (PedPartition* part);
extern int _ped_partition_attempt_align (
PedPartition* part, const PedConstraint* external,
PedConstraint* internal);
#endif /* PED_DISK_H_INCLUDED */
/** @} */

85
include/parted/endian.h Executable file
View File

@@ -0,0 +1,85 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1998-2002, 2007, 2009-2014, 2019-2023 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/>.
*/
/* should only be #included by files in libparted */
#ifndef PED_ENDIAN_H_INCLUDED
#define PED_ENDIAN_H_INCLUDED
#include <stdint.h>
/* returns the n'th least significant byte */
#define _GET_BYTE(x, n) ( ((x) >> (8 * (n))) & 0xff )
#define _PED_SWAP16(x) ( (_GET_BYTE(x, 0) << 8) \
+ (_GET_BYTE(x, 1) << 0) )
#define _PED_SWAP32(x) ( (_GET_BYTE(x, 0) << 24) \
+ (_GET_BYTE(x, 1) << 16) \
+ (_GET_BYTE(x, 2) << 8) \
+ (_GET_BYTE(x, 3) << 0) )
#define _PED_SWAP64(x) ( (_GET_BYTE(x, 0) << 56) \
+ (_GET_BYTE(x, 1) << 48) \
+ (_GET_BYTE(x, 2) << 40) \
+ (_GET_BYTE(x, 3) << 32) \
+ (_GET_BYTE(x, 4) << 24) \
+ (_GET_BYTE(x, 5) << 16) \
+ (_GET_BYTE(x, 6) << 8) \
+ (_GET_BYTE(x, 7) << 0) )
#define PED_SWAP16(x) ((uint16_t) _PED_SWAP16( (uint16_t) (x) ))
#define PED_SWAP32(x) ((uint32_t) _PED_SWAP32( (uint32_t) (x) ))
#define PED_SWAP64(x) ((uint64_t) _PED_SWAP64( (uint64_t) (x) ))
#ifdef WORDS_BIGENDIAN
#define PED_CPU_TO_LE16(x) PED_SWAP16(x)
#define PED_CPU_TO_BE16(x) (x)
#define PED_CPU_TO_LE32(x) PED_SWAP32(x)
#define PED_CPU_TO_BE32(x) (x)
#define PED_CPU_TO_LE64(x) PED_SWAP64(x)
#define PED_CPU_TO_BE64(x) (x)
#define PED_LE16_TO_CPU(x) PED_SWAP16(x)
#define PED_BE16_TO_CPU(x) (x)
#define PED_LE32_TO_CPU(x) PED_SWAP32(x)
#define PED_BE32_TO_CPU(x) (x)
#define PED_LE64_TO_CPU(x) PED_SWAP64(x)
#define PED_BE64_TO_CPU(x) (x)
#else /* !WORDS_BIGENDIAN */
#define PED_CPU_TO_LE16(x) (x)
#define PED_CPU_TO_BE16(x) PED_SWAP16(x)
#define PED_CPU_TO_LE32(x) (x)
#define PED_CPU_TO_BE32(x) PED_SWAP32(x)
#define PED_CPU_TO_LE64(x) (x)
#define PED_CPU_TO_BE64(x) PED_SWAP64(x)
#define PED_LE16_TO_CPU(x) (x)
#define PED_BE16_TO_CPU(x) PED_SWAP16(x)
#define PED_LE32_TO_CPU(x) (x)
#define PED_BE32_TO_CPU(x) PED_SWAP32(x)
#define PED_LE64_TO_CPU(x) (x)
#define PED_BE64_TO_CPU(x) PED_SWAP64(x)
#endif /* !WORDS_BIGENDIAN */
#endif /* PED_ENDIAN_H_INCLUDED */

136
include/parted/exception.h Executable file
View File

@@ -0,0 +1,136 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1999-2000, 2007, 2009-2014, 2019-2023 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/>.
*/
/**
* \addtogroup PedException
* @{
*/
/** \file exception.h */
#ifndef PED_EXCEPTION_H_INCLUDED
#define PED_EXCEPTION_H_INCLUDED
typedef struct _PedException PedException;
/**
* Exception type
*/
enum _PedExceptionType {
PED_EXCEPTION_INFORMATION=1,
PED_EXCEPTION_WARNING=2,
PED_EXCEPTION_ERROR=3,
PED_EXCEPTION_FATAL=4,
PED_EXCEPTION_BUG=5,
PED_EXCEPTION_NO_FEATURE=6,
};
typedef enum _PedExceptionType PedExceptionType;
/**
* Option for resolving the exception
*/
enum _PedExceptionOption {
/* individual options */
PED_EXCEPTION_UNHANDLED=0,
PED_EXCEPTION_FIX=1,
PED_EXCEPTION_YES=2,
PED_EXCEPTION_NO=4,
PED_EXCEPTION_OK=8,
PED_EXCEPTION_RETRY=16,
PED_EXCEPTION_IGNORE=32,
PED_EXCEPTION_CANCEL=64,
/* combinations of individual options */
PED_EXCEPTION_OK_CANCEL = PED_EXCEPTION_OK + PED_EXCEPTION_CANCEL,
PED_EXCEPTION_YES_NO = PED_EXCEPTION_YES + PED_EXCEPTION_NO,
PED_EXCEPTION_YES_NO_CANCEL =
PED_EXCEPTION_YES_NO + PED_EXCEPTION_CANCEL,
PED_EXCEPTION_IGNORE_CANCEL =
PED_EXCEPTION_IGNORE + PED_EXCEPTION_CANCEL,
PED_EXCEPTION_RETRY_CANCEL = PED_EXCEPTION_RETRY + PED_EXCEPTION_CANCEL,
PED_EXCEPTION_RETRY_IGNORE_CANCEL =
PED_EXCEPTION_RETRY + PED_EXCEPTION_IGNORE_CANCEL,
};
#define PED_EXCEPTION_OPTION_FIRST PED_EXCEPTION_FIX
#define PED_EXCEPTION_OPTION_LAST PED_EXCEPTION_CANCEL /* last individual option */
typedef enum _PedExceptionOption PedExceptionOption;
/**
* Structure with information about exception
*/
struct _PedException {
char* message; /**< text describing what the event was */
PedExceptionType type; /**< type of exception */
PedExceptionOption options; /**< ORed list of options that
the exception handler can
return (the ways an exception
can be resolved) */
};
typedef PedExceptionOption (PedExceptionHandler) (PedException* ex);
extern int ped_exception; /* set to true if there's an exception */
extern char* ped_exception_get_type_string (PedExceptionType ex_type)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__const__))
#endif
;
extern char* ped_exception_get_option_string (PedExceptionOption ex_opt)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern void ped_exception_set_handler (PedExceptionHandler* handler);
extern PedExceptionHandler *ped_exception_get_handler(void)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern PedExceptionOption ped_exception_default_handler (PedException* ex);
extern PedExceptionOption ped_exception_throw (PedExceptionType ex_type,
PedExceptionOption ex_opt,
const char* message,
...);
/* rethrows an exception - i.e. calls the exception handler, (or returns a
code to return to pass up higher) */
extern PedExceptionOption ped_exception_rethrow ();
/* frees an exception, indicating that the exception has been handled.
Calling an exception handler counts. */
extern void ped_exception_catch ();
/* indicate that exceptions should not go to the exception handler, but passed
up to the calling function(s) */
extern void ped_exception_fetch_all ();
/* indicate that exceptions should invoke the exception handler */
extern void ped_exception_leave_all ();
#endif /* PED_EXCEPTION_H_INCLUDED */
/** @} */

299
include/parted/fdasd.h Executable file
View File

@@ -0,0 +1,299 @@
/*
* File...........: s390-tools/fdasd/fdasd.h
* Author(s)......: Volker Sameske <sameske@de.ibm.com>
* Horst Hummel <Horst.Hummel@de.ibm.com>
* Bugreports.to..: <Linux390@de.ibm.com>
* (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2001-2002
*
* History of changes (starts March 2001)
* version 1.01 - menu entry 's' to show mapping devnode - DS name
* 1.02 - DS names count now from 0001 instead from 0000
* 1.03 - volser checks: 'AA AAA' to 'AAAAA '
* - removed dependency to kernel headers.
* 1.04 - added -p option
* 1.05 - new API policy, set it back to 0
*/
#ifndef FDASD_H
#define FDASD_H
#include <parted/vtoc.h>
/*****************************************************************************
* SECTION: Definitions needed for DASD-API (see dasd.h) *
*****************************************************************************/
#define DASD_IOCTL_LETTER 'D'
#define DASD_PARTN_BITS 2
#define PARTITION_LINUX_SWAP 0x82
#define PARTITION_LINUX 0x83
#define PARTITION_LINUX_LVM 0x8e
#define PARTITION_LINUX_RAID 0xfd
#define PART_TYPE_NATIVE "NATIVE"
#define PART_TYPE_SWAP "SWAP "
#define PART_TYPE_RAID "RAID "
#define PART_TYPE_LVM "LVM "
#ifdef DEBUG_DASD
#define PDEBUG fprintf(stderr, "%s:%d:%s\n", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__);
#else
#define PDEBUG
#endif
/*
* struct dasd_information_t
* represents any data about the device, which is visible to userspace.
* including foramt and featueres.
*/
typedef struct dasd_information_t {
unsigned int devno; /* S/390 devno */
unsigned int real_devno; /* for aliases */
unsigned int schid; /* S/390 subchannel identifier */
unsigned int cu_type : 16; /* from SenseID */
unsigned int cu_model : 8; /* from SenseID */
unsigned int dev_type : 16; /* from SenseID */
unsigned int dev_model : 8; /* from SenseID */
unsigned int open_count;
unsigned int req_queue_len;
unsigned int chanq_len; /* length of chanq */
char type[4]; /* from discipline.name, 'none' for */
/* unknown */
unsigned int status; /* current device level */
unsigned int label_block; /* where to find the VOLSER */
unsigned int FBA_layout; /* fixed block size (like AIXVOL) */
unsigned int characteristics_size;
unsigned int confdata_size;
char characteristics[64]; /* from read_device_characteristics */
char configuration_data[256]; /* from read_configuration_data */
} dasd_information_t;
struct dasd_eckd_characteristics {
unsigned short cu_type;
struct {
unsigned char support:2;
unsigned char async:1;
unsigned char reserved:1;
unsigned char cache_info:1;
unsigned char model:3;
} __attribute__ ((packed)) cu_model;
unsigned short dev_type;
unsigned char dev_model;
struct {
unsigned char mult_burst:1;
unsigned char RT_in_LR:1;
unsigned char reserved1:1;
unsigned char RD_IN_LR:1;
unsigned char reserved2:4;
unsigned char reserved3:8;
unsigned char defect_wr:1;
unsigned char XRC_supported:1;
unsigned char reserved4:1;
unsigned char striping:1;
unsigned char reserved5:4;
unsigned char cfw:1;
unsigned char reserved6:2;
unsigned char cache:1;
unsigned char dual_copy:1;
unsigned char dfw:1;
unsigned char reset_alleg:1;
unsigned char sense_down:1;
} __attribute__ ((packed)) facilities;
unsigned char dev_class;
unsigned char unit_type;
unsigned short no_cyl;
unsigned short trk_per_cyl;
unsigned char sec_per_trk;
unsigned char byte_per_track[3];
unsigned short home_bytes;
unsigned char formula;
union {
struct {
unsigned char f1;
unsigned short f2;
unsigned short f3;
} __attribute__ ((packed)) f_0x01;
struct {
unsigned char f1;
unsigned char f2;
unsigned char f3;
unsigned char f4;
unsigned char f5;
} __attribute__ ((packed)) f_0x02;
} __attribute__ ((packed)) factors;
unsigned short first_alt_trk;
unsigned short no_alt_trk;
unsigned short first_dia_trk;
unsigned short no_dia_trk;
unsigned short first_sup_trk;
unsigned short no_sup_trk;
unsigned char MDR_ID;
unsigned char OBR_ID;
unsigned char director;
unsigned char rd_trk_set;
unsigned short max_rec_zero;
unsigned char reserved1;
unsigned char RWANY_in_LR;
unsigned char factor6;
unsigned char factor7;
unsigned char factor8;
unsigned char reserved2[3];
unsigned char reserved3[6];
unsigned int long_no_cyl;
} __attribute__ ((packed));
/*
* struct format_data_t
* represents all data necessary to format a dasd
*/
typedef struct format_data_t {
int start_unit; /* from track */
int stop_unit; /* to track */
int blksize; /* sectorsize */
int intensity;
} format_data_t;
/*
* values to be used for format_data_t.intensity
* 0/8: normal format
* 1/9: also write record zero
* 3/11: also write home address
* 4/12: invalidate track
*/
#define DASD_FMT_INT_FMT_R0 1 /* write record zero */
#define DASD_FMT_INT_FMT_HA 2 /* write home address, also set FMT_R0 ! */
#define DASD_FMT_INT_INVAL 4 /* invalidate tracks */
#define DASD_FMT_INT_COMPAT 8 /* use OS/390 compatible disk layout */
/* Disable the volume (for Linux) */
#define BIODASDDISABLE _IO(DASD_IOCTL_LETTER,0)
/* Enable the volume (for Linux) */
#define BIODASDENABLE _IO(DASD_IOCTL_LETTER,1)
/* retrieve API version number */
#define DASDAPIVER _IOR(DASD_IOCTL_LETTER,0,int)
/* Get information on a dasd device (enhanced) */
#define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
/*****************************************************************************
* SECTION: Further IOCTL Definitions (see fs.h) *
*****************************************************************************/
#define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
/* re-read partition table */
#define BLKRRPART _IO(0x12,95)
/* get block device sector size */
#define BLKSSZGET _IO(0x12,104)
/* device size in bytes (u64 *arg)*/
#define BLKGETSIZE64 _IOR(0x12,114,size_t)
/* get device geometry */
#define HDIO_GETGEO 0x0301
/*****************************************************************************
* SECTION: FDASD internal types *
*****************************************************************************/
#define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
#define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
#define DASD_MIN_API_VERSION 0
#define DEFAULT_FDASD_CONF "/etc/fdasd.conf" /* default config file */
#define FDASD_VERSION "1.32.0"
#define DEVICE "device"
#define DISC "disc"
#define PART "part"
#define ALTERNATE_CYLINDERS_USED 0x10
typedef struct partition_info {
u_int8_t used;
unsigned long start_trk;
unsigned long end_trk;
unsigned long len_trk;
unsigned long fspace_trk;
format1_label_t *f1;
struct partition_info *next;
struct partition_info *prev;
u_int8_t type;
} partition_info_t;
typedef struct config_data {
unsigned long start;
unsigned long stop;
} config_data_t;
typedef struct fdasd_anchor {
int vlabel_changed;
int vtoc_changed;
int auto_partition;
int print_table;
int big_disk;
int silent;
int verbose;
int devno;
int option_reuse;
int option_recreate;
int partno[USABLE_PARTITIONS];
u_int16_t dev_type;
unsigned int used_partitions;
unsigned long label_pos;
unsigned int blksize;
unsigned long fspace_trk;
format4_label_t *f4;
format5_label_t *f5;
format7_label_t *f7;
format9_label_t *f9; /* template for all f9 labels */
partition_info_t *first;
partition_info_t *last;
volume_label_t *vlabel;
config_data_t confdata[USABLE_PARTITIONS];
u_int32_t hw_cylinders;
u_int32_t formatted_cylinders;
struct fdasd_hd_geometry geo;
unsigned int label_block;
unsigned int FBA_layout;
bool is_file;
} fdasd_anchor_t;
enum offset {lower, upper};
enum fdasd_failure {
unable_to_open_disk,
unable_to_seek_disk,
unable_to_read_disk,
read_only_disk,
unable_to_ioctl,
api_version_mismatch,
wrong_disk_type,
wrong_disk_format,
disk_in_use,
config_syntax_error,
vlabel_corrupted,
dsname_corrupted,
malloc_failed,
device_verification_failed,
volser_not_found
};
void fdasd_cleanup (fdasd_anchor_t *anchor);
void fdasd_initialize_anchor (fdasd_anchor_t * anc);
int fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int fd);
void fdasd_check_api_version (fdasd_anchor_t *anc, int fd);
int fdasd_check_volume (fdasd_anchor_t *anc, int fd);
int fdasd_write_labels (fdasd_anchor_t *anc, int fd);
void fdasd_recreate_vtoc(fdasd_anchor_t *anc);
partition_info_t * fdasd_add_partition (fdasd_anchor_t *anc,
unsigned int start, unsigned int stop);
int fdasd_prepare_labels (fdasd_anchor_t *anc, int fd) ;
void fdasd_check_volser(char *volser, int devno);
int fdasd_get_volser(fdasd_anchor_t *anc, char *volser, int fd);
void fdasd_change_volser(fdasd_anchor_t *anc, char *str);
void fdasd_reuse_vtoc(fdasd_anchor_t *anc);
#endif /* FDASD_H */

116
include/parted/filesys.h Executable file
View File

@@ -0,0 +1,116 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1999-2001, 2006-2007, 2009-2014, 2019-2023 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/>.
*/
/**
* \addtogroup PedFileSystem
* @{
*/
/** \file filesys.h */
#ifndef PED_FILESYS_H_INCLUDED
#define PED_FILESYS_H_INCLUDED
typedef struct _PedFileSystem PedFileSystem;
typedef struct _PedFileSystemType PedFileSystemType;
typedef struct _PedFileSystemAlias PedFileSystemAlias;
typedef const struct _PedFileSystemOps PedFileSystemOps;
#include <parted/geom.h>
#include <parted/constraint.h>
#include <parted/timer.h>
struct _PedFileSystemOps {
PedGeometry* (*probe) (PedGeometry* geom);
};
/**
* Structure describing type of file system
*/
struct _PedFileSystemType {
PedFileSystemType* next;
const char* const name; /**< name of the file system type */
PedFileSystemOps* const ops;
};
/**
* Structure describing a file system alias. This is separate from
* PedFileSystemType because probing only looks through the list of types,
* and does not probe aliases separately.
*/
struct _PedFileSystemAlias {
PedFileSystemAlias* next;
PedFileSystemType* fs_type;
const char* alias;
int deprecated;
};
/**
* Structure describing file system
*/
struct _PedFileSystem {
PedFileSystemType* type; /**< the file system type */
PedGeometry* geom; /**< where the file system actually is */
int checked; /**< 1 if the file system has been checked.
0 otherwise. */
void* type_specific;
};
extern void ped_file_system_type_register (PedFileSystemType* type);
extern void ped_file_system_type_unregister (PedFileSystemType* type);
extern void ped_file_system_alias_register (PedFileSystemType* type,
const char* alias, int deprecated);
extern void ped_file_system_alias_unregister (PedFileSystemType* type,
const char* alias);
extern PedFileSystemType* ped_file_system_type_get (const char* name);
extern PedFileSystemType*
ped_file_system_type_get_next (const PedFileSystemType* fs_type)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern PedFileSystemAlias*
ped_file_system_alias_get_next (const PedFileSystemAlias* fs_alias)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern PedFileSystemType* ped_file_system_probe (PedGeometry* geom);
extern PedGeometry* ped_file_system_probe_specific (
const PedFileSystemType* fs_type,
PedGeometry* geom);
PedFileSystem *ped_file_system_open (PedGeometry *geom);
int ped_file_system_close (PedFileSystem *fs);
int ped_file_system_resize (PedFileSystem *fs, PedGeometry *geom,
PedTimer *timer);
PedConstraint *ped_file_system_get_resize_constraint (const PedFileSystem *fs);
#endif /* PED_FILESYS_H_INCLUDED */
/** @} */

106
include/parted/geom.h Executable file
View File

@@ -0,0 +1,106 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1998-2001, 2005, 2007, 2009-2014, 2019-2023 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/>.
*/
/**
* \addtogroup PedGeometry
* @{
*/
/** \file geom.h */
#ifndef PED_GEOM_H_INCLUDED
#define PED_GEOM_H_INCLUDED
typedef struct _PedGeometry PedGeometry;
/**
* Geometry of the partition
*/
struct _PedGeometry {
PedDevice* dev;
PedSector start;
PedSector length;
PedSector end;
};
#include <parted/device.h>
#include <parted/timer.h>
extern int ped_geometry_init (PedGeometry* geom, const PedDevice* dev,
PedSector start, PedSector length);
extern PedGeometry* ped_geometry_new (const PedDevice* dev, PedSector start,
PedSector length);
extern PedGeometry* ped_geometry_duplicate (const PedGeometry* geom);
extern PedGeometry* ped_geometry_intersect (const PedGeometry* a,
const PedGeometry* b);
extern void ped_geometry_destroy (PedGeometry* geom);
extern int ped_geometry_set (PedGeometry* geom, PedSector start,
PedSector length);
extern int ped_geometry_set_start (PedGeometry* geom, PedSector start);
extern int ped_geometry_set_end (PedGeometry* geom, PedSector end);
extern int ped_geometry_test_overlap (const PedGeometry* a,
const PedGeometry* b)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern int ped_geometry_test_inside (const PedGeometry* a,
const PedGeometry* b)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern int ped_geometry_test_equal (const PedGeometry* a, const PedGeometry* b)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern int ped_geometry_test_sector_inside (const PedGeometry* geom,
PedSector sect)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern int ped_geometry_read (const PedGeometry* geom, void* buffer,
PedSector offset, PedSector count);
extern int ped_geometry_read_alloc (const PedGeometry* geom, void** buffer,
PedSector offset, PedSector count);
extern int ped_geometry_write (PedGeometry* geom, const void* buffer,
PedSector offset, PedSector count);
extern PedSector ped_geometry_check (PedGeometry* geom, void* buffer,
PedSector buffer_size, PedSector offset,
PedSector granularity, PedSector count,
PedTimer* timer);
extern int ped_geometry_sync (PedGeometry* geom);
extern int ped_geometry_sync_fast (PedGeometry* geom);
/* returns -1 if "sector" is not within dest's space. */
extern PedSector ped_geometry_map (const PedGeometry* dst,
const PedGeometry* src,
PedSector sector)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
#endif /* PED_GEOM_H_INCLUDED */
/** @} */

144
include/parted/natmath.h Executable file
View File

@@ -0,0 +1,144 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 2000, 2007-2014, 2019-2023 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/>.
*/
/**
* \addtogroup PedAlignment
* @{
*/
/** \file natmath.h */
#ifndef PED_NATMATH_H_INCLUDED
#define PED_NATMATH_H_INCLUDED
typedef struct _PedAlignment PedAlignment;
#include <parted/disk.h>
#include <parted/device.h>
#include <parted/geom.h>
#define PED_MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define PED_MAX(a, b) ( ((a)>(b)) ? (a) : (b) )
/* this is weird (I'm still not sure I should be doing this!)
*
* For the functions: new, destroy, duplicate and merge: the following values
* for align are valid:
* * align == NULL (!) represents no solution
* * align->grain_size == 0 represents a single solution
* (align->offset)
* * align->grain_size > 0 represents a set of solutions
*
* These are invalid:
* * align->offset < 0 Note: this gets "normalized"
* * align->grain_size < 0
*
* For the align_* operations, there must be a solution. i.e. align != NULL
* All solutions must be greater than zero.
*/
struct _PedAlignment {
PedSector offset;
PedSector grain_size;
};
extern PedSector ped_round_up_to (PedSector sector, PedSector grain_size)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__const__))
#endif
;
extern PedSector ped_round_down_to (PedSector sector, PedSector grain_size)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__const__))
#endif
;
extern PedSector ped_round_to_nearest (PedSector sector, PedSector grain_size)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__const__))
#endif
;
extern PedSector ped_greatest_common_divisor (PedSector a, PedSector b)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern int ped_alignment_init (PedAlignment* align, PedSector offset,
PedSector grain_size);
extern PedAlignment* ped_alignment_new (PedSector offset, PedSector grain_size);
extern void ped_alignment_destroy (PedAlignment* align);
extern PedAlignment* ped_alignment_duplicate (const PedAlignment* align);
extern PedAlignment* ped_alignment_intersect (const PedAlignment* a,
const PedAlignment* b);
extern PedSector
ped_alignment_align_up (const PedAlignment* align, const PedGeometry* geom,
PedSector sector)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern PedSector
ped_alignment_align_down (const PedAlignment* align, const PedGeometry* geom,
PedSector sector)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern PedSector
ped_alignment_align_nearest (const PedAlignment* align, const PedGeometry* geom,
PedSector sector)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern int
ped_alignment_is_aligned (const PedAlignment* align, const PedGeometry* geom,
PedSector sector)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern const PedAlignment* ped_alignment_any;
extern const PedAlignment* ped_alignment_none;
static inline PedSector
ped_div_round_up (PedSector numerator, PedSector divisor)
{
return (numerator + divisor - 1) / divisor;
}
static inline PedSector
ped_div_round_to_nearest (PedSector numerator, PedSector divisor)
{
return (numerator + divisor/2) / divisor;
}
#endif /* PED_NATMATH_H_INCLUDED */
/**
* @}
*/

61
include/parted/parted.h Executable file
View File

@@ -0,0 +1,61 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1999-2001, 2007, 2009-2014, 2019-2023 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 PARTED_H_INCLUDED
#define PARTED_H_INCLUDED
#define PED_DEFAULT_ALIGNMENT (1024 * 1024)
#ifdef __cplusplus
extern "C" {
#endif
#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
# define __attribute(arg) __attribute__ (arg)
#else
# define __attribute(arg)
#endif
#include <parted/constraint.h>
#include <parted/device.h>
#include <parted/disk.h>
#include <parted/exception.h>
#include <parted/filesys.h>
#include <parted/natmath.h>
#include <parted/unit.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
extern const char *ped_get_version ()
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__const__))
#endif
;
extern void* __attribute__ ((malloc)) ped_malloc (size_t size);
extern void* __attribute__ ((malloc)) ped_calloc (size_t size);
extern void free (void* ptr);
#ifdef __cplusplus
}
#endif
#endif /* PARTED_H_INCLUDED */

66
include/parted/timer.h Executable file
View File

@@ -0,0 +1,66 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 2001-2002, 2007, 2009-2014, 2019-2023 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/>.
*/
/**
* \addtogroup PedTimer
* @{
*/
/** \file timer.h */
#ifndef PED_TIMER_H_INCLUDED
#define PED_TIMER_H_INCLUDED
#include <time.h>
typedef struct _PedTimer PedTimer;
typedef void PedTimerHandler (PedTimer* timer, void* context);
/*
* Structure keeping track of progress and time
*/
struct _PedTimer {
float frac; /**< fraction of operation done */
time_t start; /**< time of start of op */
time_t now; /**< time of last update (now!) */
time_t predicted_end; /**< expected finish time */
const char* state_name; /**< eg: "copying data" */
PedTimerHandler* handler; /**< who to notify on updates */
void* context; /**< context to pass to handler */
};
extern PedTimer* ped_timer_new (PedTimerHandler* handler, void* context);
extern void ped_timer_destroy (PedTimer* timer);
/* a nested timer automatically notifies it's parent. You should only
* create one when you are going to use it (not before)
*/
extern PedTimer* ped_timer_new_nested (PedTimer* parent, float nest_frac);
extern void ped_timer_destroy_nested (PedTimer* timer);
extern void ped_timer_touch (PedTimer* timer);
extern void ped_timer_reset (PedTimer* timer);
extern void ped_timer_update (PedTimer* timer, float new_frac);
extern void ped_timer_set_state_name (PedTimer* timer, const char* state_name);
#endif /* PED_TIMER_H_INCLUDED */
/** @} */

101
include/parted/unit.h Executable file
View File

@@ -0,0 +1,101 @@
/*
libparted - a library for manipulating disk partitions
Copyright (C) 2005, 2007, 2009-2014, 2019-2023 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/>.
*/
/**
* \addtogroup PedUnit
* @{
*/
/** \file unit.h */
#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
/**
* Human-friendly unit for representation of a location within device
*/
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 */
/** @} */

387
include/parted/vtoc.h Executable file
View File

@@ -0,0 +1,387 @@
/*
* File...........: s390-tools/dasdview/vtoc.h
* Author(s)......: Horst Hummel <horst.hummel@de.ibm.com>
* Bugreports.to..: <Linux390@de.ibm.com>
*
* This is a user-space copy of the kernel vtoc,h.
*
* (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2002
*
* History of changes (starts March 2002)
* 2002-03-12 initial
*/
#ifndef VTOC_H
#define VTOC_H
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#define LINE_LENGTH 80
#define VTOC_START_CC 0x0
#define VTOC_START_HH 0x1
#define FIRST_USABLE_CYL 1
#define FIRST_USABLE_TRK 2
#define DASD_3380_TYPE 13148
#define DASD_3390_TYPE 13200
#define DASD_9345_TYPE 37701
#define DASD_3380_VALUE 0xbb60
#define DASD_3390_VALUE 0xe5a2
#define DASD_9345_VALUE 0xbc98
#define VOLSER_LENGTH 6
#define BIG_DISK_SIZE 0x10000
#define LV_COMPAT_CYL 0xFFFE
/*****************************************************************************
* SECTION: Definition from hdreq.h *
*****************************************************************************/
struct fdasd_hd_geometry {
unsigned char heads;
unsigned char sectors;
unsigned short cylinders;
unsigned long start;
};
typedef struct ttr ttr_t;
typedef struct cchhb cchhb_t;
typedef struct cchh cchh_t;
typedef struct labeldate labeldate_t;
typedef struct volume_label volume_label_t;
typedef struct cms_volume_label cms_volume_label_t;
typedef struct extent extent_t;
typedef struct dev_const dev_const_t;
typedef struct format1_label format1_label_t;
typedef struct format4_label format4_label_t;
typedef struct ds5ext ds5ext_t;
typedef struct format5_label format5_label_t;
typedef struct ds7ext ds7ext_t;
typedef struct format7_label format7_label_t;
typedef struct format9_label format9_label_t;
struct __attribute__ ((packed)) ttr {
u_int16_t tt;
u_int8_t r;
};
struct __attribute__ ((packed)) cchhb {
u_int16_t cc;
u_int16_t hh;
u_int8_t b;
};
struct __attribute__ ((packed)) cchh {
u_int16_t cc;
u_int16_t hh;
};
struct __attribute__ ((packed)) labeldate {
u_int8_t year;
u_int16_t day;
};
/*
* The following structure is a merger of the cdl and ldl volume label.
* On an ldl disk there is no key information, so when reading an
* ldl label from disk, the data should be copied at the address of vollbl.
* On the other side, the field ldl_version is reserved in a cdl record
* and the field formatted_blocks exists only for ldl labels. So when
* reading a cdl label from disk, the formatted_blocks field will contain
* arbitrary data.
* This layout may be a bit awkward, but the advantage of having the
* same label type for both disk layout types is bigger than the effort
* for taking a bit of extra care at the fringes.
*/
struct __attribute__ ((packed)) volume_label {
char volkey[4]; /* volume key = volume label */
char vollbl[4]; /* volume label ("VOL1" in EBCDIC) */
char volid[6]; /* volume identifier */
u_int8_t security; /* security byte */
cchhb_t vtoc; /* VTOC address */
char res1[5]; /* reserved */
char cisize[4]; /* CI-size for FBA,... */
/* ...blanks for CKD */
char blkperci[4]; /* no of blocks per CI (FBA), blanks for CKD */
char labperci[4]; /* no of labels per CI (FBA), blanks for CKD */
char res2[4]; /* reserved */
char lvtoc[14]; /* owner code for LVTOC */
char res3[28]; /* reserved */
char ldl_version; /* version number, valid for ldl format */
u_int64_t formatted_blocks; /* valid when ldl_version >= "2" (in
EBCDIC) */
};
/*
* See:
* z/VM V5R2.0 CMS Planning and Administration
* SC24-6078-01
* What CMS Does / Disk and File Management / Disk File Format
* http://publib.boulder.ibm.com/infocenter/zvm/v5r4/topic/com.ibm.zvm.v54.dmsd1/hcsg2b1018.htm
*/
struct __attribute__ ((packed)) cms_volume_label {
char label_id[4]; /* Label identifier ("CMS1" in EBCDIC) */
char vol_id[6]; /* Volume identifier */
char version_id[2]; /* Version identifier ("\0\0") */
u_int32_t block_size; /* Disk block size (512, 1024, 2048 or 4096) */
u_int32_t origin_ptr; /* Disk origin pointer (4 or 5) */
u_int32_t usable_count; /* Number of usable cylinders/blocks */
u_int32_t formatted_count; /* Max # of formatted cylinders/blocks */
u_int32_t block_count; /* Disk size in CMS blocks */
u_int32_t used_count; /* Number of CMS blocks in use */
u_int32_t fst_size; /* File Status Table (FST) size (64) */
u_int32_t fst_count; /* Number of FSTs per CMS block */
char format_date[6]; /* Disk FORMAT date (YYMMDDhhmmss) */
char reserved1[2]; /* Reserved fields.
The low-order bit of the first byte is a
century flag. 0 = 1900s, 1 = 2000s.
It is used in conjunction with
"format_date" to determine the
four-digit year. */
u_int32_t disk_offset; /* Offset in blocks to the start of the
reserved file when the disk is reserved.
This is the number of blocks to skip
before the partition starts. */
u_int32_t map_block; /* Allocation map block with next hole */
u_int32_t hblk_disp; /* Displacement in HBLK data of next hole */
u_int32_t user_disp; /* Disp into user part of allocation map */
u_int32_t open_files; /* Count of SFS open files for this ADT.
open_files is not really part of the
volume label. It is not used for
minidisks. */
char segment_name[8]; /* Name of the shared segment.
segment_name is not really part of the
volume label. It is not stored on disk. */
};
struct __attribute__ ((packed)) extent {
u_int8_t typeind; /* extent type indicator */
u_int8_t seqno; /* extent sequence number */
cchh_t llimit; /* starting point of this extent */
cchh_t ulimit; /* ending point of this extent */
};
struct __attribute__ ((packed)) dev_const {
u_int16_t DS4DSCYL; /* number of logical cyls */
u_int16_t DS4DSTRK; /* number of tracks in a logical cylinder */
u_int16_t DS4DEVTK; /* device track length */
u_int8_t DS4DEVI; /* non-last keyed record overhead */
u_int8_t DS4DEVL; /* last keyed record overhead */
u_int8_t DS4DEVK; /* non-keyed record overhead differential */
u_int8_t DS4DEVFG; /* flag byte */
u_int16_t DS4DEVTL; /* device tolerance */
u_int8_t DS4DEVDT; /* number of DSCB's per track */
u_int8_t DS4DEVDB; /* number of directory blocks per track */
};
/*
* format 1 and format 8 label have the same layout so we use the following
* structure for both.
*/
struct __attribute__ ((packed)) format1_label {
char DS1DSNAM[44]; /* data set name */
u_int8_t DS1FMTID; /* format identifier */
char DS1DSSN[6]; /* data set serial number */
u_int16_t DS1VOLSQ; /* volume sequence number */
labeldate_t DS1CREDT; /* creation date: ydd */
labeldate_t DS1EXPDT; /* expiration date */
u_int8_t DS1NOEPV; /* number of extents on volume */
u_int8_t DS1NOBDB; /* no. of bytes used in last direction blk */
u_int8_t DS1FLAG1; /* flag 1 */
char DS1SYSCD[13]; /* system code */
labeldate_t DS1REFD; /* date last referenced */
u_int8_t DS1SMSFG; /* system managed storage indicators */
u_int8_t DS1SCXTF; /* sec. space extension flag byte */
u_int16_t DS1SCXTV; /* secondary space extension value */
u_int8_t DS1DSRG1; /* data set organisation byte 1 */
u_int8_t DS1DSRG2; /* data set organisation byte 2 */
u_int8_t DS1RECFM; /* record format */
u_int8_t DS1OPTCD; /* option code */
u_int16_t DS1BLKL; /* block length */
u_int16_t DS1LRECL; /* record length */
u_int8_t DS1KEYL; /* key length */
u_int16_t DS1RKP; /* relative key position */
u_int8_t DS1DSIND; /* data set indicators */
u_int8_t DS1SCAL1; /* secondary allocation flag byte */
char DS1SCAL3[3]; /* secondary allocation quantity */
ttr_t DS1LSTAR; /* last used track and block on track */
u_int16_t DS1TRBAL; /* space remaining on last used track */
u_int16_t res1; /* reserved */
extent_t DS1EXT1; /* first extent description */
extent_t DS1EXT2; /* second extent description */
extent_t DS1EXT3; /* third extent description */
cchhb_t DS1PTRDS; /* possible pointer to f2 or f3 DSCB */
};
struct __attribute__ ((packed)) format4_label {
char DS4KEYCD[44]; /* key code for VTOC labels: 44 times 0x04 */
u_int8_t DS4IDFMT; /* format identifier */
cchhb_t DS4HPCHR; /* highest address of a format 1 DSCB */
u_int16_t DS4DSREC; /* number of available DSCB's */
cchh_t DS4HCCHH; /* CCHH of next available alternate track */
u_int16_t DS4NOATK; /* number of remaining alternate tracks */
u_int8_t DS4VTOCI; /* VTOC indicators */
u_int8_t DS4NOEXT; /* number of extents in VTOC */
u_int8_t DS4SMSFG; /* system managed storage indicators */
u_int8_t DS4DEVAC; /* number of alternate cylinders.
Subtract from first two bytes of
DS4DEVSZ to get number of usable
cylinders. can be zero. valid
only if DS4DEVAV on. */
dev_const_t DS4DEVCT; /* device constants */
char DS4AMTIM[8]; /* VSAM timestamp */
char DS4AMCAT[3]; /* VSAM catalog indicator */
char DS4R2TIM[8]; /* VSAM volume/catalog match timestamp */
char res1[5]; /* reserved */
char DS4F6PTR[5]; /* pointer to first format 6 DSCB */
extent_t DS4VTOCE; /* VTOC extent description */
char res2[10]; /* reserved */
u_int8_t DS4EFLVL; /* extended free-space management level */
cchhb_t DS4EFPTR; /* pointer to extended free-space info */
char res3; /* reserved */
u_int32_t DS4DCYL; /* number of logical cyls */
char res4[2]; /* reserved */
u_int8_t DS4DEVF2; /* device flags */
char res5; /* reserved */
};
struct __attribute__ ((packed)) ds5ext {
u_int16_t t; /* RTA of the first track of free extent */
u_int16_t fc; /* number of whole cylinders in free ext. */
u_int8_t ft; /* number of remaining free tracks */
};
struct __attribute__ ((packed)) format5_label {
char DS5KEYID[4]; /* key identifier */
ds5ext_t DS5AVEXT; /* first available (free-space) extent. */
ds5ext_t DS5EXTAV[7]; /* seven available extents */
u_int8_t DS5FMTID; /* format identifier */
ds5ext_t DS5MAVET[18]; /* eighteen available extents */
cchhb_t DS5PTRDS; /* pointer to next format5 DSCB */
};
struct __attribute__ ((packed)) ds7ext {
u_int32_t a; /* starting RTA value */
u_int32_t b; /* ending RTA value + 1 */
};
struct __attribute__ ((packed)) format7_label {
char DS7KEYID[4]; /* key identifier */
ds7ext_t DS7EXTNT[5]; /* space for 5 extent descriptions */
u_int8_t DS7FMTID; /* format identifier */
ds7ext_t DS7ADEXT[11]; /* space for 11 extent descriptions */
char res1[2]; /* reserved */
cchhb_t DS7PTRDS; /* pointer to next FMT7 DSCB */
};
struct __attribute__ ((packed)) format9_label {
u_int8_t DS9KEYID; /* key code for format 9 labels (0x09) */
u_int8_t DS9SUBTY; /* subtype (0x01) */
u_int8_t DS9NUMF9; /* number of F9 datasets */
u_int8_t res1[41]; /* reserved */
u_int8_t DS9FMTID; /* format identifier */
u_int8_t res2[95]; /* reserved */
};
char *vtoc_ebcdic_enc (char const *source, char *target, int l);
char *vtoc_ebcdic_dec (char const *source, char *target, int l);
void vtoc_set_extent (extent_t *ext, u_int8_t typeind, u_int8_t seqno,
cchh_t *lower, cchh_t *upper);
void vtoc_set_cchh (cchh_t *addr, u_int32_t cc, u_int16_t hh);
u_int32_t vtoc_get_cyl_from_cchh(cchh_t *addr);
u_int16_t vtoc_get_head_from_cchh(cchh_t *addr);
void vtoc_set_cchhb (cchhb_t *addr, u_int32_t cc, u_int16_t hh, u_int8_t b);
u_int32_t vtoc_get_cyl_from_cchhb(cchhb_t *addr);
u_int16_t vtoc_get_head_from_cchhb(cchhb_t *addr);
u_int64_t cchhb2blk(cchhb_t *p, struct fdasd_hd_geometry *geo);
u_int64_t cchh2blk (cchh_t *p, struct fdasd_hd_geometry *geo);
u_int32_t cchh2trk (cchh_t *p, struct fdasd_hd_geometry *geo);
void vtoc_set_date (labeldate_t *d, u_int8_t year, u_int16_t day);
void vtoc_volume_label_init (volume_label_t *vlabel);
int vtoc_read_volume_label (int fd, unsigned long vlabel_start,
volume_label_t *vlabel);
int vtoc_write_volume_label (int fd, unsigned long vlabel_start,
volume_label_t const *vlabel);
void vtoc_volume_label_set_volser (volume_label_t *vlabel, char const *volser);
char *vtoc_volume_label_get_volser (volume_label_t *vlabel, char *volser);
void vtoc_volume_label_set_key (volume_label_t *vlabel, char const *key);
void vtoc_volume_label_set_label (volume_label_t *vlabel, char const *lbl);
char *vtoc_volume_label_get_label (volume_label_t *vlabel, char *lbl);
void vtoc_read_label (int fd, unsigned long position, format1_label_t *f1,
format4_label_t *f4, format5_label_t *f5,
format7_label_t *f7);
void vtoc_write_label (int fd, unsigned long position,
format1_label_t const *f1,
format4_label_t const *f4,
format5_label_t const *f5,
format7_label_t const *f7,
format9_label_t const *f9);
void vtoc_init_format1_label (unsigned int blksize,
extent_t *part_extent, format1_label_t *f1);
void vtoc_init_format4_label (format4_label_t *f4lbl,
unsigned int compat_cylinders,
unsigned int real_cylinders,
unsigned int tracks,
unsigned int blocks,
unsigned int blksize,
u_int16_t dev_type);
void vtoc_update_format4_label (format4_label_t *f4, cchhb_t *highest_f1,
u_int16_t unused_update);
void vtoc_init_format5_label (format5_label_t *f5);
void vtoc_update_format5_label_add (format5_label_t *f5, int verbose,
int trk, u_int16_t a, u_int16_t b,
u_int8_t c);
void vtoc_update_format5_label_del (format5_label_t *f5, int verbose,
int trk, u_int16_t a, u_int16_t b,
u_int8_t c);
void vtoc_init_format7_label (format7_label_t *f7);
void vtoc_update_format7_label_add (format7_label_t *f7, int verbose,
u_int32_t a, u_int32_t b);
void vtoc_update_format7_label_del (format7_label_t *f7, int verbose,
u_int32_t a, u_int32_t b);
void vtoc_init_format8_label (unsigned int blksize,
extent_t *part_extent, format1_label_t *f1);
void vtoc_update_format8_label (cchhb_t *associated_f9, format1_label_t *f8);
void vtoc_init_format9_label (format9_label_t *f9);
void vtoc_set_freespace(format4_label_t *f4, format5_label_t *f5,
format7_label_t *f7, char ch, int verbose,
u_int32_t start, u_int32_t stop, u_int32_t cyl,
u_int32_t trk);
#endif /* VTOC_H */