1 /* 2 libparted - a library for manipulating disk partitions 3 Copyright (C) 1998 - 2001, 2005, 2007 Free Software Foundation, Inc. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 /** 20 * \addtogroup PedDevice 21 * @{ 22 */ 23 24 /** \file device.h */ 25 26 #ifndef PED_DEVICE_H_INCLUDED 27 #define PED_DEVICE_H_INCLUDED 28 29 #include <parted/timer.h> 30 31 /** We can address 2^63 sectors */ 32 typedef long long PedSector; 33 34 /** \deprecated Removal from API planned */ 35 typedef enum { 36 PED_DEVICE_UNKNOWN = 0, 37 PED_DEVICE_SCSI = 1, 38 PED_DEVICE_IDE = 2, 39 PED_DEVICE_DAC960 = 3, 40 PED_DEVICE_CPQARRAY = 4, 41 PED_DEVICE_FILE = 5, 42 PED_DEVICE_ATARAID = 6, 43 PED_DEVICE_I2O = 7, 44 PED_DEVICE_UBD = 8, 45 PED_DEVICE_DASD = 9, 46 PED_DEVICE_VIODASD = 10, 47 PED_DEVICE_SX8 = 11, 48 #ifdef ENABLE_DEVICE_MAPPER 49 PED_DEVICE_DM = 12, 50 #endif 51 PED_DEVICE_XVD = 13 52 } PedDeviceType; 53 54 typedef struct _PedDevice PedDevice; 55 typedef struct _PedDeviceArchOps PedDeviceArchOps; 56 typedef struct _PedCHSGeometry PedCHSGeometry; 57 58 /** 59 * A cylinder-head-sector "old-style" geometry. 60 * 61 * A device addressed in this way has C*H*S sectors. 62 */ 63 struct _PedCHSGeometry { 64 int cylinders; 65 int heads; 66 int sectors; 67 }; 68 69 /** A block device - for example, /dev/hda, not /dev/hda3 */ 70 struct _PedDevice { 71 PedDevice* next; 72 73 char* model; /**< \brief description of hardware 74 (manufacturer, model) */ 75 char* path; /**< device /dev entry */ 76 77 PedDeviceType type; /**< SCSI, IDE, etc. 78 \deprecated \sa PedDeviceType */ 79 long long sector_size; /**< logical sector size */ 80 long long phys_sector_size; /**< physical sector size */ 81 PedSector length; /**< device length (LBA) */ 82 83 int open_count; /**< the number of times this device has 84 been opened with ped_device_open(). */ 85 int read_only; 86 int external_mode; 87 int dirty; 88 int boot_dirty; 89 90 PedCHSGeometry hw_geom; 91 PedCHSGeometry bios_geom; 92 short host, did; 93 94 void* arch_specific; 95 }; 96 97 /** 98 * List of functions implementing architecture-specific operations. 99 */ 100 struct _PedDeviceArchOps { 101 PedDevice* (*_new) (const char* path); 102 void (*destroy) (PedDevice* dev); 103 int (*is_busy) (PedDevice* dev); 104 int (*open) (PedDevice* dev); 105 int (*refresh_open) (PedDevice* dev); 106 int (*close) (PedDevice* dev); 107 int (*refresh_close) (PedDevice* dev); 108 int (*read) (const PedDevice* dev, void* buffer, 109 PedSector start, PedSector count); 110 int (*write) (PedDevice* dev, const void* buffer, 111 PedSector start, PedSector count); 112 int (*sync) (PedDevice* dev); 113 int (*sync_fast) (PedDevice* dev); 114 PedSector (*check) (PedDevice* dev, void* buffer, 115 PedSector start, PedSector count); 116 void (*probe_all) (); 117 }; 118 119 extern void ped_device_probe_all (); 120 extern void ped_device_free_all (); 121 122 extern PedDevice* ped_device_get (const char* name); 123 extern PedDevice* ped_device_get_next (const PedDevice* dev); 124 extern int ped_device_is_busy (PedDevice* dev); 125 extern int ped_device_open (PedDevice* dev); 126 extern int ped_device_close (PedDevice* dev); 127 extern void ped_device_destroy (PedDevice* dev); 128 extern void ped_device_cache_remove (PedDevice* dev); 129 130 extern int ped_device_begin_external_access (PedDevice* dev); 131 extern int ped_device_end_external_access (PedDevice* dev); 132 133 extern int ped_device_read (const PedDevice* dev, void* buffer, 134 PedSector start, PedSector count); 135 extern int ped_device_write (PedDevice* dev, const void* buffer, 136 PedSector start, PedSector count); 137 extern int ped_device_sync (PedDevice* dev); 138 extern int ped_device_sync_fast (PedDevice* dev); 139 extern PedSector ped_device_check (PedDevice* dev, void* buffer, 140 PedSector start, PedSector count); 141 extern PedConstraint* ped_device_get_constraint (PedDevice* dev); 142 143 /* private stuff ;-) */ 144 145 extern void _ped_device_probe (const char* path); 146 147 #endif /* PED_DEVICE_H_INCLUDED */ 148 149 /** @} */ 150