1 /*
   2     libparted - a library for manipulating disk partitions
   3     Copyright (C) 1998-2001, 2005, 2006, 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 PedGeometry
  21  * @{
  22  */
  23 
  24 /** \file geom.h */
  25 
  26 #ifndef PED_GEOM_H_INCLUDED
  27 #define PED_GEOM_H_INCLUDED
  28 
  29 #include <parted/device.h>
  30 #include <parted/timer.h>
  31 
  32 typedef struct _PedGeometry     PedGeometry;
  33 
  34 /**
  35  * Geometry of the partition
  36  */
  37 struct _PedGeometry {
  38         PedDevice*              dev;
  39         PedSector               start;
  40         PedSector               length;
  41         PedSector               end;
  42 };
  43 
  44 extern int ped_geometry_init (PedGeometry* geom, const PedDevice* dev,
  45                               PedSector start, PedSector length);
  46 extern PedGeometry* ped_geometry_new (const PedDevice* dev, PedSector start,
  47                                       PedSector length);
  48 extern PedGeometry* ped_geometry_duplicate (const PedGeometry* geom);
  49 extern PedGeometry* ped_geometry_intersect (const PedGeometry* a,
  50                                             const PedGeometry* b);
  51 extern void ped_geometry_destroy (PedGeometry* geom);
  52 extern int ped_geometry_set (PedGeometry* geom, PedSector start,
  53                              PedSector length);
  54 extern int ped_geometry_set_start (PedGeometry* geom, PedSector start);
  55 extern int ped_geometry_set_end (PedGeometry* geom, PedSector end);
  56 extern int ped_geometry_test_overlap (const PedGeometry* a,
  57                                       const PedGeometry* b);
  58 extern int ped_geometry_test_inside (const PedGeometry* a,
  59                                      const PedGeometry* b);
  60 extern int ped_geometry_test_equal (const PedGeometry* a, const PedGeometry* b);
  61 extern int ped_geometry_test_sector_inside (const PedGeometry* geom,
  62                                             PedSector sect);
  63 
  64 extern int ped_geometry_read (const PedGeometry* geom, void* buffer,
  65                               PedSector offset, PedSector count);
  66 extern int ped_geometry_write (PedGeometry* geom, const void* buffer,
  67                                PedSector offset, PedSector count);
  68 extern PedSector ped_geometry_check (PedGeometry* geom, void* buffer,
  69                                      PedSector buffer_size, PedSector offset,
  70                                      PedSector granularity, PedSector count,
  71                                      PedTimer* timer);
  72 extern int ped_geometry_sync (PedGeometry* geom);
  73 extern int ped_geometry_sync_fast (PedGeometry* geom);
  74 
  75 /* returns -1 if "sector" is not within dest's space. */
  76 extern PedSector ped_geometry_map (const PedGeometry* dst,
  77                                    const PedGeometry* src,
  78                                    PedSector sector);
  79 
  80 #endif /* PED_GEOM_H_INCLUDED */
  81 
  82 /** @} */
  83