/*

                                   _JNJ`                        
                               .JNMH`                           
                              JMMF`       `;.                   
                            .NMM)          `MN.                 
                            MMM)            (MML                
                           (MMM`             MMML               
                     M  I  D  N  I  G  H  T    C  o  D  E       
                           (NMMF             MHNH               
                            NMML            .MMM                
                             NMML          .NMH                 
                              4MMNL       .#F                   
                               `4HNNL_   `                      
                                   `"""`                        

                          Copyright (C) 2004-2007
       "Ian (Larry) Latter" <ian dot latter at midnightcode dot org>

    Midnight Code is a registered trademark of Ian Latter.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, and mirrored at the Midnight Code web
    site; as at version 2 of the License only.
  
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
  
    You should have received a copy of the GNU General Public License
    (version 2) along with this program; if not, write to the Free
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA, or see http://midnightcode.org/gplv2.txt

*/


/* midnightcode-lvm.h :: Midnight Code Logical Volume Manager library	*/


#ifndef __MIDNIGHTCODE_LVM_H
#define __MIDNIGHTCODE_LVM_H 1


enum midnightcode_lvm_action_t
{
  MIDNIGHTCODE_LVM_ACTION_NONE = 0,
  MIDNIGHTCODE_LVM_ACTION_INITIALISE,
  MIDNIGHTCODE_LVM_ACTION_PV_CREATE,
  MIDNIGHTCODE_LVM_ACTION_VG_CREATE,
  MIDNIGHTCODE_LVM_ACTION_VG_ACTIVATE,
  MIDNIGHTCODE_LVM_ACTION_VG_REMOVE,
  MIDNIGHTCODE_LVM_ACTION_VG_EXTEND,
  MIDNIGHTCODE_LVM_ACTION_VG_REDUCE,
  MIDNIGHTCODE_LVM_ACTION_LV_CREATE,
  MIDNIGHTCODE_LVM_ACTION_LV_REMOVE,
  MIDNIGHTCODE_LVM_ACTION_LV_EXTEND,
  MIDNIGHTCODE_LVM_ACTION_LV_REDUCE,
  MIDNIGHTCODE_LVM_ACTION_SHUTDOWN
};

enum midnightcode_lvm_error_t
{
  MIDNIGHTCODE_LVM_ERROR_NONE = 0,
  MIDNIGHTCODE_LVM_ERROR_ACTION = -1,
  MIDNIGHTCODE_LVM_ERROR_INITIALISE = -2,
  MIDNIGHTCODE_LVM_ERROR_FIND = -3,
  MIDNIGHTCODE_LVM_ERROR_INSERT = -4,
  MIDNIGHTCODE_LVM_ERROR_ADD = -5,
  MIDNIGHTCODE_LVM_ERROR_DELETE = -6,
  MIDNIGHTCODE_LVM_ERROR_APPLY = -7,
  MIDNIGHTCODE_LVM_ERROR_SHUTDOWN = -8
};

struct midnightcode_lvm_vg_element_t
{
  char label[128];
  midnightcode_list_entry(midnightcode_lvm_vg_element_t)
};

midnightcode_list_head(midnightcode_lvm_vg_head_t,
                       midnightcode_lvm_vg_element_t)

struct midnightcode_lvm_lv_element_t
{
  char label[128];
  int capacity;
  char vg_label[128];
  int is_mounted;
  char mount_point[128];
  midnightcode_list_entry(midnightcode_lvm_lv_element_t)
};

midnightcode_list_head(midnightcode_lvm_lv_head_t,
                       midnightcode_lvm_lv_element_t)

struct midnightcode_lvm_command_t
{
  const char * exec;
};

int midnightcode_lvm_pvcreate(struct midnightcode_disk_head_t *elements);
int midnightcode_lvm_vgcreate(char * label,
                        struct midnightcode_disk_head_t *elements);
int midnightcode_lvm_vgactivate(char * label);
int midnightcode_lvm_vgremove(char * label);
int midnightcode_lvm_vgextend(char * label,
                        struct midnightcode_disk_head_t *elements);
int midnightcode_lvm_vgreduce(char * label,
                        struct midnightcode_disk_head_t *elements);
int midnightcode_lvm_bycommand(struct midnightcode_lvm_command_t * commands);
int midnightcode_lvm(int action, char * vg_label, char * lv_label,
                        struct midnightcode_disk_head_t * disk_elements,
                        struct midnightcode_lvm_head_t * lvm_elements);


#endif
