mirror of https://github.com/vitalif/e2fsprogs
Add EVMS FSIM plugin to e2fsprogs.
parent
0fbd1a8a9a
commit
ff6dbcca9c
|
@ -1,3 +1,9 @@
|
|||
2002-05-24 <tytso@snap.thunk.org>
|
||||
|
||||
* configure.in: Add makefile for lib/evms for the EVMS FSIM
|
||||
plugin. Add --enable-old-evms configure option which uses
|
||||
the EVMS 1.0.0 ABI, instead of the ABI used by EVMS 1.1.0.
|
||||
|
||||
2002-05-21 Theodore Ts'o <tytso@mit.edu>
|
||||
|
||||
* configure.in: On Linux systems, if the prefix is defaulted to
|
||||
|
|
16
configure.in
16
configure.in
|
@ -125,6 +125,21 @@ fi
|
|||
echo "Disabling compression support by default"
|
||||
)
|
||||
dnl
|
||||
dnl handle --enable-old-evms
|
||||
dnl
|
||||
AC_ARG_ENABLE([old-evms],
|
||||
[ --enable-old-evms use EVMS 1.0 ABI (instead of EVMS 1.1)],
|
||||
if test "$enableval" = "no"
|
||||
then
|
||||
echo "Using EVMS 1.1.0 ABI"
|
||||
else
|
||||
AC_DEFINE(ABI_EVMS_1_0)
|
||||
echo "Enabling EVMS 1.0.0 ABI"
|
||||
fi
|
||||
,
|
||||
echo "Using EVMS 1.1.0 ABI by default"
|
||||
)
|
||||
dnl
|
||||
dnl handle --enable-dll-shlibs
|
||||
dnl
|
||||
AC_ARG_ENABLE([dll-shlibs],
|
||||
|
@ -672,6 +687,7 @@ if test -d ${srcdir}/resize ; then
|
|||
fi
|
||||
AC_OUTPUT(MCONFIG Makefile util/Makefile util/subst.conf lib/et/Makefile
|
||||
lib/ss/Makefile lib/ext2fs/Makefile lib/e2p/Makefile lib/uuid/Makefile
|
||||
lib/evms/Makefile
|
||||
misc/Makefile ext2ed/Makefile e2fsck/Makefile debugfs/Makefile \
|
||||
tests/Makefile tests/progs/Makefile $rmakefile doc/Makefile
|
||||
intl/Makefile po/Makefile.in)
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_builddir = ../..
|
||||
my_dir = lib/evms
|
||||
INSTALL = @INSTALL@
|
||||
|
||||
XTRA_CFLAGS= -I@srcdir@
|
||||
|
||||
@MCONFIG@
|
||||
|
||||
OBJS= fs_ext2.o fsimext2.o
|
||||
|
||||
SRCS= $(srcdir)/fs_ext2.c $(srcdir)/fsimext2.c
|
||||
|
||||
|
||||
LIBRARY= libext2fsim
|
||||
LIBDIR= evms
|
||||
|
||||
ELF_VERSION = 1.0.0
|
||||
ELF_SO_VERSION = 1
|
||||
ELF_IMAGE = libe2fsim
|
||||
ELF_MYDIR = evms
|
||||
ELF_INSTALL_DIR = $(root_libdir)
|
||||
#ELF_OTHER_LIBS = -L../.. -lcom_err
|
||||
|
||||
@MAKEFILE_LIBRARY@
|
||||
@MAKEFILE_ELF@
|
||||
|
||||
.c.o:
|
||||
$(CC) $(ALL_CFLAGS) -c $< -o $@
|
||||
@ELF_CMT@ $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
|
||||
|
||||
clean::
|
||||
$(RM) -f \#* *.s *.o *.a *~ *.bak core profiled/* checker/*
|
||||
|
||||
mostlyclean:: clean
|
||||
distclean:: clean
|
||||
$(RM) -f .depend Makefile $(srcdir)/TAGS $(srcdir)/Makefile.in.old
|
||||
|
||||
# +++ Dependency line eater +++
|
||||
#
|
||||
# Makefile dependencies follow. This must be the last section in
|
||||
# the Makefile.in file
|
||||
#
|
||||
fs_ext2.o: $(srcdir)/fs_ext2.c $(srcdir)/plugin.h $(srcdir)/dlist.h \
|
||||
$(srcdir)/common.h $(srcdir)/evms_user.h $(srcdir)/evms_common.h \
|
||||
$(srcdir)/evms_ioctl.h $(srcdir)/options.h $(srcdir)/enginestructs.h \
|
||||
$(srcdir)/plugfuncs.h $(srcdir)/fsimext2.h
|
||||
fsimext2.o: $(srcdir)/fsimext2.c $(srcdir)/plugin.h $(srcdir)/dlist.h \
|
||||
$(srcdir)/common.h $(srcdir)/evms_user.h $(srcdir)/evms_common.h \
|
||||
$(srcdir)/evms_ioctl.h $(srcdir)/options.h $(srcdir)/enginestructs.h \
|
||||
$(srcdir)/plugfuncs.h $(srcdir)/fsimext2.h
|
|
@ -0,0 +1,287 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2001
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Module: common.h
|
||||
*/
|
||||
|
||||
#ifndef EVMS_COMMON_H_INCLUDED
|
||||
#define EVMS_COMMON_H_INCLUDED 1
|
||||
|
||||
#include <linux/types.h> /* will pull in platform specific data type info from linux/include/asm */
|
||||
|
||||
/* Need these to satisfy dependencies in evms_user.h
|
||||
* on systems running a 2.5.8 or newer kernel.
|
||||
*/
|
||||
typedef __u8 u8;
|
||||
typedef __u16 u16;
|
||||
typedef __u32 u32;
|
||||
typedef __u64 u64;
|
||||
|
||||
#include <evms/evms_user.h>
|
||||
|
||||
/* Defines for storage object names */
|
||||
#define EVMS_NAME_SIZE EVMS_VOLUME_NAME_SIZE
|
||||
|
||||
/* Defines for the flags in the storage_object_t structure */
|
||||
#define SOFLAG_DIRTY (1<<0)
|
||||
#define SOFLAG_NEW (1<<1)
|
||||
#define SOFLAG_READ_ONLY (1<<2)
|
||||
#define SOFLAG_FEATURE_HEADER_DIRTY (1<<3)
|
||||
#define SOFLAG_MUST_BE_TOP (1<<4)
|
||||
#define SOFLAG_IO_ERROR (1<<5)
|
||||
#define SOFLAG_CORRUPT (1<<6)
|
||||
#define SOFLAG_BIOS_READABLE (1<<7)
|
||||
#define SOFLAG_MUST_BE_VOLUME (1<<8)
|
||||
#define SOFLAG_NOT_CLAIMED (1<<9)
|
||||
|
||||
/* Defines for flags in the storage_container_t structure */
|
||||
#define SCFLAG_DIRTY (1<<0)
|
||||
#define SCFLAG_NEW (1<<1)
|
||||
|
||||
/* Defines for the flags in the logical_volume_t structure */
|
||||
#define VOLFLAG_DIRTY (1<<0)
|
||||
#define VOLFLAG_NEW (1<<1)
|
||||
#define VOLFLAG_READ_ONLY (1<<2)
|
||||
#define VOLFLAG_NEEDS_DEV_NODE (1<<3)
|
||||
#define VOLFLAG_COMPATIBILITY (1<<4)
|
||||
#define VOLFLAG_FOREIGN (1<<5)
|
||||
#define VOLFLAG_MKFS (1<<6)
|
||||
#define VOLFLAG_UNMKFS (1<<7)
|
||||
#define VOLFLAG_FSCK (1<<8)
|
||||
#define VOLFLAG_DEFRAG (1<<9)
|
||||
#define VOLFLAG_EXPAND_FS (1<<10)
|
||||
#define VOLFLAG_SHRINK_FS (1<<11)
|
||||
#define VOLFLAG_SYNC_FS (1<<12)
|
||||
|
||||
/* A BOOLEAN variable is one which is either TRUE or FALSE. */
|
||||
#ifndef BOOLEAN_DEFINED
|
||||
#define BOOLEAN_DEFINED 1
|
||||
typedef u_int8_t BOOLEAN;
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Logical Sector Number: This is a physical sector address on a
|
||||
* system drive.
|
||||
*/
|
||||
typedef u_int64_t lsn_t;
|
||||
|
||||
/*
|
||||
* Logical Block Address: This is a sector address on a volume which
|
||||
* will be translated to a Logical Sector Number.
|
||||
*/
|
||||
typedef u_int64_t lba_t;
|
||||
|
||||
/*
|
||||
* A sector_count_t is a count of sectors. It is mainly used to hold the size
|
||||
* of a disk, segment, region, etc.
|
||||
*/
|
||||
typedef u_int64_t sector_count_t;
|
||||
|
||||
/*
|
||||
* A module_handle_t variable is one which holds a handle (or descriptor)
|
||||
* referencing a loaded module.
|
||||
*/
|
||||
typedef void * module_handle_t;
|
||||
|
||||
/*
|
||||
* The standard data type for Engine handles.
|
||||
*/
|
||||
typedef u_int32_t engine_handle_t;
|
||||
|
||||
/*
|
||||
* An object_handle_t holds a handle for an EVMS Engine object.
|
||||
*/
|
||||
typedef engine_handle_t object_handle_t;
|
||||
|
||||
/*
|
||||
* A plugin_handle_t holds a handle for an EVMS Engine plug-in.
|
||||
*/
|
||||
typedef engine_handle_t plugin_handle_t;
|
||||
|
||||
/*
|
||||
* A plugin_ID_t holds a unique ID for a plug-in.
|
||||
*/
|
||||
typedef u_int32_t plugin_id_t;
|
||||
|
||||
/*
|
||||
* A plugin_type_t holds the type field of a plug-in's ID.
|
||||
*/
|
||||
typedef u_int8_t plugin_type_t;
|
||||
|
||||
/*
|
||||
* The various modes in which the Engine can be.
|
||||
*/
|
||||
typedef enum {
|
||||
ENGINE_CLOSED = 0,
|
||||
ENGINE_READONLY,
|
||||
ENGINE_READWRITE
|
||||
} engine_mode_t;
|
||||
|
||||
/*
|
||||
* The geometry of a disk, segment, region, etc.
|
||||
*/
|
||||
typedef struct geometry_s {
|
||||
u_int64_t cylinders;
|
||||
u_int32_t heads;
|
||||
u_int32_t sectors_per_track;
|
||||
u_int32_t bytes_per_sector;
|
||||
u_int64_t boot_cylinder_limit;
|
||||
u_int64_t block_size;
|
||||
} geometry_t;
|
||||
|
||||
/*
|
||||
* The data types which a storage object can be.
|
||||
*/
|
||||
typedef enum {
|
||||
META_DATA_TYPE = (1<<0),
|
||||
DATA_TYPE = (1<<1),
|
||||
FREE_SPACE_TYPE = (1<<2)
|
||||
} data_type_t;
|
||||
|
||||
/*
|
||||
* The types of structures the Engine exports
|
||||
*/
|
||||
typedef enum {
|
||||
PLUGIN = (1<<0),
|
||||
DISK = (1<<1),
|
||||
SEGMENT = (1<<2),
|
||||
REGION = (1<<3),
|
||||
EVMS_OBJECT = (1<<4),
|
||||
CONTAINER = (1<<5),
|
||||
VOLUME = (1<<6)
|
||||
} object_type_t;
|
||||
|
||||
/*
|
||||
* Flags that can be used for filtering plug-ins on the evms_get_plugin_list API
|
||||
*/
|
||||
typedef enum {
|
||||
SUPPORTS_CONTAINERS = (1<<0)
|
||||
} plugin_search_flags_t;
|
||||
|
||||
/*
|
||||
* Flags that can be used for filtering objects on the evms_get_object_list API
|
||||
*/
|
||||
typedef enum {
|
||||
TOPMOST = (1<<0),
|
||||
NOT_MUST_BE_TOP = (1<<1),
|
||||
WRITEABLE = (1<<2)
|
||||
} object_search_flags_t;
|
||||
|
||||
#define VALID_INPUT_OBJECT (TOPMOST | NOT_MUST_BE_TOP | WRITEABLE)
|
||||
|
||||
/*
|
||||
* Debug levels
|
||||
* These levels should be kept in sync with the debug levels defined for the
|
||||
* EVMS kernel in linux/evms/evms.h.
|
||||
*/
|
||||
typedef enum {
|
||||
/*
|
||||
* Use CRITICAL for messages that indicate that the health of the
|
||||
* system/Engine is in jeopardy. Something _really_ bad happened,
|
||||
* such as failure to allocate memory or control structures are
|
||||
* corrupted.
|
||||
*/
|
||||
CRITICAL = 0,
|
||||
|
||||
/*
|
||||
* Use SERIOUS for messages that something bad has happened, but not
|
||||
* as bad a CRITICAL.
|
||||
*/
|
||||
SERIOUS = 1,
|
||||
|
||||
/*
|
||||
* Use ERROR for messages that indicate the user caused an error,
|
||||
* such as passing a bad parameter. The message should help the
|
||||
* user correct the problem.
|
||||
*/
|
||||
ERROR = 2,
|
||||
|
||||
/*
|
||||
* Use WARNING for messages that indicate that something is not quite
|
||||
* right and the user should know about it. You may or may not be able
|
||||
* to work around the problem.
|
||||
*/
|
||||
WARNING = 3,
|
||||
|
||||
/*
|
||||
* Use DEFAULT for informational messages that do not indicate problems, or
|
||||
* that a problem occurred but there was a work-around. DEFAULT messages
|
||||
* should be things that the user would usually want to know during any run
|
||||
* of the Engine, such as how many volumes were discovered on the system,
|
||||
* and not necessarily what a developer would want to know (use DETAILS or
|
||||
* DEBUG for that). Since DEFAULT is the default debug level, be careful
|
||||
* not to put DEFAULT messages in loops or frequently executed code as they
|
||||
* will bloat the log file.
|
||||
*/
|
||||
DEFAULT = 5,
|
||||
|
||||
/*
|
||||
* Use DETAILS to provide more detailed information about the system. The
|
||||
* message may provide additional information about the progress of the
|
||||
* system. It may contain more information about a DEFAULT message or more
|
||||
* information about an error condition.
|
||||
*/
|
||||
DETAILS = 6,
|
||||
|
||||
/*
|
||||
* Use DEBUG for messages that would help debug a problem, such as tracing
|
||||
* code paths or dumping the contents of variables.
|
||||
*/
|
||||
DEBUG = 7,
|
||||
|
||||
/*
|
||||
* Use EXTRA to provided more information than your standard debug messages
|
||||
* provide.
|
||||
*/
|
||||
|
||||
EXTRA = 8,
|
||||
|
||||
/*
|
||||
* Use ENTRY_EXIT to trace entries and exits from functions.
|
||||
*/
|
||||
ENTRY_EXIT = 9,
|
||||
|
||||
/*
|
||||
* Use EVERYTHING for all manner of verbose output. Feel free to bloat the
|
||||
* log file with any messages that would help you debug a problem.
|
||||
*/
|
||||
EVERYTHING = 10
|
||||
|
||||
} debug_level_t;
|
||||
|
||||
|
||||
/*
|
||||
* Handy macros for finding the min and max of two numbers.
|
||||
*/
|
||||
#ifndef min
|
||||
#define min(a,b) (((a)<(b))?(a):(b))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,302 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2001
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Module: enginestructs.h
|
||||
*/
|
||||
|
||||
#ifndef EVMS_ENGINESTRUCTS_H_INCLUDED
|
||||
#define EVMS_ENGINESTRUCTS_H_INCLUDED 1
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <dlist.h>
|
||||
#include <common.h>
|
||||
#include <options.h>
|
||||
#include <evms/evms_user.h>
|
||||
|
||||
struct plugin_functions_s;
|
||||
struct fsim_functions_s;
|
||||
struct container_functions_s;
|
||||
|
||||
/*
|
||||
* The so_record_t contains information about a .so that was loaded which
|
||||
* contains plug-in(s).
|
||||
*/
|
||||
typedef struct so_record_s {
|
||||
char * name;
|
||||
module_handle_t handle;
|
||||
dlist_t plugin_list;
|
||||
} so_record_t;
|
||||
|
||||
|
||||
typedef struct plugin_record_s {
|
||||
object_handle_t app_handle; /* External API handle for this structure; */
|
||||
/* used only by the Engine */
|
||||
plugin_id_t id; /* Plug-in's ID */
|
||||
evms_version_t version; /* Plug-in's version */
|
||||
evms_version_t required_api_version; /* Version of the Engine plug-in API */
|
||||
/* that the plug-in requires */
|
||||
so_record_t * so_record; /* Record for the shared object from */
|
||||
/* which the plug-in was loaded */
|
||||
char * short_name;
|
||||
char * long_name;
|
||||
char * oem_name;
|
||||
union {
|
||||
struct plugin_functions_s * plugin;
|
||||
struct fsim_functions_s * fsim;
|
||||
} functions;
|
||||
struct container_functions_s * container_functions; /* Optional container functions if the */
|
||||
/* plug-in supports containers */
|
||||
} plugin_record_t;
|
||||
|
||||
|
||||
typedef struct storage_object_s {
|
||||
object_handle_t app_handle; /* External API handle for this structure; */
|
||||
/* used only by the Engine */
|
||||
object_type_t object_type; /* SEGMENT, REGION, DISK ,... */
|
||||
data_type_t data_type; /* DATA_TYPE, META_DATA_TYPE, FREE_SPACE_TYPE */
|
||||
plugin_record_t * plugin; /* Plug-in record of plug-in that manages this object */
|
||||
struct storage_container_s * producing_container; /* storage_container that produced this object */
|
||||
struct storage_container_s * consuming_container; /* storage_container that consumed this object */
|
||||
dlist_t parent_objects; /* List of parent objects, filled in by parent */
|
||||
dlist_t child_objects; /* List of child objects, filled in by owner */
|
||||
struct storage_object_s * associated_object; /* Object to which this object is associated */
|
||||
u_int32_t flags; /* Defined by SOFLAG_???? in common.h */
|
||||
lba_t start; /* Relative starting block of this object */
|
||||
sector_count_t size; /* Size of object in sectors */
|
||||
struct logical_volume_s * volume; /* Volume which comprises this object */
|
||||
evms_feature_header_t * feature_header; /* Copy of EVMS storage object's top feature header */
|
||||
/* read in by Engine */
|
||||
/* NULL if it does not exist */
|
||||
geometry_t geometry; /* Optional geometry of the object */
|
||||
void * private_data; /* Optional plug-in's data for the object */
|
||||
void * consuming_private_data;/* Optional consuming plug-in's data for the object */
|
||||
char name[EVMS_NAME_SIZE+1];/* Object's name, filled in by owner */
|
||||
} storage_object_t;
|
||||
|
||||
|
||||
typedef struct storage_container_s {
|
||||
object_handle_t app_handle; /* External API handle for this structure; */
|
||||
/* used only by the Engine */
|
||||
plugin_record_t * plugin; /* Plug-in record of the plug-in that manages */
|
||||
/* this container */
|
||||
/* Filled in by the plug-in during discover */
|
||||
/* or create_container() */
|
||||
uint flags; /* Defined by SCFLAG_???? in common.h */
|
||||
dlist_t objects_consumed; /* List of objects in this container */
|
||||
/* The Engine allocate_container API will create the */
|
||||
/* dlist_t anchor for this list. */
|
||||
/* The plug-in inserts storage_object_t structures */
|
||||
/* into this list when it assigns objects to this */
|
||||
/* container. */
|
||||
dlist_t objects_produced; /* List of objects produced from this container, */
|
||||
/* including free space objects */
|
||||
/* The Engine allocate_container API will create the */
|
||||
/* dlist_t anchor for this list. */
|
||||
/* The plug-in inserts storage_object_t structures */
|
||||
/* into this list when it produces objects from this */
|
||||
/* container. */
|
||||
sector_count_t size; /* Total size of all objects on the objects_produced list */
|
||||
void * private_data; /* Optional plug-in data for the container */
|
||||
char name[EVMS_NAME_SIZE+1]; /* Container name, filled in by the plug-in */
|
||||
} storage_container_t;
|
||||
|
||||
|
||||
/*
|
||||
* The logical_volume structures are created and managed by the Engine.
|
||||
*/
|
||||
typedef struct logical_volume_s {
|
||||
object_handle_t app_handle; /* External API handle for this structure; */
|
||||
/* used only by the Engine */
|
||||
plugin_record_t * file_system_manager; /* Plug-in record of the File System Interface */
|
||||
/* Module that handles this volume */
|
||||
plugin_record_t * original_fsim; /* Plug-in record of the File System Interface */
|
||||
/* Module that was initially discovered for this volume */
|
||||
char * mount_point; /* Dir where the volume is mounted, NULL if not mounted */
|
||||
sector_count_t fs_size; /* Size of the file system */
|
||||
sector_count_t min_fs_size; /* Minimum size for the file system */
|
||||
sector_count_t max_fs_size; /* Maximum size for the file system */
|
||||
sector_count_t original_vol_size; /* Size of the file system before expand or shrink */
|
||||
sector_count_t vol_size; /* Size of the volume */
|
||||
sector_count_t max_vol_size; /* Maximum size for the volume */
|
||||
#ifndef ABI_EVMS_1_0
|
||||
sector_count_t shrink_vol_size; /* Size to which to shrink the volume */
|
||||
#endif
|
||||
struct logical_volume_s * associated_volume; /* Volume to which this volume is associated */
|
||||
/* by an associative feature */
|
||||
option_array_t * mkfs_options; /* Options for mkfs */
|
||||
option_array_t * fsck_options; /* Options for fsck */
|
||||
option_array_t * defrag_options; /* Options for defrag */
|
||||
storage_object_t * object; /* Top level storage_object_t for the volume */
|
||||
uint minor_number; /* Volume's minor number */
|
||||
u_int64_t serial_number; /* Volume's serial number */
|
||||
u_int32_t flags; /* Defined by VOLFLAG_???? defines */
|
||||
void * private_data; /* Private data pointer for FSIMs. */
|
||||
char name[EVMS_VOLUME_NAME_SIZE+1];
|
||||
/* Volume name, filled in by the Engine */
|
||||
#ifndef ABI_EVMS_1_0
|
||||
char dev_node[EVMS_VOLUME_NAME_SIZE+1];
|
||||
/* Device node */
|
||||
#endif
|
||||
} logical_volume_t;
|
||||
|
||||
|
||||
/*
|
||||
* Structure for a declined object. Includes a pointer to the declined object
|
||||
* and a reason (usually an error code).
|
||||
*/
|
||||
typedef struct declined_object_s {
|
||||
storage_object_t * object;
|
||||
int reason;
|
||||
} declined_object_t;
|
||||
|
||||
|
||||
/*
|
||||
* Tags for objects in dlists
|
||||
*/
|
||||
typedef enum {
|
||||
PLUGIN_TAG = PLUGIN,
|
||||
DISK_TAG = DISK,
|
||||
SEGMENT_TAG = SEGMENT,
|
||||
REGION_TAG = REGION,
|
||||
EVMS_OBJECT_TAG = EVMS_OBJECT,
|
||||
CONTAINER_TAG = CONTAINER,
|
||||
VOLUME_TAG = VOLUME,
|
||||
DECLINED_OBJECT_TAG = (1<<7),
|
||||
VOLUME_DATA_TAG = (1<<8),
|
||||
TASK_TAG = (1<<9),
|
||||
KILL_SECTOR_TAG = (1<<10),
|
||||
BLOCK_RUN_TAG = (1<<11),
|
||||
EXPAND_OBJECT_TAG = (1<<12),
|
||||
SHRINK_OBJECT_TAG = (1<<13)
|
||||
} dlist_tag_t;
|
||||
|
||||
|
||||
typedef struct chs_s {
|
||||
u_int32_t cylinder;
|
||||
u_int32_t head;
|
||||
u_int32_t sector;
|
||||
} chs_t;
|
||||
|
||||
/*
|
||||
* The block_run_t is used to describe a run of contiguous physical sectors on
|
||||
* a disk.
|
||||
*/
|
||||
typedef struct block_run_s {
|
||||
storage_object_t * disk;
|
||||
lba_t lba;
|
||||
u_int64_t number_of_blocks;
|
||||
} block_run_t;
|
||||
|
||||
/*
|
||||
* The kill_sector_record_t structure records a run of contiguous physical
|
||||
* sectors on a disk that are to be zeroed out as part of the committing of
|
||||
* changes to the disk. Kill sectors are used to wipe data off of the disk
|
||||
* so that it will not be found on a rediscover.
|
||||
*/
|
||||
typedef struct kill_sector_record_s {
|
||||
storage_object_t * logical_disk;
|
||||
lsn_t sector_offset;
|
||||
sector_count_t sector_count;
|
||||
} kill_sector_record_t;
|
||||
|
||||
/*
|
||||
* The expand_object_info_t structure contains information about an object
|
||||
* that is a candidate for expanding. It contains a pointer to the object
|
||||
* and the maximum delta size by which the object can expand.
|
||||
*/
|
||||
typedef struct expand_object_info_s {
|
||||
storage_object_t * object;
|
||||
sector_count_t max_expand_size;
|
||||
} expand_object_info_t;
|
||||
|
||||
/*
|
||||
* The shrink_object_info_t structure contains information about an object
|
||||
* that is a candidate for shrinking. It contains a pointer to the object
|
||||
* and the maximum delta size by which the object can shrink.
|
||||
*/
|
||||
typedef struct shrink_object_info_s {
|
||||
storage_object_t * object;
|
||||
sector_count_t max_shrink_size;
|
||||
} shrink_object_info_t;
|
||||
|
||||
/*
|
||||
* Option descriptor structure
|
||||
*/
|
||||
typedef struct option_desc_array_s {
|
||||
u_int32_t count; /* Number of option descriptors in the following array */
|
||||
option_descriptor_t option[1]; /* option_descriptor_t is defined in option.h */
|
||||
} option_desc_array_t;
|
||||
|
||||
|
||||
/*
|
||||
* Task context structure
|
||||
*/
|
||||
typedef struct task_context_s {
|
||||
plugin_record_t * plugin; /* Plug-in being communicated with */
|
||||
storage_object_t * object; /* Object upon which to do the action */
|
||||
storage_container_t * container; /* Container upon which to do the action */
|
||||
logical_volume_t * volume; /* Volume upon which to do the action */
|
||||
task_action_t action; /* API application is interested in calling */
|
||||
option_desc_array_t * option_descriptors; /* Array of current task option descriptors */
|
||||
dlist_t acceptable_objects; /* Current list of acceptable parameters */
|
||||
dlist_t selected_objects; /* Current list of selected parameters */
|
||||
u_int32_t min_selected_objects; /* Minimum number of objects that must be selected. */
|
||||
u_int32_t max_selected_objects; /* Maximum number of objects that can be selected. */
|
||||
} task_context_t;
|
||||
|
||||
|
||||
/* Enum for the phases of the commit process. */
|
||||
typedef enum {
|
||||
SETUP = 0,
|
||||
FIRST_METADATA_WRITE = 1,
|
||||
SECOND_METADATA_WRITE = 2,
|
||||
POST_REDISCOVER = 3
|
||||
} commit_phase_t;
|
||||
|
||||
|
||||
/*
|
||||
* Macros for referencing fields in disk structures.
|
||||
* EVMS writes all disk structures in little endian format. These macros can
|
||||
* be used to access the fields of structures on disk regardless of the
|
||||
* endianness of the CPU architecture.
|
||||
*/
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define CPU_TO_DISK16(x) (bswap_16(x))
|
||||
#define CPU_TO_DISK32(x) (bswap_32(x))
|
||||
#define CPU_TO_DISK64(x) (bswap_64(x))
|
||||
|
||||
#define DISK_TO_CPU16(x) (bswap_16(x))
|
||||
#define DISK_TO_CPU32(x) (bswap_32(x))
|
||||
#define DISK_TO_CPU64(x) (bswap_64(x))
|
||||
|
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define CPU_TO_DISK16(x) (x)
|
||||
#define CPU_TO_DISK32(x) (x)
|
||||
#define CPU_TO_DISK64(x) (x)
|
||||
|
||||
#define DISK_TO_CPU16(x) (x)
|
||||
#define DISK_TO_CPU32(x) (x)
|
||||
#define DISK_TO_CPU64(x) (x)
|
||||
|
||||
#else
|
||||
#error "__BYTE_ORDER must be defined as __LITTLE_ENDIAN or __BIG_ENDIAN"
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,161 @@
|
|||
/* -*- linux-c -*- */
|
||||
/*
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2000
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
* linux/include/linux/evms/evms_common.h
|
||||
*
|
||||
* EVMS common (kernel and user) header file
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __EVMS_COMMON_INCLUDED__
|
||||
#define __EVMS_COMMON_INCLUDED__
|
||||
|
||||
/* version info */
|
||||
#define EVMS_MAJOR 63 /* use experimental major 63 for now */
|
||||
#define EVMS_MAJOR_VERSION 1
|
||||
#define EVMS_MINOR_VERSION 1
|
||||
#define EVMS_PATCHLEVEL_VERSION 0
|
||||
|
||||
#define MAX_EVMS_VOLUMES 256 /* There are 256 minors */
|
||||
#define EVMS_VOLUME_NAME_SIZE 127
|
||||
|
||||
#define IBM_OEM_ID 8112 // could be anything, but used
|
||||
// I=8, B=1, M=12
|
||||
// this one going away as well.
|
||||
#define EVMS_OEM_IBM IBM_OEM_ID
|
||||
|
||||
#define EVMS_INITIAL_CRC 0xFFFFFFFF
|
||||
#define EVMS_MAGIC_CRC 0x31415926
|
||||
|
||||
#define EVMS_VSECTOR_SIZE 512
|
||||
#define EVMS_VSECTOR_SIZE_SHIFT 9
|
||||
|
||||
#define DEV_PATH "/dev"
|
||||
#define EVMS_DIR_NAME "evms"
|
||||
#define EVMS_DEV_NAME "block_device"
|
||||
#define EVMS_DEV_NODE_PATH DEV_PATH "/" EVMS_DIR_NAME "/"
|
||||
#define EVMS_DEVICE_NAME DEV_PATH "/" EVMS_DIR_NAME "/" EVMS_DEV_NAME
|
||||
|
||||
/* EVMS will always use 64-bit fields */
|
||||
typedef u_int64_t evms_sector_t;
|
||||
|
||||
/* EVMS specific device handle type definition */
|
||||
typedef u_int64_t evms_dev_handle_t;
|
||||
|
||||
typedef struct evms_version_s {
|
||||
/* major changes when incompatible differences are introduced */
|
||||
u_int32_t major;
|
||||
/* minor changes when additions are made */
|
||||
u_int32_t minor;
|
||||
/* patchlevel changes when bugs are fixed */
|
||||
u_int32_t patchlevel;
|
||||
} evms_version_t;
|
||||
|
||||
typedef enum evms_plugin_code_s {
|
||||
EVMS_NO_PLUGIN, // 0
|
||||
EVMS_DEVICE_MANAGER, // 1
|
||||
EVMS_SEGMENT_MANAGER, // 2
|
||||
EVMS_REGION_MANAGER, // 3
|
||||
EVMS_FEATURE, // 4
|
||||
EVMS_ASSOCIATIVE_FEATURE, // 5
|
||||
EVMS_FILESYSTEM_INTERFACE_MODULE, // 6
|
||||
EVMS_CLUSTER_MANAGER_INTERFACE_MODULE, // 7
|
||||
EVMS_DISTRIBUTED_LOCK_MANAGER_INTERFACE_MODULE // 8
|
||||
} evms_plugin_code_t;
|
||||
|
||||
#define SetPluginID(oem, type, id) ((oem << 16) | (type << 12) | id)
|
||||
#define GetPluginOEM(pluginid) (pluginid >> 16)
|
||||
#define GetPluginType(pluginid) ((pluginid >> 12) & 0xf)
|
||||
#define GetPluginID(pluginid) (pluginid & 0xfff)
|
||||
|
||||
/* bit definitions for the flags field in
|
||||
* the EVMS LOGICAL NODE (kernel) and
|
||||
* the EVMS LOGICAL VOLUME (user) structures.
|
||||
*/
|
||||
#define EVMS_FLAGS_WIDTH 32
|
||||
#define EVMS_VOLUME_FLAG (1<<0)
|
||||
#define EVMS_VOLUME_PARTIAL_FLAG (1<<1)
|
||||
#define EVMS_VOLUME_PARTIAL (1<<1)
|
||||
#define EVMS_VOLUME_SET_READ_ONLY (1<<2)
|
||||
#define EVMS_VOLUME_READ_ONLY (1<<2)
|
||||
/* queued flags bits */
|
||||
#define EVMS_REQUESTED_DELETE (1<<5)
|
||||
#define EVMS_REQUESTED_QUIESCE (1<<6)
|
||||
#define EVMS_REQUESTED_VFS_QUIESCE (1<<7)
|
||||
/* this bit indicates corruption */
|
||||
#define EVMS_VOLUME_CORRUPT (1<<8)
|
||||
/* these bits define the source of the corruption */
|
||||
#define EVMS_VOLUME_SOFT_DELETED (1<<9)
|
||||
#define EVMS_DEVICE_UNAVAILABLE (1<<10)
|
||||
/* these bits define volume status */
|
||||
#define EVMS_MEDIA_CHANGED (1<<20)
|
||||
#define EVMS_DEVICE_UNPLUGGED (1<<21)
|
||||
/* these bits used for removable status */
|
||||
#define EVMS_DEVICE_MEDIA_PRESENT (1<<24)
|
||||
#define EVMS_DEVICE_PRESENT (1<<25)
|
||||
#define EVMS_DEVICE_LOCKABLE (1<<26)
|
||||
#define EVMS_DEVICE_REMOVABLE (1<<27)
|
||||
|
||||
/* version info for evms_feature_header_t */
|
||||
#define EVMS_FEATURE_HEADER_MAJOR 3
|
||||
#define EVMS_FEATURE_HEADER_MINOR 0
|
||||
#define EVMS_FEATURE_HEADER_PATCHLEVEL 0
|
||||
|
||||
/* bit definitions of FEATURE HEADER bits in the FLAGS field */
|
||||
#define EVMS_FEATURE_ACTIVE (1<<0)
|
||||
#define EVMS_FEATURE_VOLUME_COMPLETE (1<<1)
|
||||
/* bit definitions for VOLUME bits in the FLAGS field */
|
||||
#define EVMS_VOLUME_DATA_OBJECT (1<<16)
|
||||
#define EVMS_VOLUME_DATA_STOP (1<<17)
|
||||
|
||||
#define EVMS_FEATURE_HEADER_SIGNATURE 0x54414546 //FEAT
|
||||
typedef struct evms_feature_header_s {
|
||||
/* 0*/ u_int32_t signature;
|
||||
/* 4*/ u_int32_t crc;
|
||||
/* 8*/ evms_version_t version; /* structure version */
|
||||
/* 20*/ evms_version_t engine_version; /* version of the Engine that */
|
||||
/* wrote this feature header */
|
||||
/* 32*/ u_int32_t flags;
|
||||
/* 36*/ u_int32_t feature_id;
|
||||
/* 40*/ u_int64_t sequence_number;
|
||||
/* 48*/ u_int64_t alignment_padding;
|
||||
//required: starting lsn to 1st copy of feature's metadata.
|
||||
/* 56*/ evms_sector_t feature_data1_start_lsn;
|
||||
/* 64*/ evms_sector_t feature_data1_size; //in 512 byte units
|
||||
//optional: starting lsn to 2nd copy of feature's metadata.
|
||||
// if unused set size field to 0.
|
||||
/* 72*/ evms_sector_t feature_data2_start_lsn;
|
||||
/* 80*/ evms_sector_t feature_data2_size; //in 512 byte units
|
||||
/* 88*/ u_int64_t volume_serial_number;
|
||||
/* 96*/ u_int32_t volume_system_id; /* the minor is stored here */
|
||||
/*100*/ u_int32_t object_depth; /* depth of object in the volume tree */
|
||||
/*104*/ char object_name[EVMS_VOLUME_NAME_SIZE+1];
|
||||
/*232*/ char volume_name[EVMS_VOLUME_NAME_SIZE+1];
|
||||
/*360*/ unsigned char pad[152];
|
||||
/*512*/
|
||||
} evms_feature_header_t;
|
||||
|
||||
/* EVMS specific error codes */
|
||||
#define EVMS_FEATURE_FATAL_ERROR 257
|
||||
#define EVMS_VOLUME_FATAL_ERROR 258
|
||||
|
||||
#define EVMS_FEATURE_INCOMPLETE_ERROR 259
|
||||
|
||||
#endif
|
|
@ -0,0 +1,297 @@
|
|||
/* -*- linux-c -*- */
|
||||
/*
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2000
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
* linux/include/linux/evms.h
|
||||
*
|
||||
* EVMS public kernel header file
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __EVMS_IOCTL_INCLUDED__
|
||||
#define __EVMS_IOCTL_INCLUDED__
|
||||
|
||||
#include <linux/hdreg.h>
|
||||
|
||||
/* IOCTL interface version definitions */
|
||||
#define EVMS_IOCTL_INTERFACE_MAJOR 10
|
||||
#define EVMS_IOCTL_INTERFACE_MINOR 0
|
||||
#define EVMS_IOCTL_INTERFACE_PATCHLEVEL 0
|
||||
|
||||
/* IOCTL definitions */
|
||||
typedef enum evms_ioctl_cmds_s {
|
||||
/* version commands */
|
||||
EVMS_GET_IOCTL_VERSION_NUMBER = 0,
|
||||
EVMS_GET_VERSION_NUMBER,
|
||||
#ifdef __KERNEL__
|
||||
/* EVMS internal commands */
|
||||
EVMS_GET_DISK_LIST_NUMBER = 0x40,
|
||||
EVMS_CHECK_MEDIA_CHANGE_NUMBER,
|
||||
EVMS_REVALIDATE_DISK_NUMBER,
|
||||
EVMS_OPEN_VOLUME_NUMBER,
|
||||
EVMS_CLOSE_VOLUME_NUMBER,
|
||||
EVMS_QUIESCE_VOLUME_NUMBER,
|
||||
EVMS_CHECK_DEVICE_STATUS_NUMBER,
|
||||
#endif
|
||||
/* configuration commands */
|
||||
EVMS_GET_INFO_LEVEL_NUMBER = 0x80,
|
||||
EVMS_SET_INFO_LEVEL_NUMBER,
|
||||
EVMS_REDISCOVER_VOLUMES_NUMBER,
|
||||
EVMS_DELETE_VOLUME_NUMBER,
|
||||
EVMS_PLUGIN_IOCTL_NUMBER,
|
||||
EVMS_PROCESS_NOTIFY_EVENT_NUMBER,
|
||||
/* query info commands */
|
||||
EVMS_GET_LOGICAL_DISK_NUMBER = 0xC0,
|
||||
EVMS_GET_LOGICAL_DISK_INFO_NUMBER,
|
||||
EVMS_SECTOR_IO_NUMBER,
|
||||
EVMS_GET_MINOR_NUMBER,
|
||||
EVMS_GET_VOLUME_DATA_NUMBER,
|
||||
EVMS_GET_PLUGIN_NUMBER,
|
||||
EVMS_COMPUTE_CSUM_NUMBER,
|
||||
EVMS_GET_BMAP_NUMBER,
|
||||
} evms_ioctl_cmds_t;
|
||||
|
||||
/* version commands */
|
||||
#define EVMS_GET_IOCTL_VERSION_STRING "EVMS_GET_IOCTL_VERSION"
|
||||
#define EVMS_GET_IOCTL_VERSION _IOR(EVMS_MAJOR, EVMS_GET_IOCTL_VERSION_NUMBER, evms_version_t)
|
||||
|
||||
#define EVMS_GET_VERSION_STRING "EVMS_GET_VERSION"
|
||||
#define EVMS_GET_VERSION _IOR(EVMS_MAJOR, EVMS_GET_VERSION_NUMBER, evms_version_t)
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/* EVMS internal commands */
|
||||
#define EVMS_GET_DISK_LIST_STRING "EVMS_GET_DISK_LIST"
|
||||
#define EVMS_GET_DISK_LIST _IOWR(EVMS_MAJOR, EVMS_GET_DISK_LIST_NUMBER, evms_list_node_t **)
|
||||
|
||||
#define EVMS_CHECK_MEDIA_CHANGE_STRING "EVMS_CHECK_MEDIA_CHANGE"
|
||||
#define EVMS_CHECK_MEDIA_CHANGE _IO(EVMS_MAJOR, EVMS_CHECK_MEDIA_CHANGE_NUMBER)
|
||||
|
||||
#define EVMS_REVALIDATE_DISK_STRING "EVMS_REVALIDATE_DISK"
|
||||
#define EVMS_REVALIDATE_DISK _IO(EVMS_MAJOR, EVMS_REVALIDATE_DISK_NUMBER)
|
||||
|
||||
#define EVMS_OPEN_VOLUME_STRING "EVMS_OPEN_VOLUME"
|
||||
#define EVMS_OPEN_VOLUME _IO(EVMS_MAJOR, EVMS_OPEN_VOLUME_NUMBER)
|
||||
|
||||
#define EVMS_CLOSE_VOLUME_STRING "EVMS_CLOSE_VOLUME"
|
||||
#define EVMS_CLOSE_VOLUME _IO(EVMS_MAJOR, EVMS_CLOSE_VOLUME_NUMBER)
|
||||
|
||||
/* field: command: defines */
|
||||
#define EVMS_UNQUIESCE 0
|
||||
#define EVMS_QUIESCE 1
|
||||
|
||||
/* field: do_vfs: defines */
|
||||
/* see evms_delete_volume */
|
||||
typedef struct evms_quiesce_volume_s {
|
||||
int command; /* 0 = unquiesce, 1 = quiesce */
|
||||
int minor; /* minor device number of target volume */
|
||||
int do_vfs; /* 0 = do nothing, 1 = also perform equivalent VFS operation */
|
||||
int status; /* 0 = success */
|
||||
} evms_quiesce_volume_t;
|
||||
|
||||
#define EVMS_QUIESCE_VOLUME_STRING "EVMS_QUIESCE_VOLUME"
|
||||
#define EVMS_QUIESCE_VOLUME _IOR(EVMS_MAJOR, EVMS_QUIESCE_VOLUME_NUMBER, evms_quiesce_volume_t)
|
||||
|
||||
#define EVMS_CHECK_DEVICE_STATUS_STRING "EVMS_CHECK_DEVICE_STATUS"
|
||||
#define EVMS_CHECK_DEVICE_STATUS _IOR(EVMS_MAJOR, EVMS_CHECK_DEVICE_STATUS_NUMBER, int)
|
||||
|
||||
#endif
|
||||
|
||||
/* configuration commands */
|
||||
#define EVMS_GET_INFO_LEVEL_STRING "EVMS_GET_INFO_LEVEL"
|
||||
#define EVMS_GET_INFO_LEVEL _IOR(EVMS_MAJOR, EVMS_GET_INFO_LEVEL_NUMBER, int)
|
||||
|
||||
#define EVMS_SET_INFO_LEVEL_STRING "EVMS_SET_INFO_LEVEL"
|
||||
#define EVMS_SET_INFO_LEVEL _IOW(EVMS_MAJOR, EVMS_SET_INFO_LEVEL_NUMBER, int)
|
||||
|
||||
/* field: drive_count: defines */
|
||||
#define REDISCOVER_ALL_DEVICES 0xFFFFFFFF
|
||||
typedef struct evms_rediscover_s {
|
||||
int status;
|
||||
unsigned int drive_count; /* 0xffffffff = rediscover all known disks */
|
||||
unsigned long *drive_array;
|
||||
} evms_rediscover_t;
|
||||
|
||||
#define EVMS_REDISCOVER_VOLUMES_STRING "EVMS_REDISCOVER_VOLUMES"
|
||||
#define EVMS_REDISCOVER_VOLUMES _IOWR(EVMS_MAJOR, EVMS_REDISCOVER_VOLUMES_NUMBER, evms_rediscover_t)
|
||||
|
||||
/* field: command: defines */
|
||||
#define EVMS_SOFT_DELETE 0
|
||||
#define EVMS_HARD_DELETE 1
|
||||
|
||||
/* field: do_vfs: defines */
|
||||
#define EVMS_VFS_DO_NOTHING 0
|
||||
#define EVMS_VFS_DO 1
|
||||
typedef struct evms_delete_volume_s {
|
||||
int command; /* 0 = "temp", 1 = "permanent" */
|
||||
int minor; /* minor device number of target volume */
|
||||
int do_vfs; /* 0 = do nothing, 1 = perform VFS operations */
|
||||
int associative_minor; /* optional minor of associative volume */
|
||||
/* must be 0 when not in use */
|
||||
int status; /* 0 = success, other is error */
|
||||
} evms_delete_volume_t;
|
||||
|
||||
#define EVMS_DELETE_VOLUME_STRING "EVMS_DELETE_VOLUME"
|
||||
#define EVMS_DELETE_VOLUME _IOR(EVMS_MAJOR, EVMS_DELETE_VOLUME_NUMBER, evms_delete_volume_t)
|
||||
|
||||
typedef struct evms_plugin_ioctl_s {
|
||||
unsigned long feature_id; /* ID of feature to receive this ioctl */
|
||||
int feature_command; /* feature specific ioctl command */
|
||||
int status; /* 0 = completed, non-0 = error */
|
||||
void *feature_ioctl_data; /* ptr to feature specific struct */
|
||||
} evms_plugin_ioctl_t;
|
||||
|
||||
#define EVMS_PLUGIN_IOCTL_STRING "EVMS_PLUGIN_IOCTL"
|
||||
#define EVMS_PLUGIN_IOCTL _IOR(EVMS_MAJOR, EVMS_PLUGIN_IOCTL_NUMBER, evms_plugin_ioctl_t)
|
||||
|
||||
/* field: eventid: defines */
|
||||
#define EVMS_EVENT_END_OF_DISCOVERY 0
|
||||
typedef struct evms_event_s {
|
||||
int pid; /* PID to act on */
|
||||
int eventid; /* event id to respond to */
|
||||
int signo; /* signal # to send when event occurs */
|
||||
} evms_event_t;
|
||||
|
||||
/* field: command: defines */
|
||||
#define EVMS_EVENT_UNREGISTER 0
|
||||
#define EVMS_EVENT_REGISTER 1
|
||||
typedef struct evms_notify_s {
|
||||
int command; /* 0 = unregister, 1 = register */
|
||||
evms_event_t eventry; /* event structure */
|
||||
int status; /* return status */
|
||||
} evms_notify_t;
|
||||
|
||||
#define EVMS_PROCESS_NOTIFY_EVENT_STRING "EVMS_PROCESS_NOTIFY_EVENT"
|
||||
#define EVMS_PROCESS_NOTIFY_EVENT _IOWR(EVMS_MAJOR, EVMS_PROCESS_NOTIFY_EVENT_NUMBER, evms_notify_t)
|
||||
|
||||
/* query info commands */
|
||||
|
||||
/* field: command: defines */
|
||||
#define EVMS_FIRST_DISK 0
|
||||
#define EVMS_NEXT_DISK 1
|
||||
|
||||
/* field: status: defines */
|
||||
#define EVMS_DISK_INVALID 0
|
||||
#define EVMS_DISK_VALID 1
|
||||
typedef struct evms_user_disk_s {
|
||||
int command; /* 0 = first disk, 1 = next disk */
|
||||
int status; /* 0 = no more disks, 1 = valid disk info */
|
||||
unsigned long disk_handle; /* only valid when status == 1 */
|
||||
} evms_user_disk_t;
|
||||
|
||||
#define EVMS_GET_LOGICAL_DISK_STRING "EVMS_GET_LOGICAL_DISK"
|
||||
#define EVMS_GET_LOGICAL_DISK _IOWR(EVMS_MAJOR, EVMS_GET_LOGICAL_DISK_NUMBER, evms_user_disk_t)
|
||||
|
||||
/* flags fields described in evms_common.h */
|
||||
typedef struct evms_user_disk_info_s {
|
||||
unsigned int status;
|
||||
unsigned int flags;
|
||||
unsigned long disk_handle;
|
||||
unsigned int disk_dev;
|
||||
struct hd_geometry geometry;
|
||||
unsigned int block_size;
|
||||
unsigned int hardsect_size;
|
||||
u_int64_t total_sectors;
|
||||
char disk_name[EVMS_VOLUME_NAME_SIZE];
|
||||
} evms_user_disk_info_t;
|
||||
|
||||
#define EVMS_GET_LOGICAL_DISK_INFO_STRING "EVMS_GET_LOGICAL_DISK_INFO"
|
||||
#define EVMS_GET_LOGICAL_DISK_INFO _IOWR(EVMS_MAJOR, EVMS_GET_LOGICAL_DISK_INFO_NUMBER, evms_user_disk_info_t)
|
||||
|
||||
/* field: io_flag: defines */
|
||||
#define EVMS_SECTOR_IO_READ 0
|
||||
#define EVMS_SECTOR_IO_WRITE 1
|
||||
typedef struct evms_sector_io_s {
|
||||
unsigned long disk_handle; /* valid disk handle */
|
||||
int io_flag; /* 0 = READ, 1 = WRITE */
|
||||
evms_sector_t starting_sector; /* disk relative LBA */
|
||||
evms_sector_t sector_count; /* number of sectors in IO */
|
||||
unsigned char *buffer_address; /* IO address */
|
||||
int status; /* 0 = success, not 0 = error */
|
||||
} evms_sector_io_t;
|
||||
|
||||
#define EVMS_SECTOR_IO_STRING "EVMS_SECTOR_IO"
|
||||
#define EVMS_SECTOR_IO _IOWR(EVMS_MAJOR, EVMS_SECTOR_IO_NUMBER, evms_sector_io_t)
|
||||
|
||||
/* field: command: defines */
|
||||
#define EVMS_FIRST_VOLUME 0
|
||||
#define EVMS_NEXT_VOLUME 1
|
||||
|
||||
/* field: status: defines */
|
||||
#define EVMS_VOLUME_INVALID 0
|
||||
#define EVMS_VOLUME_VALID 1
|
||||
typedef struct evms_user_minor_s {
|
||||
int command; /* 0 = first volume, 1 = next volume */
|
||||
int status; /* 0 = no more, 1 = valid info */
|
||||
int minor; /* only valid when status == 1 */
|
||||
} evms_user_minor_t;
|
||||
|
||||
#define EVMS_GET_MINOR_STRING "EVMS_GET_MINOR"
|
||||
#define EVMS_GET_MINOR _IOWR(EVMS_MAJOR, EVMS_GET_MINOR_NUMBER, evms_user_minor_t)
|
||||
|
||||
/* flags field described in evms_common.h */
|
||||
typedef struct evms_volume_data_s {
|
||||
int minor; /* minor of target volume */
|
||||
int flags;
|
||||
char volume_name[EVMS_VOLUME_NAME_SIZE + 1];
|
||||
int status;
|
||||
} evms_volume_data_t;
|
||||
|
||||
#define EVMS_GET_VOLUME_DATA_STRING "EVMS_GET_VOLUME_DATA"
|
||||
#define EVMS_GET_VOLUME_DATA _IOWR(EVMS_MAJOR, EVMS_GET_VOLUME_DATA_NUMBER, evms_volume_data_t)
|
||||
|
||||
/* field: command: defines */
|
||||
#define EVMS_FIRST_PLUGIN 0
|
||||
#define EVMS_NEXT_PLUGIN 1
|
||||
|
||||
/* field: status: defines */
|
||||
#define EVMS_PLUGIN_INVALID 0
|
||||
#define EVMS_PLUGIN_VALID 1
|
||||
typedef struct evms_kernel_plugin_s {
|
||||
int command; /* 0 = first item, 1 = next item */
|
||||
u_int32_t id; /* returned plugin id */
|
||||
evms_version_t version; /* maj,min,patch of plugin */
|
||||
int status; /* 0 = no more, 1 = valid info */
|
||||
} evms_kernel_plugin_t;
|
||||
|
||||
#define EVMS_GET_PLUGIN_STRING "EVMS_GET_PLUGIN"
|
||||
#define EVMS_GET_PLUGIN _IOWR(EVMS_MAJOR, EVMS_GET_PLUGIN_NUMBER, evms_kernel_plugin_t)
|
||||
|
||||
typedef struct evms_compute_csum_s {
|
||||
unsigned char *buffer_address; /* IO address */
|
||||
int buffer_size; /* byte size of buffer */
|
||||
unsigned int insum; /* previous csum to be factored in */
|
||||
unsigned int outsum; /* resulting csum value of buffer */
|
||||
int status; /* 0 = success, not 0 = error */
|
||||
} evms_compute_csum_t;
|
||||
|
||||
#define EVMS_COMPUTE_CSUM_STRING "EVMS_COMPUTE_CSUM"
|
||||
#define EVMS_COMPUTE_CSUM _IOWR(EVMS_MAJOR, EVMS_COMPUTE_CSUM_NUMBER, evms_compute_csum_t)
|
||||
|
||||
typedef struct evms_get_bmap_s {
|
||||
u_int64_t rsector; /* input: volume relative rsector value */
|
||||
/* output: disk relative rsector value */
|
||||
u_int32_t dev; /* output = physical device */
|
||||
int status; /* 0 = success, not 0 = error */
|
||||
} evms_get_bmap_t;
|
||||
|
||||
#define EVMS_GET_BMAP_STRING "EVMS_GET_BMAP"
|
||||
#define EVMS_GET_BMAP _IOWR(EVMS_MAJOR, EVMS_GET_BMAP_NUMBER, evms_get_bmap_t)
|
||||
|
||||
#endif
|
|
@ -0,0 +1,28 @@
|
|||
/* -*- linux-c -*- */
|
||||
/*
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2000
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
* linux/include/linux/evms_user.h
|
||||
*
|
||||
* EVMS (master) user header file
|
||||
*
|
||||
*/
|
||||
|
||||
#include <evms/evms_common.h>
|
||||
#include <evms/evms_ioctl.h>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,578 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2000
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Module: fsimext2.c
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <plugin.h>
|
||||
#include "fsimext2.h"
|
||||
|
||||
int fsim_rw_diskblocks( int, int64_t, int32_t, void *, int );
|
||||
void set_mkfs_options( option_array_t *, char **, logical_volume_t *, char * );
|
||||
void set_fsck_options( option_array_t *, char **, logical_volume_t * );
|
||||
|
||||
// Vector of plugin record ptrs that we export for the EVMS Engine.
|
||||
plugin_record_t *evms_plugin_records[] = {
|
||||
&ext2_plugrec,
|
||||
NULL
|
||||
};
|
||||
|
||||
static plugin_record_t * pMyPluginRecord = &ext2_plugrec;
|
||||
|
||||
/*-------------------------------------------------------------------------------------+
|
||||
+ +
|
||||
+ Common Routines +
|
||||
+ +
|
||||
+--------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*
|
||||
* Get the size limits for this volume.
|
||||
*/
|
||||
int fsim_get_volume_limits( struct ext2_super_block * sb,
|
||||
sector_count_t * min_size,
|
||||
sector_count_t * max_volume_size,
|
||||
sector_count_t * max_object_size)
|
||||
{
|
||||
int rc = 0;
|
||||
sector_count_t fs_size;
|
||||
|
||||
/*
|
||||
* Since ext2/3 does not yet support shrink or expand,
|
||||
* all values are actual file system size.
|
||||
*/
|
||||
fs_size = sb->s_blocks_count << (1 + sb->s_log_block_size);
|
||||
*max_volume_size = fs_size;
|
||||
*max_object_size = fs_size;
|
||||
*min_size = fs_size;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Un-Format the volume.
|
||||
*/
|
||||
int fsim_unmkfs( logical_volume_t * volume )
|
||||
{
|
||||
int fd;
|
||||
int rc = 0;
|
||||
|
||||
fd = open(EVMS_GET_DEVNAME(volume), O_RDWR|O_EXCL, 0);
|
||||
if (fd < 0) return -1;
|
||||
|
||||
if ( volume->private_data ) {
|
||||
/* clear private data */
|
||||
memset( (void *) volume->private_data, 0, SIZE_OF_SUPER );
|
||||
/* zero primary superblock */
|
||||
rc = fsim_rw_diskblocks( fd, EXT2_SUPER_LOC, SIZE_OF_SUPER,
|
||||
volume->private_data, PUT );
|
||||
} else {
|
||||
rc = ERROR;
|
||||
}
|
||||
|
||||
fd = close(fd);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Format the volume.
|
||||
*/
|
||||
int fsim_mkfs(logical_volume_t * volume, option_array_t * options )
|
||||
{
|
||||
int rc = FSIM_ERROR;
|
||||
char *argv[MKFS_EXT2_OPTIONS_COUNT + 6];
|
||||
char logsize[sizeof(unsigned int) + 1];
|
||||
pid_t pidm;
|
||||
int status;
|
||||
|
||||
/* Fork and execute the correct program. */
|
||||
switch (pidm = fork()) {
|
||||
|
||||
/* error */
|
||||
case -1:
|
||||
return EIO;
|
||||
|
||||
/* child */
|
||||
case 0:
|
||||
set_mkfs_options( options, argv, volume, logsize );
|
||||
|
||||
/* close stderr, stdout to suppress mke2fs output */
|
||||
close(1);
|
||||
close(2);
|
||||
open("/dev/null", O_WRONLY);
|
||||
open("/dev/null", O_WRONLY);
|
||||
|
||||
(void) execvp(argv[0], argv);
|
||||
/* using exit() can hang GUI, use _exit */
|
||||
_exit(errno);
|
||||
|
||||
/* parent */
|
||||
default:
|
||||
/* wait for child to complete */
|
||||
pidm = waitpid( pidm, &status, 0 );
|
||||
if ( WIFEXITED(status) ) {
|
||||
/* get mke2fs exit code */
|
||||
rc = WEXITSTATUS(status);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* NAME: set_mkfs_options
|
||||
*
|
||||
* FUNCTION: Build options array (argv) for mkfs.ext2
|
||||
*
|
||||
* PARAMETERS:
|
||||
* options - options array passed from EVMS engine
|
||||
* argv - mkfs options array
|
||||
* vol_name - volume name on which program will be executed
|
||||
*
|
||||
*/
|
||||
void set_mkfs_options( option_array_t * options,
|
||||
char ** argv,
|
||||
logical_volume_t * volume,
|
||||
char * logsize )
|
||||
{
|
||||
int i, opt_count = 2;
|
||||
|
||||
argv[0] = "mke2fs";
|
||||
|
||||
/* 'quiet' option */
|
||||
argv[1] = "-q";
|
||||
|
||||
for ( i=0; i<options->count; i++ ) {
|
||||
|
||||
if ( options->option[i].is_number_based ) {
|
||||
|
||||
switch (options->option[i].number) {
|
||||
|
||||
case MKFS_CHECKBB_INDEX:
|
||||
/* 'check for bad blocks' option */
|
||||
if ( options->option[i].value.bool == TRUE ) {
|
||||
argv[opt_count++] = "-c";
|
||||
}
|
||||
break;
|
||||
|
||||
case MKFS_CHECKRW_INDEX:
|
||||
/* 'check for r/w bad blocks' option */
|
||||
if ( options->option[i].value.bool == TRUE ) {
|
||||
argv[opt_count++] = "-cc";
|
||||
}
|
||||
break;
|
||||
|
||||
case MKFS_JOURNAL_INDEX:
|
||||
/* 'create ext3 journal' option */
|
||||
if ( options->option[i].value.bool == TRUE ) {
|
||||
argv[opt_count++] = "-j";
|
||||
}
|
||||
break;
|
||||
|
||||
case MKFS_SETVOL_INDEX:
|
||||
/* 'set volume name' option */
|
||||
if ( options->option[i].value.s ) {
|
||||
argv[opt_count++] = "-L";
|
||||
argv[opt_count++] = options->option[i].value.s;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ( !strcmp(options->option[i].name, "badblocks") ) {
|
||||
/* 'check for bad blocks' option */
|
||||
if ( options->option[i].value.bool == TRUE ) {
|
||||
argv[opt_count++] = "-c";
|
||||
}
|
||||
}
|
||||
|
||||
if ( !strcmp(options->option[i].name, "badblocks_rw") ) {
|
||||
/* 'check for r/w bad blocks' option */
|
||||
if ( options->option[i].value.bool == TRUE ) {
|
||||
argv[opt_count++] = "-cc";
|
||||
}
|
||||
}
|
||||
|
||||
if ( !strcmp(options->option[i].name, "journal") ) {
|
||||
/* 'create ext3 journal' option */
|
||||
if ( options->option[i].value.bool == TRUE ) {
|
||||
argv[opt_count++] = "-j";
|
||||
}
|
||||
}
|
||||
|
||||
if ( !strcmp(options->option[i].name, "vollabel") ) {
|
||||
/* 'check for bad blocks' option */
|
||||
if ( options->option[i].value.s ) {
|
||||
argv[opt_count++] = "-L";
|
||||
argv[opt_count++] = options->option[i].value.s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
argv[opt_count++] = EVMS_GET_DEVNAME(volume);
|
||||
argv[opt_count] = NULL;
|
||||
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = fopen("/var/tmp/evms-log", "a");
|
||||
for ( i=0; argv[i]; i++) {
|
||||
fprintf(f, "'%s' ", argv[i]);
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Run fsck on the volume.
|
||||
*/
|
||||
int fsim_fsck(logical_volume_t * volume, option_array_t * options )
|
||||
{
|
||||
int rc = FSIM_ERROR;
|
||||
char *argv[FSCK_EXT2_OPTIONS_COUNT + 3];
|
||||
pid_t pidf;
|
||||
int status, bytes_read;
|
||||
char *buffer = NULL;
|
||||
int fds2[2];
|
||||
int banner = 0;
|
||||
|
||||
/* open pipe, alloc buffer for collecting fsck.jfs output */
|
||||
rc = pipe(fds2);
|
||||
if (rc) {
|
||||
return(rc);
|
||||
}
|
||||
if (!(buffer = EngFncs->engine_alloc(MAX_USER_MESSAGE_LEN))) {
|
||||
return(ENOMEM);
|
||||
}
|
||||
|
||||
/* Fork and execute the correct program. */
|
||||
switch (pidf = fork()) {
|
||||
|
||||
/* error */
|
||||
case -1:
|
||||
return EIO;
|
||||
|
||||
/* child */
|
||||
case 0:
|
||||
set_fsck_options( options, argv, volume );
|
||||
|
||||
/* pipe stderr, stdout */
|
||||
dup2(fds2[1],1); /* fds2[1] replaces stdout */
|
||||
dup2(fds2[1],2); /* fds2[1] replaces stderr */
|
||||
close(fds2[0]); /* don't need this here */
|
||||
|
||||
rc = execvp( argv[0], argv );
|
||||
|
||||
/*
|
||||
* The value of fsck exit code FSCK_CORRECTED is the same
|
||||
* as errno EPERM. Thus, if EPERM is returned from execv,
|
||||
* exit out of the child with rc = -1 instead of EPERM.
|
||||
*/
|
||||
if( rc && (errno == EPERM) ) {
|
||||
/* using exit() can hang GUI, use _exit */
|
||||
_exit(-1);
|
||||
} else {
|
||||
/* using exit() can hang GUI, use _exit */
|
||||
_exit(errno);
|
||||
}
|
||||
|
||||
/* parent */
|
||||
default:
|
||||
close(fds2[1]);
|
||||
|
||||
/* wait for child to complete */
|
||||
while (!(pidf = waitpid( pidf, &status, WNOHANG ))) {
|
||||
/* read e2fsck output */
|
||||
bytes_read = read(fds2[0],buffer,MAX_USER_MESSAGE_LEN);
|
||||
if (bytes_read > 0) {
|
||||
/* display e2fsck output */
|
||||
if (!banner)
|
||||
MESSAGE("e2fsck output: \n\n%s",buffer);
|
||||
else
|
||||
banner = 1;
|
||||
memset(buffer,0,bytes_read); //clear out message
|
||||
}
|
||||
usleep(10000); /* don't hog all the cpu */
|
||||
}
|
||||
|
||||
/* wait for child to complete */
|
||||
pidf = waitpid( pidf, &status, 0 );
|
||||
if ( WIFEXITED(status) ) {
|
||||
/* get e2fsck exit code */
|
||||
rc = WEXITSTATUS(status);
|
||||
LOG("e2fsck completed with exit code %d \n", rc);
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer) {
|
||||
EngFncs->engine_free(buffer);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* NAME: set_fsck_options
|
||||
*
|
||||
* FUNCTION: Build options array (argv) for e2fsck
|
||||
*
|
||||
* PARAMETERS:
|
||||
* options - options array passed from EVMS engine
|
||||
* argv - fsck options array
|
||||
* volume - volume on which program will be executed
|
||||
*
|
||||
*/
|
||||
void set_fsck_options( option_array_t * options, char ** argv, logical_volume_t * volume )
|
||||
{
|
||||
int i, opt_count = 1;
|
||||
int do_preen = 1;
|
||||
|
||||
argv[0] = "e2fsck";
|
||||
|
||||
for ( i=0; i<options->count; i++) {
|
||||
|
||||
if ( options->option[i].is_number_based ) {
|
||||
|
||||
/* 'force check' option */
|
||||
if ( (options->option[i].number == FSCK_FORCE_INDEX) &&
|
||||
(options->option[i].value.bool == TRUE) ) {
|
||||
argv[opt_count++] = "-f";
|
||||
}
|
||||
|
||||
/* 'check read only' option or mounted */
|
||||
if ((options->option[i].number == FSCK_READONLY_INDEX) &&
|
||||
((options->option[i].value.bool == TRUE) ||
|
||||
EVMS_IS_MOUNTED(volume))) {
|
||||
argv[opt_count++] = "-n";
|
||||
do_preen = 0;
|
||||
}
|
||||
|
||||
/* 'bad blocks check' option and NOT mounted */
|
||||
if ( (options->option[i].number == FSCK_CHECKBB_INDEX) &&
|
||||
(options->option[i].value.bool == TRUE) &&
|
||||
!EVMS_IS_MOUNTED(volume) ) {
|
||||
argv[opt_count++] = "-c";
|
||||
do_preen = 0;
|
||||
}
|
||||
|
||||
/* 'bad blocks check' option and NOT mounted */
|
||||
if ( (options->option[i].number == FSCK_CHECKRW_INDEX) &&
|
||||
(options->option[i].value.bool == TRUE) &&
|
||||
!EVMS_IS_MOUNTED(volume) ) {
|
||||
argv[opt_count++] = "-cc";
|
||||
do_preen = 0;
|
||||
}
|
||||
|
||||
/* timing option */
|
||||
if ( (options->option[i].number == FSCK_TIMING_INDEX) &&
|
||||
(options->option[i].value.bool == TRUE) ) {
|
||||
argv[opt_count++] = "-tt";
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/* 'force check' option selected and NOT mounted */
|
||||
if ( !strcmp(options->option[i].name, "force") &&
|
||||
(options->option[i].value.bool == TRUE) &&
|
||||
!EVMS_IS_MOUNTED(volume) ) {
|
||||
argv[opt_count++] = "-f";
|
||||
}
|
||||
|
||||
/* 'check read only' option selected or mounted */
|
||||
if ((!strcmp(options->option[i].name, "readonly")) &&
|
||||
((options->option[i].value.bool == TRUE) ||
|
||||
EVMS_IS_MOUNTED(volume))) {
|
||||
argv[opt_count++] = "-n";
|
||||
do_preen = 0;
|
||||
}
|
||||
|
||||
/* 'check badblocks' option selected and NOT mounted */
|
||||
if (!strcmp(options->option[i].name, "badblocks") &&
|
||||
(options->option[i].value.bool == TRUE) &&
|
||||
!EVMS_IS_MOUNTED(volume)) {
|
||||
argv[opt_count++] = "-c";
|
||||
do_preen = 0;
|
||||
}
|
||||
|
||||
/* 'check r/w badblocks' option selected and NOT mounted */
|
||||
if (!strcmp(options->option[i].name, "badblocks_rw") &&
|
||||
(options->option[i].value.bool == TRUE) &&
|
||||
!EVMS_IS_MOUNTED(volume)) {
|
||||
argv[opt_count++] = "-cc";
|
||||
do_preen = 0;
|
||||
}
|
||||
|
||||
/* 'timing' option selected */
|
||||
if (!strcmp(options->option[i].name, "badblocks") &&
|
||||
(options->option[i].value.bool == TRUE)) {
|
||||
argv[opt_count++] = "-tt";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (do_preen)
|
||||
argv[opt_count++] = "-p";
|
||||
argv[opt_count++] = EVMS_GET_DEVNAME(volume);
|
||||
argv[opt_count] = NULL;
|
||||
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = fopen("/var/tmp/evms-log", "a");
|
||||
for ( i=0; argv[i]; i++) {
|
||||
fprintf(f, "'%s' ", argv[i]);
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* NAME: fsim_get_ext2_superblock
|
||||
*
|
||||
* FUNCTION: Get and validate a ext2/3 superblock
|
||||
*
|
||||
* PARAMETERS:
|
||||
* volume - pointer to volume from which to get the superblock
|
||||
* sb_ptr - pointer to superblock
|
||||
*
|
||||
* RETURNS:
|
||||
* (0) for success
|
||||
* != 0 otherwise
|
||||
*
|
||||
*/
|
||||
int fsim_get_ext2_superblock( logical_volume_t *volume, struct ext2_super_block *sb_ptr )
|
||||
{
|
||||
int fd;
|
||||
int rc = 0;
|
||||
|
||||
fd = open(EVMS_GET_DEVNAME(volume), O_RDONLY, 0);
|
||||
if (fd < 0) return EIO;
|
||||
|
||||
/* get primary superblock */
|
||||
rc = fsim_rw_diskblocks( fd, EXT2_SUPER_LOC, SIZE_OF_SUPER, sb_ptr, GET );
|
||||
|
||||
if( rc == 0 ) {
|
||||
/* see if superblock is ext2/3 */
|
||||
if (( sb_ptr->s_magic != EXT2_SUPER_MAGIC ) ||
|
||||
( sb_ptr->s_rev_level > 1 ))
|
||||
rc = FSIM_ERROR;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* NAME: fsim_rw_diskblocks
|
||||
*
|
||||
* FUNCTION: Read or write specific number of bytes for an opened device.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* dev_ptr - file handle of an opened device to read/write
|
||||
* disk_offset - byte offset from beginning of device for start of disk
|
||||
* block read/write
|
||||
* disk_count - number of bytes to read/write
|
||||
* data_buffer - On read this will be filled in with data read from
|
||||
* disk; on write this contains data to be written
|
||||
* mode - GET (read) or PUT (write)
|
||||
*
|
||||
* RETURNS:
|
||||
* FSIM_SUCCESS (0) for success
|
||||
* ERROR (-1) can't lseek
|
||||
* EINVAL
|
||||
* EIO
|
||||
*
|
||||
*/
|
||||
int fsim_rw_diskblocks( int dev_ptr,
|
||||
int64_t disk_offset,
|
||||
int32_t disk_count,
|
||||
void *data_buffer,
|
||||
int mode )
|
||||
{
|
||||
off_t Actual_Location;
|
||||
size_t Bytes_Transferred;
|
||||
|
||||
Actual_Location = lseek(dev_ptr,disk_offset, SEEK_SET);
|
||||
if ( ( Actual_Location < 0 ) || ( Actual_Location != disk_offset ) )
|
||||
return ERROR;
|
||||
|
||||
switch ( mode ) {
|
||||
case GET:
|
||||
Bytes_Transferred = read(dev_ptr,data_buffer,disk_count);
|
||||
break;
|
||||
case PUT:
|
||||
Bytes_Transferred = write(dev_ptr,data_buffer,disk_count);
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( Bytes_Transferred != disk_count ) {
|
||||
return EIO;
|
||||
}
|
||||
|
||||
return FSIM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Test e2fsprogs version.
|
||||
*
|
||||
* We don't bother since we don't need any special functionality that
|
||||
* hasn't been around for *years*
|
||||
*/
|
||||
int fsim_test_version( )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,276 @@
|
|||
/* Version number of the ext2 plugin */
|
||||
#define MAJOR_VERSION 1
|
||||
#define MINOR_VERSION 0
|
||||
#define PATCH_LEVEL 0
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2000
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Module: fsimext2.h
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* EVMS 1.0 backwards compatibility functions
|
||||
*/
|
||||
#ifdef ABI_EVMS_1_0
|
||||
#define EVMS_IS_MOUNTED(vol) ((vol)->mount_point != 0)
|
||||
#define EVMS_GET_DEVNAME(vol) ((vol)->name)
|
||||
#else
|
||||
#define EVMS_IS_MOUNTED(vol) (EngFncs->is_mounted((vol)->dev_node, NULL))
|
||||
#define EVMS_GET_DEVNAME(vol) ((vol)->dev_node)
|
||||
#endif
|
||||
|
||||
/********************
|
||||
********************
|
||||
** **
|
||||
** EVMS defines **
|
||||
** **
|
||||
********************
|
||||
********************/
|
||||
|
||||
extern plugin_record_t ext2_plugrec;
|
||||
engine_functions_t *EngFncs;
|
||||
|
||||
// file system type ... used by the SetPluginID macro
|
||||
#define FS_TYPE_EXT2 7
|
||||
|
||||
// logging macros
|
||||
#define LOGENTRY() EngFncs->write_log_entry(ENTRY_EXIT, pMyPluginRecord, "%s: Enter.\n", __FUNCTION__)
|
||||
#define LOGEXIT() EngFncs->write_log_entry(ENTRY_EXIT, pMyPluginRecord, "%s: Exit.\n", __FUNCTION__ )
|
||||
#define LOGEXITRC() EngFncs->write_log_entry(ENTRY_EXIT, pMyPluginRecord, "%s: Exit. RC= %d.\n", __FUNCTION__, rc)
|
||||
#define MESSAGE(msg, args...) EngFncs->user_message(pMyPluginRecord, NULL, NULL, msg, ##args)
|
||||
#define LOG_CRITICAL(msg, args...) EngFncs->write_log_entry(CRITICAL, pMyPluginRecord, __FUNCTION__ ": " msg, ## args)
|
||||
#define LOG_SERIOUS(msg, args...) EngFncs->write_log_entry(SERIOUS, pMyPluginRecord, __FUNCTION__ ": " msg, ## args)
|
||||
#define LOG_ERROR(msg, args...) EngFncs->write_log_entry(ERROR, pMyPluginRecord, __FUNCTION__ ": " msg, ## args)
|
||||
#define LOG_WARNING(msg, args...) EngFncs->write_log_entry(WARNING, pMyPluginRecord, __FUNCTION__ ": " msg, ## args)
|
||||
#define LOG(msg, args...) EngFncs->write_log_entry(DEFAULT, pMyPluginRecord, __FUNCTION__ ": " msg, ## args)
|
||||
#define LOG_DETAILS(msg, args...) EngFncs->write_log_entry(DETAILS, pMyPluginRecord, __FUNCTION__ ": " msg, ## args)
|
||||
#define LOG_DEBUG(msg, args...) EngFncs->write_log_entry(DEBUG, pMyPluginRecord, __FUNCTION__ ": " msg, ## args)
|
||||
#define LOG_EXTRA(msg, args...) EngFncs->write_log_entry(EXTRA, pMyPluginRecord, __FUNCTION__ ": " msg, ## args)
|
||||
|
||||
// useful macro for option code
|
||||
#define SET_STRING_FIELD(a,b)\
|
||||
a = EngFncs->engine_alloc( strlen(b)+1 );\
|
||||
if (a ) {\
|
||||
strcpy(a, b);\
|
||||
}\
|
||||
else {\
|
||||
return -ENOMEM;\
|
||||
}
|
||||
|
||||
#define SET_STRING(a,b) a = EngFncs->engine_alloc( strlen(b)+1 );if (a ) { strcpy(a, b); } else { rc = ENOMEM; LOG_EXIT(rc);}
|
||||
#define LOG_EXIT(x) LOG_PROC("Exiting: rc = %d\n", x)
|
||||
#define LOG_PROC(msg, args...) EngFncs->write_log_entry(ENTRY_EXIT, pMyPluginRecord, "%s: " msg, __FUNCTION__ , ## args)
|
||||
|
||||
|
||||
/**********************************
|
||||
**********************************
|
||||
** **
|
||||
** fsck.jfs, mkfs.jfs defines **
|
||||
** **
|
||||
**********************************
|
||||
**********************************/
|
||||
|
||||
/* fsck.jfs, mkfs.jfs option counts */
|
||||
|
||||
/* fsck.jfs option array indices */
|
||||
#define FSCK_FORCE_INDEX 0
|
||||
#define FSCK_READONLY_INDEX 1
|
||||
#define FSCK_CHECKBB_INDEX 2
|
||||
#define FSCK_CHECKRW_INDEX 3
|
||||
#define FSCK_TIMING_INDEX 4
|
||||
#define FSCK_EXT2_OPTIONS_COUNT 5
|
||||
|
||||
/* mkfs.jfs option array indices */
|
||||
#define MKFS_CHECKBB_INDEX 0
|
||||
#define MKFS_CHECKRW_INDEX 1
|
||||
#define MKFS_SETVOL_INDEX 2
|
||||
#define MKFS_JOURNAL_INDEX 3
|
||||
#define MKFS_EXT2_OPTIONS_COUNT 4
|
||||
|
||||
/* fsck exit codes */
|
||||
#define FSCK_OK 0
|
||||
#define FSCK_CORRECTED 1
|
||||
#define FSCK_REBOOT 2
|
||||
#define FSCK_ERRORS_UNCORRECTED 4
|
||||
#define FSCK_OP_ERROR 8
|
||||
#define FSCK_USAGE_ERROR 16
|
||||
|
||||
|
||||
/*
|
||||
* EXT2/3 defines and structs
|
||||
*/
|
||||
|
||||
/* generic defines */
|
||||
#define FSIM_SUCCESS 0
|
||||
#define FSIM_ERROR -1
|
||||
#define GET 0
|
||||
#define PUT 1
|
||||
|
||||
#define EXT2_SUPER_LOC 1024
|
||||
|
||||
#define EXT2_SUPER_MAGIC 0xEF53
|
||||
|
||||
#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
|
||||
|
||||
#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
|
||||
#define EXT2_ERROR_FS 0x0002 /* Errors detected */
|
||||
|
||||
/*
|
||||
* Structure of the ext2 super block
|
||||
*/
|
||||
struct ext2_super_block {
|
||||
__u32 s_inodes_count; /* Inodes count */
|
||||
__u32 s_blocks_count; /* Blocks count */
|
||||
__u32 s_r_blocks_count; /* Reserved blocks count */
|
||||
__u32 s_free_blocks_count; /* Free blocks count */
|
||||
__u32 s_free_inodes_count; /* Free inodes count */
|
||||
__u32 s_first_data_block; /* First Data Block */
|
||||
__u32 s_log_block_size; /* Block size */
|
||||
__s32 s_log_frag_size; /* Fragment size */
|
||||
__u32 s_blocks_per_group; /* # Blocks per group */
|
||||
__u32 s_frags_per_group; /* # Fragments per group */
|
||||
__u32 s_inodes_per_group; /* # Inodes per group */
|
||||
__u32 s_mtime; /* Mount time */
|
||||
__u32 s_wtime; /* Write time */
|
||||
__u16 s_mnt_count; /* Mount count */
|
||||
__s16 s_max_mnt_count; /* Maximal mount count */
|
||||
__u16 s_magic; /* Magic signature */
|
||||
__u16 s_state; /* File system state */
|
||||
__u16 s_errors; /* Behaviour when detecting errors */
|
||||
__u16 s_minor_rev_level; /* minor revision level */
|
||||
__u32 s_lastcheck; /* time of last check */
|
||||
__u32 s_checkinterval; /* max. time between checks */
|
||||
__u32 s_creator_os; /* OS */
|
||||
__u32 s_rev_level; /* Revision level */
|
||||
__u16 s_def_resuid; /* Default uid for reserved blocks */
|
||||
__u16 s_def_resgid; /* Default gid for reserved blocks */
|
||||
/*
|
||||
* These fields are for EXT2_DYNAMIC_REV superblocks only.
|
||||
*
|
||||
* Note: the difference between the compatible feature set and
|
||||
* the incompatible feature set is that if there is a bit set
|
||||
* in the incompatible feature set that the kernel doesn't
|
||||
* know about, it should refuse to mount the filesystem.
|
||||
*
|
||||
* e2fsck's requirements are more strict; if it doesn't know
|
||||
* about a feature in either the compatible or incompatible
|
||||
* feature set, it must abort and not try to meddle with
|
||||
* things it doesn't understand...
|
||||
*/
|
||||
__u32 s_first_ino; /* First non-reserved inode */
|
||||
__u16 s_inode_size; /* size of inode structure */
|
||||
__u16 s_block_group_nr; /* block group # of this superblock */
|
||||
__u32 s_feature_compat; /* compatible feature set */
|
||||
__u32 s_feature_incompat; /* incompatible feature set */
|
||||
__u32 s_feature_ro_compat; /* readonly-compatible feature set */
|
||||
__u8 s_uuid[16]; /* 128-bit uuid for volume */
|
||||
char s_volume_name[16]; /* volume name */
|
||||
char s_last_mounted[64]; /* directory where last mounted */
|
||||
__u32 s_algorithm_usage_bitmap; /* For compression */
|
||||
/*
|
||||
* Performance hints. Directory preallocation should only
|
||||
* happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
|
||||
*/
|
||||
__u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
|
||||
__u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
|
||||
__u16 s_padding1;
|
||||
/*
|
||||
* Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
|
||||
*/
|
||||
__u8 s_journal_uuid[16]; /* uuid of journal superblock */
|
||||
__u32 s_journal_inum; /* inode number of journal file */
|
||||
__u32 s_journal_dev; /* device number of journal file */
|
||||
__u32 s_last_orphan; /* start of list of inodes to delete */
|
||||
|
||||
__u32 s_reserved[197]; /* Padding to the end of the block */
|
||||
};
|
||||
|
||||
#define L2MEGABYTE 20
|
||||
#define MEGABYTE (1 << L2MEGABYTE)
|
||||
#define MEGABYTE32 (MEGABYTE << 5)
|
||||
#define MAX_LOG_PERCENTAGE 10 /* Log can be at most 10% of disk */
|
||||
|
||||
/*
|
||||
* buffer cache configuration
|
||||
*/
|
||||
/* page size */
|
||||
#ifdef PSIZE
|
||||
#undef PSIZE
|
||||
#endif
|
||||
#define PSIZE 4096 /* page size (in byte) */
|
||||
|
||||
#define PBSIZE 512 /* physical block size (in byte) */
|
||||
|
||||
/*
|
||||
* Minimum number of bytes supported for an ext2 partition
|
||||
* (64k, quite small!)
|
||||
*/
|
||||
#define MINEXT2 (64*1024)
|
||||
|
||||
/*
|
||||
* SIZE_OF_SUPER defines the total amount of space reserved on disk for the
|
||||
* superblock. This is not the same as the superblock structure, since all of
|
||||
* this space is not currently being used.
|
||||
*/
|
||||
#define SIZE_OF_SUPER sizeof(struct ext2_super_block)
|
||||
|
||||
/*
|
||||
* SIZE_OF_MAP_PAGE defines the amount of disk space reserved for each page of
|
||||
* the inode allocation map (to hold iag)
|
||||
*/
|
||||
#define SIZE_OF_MAP_PAGE PSIZE
|
||||
|
||||
/*
|
||||
* directory configuration
|
||||
*/
|
||||
#define JFS_NAME_MAX 255
|
||||
#define JFS_PATH_MAX BPSIZE
|
||||
|
||||
/*
|
||||
* file system state (superblock state)
|
||||
*/
|
||||
#define FM_CLEAN 0x00000000 /* file system is unmounted and clean */
|
||||
#define FM_MOUNT 0x00000001 /* file system is mounted cleanly */
|
||||
#define FM_DIRTY 0x00000002 /* file system was not unmounted and clean
|
||||
* when mounted or
|
||||
* commit failure occurred while being mounted:
|
||||
* fsck() must be run to repair
|
||||
*/
|
||||
#define FM_LOGREDO 0x00000004 /* log based recovery (logredo()) failed:
|
||||
* fsck() must be run to repair
|
||||
*/
|
||||
#define FM_EXTENDFS 0x00000008 /* file system extendfs() in progress */
|
||||
|
||||
|
||||
/*******************
|
||||
*******************
|
||||
** **
|
||||
** Common code **
|
||||
** **
|
||||
*******************
|
||||
*******************/
|
||||
|
||||
int fsim_get_ext2_superblock( logical_volume_t *, struct ext2_super_block * );
|
||||
int fsim_unmkfs( logical_volume_t * );
|
||||
int fsim_mkfs( logical_volume_t *, option_array_t * );
|
||||
int fsim_fsck( logical_volume_t *, option_array_t * );
|
||||
int fsim_get_volume_limits( struct ext2_super_block *, sector_count_t *,
|
||||
sector_count_t *, sector_count_t * );
|
||||
int fsim_test_version( void );
|
|
@ -0,0 +1,315 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2001
|
||||
* Copyright (C) 1997-1999 David Mosberger-Tang and Andreas Beck
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Module: options.h
|
||||
*/
|
||||
|
||||
#ifndef EVMS_OPTIONS_H_INCLUDED
|
||||
#define EVMS_OPTIONS_H_INCLUDED 1
|
||||
|
||||
#include <common.h>
|
||||
|
||||
/*
|
||||
* Dear Reader,
|
||||
*
|
||||
* Yes, some of the structures look a lot like the ones the SANE
|
||||
* (Scanner Access Now Easy) folks use for negotiating options
|
||||
* between a frontend and backend. In fact, some of the structures
|
||||
* here were derived from their solution with some tweaks for EVMS.
|
||||
*
|
||||
* Kindest regards and most humble apologies to the SANE folks for
|
||||
* borrowing their solution.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Task API typedefs
|
||||
*/
|
||||
|
||||
typedef u_int32_t task_handle_t;
|
||||
|
||||
/*
|
||||
* Task actions correspond to the low-level API available to frontends.
|
||||
* The task API allows binding of action, plugin, target objects, and
|
||||
* plugin-specific options. This allows for interaction with the backend
|
||||
* to validate the correctness of parameters and options necessary to
|
||||
* fulfill the requirements of the low-level API which eventually is invoked.
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
EVMS_Task_Create = 0,
|
||||
EVMS_Task_Create_Container,
|
||||
EVMS_Task_Assign_Plugin,
|
||||
EVMS_Task_Expand_Container,
|
||||
EVMS_Task_Set_Info,
|
||||
EVMS_Task_Expand,
|
||||
EVMS_Task_Shrink,
|
||||
EVMS_Task_Slide,
|
||||
EVMS_Task_Move,
|
||||
EVMS_Task_mkfs,
|
||||
EVMS_Task_fsck,
|
||||
EVMS_Task_defrag,
|
||||
EVMS_Task_Message,
|
||||
EVMS_Task_Add_Feature,
|
||||
EVMS_Task_Plugin_Function = 0x1000 /* Base number for plug-in funtions */
|
||||
} task_action_t;
|
||||
|
||||
|
||||
typedef struct function_info_s {
|
||||
task_action_t function; /* Plugin function number */
|
||||
char * title; /* Short title for the function */
|
||||
/* e.g. "Add a spare" */
|
||||
/* Example usage: A UI might put this in */
|
||||
/* a menu of functions to select. */
|
||||
char * verb; /* One or two action words for the function */
|
||||
/* e.g. "Add" */
|
||||
/* Example usage: A GUI may use this on an */
|
||||
/* action button for the function. */
|
||||
char * help; /* Full help text */
|
||||
/* e.g. "Use this function to add a spare blah blah blah..." */
|
||||
} function_info_t;
|
||||
|
||||
typedef struct function_info_array_s {
|
||||
uint count;
|
||||
function_info_t info[1];
|
||||
} function_info_array_t;
|
||||
|
||||
|
||||
/*
|
||||
* Object API typedefs
|
||||
*/
|
||||
|
||||
typedef struct declined_handle_s {
|
||||
object_handle_t handle; /* Handle of object declined */
|
||||
int reason; /* Reason for being declined */
|
||||
} declined_handle_t;
|
||||
|
||||
typedef struct declined_handle_array_s {
|
||||
uint count;
|
||||
declined_handle_t declined[1];
|
||||
} declined_handle_array_t;
|
||||
|
||||
/*
|
||||
* Option API typedefs and constants
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
EVMS_Type_String = 1, /* char* */
|
||||
EVMS_Type_Boolean, /* BOOLEAN */
|
||||
EVMS_Type_Char, /* char */
|
||||
EVMS_Type_Unsigned_Char, /* unsigned char */
|
||||
EVMS_Type_Real32, /* float */
|
||||
EVMS_Type_Real64, /* double */
|
||||
EVMS_Type_Int, /* int */
|
||||
EVMS_Type_Int8, /* int8_t */
|
||||
EVMS_Type_Int16, /* int16_t */
|
||||
EVMS_Type_Int32, /* int32_t */
|
||||
EVMS_Type_Int64, /* int64_t */
|
||||
EVMS_Type_Unsigned_Int, /* uint */
|
||||
EVMS_Type_Unsigned_Int8, /* u_int8_t */
|
||||
EVMS_Type_Unsigned_Int16, /* u_int16_t */
|
||||
EVMS_Type_Unsigned_Int32, /* u_int32_t */
|
||||
EVMS_Type_Unsigned_Int64 /* u_int64_t */
|
||||
} value_type_t;
|
||||
|
||||
typedef enum {
|
||||
EVMS_Unit_None = 0,
|
||||
EVMS_Unit_Disks,
|
||||
EVMS_Unit_Sectors,
|
||||
EVMS_Unit_Segments,
|
||||
EVMS_Unit_Regions,
|
||||
EVMS_Unit_Percent,
|
||||
EVMS_Unit_Milliseconds,
|
||||
EVMS_Unit_Microseconds,
|
||||
EVMS_Unit_Bytes,
|
||||
EVMS_Unit_Kilobytes,
|
||||
EVMS_Unit_Megabytes,
|
||||
EVMS_Unit_Gigabytes,
|
||||
EVMS_Unit_Terabytes,
|
||||
EVMS_Unit_Petabytes
|
||||
} value_unit_t;
|
||||
|
||||
typedef enum {
|
||||
EVMS_Collection_None = 0, /* No collection */
|
||||
EVMS_Collection_List, /* Use a value_list_t structure */
|
||||
EVMS_Collection_Range /* Use a value_range_t structure */
|
||||
} collection_type_t;
|
||||
|
||||
typedef enum {
|
||||
EVMS_Format_Normal = 0,
|
||||
EVMS_Format_Hex,
|
||||
EVMS_Format_Ascii,
|
||||
EVMS_Format_Binary
|
||||
} value_format_t;
|
||||
|
||||
typedef union {
|
||||
char c; /* one character, e.g. 'C' */
|
||||
char *s; /* string pointer */
|
||||
u_char uc;
|
||||
int bool;
|
||||
int i;
|
||||
int8_t i8;
|
||||
int16_t i16;
|
||||
int32_t i32;
|
||||
int64_t i64;
|
||||
u_int ui;
|
||||
u_int8_t ui8;
|
||||
u_int16_t ui16;
|
||||
u_int32_t ui32;
|
||||
u_int64_t ui64;
|
||||
float r32;
|
||||
double r64;
|
||||
struct value_list_s *list;
|
||||
} value_t;
|
||||
|
||||
/*
|
||||
* The struct key_value_pair_s allows some generic passing
|
||||
* of a key/value pair for some basic data type values. The
|
||||
* key can be a name (a string) or a number. The sending
|
||||
* and receiving ends denote, through the is_number_based flag,
|
||||
* which key should be looked at for identification purposes.
|
||||
*/
|
||||
|
||||
typedef struct key_value_pair_s {
|
||||
char *name; /* Key if name-based */
|
||||
u_int16_t number; /* Key if number-based */
|
||||
BOOLEAN is_number_based; /* TRUE if number-based */
|
||||
value_type_t type; /* Value type */
|
||||
value_t value; /* Union of basic data types */
|
||||
} key_value_pair_t;
|
||||
|
||||
/*
|
||||
* Some frontends may supply plugin-specific data as "options" through
|
||||
* the API functions, e.g. evms_create(), available to a frontend.
|
||||
* Options are essentially key/value pairs where the key and value types
|
||||
* are known ahead-of-time or were interrogated through the option
|
||||
* descriptor API.
|
||||
*/
|
||||
|
||||
typedef struct option_array_s {
|
||||
u_int count;
|
||||
key_value_pair_t option[1];
|
||||
} option_array_t;
|
||||
|
||||
typedef struct value_list_s {
|
||||
u_int count;
|
||||
value_t value[1];
|
||||
} value_list_t;
|
||||
|
||||
typedef struct value_range_s {
|
||||
value_t min; /* Minimum value */
|
||||
value_t max; /* Maximum value */
|
||||
value_t increment; /* Step or increment for changes in-between */
|
||||
} value_range_t;
|
||||
|
||||
typedef union {
|
||||
value_list_t *list; /* Array of values of the same type */
|
||||
value_range_t *range; /* Range of values for numeric types */
|
||||
} value_collection_t;
|
||||
|
||||
typedef struct group_info_s {
|
||||
u_int32_t group_number; /* group number, 0 if not grouped */
|
||||
u_int32_t group_level; /* possibly used for indenting, or sub fields */
|
||||
char *group_name; /* name of group */
|
||||
} group_info_t;
|
||||
|
||||
typedef struct option_descriptor_s {
|
||||
char *name; /* Option name/key */
|
||||
char *title; /* One or two word description of option */
|
||||
char *tip; /* Multi-sentence description of option for tip */
|
||||
char *help; /* Multi-paragraph detailed option help */
|
||||
value_type_t type; /* Defines option data type */
|
||||
value_unit_t unit; /* Defines unit value */
|
||||
#ifdef ABI_EVMS_1_0
|
||||
u_int32_t size; /* Maximum size (in bytes) of option value */
|
||||
#else
|
||||
value_format_t format; /* Suggested format for display of values */
|
||||
u_int32_t min_len; /* Minimum length for string types */
|
||||
u_int32_t max_len; /* Maximum length for string types */
|
||||
#endif
|
||||
u_int64_t flags; /* Option flags (defined below) */
|
||||
collection_type_t constraint_type; /* Constraint type (none, range, list) */
|
||||
value_collection_t constraint; /* Either a list or range of valid input values */
|
||||
value_t value; /* Initial/current value */
|
||||
group_info_t group; /* Group information for display purposes */
|
||||
} option_descriptor_t;
|
||||
|
||||
/*
|
||||
* option_descriptor_t flags bitset
|
||||
*/
|
||||
|
||||
#define EVMS_OPTION_FLAGS_NOT_REQUIRED (1 << 0) /* A key_value_pair_t for this option can be provided */
|
||||
/* but is not absolutely required by the plug-in */
|
||||
#define EVMS_OPTION_FLAGS_NO_INITIAL_VALUE (1 << 1) /* The plug-in has not provided an initial value */
|
||||
#define EVMS_OPTION_FLAGS_AUTOMATIC (1 << 2) /* Backend is capable of selecting reasonable value */
|
||||
#define EVMS_OPTION_FLAGS_INACTIVE (1 << 3) /* Option exists but is neither optional or required */
|
||||
#define EVMS_OPTION_FLAGS_ADVANCED (1 << 4) /* Option is an "advanced user option" */
|
||||
#define EVMS_OPTION_FLAGS_VALUE_IS_LIST (1 << 5) /* Value is/is expected to be a pointer to value_list_t */
|
||||
#define EVMS_OPTION_FLAGS_NO_UNIT_CONVERSION (1 << 6) /* Don't convert unit measurements, e.g. I really mean */
|
||||
/* to have the user specify/see sectors not KB or MB */
|
||||
|
||||
#define EVMS_OPTION_IS_ACTIVE(flags) (((flags) & EVMS_OPTION_FLAGS_INACTIVE) == 0)
|
||||
#define EVMS_OPTION_IS_REQUIRED(flags) (((flags) & EVMS_OPTION_FLAGS_NOT_REQUIRED) == 0)
|
||||
#define EVMS_OPTION_HAS_VALUE(flags) (((flags) & EVMS_OPTION_FLAGS_NO_INITIAL_VALUE) == 0)
|
||||
#define EVMS_OPTION_VALUE_IS_LIST(flags) (((flags) & EVMS_OPTION_FLAGS_VALUE_IS_LIST) != 0)
|
||||
|
||||
/*
|
||||
* Following bitset indicating additional information of
|
||||
* the outcome of a set_object or a set action on a option value.
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
EVMS_Effect_Inexact = (1 << 0), /* Option value was adjusted by backend */
|
||||
EVMS_Effect_Reload_Options = (1 << 1), /* Setting of an object or option has affected */
|
||||
/* the value or availability of other options */
|
||||
EVMS_Effect_Reload_Objects = (1 << 2) /* Setting of an object or option has affected */
|
||||
/* the acceptable and/or selected objects */
|
||||
/* or the limits of objects selected. */
|
||||
} task_effect_t;
|
||||
|
||||
/*
|
||||
* Extended information structure. Plug-ins generate an
|
||||
* array of these to supply plugin-specific information.
|
||||
* They are similar to option descriptors but lighter.
|
||||
*/
|
||||
|
||||
typedef struct extended_info_s {
|
||||
char *name; /* Info field name */
|
||||
char *title; /* One or two word description of info field */
|
||||
char *desc; /* Multi-sentence description of info field */
|
||||
value_type_t type; /* Defines info data type */
|
||||
value_unit_t unit; /* Defines info unit value */
|
||||
value_format_t format; /* Suggested format for display of values */
|
||||
value_t value; /* Single value if not a collection */
|
||||
collection_type_t collection_type; /* Defines if either a list or range of values */
|
||||
value_collection_t collection; /* Either a list or range of values of value_type_t */
|
||||
group_info_t group; /* Group information for display purposes */
|
||||
u_int16_t flags; /* Extended info flags (defined below) */
|
||||
} extended_info_t;
|
||||
|
||||
#define EVMS_EINFO_FLAGS_NO_UNIT_CONVERSION (1 << 0) /* Don't convert unit measurements, e.g. I really */
|
||||
/* mean the user to see sectors not KB or MB */
|
||||
#define EVMS_EINFO_FLAGS_MORE_INFO_AVAILABLE (1 << 1)/* This entry has more information if */
|
||||
/* queried by name. */
|
||||
|
||||
typedef struct extended_info_array_s {
|
||||
u_int count; /* Count of extended_info_t structs in array */
|
||||
extended_info_t info[1]; /* Info descriptors */
|
||||
} extended_info_array_t;
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2001
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Module: plugin.h
|
||||
*/
|
||||
|
||||
#ifndef EVMS_PLUGIN_H_INCLUDED
|
||||
#define EVMS_PLUGIN_H_INCLUDED 1
|
||||
|
||||
#include <dlist.h>
|
||||
#include <common.h>
|
||||
#include <options.h>
|
||||
|
||||
#include <enginestructs.h>
|
||||
#include <plugfuncs.h>
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue