Remove support for EVMS 1.x plugin library.

bitmap-optimize
Theodore Ts'o 2004-11-19 17:25:27 -05:00
parent 2b5901d9c7
commit 921f4ad536
16 changed files with 224 additions and 7819 deletions

View File

@ -9,11 +9,9 @@ INSTALL = @INSTALL@
@RESIZER_CMT@RESIZE_DIR= resize
@DEBUGFS_CMT@DEBUGFS_DIR= debugfs
@EVMS_CMT@EVMS_DIR= lib/evms
LIB_SUBDIRS=lib/et lib/ss lib/e2p lib/ext2fs lib/uuid lib/blkid intl
PROG_SUBDIRS=e2fsck $(DEBUGFS_DIR) misc $(RESIZE_DIR) tests/progs po \
$(EVMS_DIR)
PROG_SUBDIRS=e2fsck $(DEBUGFS_DIR) misc $(RESIZE_DIR) tests/progs po
SUBDIRS=util $(LIB_SUBDIRS) $(PROG_SUBDIRS) tests
SUBS= lib/ext2fs/ext2_types.h lib/blkid/blkid_types.h lib/uuid/uuid_types.h

493
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -47,17 +47,11 @@ AC_SUBST(E2FSPROGS_DAY)
AC_SUBST(E2FSPROGS_VERSION)
AC_CANONICAL_HOST
dnl
dnl Should we compile EVMS plugin or not. Complicated logic, spread
dnl over several different command-line options...
dnl
EVMS_CMT=
dnl
dnl Use diet libc
dnl
AC_ARG_WITH([diet-libc],
[ --with-diet-libc Use diet libc],
CC="diet cc -nostdinc"
EVMS_CMT="#"
AC_MSG_RESULT(CC=$CC))dnl
dnl
dnl set $(CC) from --with-cc=value
@ -196,45 +190,6 @@ echo "Disabling htree clearing by default"
)
AC_SUBST(HTREE_CLR_CMT)
dnl
dnl handle --enable-evms
dnl
AC_ARG_ENABLE([evms],
[ --disable-evms don't build EVMS plugin],
if test "$enableval" == "no"
then
EVMS_CMT="#"
echo "Disabling EVMS plugin"
fi
)
dnl
dnl handle --enable-emvs-10
dnl
EVMS_ABI_CODE=120
AC_ARG_ENABLE([evms-10],
[ --enable-evms-10 use EVMS 1.0 ABI (instead of EVMS 1.2)],
if test "$enableval" != "no"
then
EVMS_ABI_CODE=100
echo "Enabling EVMS 1.0.0 ABI"
fi
)
dnl
dnl handle --enable-emvs-11
dnl
AC_ARG_ENABLE([evms-11],
[ --enable-evms-11 use EVMS 1.1 ABI (instead of EVMS 1.2)],
if test "$enableval" != "no"
then
EVMS_ABI_CODE=110
echo "Enabling EVMS 1.1.0 ABI"
fi
)
if test "$EVMS_ABI_CODE" = "120"
then
echo "Using EVMS 1.2.0 ABI by default"
fi
AC_SUBST(EVMS_ABI_CODE)
dnl
dnl handle --enable-elf-shlibs
dnl
AC_ARG_ENABLE([elf-shlibs],
@ -760,15 +715,11 @@ linux*)
cygwin)
CYGWIN_CMT=
UNIX_CMT="#"
EVMS_CMT="#"
;;
*)
EVMS_CMT="#"
esac
AC_SUBST(LINUX_CMT)
AC_SUBST(CYGWIN_CMT)
AC_SUBST(UNIX_CMT)
AC_SUBST([EVMS_CMT])
dnl
dnl Linux and Hurd places root files in the / by default
dnl
@ -891,7 +842,7 @@ for i in MCONFIG Makefile e2fsprogs.spec \
lib/et/Makefile lib/ss/Makefile lib/ext2fs/Makefile lib/e2p/Makefile \
lib/uuid/Makefile lib/uuid/uuid_types.h \
lib/blkid/Makefile lib/blkid/blkid_types.h \
lib/evms/Makefile misc/Makefile ext2ed/Makefile e2fsck/Makefile \
misc/Makefile ext2ed/Makefile e2fsck/Makefile \
debugfs/Makefile tests/Makefile tests/progs/Makefile \
resize/Makefile doc/Makefile intl/Makefile po/Makefile.in ; do
if test -d `dirname ${srcdir}/$i` ; then

