1 /*
   2     libparted - a library for manipulating disk partitions
   3     Copyright (C) 1999, 2000, 2001, 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 PedFileSystem
  21  * @{
  22  */
  23 
  24 /** \file filesys.h */
  25 
  26 #ifndef PED_FILESYS_H_INCLUDED
  27 #define PED_FILESYS_H_INCLUDED
  28 
  29 typedef struct _PedFileSystem           PedFileSystem;
  30 typedef struct _PedFileSystemType       PedFileSystemType;
  31 typedef const struct _PedFileSystemOps  PedFileSystemOps;
  32 
  33 #include <parted/geom.h>
  34 #include <parted/disk.h>
  35 #include <parted/exception.h>
  36 #include <parted/constraint.h>
  37 #include <parted/timer.h>
  38 #include <stdio.h>
  39 
  40 struct _PedFileSystemOps {
  41         PedGeometry* (*probe) (PedGeometry* geom);
  42         int (*clobber) (PedGeometry* geom);
  43 
  44         PedFileSystem* (*open) (PedGeometry* geom);
  45         PedFileSystem* (*create) (PedGeometry* geom, PedTimer* timer);
  46         int (*close) (PedFileSystem* fs);
  47         int (*check) (PedFileSystem* fs, PedTimer* timer);
  48         PedFileSystem* (*copy) (const PedFileSystem* fs, PedGeometry* geom,
  49                                 PedTimer* timer);
  50         int (*resize) (PedFileSystem* fs, PedGeometry* geom, PedTimer* timer);
  51 
  52         PedConstraint* (*get_create_constraint) (const PedDevice* dev);
  53         PedConstraint* (*get_resize_constraint) (const PedFileSystem* fs);
  54         PedConstraint* (*get_copy_constraint) (const PedFileSystem* fs,
  55                                                const PedDevice* dev);
  56 };
  57 
  58 /**
  59  * Structure describing type of file system 
  60  */
  61 struct _PedFileSystemType {
  62         PedFileSystemType*      next;
  63         const char* const       name;           /**< name of the file system type */
  64         const int*              block_sizes;
  65         PedFileSystemOps* const ops;
  66 };
  67 
  68 
  69 /**
  70  * Structure describing file system
  71  */
  72 struct _PedFileSystem {
  73         PedFileSystemType*      type;           /**< the file system type */
  74         PedGeometry*            geom;           /**< where the file system actually is */
  75         int                     checked;        /**< 1 if the file system has been checked.
  76                                                       0 otherwise. */
  77 
  78         void*                   type_specific;
  79 
  80 };
  81 
  82 extern void ped_file_system_type_register (PedFileSystemType* type);
  83 extern void ped_file_system_type_unregister (PedFileSystemType* type);
  84 
  85 extern PedFileSystemType* ped_file_system_type_get (const char* name);
  86 extern PedFileSystemType*
  87 ped_file_system_type_get_next (const PedFileSystemType* fs_type);
  88 
  89 extern PedFileSystemType* ped_file_system_probe (PedGeometry* geom);
  90 extern PedGeometry* ped_file_system_probe_specific (
  91                         const PedFileSystemType* fs_type,
  92                         PedGeometry* geom);
  93 extern int ped_file_system_clobber (PedGeometry* geom);
  94 
  95 extern PedFileSystem* ped_file_system_open (PedGeometry* geom);
  96 extern PedFileSystem* ped_file_system_create (PedGeometry* geom,
  97                                               const PedFileSystemType* type,
  98                                               PedTimer* timer);
  99 extern int ped_file_system_close (PedFileSystem* fs);
 100 extern int ped_file_system_check (PedFileSystem* fs, PedTimer* timer);
 101 extern PedFileSystem* ped_file_system_copy (PedFileSystem* fs,
 102                                             PedGeometry* geom,
 103                                             PedTimer* timer);
 104 extern int ped_file_system_resize (PedFileSystem* fs, PedGeometry* geom,
 105                                    PedTimer* timer);
 106 
 107 extern PedConstraint* ped_file_system_get_create_constraint (
 108                 const PedFileSystemType* fs_type, const PedDevice* dev);
 109 extern PedConstraint* ped_file_system_get_resize_constraint (
 110                 const PedFileSystem* fs);
 111 extern PedConstraint* ped_file_system_get_copy_constraint (
 112                 const PedFileSystem* fs, const PedDevice* dev);
 113 
 114 #endif /* PED_FILESYS_H_INCLUDED */
 115 
 116 /** @} */