1 /*
   2     geom_dal.h -- parted device abstraction layer
   3     Copyright (C) 2001, 2002, 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 #ifndef GEOM_DAL_H
  20 #define GEOM_DAL_H
  21 
  22 #include <parted/parted.h>
  23 
  24 #if DYNAMIC_LOADING || !DISCOVER_ONLY
  25 
  26 #include <sys/stat.h>
  27 
  28 typedef unsigned long blk_t;
  29 
  30 struct dal_ops;
  31 
  32 struct _dal {
  33     struct dal_ops *ops;
  34     const void *dev;
  35     size_t block_size;
  36     int flags;
  37     void *data;
  38     blk_t len;
  39 };
  40 
  41 typedef struct _dal dal_t;
  42 
  43 struct dal_ops {
  44     blk_t (*len)(dal_t *);
  45     int (*read)(dal_t *, void *, blk_t, blk_t);
  46     int (*write)(dal_t *, void *, blk_t, blk_t);
  47     int (*sync)(dal_t *);
  48     int (*flags)(dal_t *);
  49     int (*equals)(dal_t *, dal_t *);
  50     int (*stat)(dal_t *, struct stat *);
  51     dev_t (*dev)(dal_t *);
  52 };
  53 
  54 extern dal_t *geom_dal_create(PedGeometry *geom, size_t block_size, int flags);
  55 extern int geom_dal_reopen(dal_t *dal, int flags);
  56 extern void geom_dal_free(dal_t *dal);
  57 
  58 #endif
  59 
  60 #endif