2
debian/rules vendored
View File

@ -84,7 +84,7 @@ endif
BF_CCOPTS = -Os -fomit-frame-pointer
COMMON_CONF_FLAGS = \
--enable-elf-shlibs --enable-dynamic-e2fsck --disable-evms \
--enable-elf-shlibs --enable-dynamic-e2fsck \
--infodir=/usr/share/info --enable-fsck
STD_CONF_FLAGS = --with-ccopts="${CCOPTS}" --enable-compression

View File

@ -49,7 +49,7 @@ also want to install e2fsprogs.
%setup
%build
%configure --enable-elf-shlibs --enable-nls --disable-evms
%configure --enable-elf-shlibs --enable-nls
make
%install

View File

@ -1,169 +0,0 @@
2004-02-28 Theodore Ts'o <tytso@mit.edu>
* Release of E2fsprogs 1.35
2003-08-01 Philipp Thomas <pthomas@suse.de>
* fs_ext2.c (fs_cleanup, fs_init_task, fs_set_volumes): Use an
ugly union to fix pointer aliasing problems.
2003-07-25 Theodore Ts'o <tytso@mit.edu>
* Release of E2fsprogs 1.34
2003-04-21 Theodore Ts'o <tytso@mit.edu>
* Release of E2fsprogs 1.33
2003-04-03 Theodore Ts'o <tytso@mit.edu>
* fs_ext2.c (fs_setup): During FSIM setup, when the FSIM cannot be
loaded due to incompatible tool versions, just print a
message to the log instead of displaying a message to the
user. (EVMS 2.0, rev 1.3, change to commented out code only)
(ext2_plugrec): fix long plug-in name to indicate support
for ext3 (EVMS 2.0, rev 1.4)
(fs_expand, fs_shrink): Don't save the return value from
waitpid(). Especially don't save it back to the same
variable that will be used to call waitpid() again.
(EVMS 2.0, rev 1.12)
(fs_mkfs, fs_init_task, fs_set_option): Make sure most
functions have entry/exit log macros. (EVMS 2.0 rev 1.14)
(fs_expand, fs_shrink): Check for errors from
fsim_get_ext2_superblock(). (EVMS 2.0 rev 1.15)
* fsimext2.c (set_mkfs_options): Fix compile warnings.
gcc 3.2.1 doesn't like empty "default:" cases at the end
of "switch" statements (EVMS 2.0 rev 1.2)
(fsim_get_volume_limits): Remove unused varable (EVMS 2.0
rev 1.4)
(ext2fs_swap_super): Remove unnecessary "return" (EVMS 2.0
rev 1.7)
Make sure most functions have entry/exit log macros (EVMS
2.0 rev 1.8, 1.9)
(fsim_fsck, fsim_mkfs): Don't save the return value from
waitpid(). Especially don't save it back to the same
variable that will be used to call waitpid() again. (EVMS
2.0 rev 1.5/partial).
(fsim_fsck): In fsim_fsck(), set the read pipe to
non-blocking before going into the loop waiting for data.
If there are no more data left, the function hangs waiting
for the read() to complete. (EVMS 2.0 rev 1.5/partial)
(fsim_fsck): Fix file descriptor leak.
* fsimext2.h (LOGEXITRC): Synchronize text for exit macro with
EVMS 2.0 (rev 1.2).
2002-11-09 Theodore Ts'o <tytso@mit.edu>
* Release of E2fsprogs 1.32
2002-11-08 Theodore Ts'o <tytso@mit.edu>
* Release of E2fsprogs 1.31
2002-11-08 Theodore Ts'o <tytso@mit.edu>
* fs_ext2.c (fs_expand, fs_shrink),
fsimext2.c (fsim_mkfs, fsim_fsck): Inform the user if e2fsck,
mke2fs or resize2fs dies with a signal, or if the exit
with a non-zero exit status.
* fsimext2.c (set_mkfs_options): If the hard sector size is 1024,
don't force a blocksize of 1024; there's no need to do so.
* fs_ext2.c (fs_setup): Synchronize with EVMS CVS rev 1.14
(2002/10/17): Changed function to correspond with EVMS ABI
1.2
* Makefile.in, common.h, enginestructs.h, fs_ext2.c, fsimext2.h,
options.h, plugfuncs.h: Change #define from ABI_EVMS_1_0
to EVMS_ABI_CODE which may be 100, 110, or 120,
corresponding to EVMS releases 1.0.0, 1.1.0, and 1.2.0.
Update header files to support EVMS ABI 1.2.
* fsimext2.c (set_mkfs_options): Synchronize with EVMS CVS rev
1.7 (2002/09/11): Add a hack to force mkfs won't a
blocksize equal to the hardsector size if it is larger
than 512 bytes.
* fs_ext2.c (fs_expand, fs_shrink): Synchronize with EVMS CVS rev
1.13 (2002/09/03). Add better error handling for child
processes that die unexpectedly.
* fsimext2.c (fsim_mkfs, fsim_fsck): Synchronize with EVMS CVS rev
1.6 (2002/09/03). Add better error handling for child
processes that die unexpectedly.
* fs_ext2.c (fs_expand): Synchronize with EVMS CVS rev 1.12
(2002/08/28): Use the EVMS_IS_MOUNTED macro.
* fs_ext2.c (fs_expand, fs_shrink): Synchronize with EVMS CVS rev
1.11 (2002/8/27). Read from the resize2fs output in
non-blocking mode, so the GUI continues to updates the window.
* fsimext2.h: Synchronize with EVMS CVS rev 1.8 (2002/8/29).
Change all __uXX's to u_intXX_t's.
2002-10-31 Theodore Ts'o <tytso@mit.edu>
* Release of E2fsprogs 1.30
2001-09-24 Theodore Tso <tytso@mit.edu>
* Release of E2fsprogs 1.29
2001-08-31 Theodore Tso <tytso@thunk.org>
* Release of E2fsprogs 1.28
2002-08-18 Theodore Ts'o <tytso@mit.edu>
* Makefile.in: Revamp makefile so that it doesn't depend
--enable-elf-shlibs. We always build the shared library,
since it's meant to be used as a plugin library.
* fs_ext2.c (fs_fsck, fs_shrink, fs_expand): Change to use new
calling convention of fsim_fsck. Fixed bug in fs_shrink
and f_expand where the shrink or expand would get aborted
if fsck returned an exit status code of 1 (which is normal).
* fsimext2.c (fsim_fsck): Add new parameter ret_status, and return
the exit status there. The return code now returns 0 for
success, and an error code in case of failure, which
removes a lot of the ambiguity.
2002-08-17 Theodore Ts'o <tytso@mit.edu>
* fs_ext2.c, fsimext2.c: Synchronize with EVMS CVS tree.
Fixed up confusion caused by bad parameter names for
get_fs_limits(). Added missing conversion of
volume->vol_size from sectors to bytes. Fix up error
returns for unsupported tasks as EINVAL, not ENOSYS.
Use logical names for the API version numbers, since
the ABI is much more dependent on the headers. Add
code to byte-swap the superblock if necessary.
Fix up logging macros to use __FUNCTION__ correctly.
* common.h, dlist.h, enginestructs.h, options.h, plugfuncs.c,
fs_ext2.c: Synchronize with ABI of EVMS 1.1.
2002-06-01 <tytso@thunk.org>
* fs_ext2.c (fs_init_task): Fix minor bugs pointed out by Steve
Pratt. Fixed a selection bug and added checks to make
sure volumes are not mounted when creating the list of
volumes which can be mkfs'ed by the ext2/3 plugin.
2002-05-28 <tytso@thunk.org>
* fsimext2.c: Log the fsck and mke2fs command lines. Return
appropriate volume limits so that resizing will work
correctly. Fix bug in how the e2fsck output was presented
to the user.
* fs_ext2.c: Add support for expanding and shrinking ext2/3
filesystems.

