1N/A/*
1N/A libparted - a library for manipulating disk partitions
1N/A Copyright (C) 1998 - 2001, 2005, 2007-2008 Free Software Foundation, Inc.
1N/A
1N/A This program is free software; you can redistribute it and/or modify
1N/A it under the terms of the GNU General Public License as published by
1N/A the Free Software Foundation; either version 3 of the License, or
1N/A (at your option) any later version.
1N/A
1N/A This program is distributed in the hope that it will be useful,
1N/A but WITHOUT ANY WARRANTY; without even the implied warranty of
1N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1N/A GNU General Public License for more details.
1N/A
1N/A You should have received a copy of the GNU General Public License
1N/A along with this program. If not, see <http://www.gnu.org/licenses/>.
1N/A*/
1N/A
1N/A/**
1N/A * \addtogroup PedDevice
1N/A * @{
1N/A */
1N/A
1N/A/** \file device.h */
1N/A
1N/A#ifndef PED_DEVICE_H_INCLUDED
1N/A#define PED_DEVICE_H_INCLUDED
1N/A
1N/A/** We can address 2^63 sectors */
1N/Atypedef long long PedSector;
1N/A
1N/A/** \deprecated Removal from API planned */
1N/Atypedef enum {
1N/A PED_DEVICE_UNKNOWN = 0,
1N/A PED_DEVICE_SCSI = 1,
1N/A PED_DEVICE_IDE = 2,
1N/A PED_DEVICE_DAC960 = 3,
1N/A PED_DEVICE_CPQARRAY = 4,
1N/A PED_DEVICE_FILE = 5,
1N/A PED_DEVICE_ATARAID = 6,
1N/A PED_DEVICE_I2O = 7,
1N/A PED_DEVICE_UBD = 8,
1N/A PED_DEVICE_DASD = 9,
1N/A PED_DEVICE_VIODASD = 10,
1N/A PED_DEVICE_SX8 = 11,
1N/A PED_DEVICE_DM = 12,
1N/A PED_DEVICE_XVD = 13,
1N/A PED_DEVICE_SDMMC = 14,
1N/A PED_DEVICE_VIRTBLK = 15,
1N/A PED_DEVICE_AOE = 16,
1N/A PED_DEVICE_MD = 17
1N/A} PedDeviceType;
1N/A
1N/Atypedef struct _PedDevice PedDevice;
1N/Atypedef struct _PedDeviceArchOps PedDeviceArchOps;
1N/Atypedef struct _PedCHSGeometry PedCHSGeometry;
1N/A
1N/A/**
1N/A * A cylinder-head-sector "old-style" geometry.
1N/A *
1N/A * A device addressed in this way has C*H*S sectors.
1N/A */
1N/Astruct _PedCHSGeometry {
1N/A int cylinders;
1N/A int heads;
1N/A int sectors;
1N/A};
1N/A
1N/A/** A block device - for example, /dev/hda, not /dev/hda3 */
1N/Astruct _PedDevice {
1N/A PedDevice* next;
1N/A
1N/A char* model; /**< \brief description of hardware
1N/A (manufacturer, model) */
1N/A char* path; /**< device /dev entry */
1N/A
1N/A PedDeviceType type; /**< SCSI, IDE, etc.
1N/A \deprecated \sa PedDeviceType */
1N/A long long sector_size; /**< logical sector size */
1N/A long long phys_sector_size; /**< physical sector size */
1N/A PedSector length; /**< device length (LBA) */
1N/A
1N/A int open_count; /**< the number of times this device has
1N/A been opened with ped_device_open(). */
1N/A int read_only;
1N/A int external_mode;
1N/A int dirty;
1N/A int boot_dirty;
1N/A
1N/A PedCHSGeometry hw_geom;
1N/A PedCHSGeometry bios_geom;
1N/A short host, did;
1N/A
1N/A void* arch_specific;
1N/A};
1N/A
1N/A#include <parted/natmath.h>
1N/A
1N/A/**
1N/A * List of functions implementing architecture-specific operations.
1N/A */
1N/Astruct _PedDeviceArchOps {
1N/A PedDevice* (*_new) (const char* path);
1N/A void (*destroy) (PedDevice* dev);
1N/A int (*is_busy) (PedDevice* dev);
1N/A int (*open) (PedDevice* dev);
1N/A int (*refresh_open) (PedDevice* dev);
1N/A int (*close) (PedDevice* dev);
1N/A int (*refresh_close) (PedDevice* dev);
1N/A int (*read) (const PedDevice* dev, void* buffer,
1N/A PedSector start, PedSector count);
1N/A int (*write) (PedDevice* dev, const void* buffer,
1N/A PedSector start, PedSector count);
1N/A int (*sync) (PedDevice* dev);
1N/A int (*sync_fast) (PedDevice* dev);
1N/A PedSector (*check) (PedDevice* dev, void* buffer,
1N/A PedSector start, PedSector count);
1N/A void (*probe_all) ();
1N/A /* These functions are optional */
1N/A PedAlignment *(*get_minimum_alignment)(const PedDevice *dev);
1N/A PedAlignment *(*get_optimum_alignment)(const PedDevice *dev);
1N/A};
1N/A
1N/A#include <parted/constraint.h>
1N/A#include <parted/timer.h>
1N/A
1N/Aextern void ped_device_probe_all ();
1N/Aextern void ped_device_free_all ();
1N/A
1N/Aextern PedDevice* ped_device_get (const char* name);
1N/Aextern PedDevice* ped_device_get_next (const PedDevice* dev);
1N/Aextern int ped_device_is_busy (PedDevice* dev);
1N/Aextern int ped_device_open (PedDevice* dev);
1N/Aextern int ped_device_close (PedDevice* dev);
1N/Aextern void ped_device_destroy (PedDevice* dev);
1N/Aextern void ped_device_cache_remove (PedDevice* dev);
1N/A
1N/Aextern int ped_device_begin_external_access (PedDevice* dev);
1N/Aextern int ped_device_end_external_access (PedDevice* dev);
1N/A
1N/Aextern int ped_device_read (const PedDevice* dev, void* buffer,
1N/A PedSector start, PedSector count);
1N/Aextern int ped_device_write (PedDevice* dev, const void* buffer,
1N/A PedSector start, PedSector count);
1N/Aextern int ped_device_sync (PedDevice* dev);
1N/Aextern int ped_device_sync_fast (PedDevice* dev);
1N/Aextern PedSector ped_device_check (PedDevice* dev, void* buffer,
1N/A PedSector start, PedSector count);
1N/Aextern PedConstraint* ped_device_get_constraint (const PedDevice* dev);
1N/A
1N/Aextern PedConstraint *ped_device_get_minimal_aligned_constraint(
1N/A const PedDevice *dev);
1N/Aextern PedConstraint *ped_device_get_optimal_aligned_constraint(
1N/A const PedDevice *dev);
1N/A
1N/Aextern PedAlignment *ped_device_get_minimum_alignment(const PedDevice *dev);
1N/Aextern PedAlignment *ped_device_get_optimum_alignment(const PedDevice *dev);
1N/A
1N/A/* private stuff ;-) */
1N/A
1N/Aextern void _ped_device_probe (const char* path);
1N/A
1N/A#endif /* PED_DEVICE_H_INCLUDED */
1N/A
1N/A/** @} */