device.h

Go to the documentation of this file.
00001 /*
00002     libparted - a library for manipulating disk partitions
00003     Copyright (C) 1998 - 2001, 2005 Free Software Foundation, Inc.
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00018 */
00019 
00027 #ifndef PED_DEVICE_H_INCLUDED
00028 #define PED_DEVICE_H_INCLUDED
00029 
00030 #include <parted/timer.h>
00031 
00033 typedef long long PedSector;
00034 
00036 typedef enum {
00037         PED_DEVICE_UNKNOWN      = 0,
00038         PED_DEVICE_SCSI         = 1,
00039         PED_DEVICE_IDE          = 2,
00040         PED_DEVICE_DAC960       = 3,
00041         PED_DEVICE_CPQARRAY     = 4,
00042         PED_DEVICE_FILE         = 5,
00043         PED_DEVICE_ATARAID      = 6,
00044         PED_DEVICE_I2O          = 7,
00045         PED_DEVICE_UBD          = 8,
00046         PED_DEVICE_DASD         = 9,
00047         PED_DEVICE_VIODASD      = 10,
00048         PED_DEVICE_SX8          = 11
00049 #ifdef ENABLE_DEVICE_MAPPER
00050                                     ,
00051         PED_DEVICE_DM           = 12
00052 #endif
00053 } PedDeviceType;
00054 
00055 typedef struct _PedDevice PedDevice;
00056 typedef struct _PedDeviceArchOps PedDeviceArchOps;
00057 typedef struct _PedCHSGeometry PedCHSGeometry;
00058 
00064 struct _PedCHSGeometry {
00065         int             cylinders;
00066         int             heads;
00067         int             sectors;
00068 };
00069 
00071 struct _PedDevice {
00072         PedDevice*      next;
00073 
00074         char*           model;          
00076         char*           path;           
00078         PedDeviceType   type;           
00080         long long       sector_size;            
00081         long long       phys_sector_size;       
00082         PedSector       length;                 
00084         int             open_count; 
00086         int             read_only;
00087         int             external_mode;
00088         int             dirty;
00089         int             boot_dirty;
00090 
00091         PedCHSGeometry  hw_geom;
00092         PedCHSGeometry  bios_geom;
00093         short           host, did;
00094 
00095         void*           arch_specific;
00096 };
00097 
00101 struct _PedDeviceArchOps {
00102         PedDevice* (*_new) (const char* path);
00103         void (*destroy) (PedDevice* dev);
00104         int (*is_busy) (PedDevice* dev);
00105         int (*open) (PedDevice* dev);
00106         int (*refresh_open) (PedDevice* dev);
00107         int (*close) (PedDevice* dev);
00108         int (*refresh_close) (PedDevice* dev);
00109         int (*read) (const PedDevice* dev, void* buffer,
00110                      PedSector start, PedSector count);
00111         int (*write) (PedDevice* dev, const void* buffer,
00112                       PedSector start, PedSector count);
00113         int (*sync) (PedDevice* dev);
00114         int (*sync_fast) (PedDevice* dev);
00115         PedSector (*check) (PedDevice* dev, void* buffer,
00116                             PedSector start, PedSector count);
00117         void (*probe_all) ();
00118 };
00119 
00120 extern void ped_device_probe_all ();
00121 extern void ped_device_free_all ();
00122 
00123 extern PedDevice* ped_device_get (const char* name);
00124 extern PedDevice* ped_device_get_next (const PedDevice* dev);
00125 extern int ped_device_is_busy (PedDevice* dev);
00126 extern int ped_device_open (PedDevice* dev);
00127 extern int ped_device_close (PedDevice* dev);
00128 extern void ped_device_destroy (PedDevice* dev);
00129 extern void ped_device_cache_remove (PedDevice* dev);
00130 
00131 extern int ped_device_begin_external_access (PedDevice* dev);
00132 extern int ped_device_end_external_access (PedDevice* dev);
00133 
00134 extern int ped_device_read (const PedDevice* dev, void* buffer,
00135                             PedSector start, PedSector count);
00136 extern int ped_device_write (PedDevice* dev, const void* buffer,
00137                              PedSector start, PedSector count);
00138 extern int ped_device_sync (PedDevice* dev);
00139 extern int ped_device_sync_fast (PedDevice* dev);
00140 extern PedSector ped_device_check (PedDevice* dev, void* buffer,
00141                                    PedSector start, PedSector count);
00142 extern PedConstraint* ped_device_get_constraint (PedDevice* dev);
00143 
00144 /* private stuff ;-) */
00145 
00146 extern void _ped_device_probe (const char* path);
00147 
00148 #endif /* PED_DEVICE_H_INCLUDED */
00149 

Generated on Fri May 4 05:15:31 2007 for libparted by  doxygen 1.5.2