View File

@ -1,75 +0,0 @@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
top_builddir = ../..
my_dir = lib/evms
INSTALL = @INSTALL@
MAJOR_VERSION = 1
MINOR_VERSION = 2
PATCH_LEVEL = 1
EXTRAVERSION =
XTRA_CFLAGS= -I@srcdir@ -DMAJOR_VERSION=$(MAJOR_VERSION) -DMINOR_VERSION=$(MINOR_VERSION) -DPATCH_LEVEL=$(PATCH_LEVEL) -DEVMS_ABI_CODE=@EVMS_ABI_CODE@
@MCONFIG@
OBJS= fs_ext2.o fsimext2.o
SRCS= $(srcdir)/fs_ext2.c $(srcdir)/fsimext2.c
LIBRARY= libext2fsim
LIBDIR= evms
ELF_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_LEVEL)
ELF_SO_VERSION = $(MAJOR_VERSION)
ELF_IMAGE = libe2fsim
ELF_MYDIR = evms
ELF_INSTALL_DIR = $(root_libdir)/evms
#ELF_OTHER_LIBS = -L../.. -lcom_err
ELF_LIB = $(ELF_IMAGE).$(ELF_VERSION).so
ELF_SONAME = $(ELF_IMAGE).$(ELF_SO_VERSION).so
all:: $(ELF_LIB)
$(ELF_LIB): $(OBJS)
$(CC) --shared -o $(ELF_LIB) -Wl,-soname,$(ELF_SONAME) \
$(OBJS) $(ELF_OTHER_LIBS)
installdirs::
$(top_srcdir)/mkinstalldirs $(DESTDIR)$(ELF_INSTALL_DIR)
install:: $(ELF_LIB) installdirs
$(INSTALL_PROGRAM) $(ELF_LIB) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
$(STRIP) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
uninstall-shlibs uninstall::
$(RM) -f $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
clean::
$(RM) -f $(ELF_LIB)
$(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME)
.c.o:
$(CC) $(ALL_CFLAGS) -fPIC -c $< -o $@
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)/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)/options.h $(srcdir)/enginestructs.h \
$(srcdir)/plugfuncs.h $(srcdir)/fsimext2.h

View File

@ -1,510 +0,0 @@
/*
*
* 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 <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
/* version info */
#define EVMS_MAJOR_VERSION 1
#define EVMS_MINOR_VERSION 2
#define EVMS_PATCHLEVEL_VERSION 0
#define EVMS_MAJOR 117
#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 {
/* 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 {
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 are used for moving objects. */
#define EVMS_MOVE_PARENT (1<<11)
/* 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
/* version info for evms_feature_header_t that has fields for move*/
#define EVMS_MOVE_FEATURE_HEADER_MAJOR 3
#define EVMS_MOVE_FEATURE_HEADER_MINOR 1
#define EVMS_MOVE_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 {
/* 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*/ u_int32_t move_source;
/* version 3.1.0 feature header */
/*364*/ u_int32_t move_target;
/* version 3.1.0 feature header */
/*368*/ unsigned char pad[144];
/*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
/* 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)
#define SOFLAG_HAS_STOP_DATA (1<<10)
/* 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)
#define VOLFLAG_PROBE_FS (1<<13)
#define VOLFLAG_IS_EXTERNAL_LOG (1<<14)
#define VOLFLAG_HAS_EXTERNAL_LOG (1<<15)
/* A BOOLEAN variable is one which is either TRUE or FALSE. */
#ifndef BOOLEAN_DEFINED
#define BOOLEAN_DEFINED 1
typedef unsigned char 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;
/*
* Definitions and structures for progress indicators.
*/
typedef enum {
DISPLAY_PERCENT = 0, /* Display the progress as a percentage. */
/* This is the default display mode. */
DISPLAY_COUNT, /* Display the progress as a count. */
INDETERMINATE /* Progress cannot be measured with a count */
/* of items. Progress is simply "working". */
} progress_type_t;
typedef struct progress_s {
/*
* The plug-in MUST set id to zero on the first call. An id of zero
* tells the UI to start a new progress indicator. The UI MUST set the
* id field to a nonzero number that is unique from any other progress
* indicators that may be in effect.
*/
uint id;
/* Short title for the progress indicator */
char * title;
/* Longer description of the task that is in progress */
char * description;
/* Type of progress indicator */
progress_type_t type;
/*
* Current number of items completed. The plug-in should set count to
* zero on the first call.
*/
uint count;
/*
* Total number of items to be completed. The UI uses count/total_count
* to calculate the percent complete. On the plug-in's last call to
* update the progress it MUST set count >= total_count. When the UI
* gets a call for progress and count >= total_count, it knows it is the
* last call and closes the progress indicator.
*/
uint total_count;
/*
* The plug-in may provide an estimate of how many seconds it will take
* to complete the operation, but it is not required. If the plug-in is
* not providing a time estimate it MUST set remaining_seconds to zero.
*
* The plug-in may update remaining_seconds on subsequent calls for
* progress. If the plug-in does not provide a time estimate, the UI
* may provide one based on the time elapsed between the calls to update
* the progress and the numbers in the count and total_count fields.
*/
uint remaining_seconds;
/*
* A place for the plug-in to store any data relating to this progress
* indicator.
*/
void * plugin_private_data;
/*
* A place for the UI to store any data relating to this progress
* indicator.
*/
void * ui_private_data;
} progress_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

View File

@ -1,320 +0,0 @@
/*
*
* 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>
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 */
#if (EVMS_ABI_CODE == 100)
evms_version_t required_api_version; /* Version of the Engine plug-in API */
/* that the plug-in requires */
#else
evms_version_t required_engine_api_version;
/* Version of the Engine services API */
/* that the plug-in requires */
union {
evms_version_t plugin; /* Version of the Engine plug-in API */
/* that the plug-in requires */
evms_version_t fsim; /* Version of the Engine FSIM API */
/* that the FSIM plug-in requires */
} required_plugin_api_version;
evms_version_t required_container_api_version;
/* Version of the Engine container API */
/* that the plug-in requires */
#endif
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 */
lsn_t start; /* Relative starting sector 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 */
#if (EVMS_ABI_CODE >= 110)
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. */
#if (EVMS_ABI_CODE >= 110)
void * original_fsim_private_data;
/* Private data of original FSIM. */
#endif
char name[EVMS_VOLUME_NAME_SIZE+1];
/* Volume name, filled in by the Engine */
#if (EVMS_ABI_CODE >= 110)
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

File diff suppressed because it is too large Load Diff

View File

@ -1,718 +0,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.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 * fs_min_size,
sector_count_t * fs_max_size,
sector_count_t * vol_max_size)
{
int rc = 0;
int blk_to_sect;
blk_to_sect = (1 + sb->s_log_block_size);
*fs_min_size = (sb->s_blocks_count - sb->s_free_blocks_count) << blk_to_sect;
*fs_max_size = (sector_count_t) 1 << (32+blk_to_sect);
*vol_max_size = 0xffffffffff;
LOGEXITRC();
return rc;
}
/*
* Un-Format the volume.
*/
int fsim_unmkfs( logical_volume_t * volume )
{
int fd;
int rc = 0;
LOGENTRY();
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);
LOGEXITRC();
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;
LOGENTRY();
/* Fork and execute the correct program. */
switch (pidm = fork()) {
/* error */
case -1:
rc = 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 */
while (1) {
rc = waitpid( pidm, &status, 0 );
if (rc == -1) {
if (errno == EINTR)
continue;
rc = errno;
goto reterr;
} else
break;
}
if ( WIFEXITED(status) ) {
/* get mke2fs exit code */
rc = WEXITSTATUS(status);
if (rc)
LOG("mke2fs exited with status %d", rc);
} else {
if (WIFSIGNALED(status))
LOG("mke2fs died with signal %d",
WTERMSIG(status));
rc = EINTR;
}
}
reterr:
LOGEXITRC();
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, bufsize, opt_count = 2;
char *buf;
LOGENTRY();
argv[0] = "mke2fs";
/* 'quiet' option */
argv[1] = "-q";
/* the following is a big hack to make sure that we don't use a block */
/* size smaller than hardsector size since this does not work. */
/* would be nice if the ext2/3 utilities (mkfs) handled this themselves */
/* also, eventually we will implement this as a user option to manually */
/* set block size */
if (volume->object->geometry.bytes_per_sector != EVMS_VSECTOR_SIZE) {
switch (volume->object->geometry.bytes_per_sector) {
case 2048:
argv[2] = "-b2048";
opt_count++;
break;
case 4096:
argv[2] = "-b4096";
opt_count++;
break;
default:
/* not one we expect, just skip it */
break;
}
}
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;
bufsize = 0;
for (i=0; argv[i]; i++)
bufsize += strlen(argv[i]) + 5;
buf = malloc(bufsize+1);
if (!buf)
return;
buf[0] = 0;
for (i=0; argv[i]; i++) {
strcat(buf, argv[i]);
strcat(buf, " ");
}
EngFncs->write_log_entry(DEBUG, pMyPluginRecord,
"mke2fs command: %s\n", buf);
free(buf);
LOGEXIT();
return;
}
/*
* Run fsck on the volume.
*/
int fsim_fsck(logical_volume_t * volume, option_array_t * options,
int *ret_status)
{
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;
LOGENTRY();
/* open pipe, alloc buffer for collecting fsck.jfs output */
rc = pipe(fds2);
if (rc) {
return(errno);
}
if (!(buffer = EngFncs->engine_alloc(MAX_USER_MESSAGE_LEN))) {
return(ENOMEM);
}
/* Fork and execute the correct program. */
switch (pidf = fork()) {
/* error */
case -1:
rc = 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 */
execvp( argv[0], argv );
/* should never get here */
_exit(8); /* FSCK_ERROR -- operational error */
/* parent */
default:
close(fds2[1]);
/* wait for child to complete */
fcntl(fds2[0], F_SETFL, fcntl(fds2[0], F_GETFL,0) | O_NONBLOCK);
while (!(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:");
banner = 1;
MESSAGE("%s",buffer);
memset(buffer,0,bytes_read); /* clear out message */
}
usleep(10000); /* don't hog all the cpu */
}
/* do final read, just in case we missed some */
bytes_read = read(fds2[0],buffer,MAX_USER_MESSAGE_LEN);
if (bytes_read > 0) {
if (!banner)
MESSAGE("e2fsck output:");
MESSAGE("%s",buffer);
}
if ( WIFEXITED(status) ) {
/* get e2fsck exit code */
*ret_status = WEXITSTATUS(status);
LOG("e2fsck completed with exit code %d\n",
*ret_status);
rc = 0;
} else {
if (WIFSIGNALED(status))
LOG("e2fsck died with signal %d",
WTERMSIG(status));
rc = EINTR;
}
}
if (buffer) {
EngFncs->engine_free(buffer);
}
close(fds2[0]);
LOGEXITRC();
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, bufsize, num_opts, opt_count = 1;
int do_preen = 1;
char *buf;
LOGENTRY();
argv[0] = "e2fsck";
if (options)
num_opts = options->count;
else {
/* No options, assume force (for resizing) */
argv[opt_count++] = "-f";
num_opts = 0;
}
for ( i=0; i < num_opts; 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;
bufsize = 0;
for (i=0; argv[i]; i++)
bufsize += strlen(argv[i]) + 5;
buf = malloc(bufsize+1);
if (!buf)
return;
buf[0] = 0;
for (i=0; argv[i]; i++) {
strcat(buf, argv[i]);
strcat(buf, " ");
}
EngFncs->write_log_entry(DEBUG, pMyPluginRecord,
"fsck command: %s\n", buf);
free(buf);
LOGEXIT();
return;
}
/*
* NAME:ext2fs_swap_super
*
* FUNCTION: Swap all fields in the super block to CPU format.
*
* PARAMETERS:
* sb - pointer to superblock
*
* RETURNS:
* void
*/
static void ext2fs_swap_super(struct ext2_super_block * sb)
{
LOGENTRY();
sb->s_inodes_count = DISK_TO_CPU32(sb->s_inodes_count);
sb->s_blocks_count = DISK_TO_CPU32(sb->s_blocks_count);
sb->s_r_blocks_count = DISK_TO_CPU32(sb->s_r_blocks_count);
sb->s_free_blocks_count = DISK_TO_CPU32(sb->s_free_blocks_count);
sb->s_free_inodes_count = DISK_TO_CPU32(sb->s_free_inodes_count);
sb->s_first_data_block = DISK_TO_CPU32(sb->s_first_data_block);
sb->s_log_block_size = DISK_TO_CPU32(sb->s_log_block_size);
sb->s_log_frag_size = DISK_TO_CPU32(sb->s_log_frag_size);
sb->s_blocks_per_group = DISK_TO_CPU32(sb->s_blocks_per_group);
sb->s_frags_per_group = DISK_TO_CPU32(sb->s_frags_per_group);
sb->s_inodes_per_group = DISK_TO_CPU32(sb->s_inodes_per_group);
sb->s_mtime = DISK_TO_CPU32(sb->s_mtime);
sb->s_wtime = DISK_TO_CPU32(sb->s_wtime);
sb->s_mnt_count = DISK_TO_CPU16(sb->s_mnt_count);
sb->s_max_mnt_count = DISK_TO_CPU16(sb->s_max_mnt_count);
sb->s_magic = DISK_TO_CPU16(sb->s_magic);
sb->s_state = DISK_TO_CPU16(sb->s_state);
sb->s_errors = DISK_TO_CPU16(sb->s_errors);
sb->s_minor_rev_level = DISK_TO_CPU16(sb->s_minor_rev_level);
sb->s_lastcheck = DISK_TO_CPU32(sb->s_lastcheck);
sb->s_checkinterval = DISK_TO_CPU32(sb->s_checkinterval);
sb->s_creator_os = DISK_TO_CPU32(sb->s_creator_os);
sb->s_rev_level = DISK_TO_CPU32(sb->s_rev_level);
sb->s_def_resuid = DISK_TO_CPU16(sb->s_def_resuid);
sb->s_def_resgid = DISK_TO_CPU16(sb->s_def_resgid);
sb->s_first_ino = DISK_TO_CPU32(sb->s_first_ino);
sb->s_inode_size = DISK_TO_CPU16(sb->s_inode_size);
sb->s_block_group_nr = DISK_TO_CPU16(sb->s_block_group_nr);
sb->s_feature_compat = DISK_TO_CPU32(sb->s_feature_compat);
sb->s_feature_incompat = DISK_TO_CPU32(sb->s_feature_incompat);
sb->s_feature_ro_compat = DISK_TO_CPU32(sb->s_feature_ro_compat);
sb->s_algorithm_usage_bitmap = DISK_TO_CPU32(sb->s_algorithm_usage_bitmap);
sb->s_journal_inum = DISK_TO_CPU32(sb->s_journal_inum);
sb->s_journal_dev = DISK_TO_CPU32(sb->s_journal_dev);
sb->s_last_orphan = DISK_TO_CPU32(sb->s_last_orphan);
LOGEXIT();
}
/*
* 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;
LOGENTRY();
fd = open(EVMS_GET_DEVNAME(volume), O_RDONLY, 0);
if (fd < 0) {
rc = EIO;
LOGEXITRC();
return rc;
}
/* get primary superblock */
rc = fsim_rw_diskblocks( fd, EXT2_SUPER_LOC, SIZE_OF_SUPER, sb_ptr, GET );
if( rc == 0 ) {
ext2fs_swap_super(sb_ptr);
/* 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);
LOGEXITRC();
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;
int rc = 0;
LOGENTRY();
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:
rc = EINVAL;
LOGEXITRC();
return rc;
break;
}
if ( Bytes_Transferred != disk_count ) {
rc = EIO;
LOGEXITRC();
return rc;
}
LOGEXIT();
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;
}

View File

@ -1,276 +0,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
*
*/
/* If EVMS_ABI_CODE is not defined, default to EVMS ABI 1.2 */
#ifndef EVMS_ABI_CODE
#define EVMS_ABI_CODE 120
#endif
/*
* EVMS 1.0 backwards compatibility functions
*/
#if (EVMS_ABI_CODE == 100)
#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 MESSAGE(msg, args...) EngFncs->user_message(pMyPluginRecord, NULL, NULL, msg, ##args)
#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 LOG_CRITICAL(msg, args...) EngFncs->write_log_entry(CRITICAL, pMyPluginRecord, "%s: " msg, __FUNCTION__ , ## args)
#define LOG_SERIOUS(msg, args...) EngFncs->write_log_entry(SERIOUS, pMyPluginRecord, "%s: " msg, __FUNCTION__ , ## args)
#define LOG_ERROR(msg, args...) EngFncs->write_log_entry(ERROR, pMyPluginRecord, "%s: " msg, __FUNCTION__ , ## args)
#define LOG_WARNING(msg, args...) EngFncs->write_log_entry(WARNING, pMyPluginRecord, "%s: " msg, __FUNCTION__ , ## args)
#define LOG(msg, args...) EngFncs->write_log_entry(DEFAULT, pMyPluginRecord, "%s: " msg, __FUNCTION__ , ## args)
#define LOG_DETAILS(msg, args...) EngFncs->write_log_entry(DETAILS, pMyPluginRecord, "%s: " msg, __FUNCTION__ , ## args)
#define LOG_DEBUG(msg, args...) EngFncs->write_log_entry(DEBUG, pMyPluginRecord, "%s: " msg, __FUNCTION__ , ## args)
#define LOG_EXTRA(msg, args...) EngFncs->write_log_entry(EXTRA, pMyPluginRecord, "%s: " msg, __FUNCTION__ , ## 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 {
u_int32_t s_inodes_count; /* Inodes count */
u_int32_t s_blocks_count; /* Blocks count */
u_int32_t s_r_blocks_count; /* Reserved blocks count */
u_int32_t s_free_blocks_count; /* Free blocks count */
u_int32_t s_free_inodes_count; /* Free inodes count */
u_int32_t s_first_data_block; /* First Data Block */
u_int32_t s_log_block_size; /* Block size */
int32_t s_log_frag_size; /* Fragment size */
u_int32_t s_blocks_per_group; /* # Blocks per group */
u_int32_t s_frags_per_group; /* # Fragments per group */
u_int32_t s_inodes_per_group; /* # Inodes per group */
u_int32_t s_mtime; /* Mount time */
u_int32_t s_wtime; /* Write time */
u_int16_t s_mnt_count; /* Mount count */
int16_t s_max_mnt_count; /* Maximal mount count */
u_int16_t s_magic; /* Magic signature */
u_int16_t s_state; /* File system state */
u_int16_t s_errors; /* Behaviour when detecting errors */
u_int16_t s_minor_rev_level; /* minor revision level */
u_int32_t s_lastcheck; /* time of last check */
u_int32_t s_checkinterval; /* max. time between checks */
u_int32_t s_creator_os; /* OS */
u_int32_t s_rev_level; /* Revision level */
u_int16_t s_def_resuid; /* Default uid for reserved blocks */
u_int16_t 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...
*/
u_int32_t s_first_ino; /* First non-reserved inode */
u_int16_t s_inode_size; /* size of inode structure */
u_int16_t s_block_group_nr; /* block group # of this superblock */
u_int32_t s_feature_compat; /* compatible feature set */
u_int32_t s_feature_incompat; /* incompatible feature set */
u_int32_t s_feature_ro_compat; /* readonly-compatible feature set */
u_int8_t s_uuid[16]; /* 128-bit uuid for volume */
int8_t s_volume_name[16]; /* volume name */
int8_t s_last_mounted[64]; /* directory where last mounted */
u_int32_t s_algorithm_usage_bitmap; /* For compression */
/*
* Performance hints. Directory preallocation should only
* happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
*/
u_int8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
u_int8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
u_int16_t s_padding1;
/*
* Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
*/
u_int8_t s_journal_uuid[16]; /* uuid of journal superblock */
u_int32_t s_journal_inum; /* inode number of journal file */
u_int32_t s_journal_dev; /* device number of journal file */
u_int32_t s_last_orphan; /* start of list of inodes to delete */
u_int32_t 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 * );
int fsim_get_volume_limits( struct ext2_super_block *, sector_count_t *,
sector_count_t *, sector_count_t * );
int fsim_test_version( void );

View File

@ -1,321 +0,0 @@
/*
*
* 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_Shrink_Container,
EVMS_Task_Set_Container_Info,
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 */
#if (EVMS_ABI_CODE >= 110)
char * name; /* Short, unique (within the plug-in) name for the function */
/* e.g., "addspare" */
#endif
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 */
#if (EVMS_ABI_CODE == 100)
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

View File

@ -1,32 +0,0 @@
/*
*
* 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