[Ocfs-tools-commits] manish commits r206 - in trunk: . advanced bugfix debugocfs format fsck libocfs ocfs ocfstool

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Aug 30 17:38:01 CDT 2004


Author: manish
Date: 2004-08-30 17:37:59 -0500 (Mon, 30 Aug 2004)
New Revision: 206

Added:
   trunk/advanced/
   trunk/advanced/sizetest/
   trunk/bugfix/
   trunk/bugfix/Makefile
   trunk/bugfix/bug3016598-README.txt
   trunk/bugfix/bug3016598.c
   trunk/bugfix/bug3123542-README.txt
   trunk/bugfix/bug3123542.c
   trunk/bugfix/generic.c
   trunk/bugfix/ver.c
   trunk/debugocfs/
   trunk/debugocfs/Cscope.make
   trunk/debugocfs/Makefile
   trunk/debugocfs/debugocfs.8.in
   trunk/debugocfs/debugocfs.c
   trunk/debugocfs/debugocfs.h
   trunk/debugocfs/debugocfs.txt
   trunk/debugocfs/extfinder.c
   trunk/debugocfs/io.c
   trunk/debugocfs/libdebugocfs.c
   trunk/debugocfs/libdebugocfs.h
   trunk/debugocfs/main.c
   trunk/debugocfs/print.c
   trunk/debugocfs/test.c
   trunk/format/
   trunk/format/Cscope.make
   trunk/format/Makefile
   trunk/format/format.c
   trunk/format/frmtport.c
   trunk/format/inc/
   trunk/format/journal.c
   trunk/format/mkfs.ocfs.8.in
   trunk/format/mounted.c
   trunk/format/system.c
   trunk/format/tune.c
   trunk/format/tuneocfs.8.in
   trunk/fsck/
   trunk/fsck/Cscope.make
   trunk/fsck/Makefile
   trunk/fsck/blked.c
   trunk/fsck/class_print.c
   trunk/fsck/class_rw.c
   trunk/fsck/classes.h
   trunk/fsck/defaults.c
   trunk/fsck/defaults.h
   trunk/fsck/fsck.c
   trunk/fsck/fsck.h
   trunk/fsck/fsck.ocfs.8.in
   trunk/fsck/fsck_io.c
   trunk/fsck/fsck_print.c
   trunk/fsck/fsck_print.h
   trunk/fsck/layout.c
   trunk/fsck/layout.h
   trunk/fsck/mkgetconst
   trunk/fsck/parse.c
   trunk/fsck/sig.c
   trunk/fsck/sig.h
   trunk/fsck/utils.c
   trunk/fsck/ver.c
   trunk/fsck/verify.c
   trunk/fsck/verify.h
   trunk/libocfs/
   trunk/libocfs/Common/
   trunk/libocfs/Linux/
   trunk/libocfs/Makefile
   trunk/libocfs/bindraw.c
   trunk/libocfs/bindraw.h
   trunk/libocfs/bitmap.S
   trunk/libocfs/libocfs.c
   trunk/libocfs/libocfs.h
Removed:
   trunk/advanced/sizetest/
   trunk/bugfix/Makefile
   trunk/bugfix/bug3016598-README.txt
   trunk/bugfix/bug3016598.c
   trunk/bugfix/bug3123542-README.txt
   trunk/bugfix/bug3123542.c
   trunk/bugfix/generic.c
   trunk/bugfix/ver.c
   trunk/debugocfs/Cscope.make
   trunk/debugocfs/Makefile
   trunk/debugocfs/debugocfs.8.in
   trunk/debugocfs/debugocfs.c
   trunk/debugocfs/debugocfs.h
   trunk/debugocfs/debugocfs.txt
   trunk/debugocfs/extfinder.c
   trunk/debugocfs/io.c
   trunk/debugocfs/libdebugocfs.c
   trunk/debugocfs/libdebugocfs.h
   trunk/debugocfs/main.c
   trunk/debugocfs/print.c
   trunk/debugocfs/test.c
   trunk/format/Cscope.make
   trunk/format/Makefile
   trunk/format/format.c
   trunk/format/frmtport.c
   trunk/format/inc/
   trunk/format/journal.c
   trunk/format/mkfs.ocfs.8.in
   trunk/format/mounted.c
   trunk/format/system.c
   trunk/format/tune.c
   trunk/format/tuneocfs.8.in
   trunk/fsck/Cscope.make
   trunk/fsck/Makefile
   trunk/fsck/blked.c
   trunk/fsck/class_print.c
   trunk/fsck/class_rw.c
   trunk/fsck/classes.h
   trunk/fsck/defaults.c
   trunk/fsck/defaults.h
   trunk/fsck/fsck.c
   trunk/fsck/fsck.h
   trunk/fsck/fsck.ocfs.8.in
   trunk/fsck/fsck_io.c
   trunk/fsck/fsck_print.c
   trunk/fsck/fsck_print.h
   trunk/fsck/layout.c
   trunk/fsck/layout.h
   trunk/fsck/mkgetconst
   trunk/fsck/parse.c
   trunk/fsck/sig.c
   trunk/fsck/sig.h
   trunk/fsck/utils.c
   trunk/fsck/ver.c
   trunk/fsck/verify.c
   trunk/fsck/verify.h
   trunk/libocfs/Common/
   trunk/libocfs/Linux/
   trunk/libocfs/Makefile
   trunk/libocfs/bindraw.c
   trunk/libocfs/bindraw.h
   trunk/libocfs/bitmap.S
   trunk/libocfs/libocfs.c
   trunk/libocfs/libocfs.h
   trunk/ocfs/Makefile
   trunk/ocfs/advanced/
   trunk/ocfs/bugfix/
   trunk/ocfs/debugocfs/
   trunk/ocfs/format/
   trunk/ocfs/fsck/
   trunk/ocfs/libocfs/
Modified:
   trunk/Config.make.in
   trunk/Makefile
   trunk/README
   trunk/configure.in
   trunk/ocfstool/Makefile
Log:
Move everything out to toplevel dir, since ocfs2 stuff is moved out


Modified: trunk/Config.make.in
===================================================================
--- trunk/Config.make.in	2004-08-30 22:26:51 UTC (rev 205)
+++ trunk/Config.make.in	2004-08-30 22:37:59 UTC (rev 206)
@@ -36,7 +36,6 @@
 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@ 
-COM_ERR_LIBS = @COM_ERR_LIBS@
 
 GLIB_CFLAGS = @GLIB_CFLAGS@
 GLIB_LIBS = @GLIB_LIBS@
@@ -44,15 +43,9 @@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 
-BUILD_OCFS = @BUILD_OCFS@
-BUILD_OCFS2 = @BUILD_OCFS2@
 BUILD_OCFSTOOL = @BUILD_OCFSTOOL@
 
-DEBUGOCFS2 = @DEBUGOCFS2@
-
 OCFS_DEBUG = @OCFS_DEBUG@
 OCFS_MEMDEBUG = @OCFS_MEMDEBUG@
 OCFS_TRACE = @OCFS_TRACE@
 OCFS_PROCESSOR = @OCFS_PROCESSOR@
-
-OCFS2_DEBUG_EXE = @OCFS2_DEBUG_EXE@

Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2004-08-30 22:26:51 UTC (rev 205)
+++ trunk/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -22,16 +22,8 @@
 $(error could not detect architecture for tools)
 endif
 
-SUBDIRS = load_ocfs ocfs_uid_gen
+SUBDIRS = libocfs debugocfs format fsck bugfix load_ocfs ocfs_uid_gen
 
-ifdef BUILD_OCFS
-SUBDIRS += ocfs
-endif
-
-ifdef BUILD_OCFS2
-SUBDIRS += ocfs2
-endif
-
 ifdef BUILD_OCFSTOOL
 SUBDIRS += ocfstool
 endif

Modified: trunk/README
===================================================================
--- trunk/README	2004-08-30 22:26:51 UTC (rev 205)
+++ trunk/README	2004-08-30 22:37:59 UTC (rev 206)
@@ -1 +1 @@
-These are common tools for ocfs v1 and v2.
+These are tools for OCFS.

Copied: trunk/advanced (from rev 204, trunk/ocfs/advanced)

Copied: trunk/advanced/sizetest (from rev 205, trunk/ocfs/advanced/sizetest)

Copied: trunk/bugfix (from rev 204, trunk/ocfs/bugfix)

Deleted: trunk/bugfix/Makefile
===================================================================
--- trunk/ocfs/bugfix/Makefile	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/bugfix/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,64 +0,0 @@
-TOPDIR = ../..
-
-include $(TOPDIR)/Preamble.make
-
-WARNINGS = -Wall -Wstrict-prototypes -Wno-format -Wmissing-prototypes \
-           -Wmissing-declarations
-
-ifdef OCFS_DEBUG
-OPTS = -g
-endif
-
-CFLAGS = $(OPTS) -fno-strict-aliasing $(WARNINGS) -pthread
-
-DIST_FILES = bug3123542.c bug3016598.c bug3123542-README.txt bug3016598-README.txt
-
-SBIN_PROGRAMS = bug3016598 bug3123542
-
-INCLUDES = -I$(TOPDIR)/ocfs/libocfs/Common/inc -I$(TOPDIR)/ocfs/libocfs/Linux/inc -Iinc -I$(TOPDIR)/ocfs/libocfs
-DEFINES = -DLINUX -DUSERSPACE_TOOL
-
-OPTIMIZE = -O2
-
-ifeq ($(OCFS_PROCESSOR),ppc64)
-endif
-ifeq ($(OCFS_PROCESSOR),x86_64)
-endif
-ifeq ($(OCFS_PROCESSOR),ia64)
-endif
-ifeq ($(OCFS_PROCESSOR),i686)
-  DEFINES += -D__ILP32__
-endif
-ifeq ($(OCFS_PROCESSOR),i586)
-  DEFINES += -D__ILP32__
-endif
-ifeq ($(OCFS_PROCESSOR),s390x)
-  DEFINES += -D__LP64__
-endif
-
-CFLAGS += $(OPTIMIZE)
-
-ifdef OCFS_DEBUG
-DEFINES += -DDEBUG
-endif
-ifdef OCFS_TRACE
-DEFINES += -DTRACE
-endif
-
-
-VERSION_FILES = generic.c ver.c
-VERSION_SRC = ver.c
-VERSION_PREFIX = BUGFIX
-
-DIST_RULES = dist-incdir
-
-bug3016598: bug3016598.o ver.o generic.o
-	$(LINK) -L$(TOPDIR)/ocfs/libocfs -locfs
-
-bug3123542: bug3123542.o ver.o generic.o
-	$(LINK) -L$(TOPDIR)/ocfs/libocfs -locfs
-
-dist-incdir:
-	$(TOPDIR)/mkinstalldirs $(DIST_DIR)/inc
-
-include $(TOPDIR)/Postamble.make

Copied: trunk/bugfix/Makefile (from rev 205, trunk/ocfs/bugfix/Makefile)
===================================================================
--- trunk/ocfs/bugfix/Makefile	2004-08-30 22:26:51 UTC (rev 205)
+++ trunk/bugfix/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -0,0 +1,64 @@
+TOPDIR = ..
+
+include $(TOPDIR)/Preamble.make
+
+WARNINGS = -Wall -Wstrict-prototypes -Wno-format -Wmissing-prototypes \
+           -Wmissing-declarations
+
+ifdef OCFS_DEBUG
+OPTS = -g
+endif
+
+CFLAGS = $(OPTS) -fno-strict-aliasing $(WARNINGS) -pthread
+
+DIST_FILES = bug3123542.c bug3016598.c bug3123542-README.txt bug3016598-README.txt
+
+SBIN_PROGRAMS = bug3016598 bug3123542
+
+INCLUDES = -I$(TOPDIR)/libocfs/Common/inc -I$(TOPDIR)/libocfs/Linux/inc -Iinc -I$(TOPDIR)/libocfs
+DEFINES = -DLINUX -DUSERSPACE_TOOL
+
+OPTIMIZE = -O2
+
+ifeq ($(OCFS_PROCESSOR),ppc64)
+endif
+ifeq ($(OCFS_PROCESSOR),x86_64)
+endif
+ifeq ($(OCFS_PROCESSOR),ia64)
+endif
+ifeq ($(OCFS_PROCESSOR),i686)
+  DEFINES += -D__ILP32__
+endif
+ifeq ($(OCFS_PROCESSOR),i586)
+  DEFINES += -D__ILP32__
+endif
+ifeq ($(OCFS_PROCESSOR),s390x)
+  DEFINES += -D__LP64__
+endif
+
+CFLAGS += $(OPTIMIZE)
+
+ifdef OCFS_DEBUG
+DEFINES += -DDEBUG
+endif
+ifdef OCFS_TRACE
+DEFINES += -DTRACE
+endif
+
+
+VERSION_FILES = generic.c ver.c
+VERSION_SRC = ver.c
+VERSION_PREFIX = BUGFIX
+
+DIST_RULES = dist-incdir
+
+bug3016598: bug3016598.o ver.o generic.o
+	$(LINK) -L$(TOPDIR)/libocfs -locfs
+
+bug3123542: bug3123542.o ver.o generic.o
+	$(LINK) -L$(TOPDIR)/libocfs -locfs
+
+dist-incdir:
+	$(TOPDIR)/mkinstalldirs $(DIST_DIR)/inc
+
+include $(TOPDIR)/Postamble.make

Deleted: trunk/bugfix/bug3016598-README.txt
===================================================================
--- trunk/ocfs/bugfix/bug3016598-README.txt	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/bugfix/bug3016598-README.txt	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,102 +0,0 @@
-bug 3016598
-===========
-
-Symptoms
---------
-* "rmdir foo" of an empty directory "foo" in OCFS fails (or even rm -rf foo)
-* debugocfs output for the undeletable directory shows that num_ent_used
-  is still greater than 0  
-  (ex. debugocfs -d /path/to/dir/ /dev/device)
-* if the "old" file entries immediately following this directory block
-  are inspected with debugocfs, the sync_flags field will be set to
-  OCFS_SYNC_FLAG_MARK_FOR_DELETION on all remaining files in the
-  directory, and thus they are not visible 
-  (ex. debugocfs -X -h ## -l ## -t ocfs_file_entry /dev/device, where 
-   the -h and -l params are the high and low 64-bit offsets to the block in
-   question.  to find the first block in a directory, add 512 to the 
-   node_disk_off field from the "debugocfs -d" above.  each subsequent
-   file entry will be 512 bytes after the previous)
-
-
-Cause
------
-At certain rare times in OCFS, a file will be marked as deleted but
-its parent directory will never decrement the num_ent_used count of
-existing files in that directory.  However, the deleted file will be
-marked as such, and therefore skipped when a file listing (ls) is done
-in that directory.  The directory will appear empty but the user will be
-unable to delete it.  This is different from a directory which cannot be
-deleted because it is in use by a process on the node attempting the
-delete or another node in the cluster.  Use standard tools (lsof, fuser)
-to determine whether the directory is simply in use, or whether you
-actually have this corruption in the filesystem.
-
-
-Solution
---------
-bug3016598 executable:
-
-* The bug3016598 executable is a one-off patch which will "mount" the
-  filesystem, take locks on necessary filesystem structures, make a fix
-  to any affected indices, unlock and unmount.  While it is safe to run
-  this utility (if directed to do so by support), you should attempt to
-  minimize activity on the affected partition and/or directory while
-  running.
-* Use this utility if you are concerned about downtime and cannot afford
-  to bring down the entire cluster to clean up the filesystem.  If the
-  filesystem is already dismounted on all nodes, please see the
-  fsck.ocfs option below.
-* DO NOT run more that one instance of this utility on this node or
-  other nodes in the cluster.
-* DO NOT run any other one-off patch utilities on this node or any other 
-  nodes in the cluster at the same time.
-* DO NOT run fsck.ocfs at the same time as this utility.  (you can and
-  should run fsck.ocfs.ro (readonly) before and after running this patch
-  to verify that the problem is fixed and that no other filesystem
-  corruptions have taken place)
-* This utility requires an autoconfig slot (it defaults to the last one,
-  number 31) and will not be able to run if all slots are filled.  Other
-  nodes will see the utility as a full-fledged node.
-
-
-fsck.ocfs (included as part of OCFS tools):
-
-* The fsck.ocfs command is a full filesystem checker for OCFS.  It does
-  *not* do any filesystem locking and therefore can only be run when the
-  volume in question is dismounted on all nodes.  
-* This utility checks many structures within the filesystem for
-  validity, and can also fix bug 3016598, in addition to several other
-  bugs.
-* A heartbeat check will be performed before running to attempt to
-  prevent the user from making changes while any nodes have this
-  filesystem mounted.  DO NOT circumvent this by mounting on another
-  node immediately after the heartbeat check.  Wait until fsck.ocfs
-  completes before mounting.
-
-
-fsck.ocfs.ro (included as part of OCFS tools):
-
-* This is a readonly version of fsck.ocfs that can be run at any time to
-  detect any of the problems normally found by fsck.ocfs.  Redirect the
-  output of this command to a file to assist support in determining any
-  problems with your filesystem.
-* Can be safely run at any time, but may temporarily do a great deal of
-  I/O against the device.  
-* Sometimes reports false positives for problems.  Filesystem structures
-  are in-flight during some system calls.  Re-run the utility few more
-  times to see if the errors reported are still present.
-
-
-Note about all utilities:
-
-* These utilities require at least read access (and write access for
-  fsck.ocfs and bug3016598) on the device to be checked.
-* For a consistent view of the filesystem, these commands need to use
-  DIRECT-IO to access the device.  With some versions of the linux
-  kernel, this can only be done if you first bind a raw device (see
-  man raw(8) for more details) to the block device.  Also, in some
-  kernel versions, attempting to do DIRECT-IO to a block device will
-  fail, and in other versions it may silently succeed but not actually
-  give you direct access to the device.  It is safest to always bind a
-  raw device to the block device and use this as your target.  Remember
-  to free up the raw device when finished.

Copied: trunk/bugfix/bug3016598-README.txt (from rev 205, trunk/ocfs/bugfix/bug3016598-README.txt)

Deleted: trunk/bugfix/bug3016598.c
===================================================================
--- trunk/ocfs/bugfix/bug3016598.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/bugfix/bug3016598.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,156 +0,0 @@
-#include <libocfs.h>
-
-extern int fd;
-extern ocfs_super *osb;
-extern struct super_block sb;
-extern ocfs_vol_disk_hdr *vdh;
-extern ocfs_file_entry *fe;
-extern __u32 debug_context;
-extern __u32 debug_level;
-extern __u32 debug_exclude;
-extern ocfs_global_ctxt OcfsGlobalCtxt;
-
-
-
-int do_bugfix(void);
-void print_bugfix_string(void);
-bool find_the_bug(ocfs_dir_node *dir);
-int fix_the_bug(ocfs_dir_node *dir, __u64 offset, __u64 lock_id);
-int scan_directory(__u64 top, int *found);
-
-
-int do_bugfix()
-{
-	int ret;
-	int found = 0;
-
-	ret = scan_directory(vdh->root_off, &found);
-	
-	if (found)
-		printf("Undeletable directory was found %d times.\n", found);
-	else
-		printf("Undeletable directory was not found!  OK.\n");
-
-	return ret;
-}
-
-void print_bugfix_string()
-{
-	fprintf(stderr, "\nThis utility fixes bug#3016598, the undeletable directory bug.\n");
-}
-
-int scan_directory(__u64 top, int *found)
-{
-	int ret, i;
-	__u64 off;
-	ocfs_dir_node *dir = NULL;
-
-	if ((dir = malloc_aligned(OCFS_DEFAULT_DIR_NODE_SIZE)) == NULL) {
-		fprintf(stderr, "failed to alloc %d bytes!  exiting!\n", OCFS_DEFAULT_DIR_NODE_SIZE);
-		exit(ENOMEM);
-	}
-	memset(dir, 0, OCFS_DEFAULT_DIR_NODE_SIZE);
-
-	off = top;
-	while (1) {
-		ret = ocfs_read_dir_node(osb, dir, off);
-		if (ret < 0) {
-			fprintf(stderr, "error during read of %llu : %s\n", off, strerror(errno));
-			return ret;
-		}
-		
-		if (find_the_bug(dir)) {
-			(*found)++;
-			ret = fix_the_bug(dir, off, top);
-		}
-
-		for (i=0; i < dir->num_ent_used; i++)
-		{
-			ocfs_file_entry *fe;
-			fe = FILEENT(dir, i);
-			if (fe->sync_flags && !(fe->sync_flags & DELETED_FLAGS) &&
-			    	fe->attribs & OCFS_ATTRIB_DIRECTORY)
-			{
-				ret = scan_directory(fe->extents[0].disk_off, found);
-			}
-		}
-
-			
-		if (dir->next_node_ptr == -1)
-			break;
-		else
-			off = dir->next_node_ptr;
-	}
-	if (dir)
-		free_aligned(dir);
-
-	if (!found)
-		printf("Undeletable directory was not found!  OK.\n");		
-	return ret;
-}
-
-bool find_the_bug(ocfs_dir_node *dir)
-{
-	int deleted_files, i;
-	
-	/* check the undeletable dir bug, BUG #3016598 */
-	for (i=0, deleted_files=0; i < dir->num_ent_used; i++) {
-		if (IS_FE_DELETED((FILEENT(dir, i))->sync_flags))
-			deleted_files++;
-	}
-	if (dir->num_ent_used && dir->num_ent_used == deleted_files) {
-		/* we hit the bug... fix by zeroing num_ent_used */
-		return true;
-	}
-	return false;
-}
-
-int fix_the_bug(ocfs_dir_node *dir, __u64 offset, __u64 lock_id)
-{
-	int ret = 0, tmpret;
-	ocfs_lock_res *lockres = NULL;
-	ocfs_file_entry *lock_fe = NULL;
-	__u8 num_ent_used = dir->num_ent_used;
-
-
-	/* if we are changing the block being locked   */
-	/* we need to make sure to use the same buffer */
-	if (offset != lock_id) {
-		memset(fe, 0, 512);
-		lock_fe = fe;
-	} else
-		lock_fe = (ocfs_file_entry *)dir;
-
-	if (offset != lock_id) {
-		// it seems that the bug only happens on the topmost
-		return 0;
-	}
-	
-	printf("Undeletable directory found. Fixing.\n");
-
-	// locking the toplevel dir
-	ret = ocfs_acquire_lock (osb, lock_id, OCFS_DLM_EXCLUSIVE_LOCK, FLAG_DIR, 
-				 &lockres, lock_fe);
-
-	if (ret < 0) {
-		fprintf(stderr, "failed to lock directory\n");
-		goto done;
-	}
-	
-	dir->num_ent_used = 0;
-	ret = ocfs_write_disk(osb, dir, 512, offset);
-	if (ret == -1) {
-		fprintf(stderr, "failed to write at offset %u/%u\n", offset);
-		dir->num_ent_used = num_ent_used;
-	}
-	tmpret = ocfs_release_lock(osb, lock_id, OCFS_DLM_EXCLUSIVE_LOCK, FLAG_DIR, 
-			      lockres, lock_fe);
-	if (tmpret < 0) {
-		fprintf(stderr, "failed to release lock\n");
-		if (ret == 0)
-			ret = tmpret;
-	}
-done:
-	printf("Undeletable directory : %s!\n", ret==0 ? "FIXED" : "NOT FIXED");
-	return ret;
-}

Copied: trunk/bugfix/bug3016598.c (from rev 205, trunk/ocfs/bugfix/bug3016598.c)

Deleted: trunk/bugfix/bug3123542-README.txt
===================================================================
--- trunk/ocfs/bugfix/bug3123542-README.txt	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/bugfix/bug3123542-README.txt	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,112 +0,0 @@
-bug 3123542
-===========
-
-Symptoms
---------
-* "ls -l" in a directory produces output like the following:
-
-sh-2.05a$ ls -l /ocfs/include/linux/
-ls: /ocfs/include/linux/mroute.h: No such file or directory
-ls: /ocfs/include/linux/mount.h: No such file or directory
-ls: /ocfs/include/linux/modsetver.h: No such file or directory
-ls: /ocfs/include/linux/mm.h: No such file or directory
-total 2871
--rwxr-xr-x    1 khackel  khackel      7295 Sep 16 10:42 a.out.h
--rwxr-xr-x    1 khackel  khackel     11089 Sep 16 10:43 ac97_codec.h
--rwxr-xr-x    1 khackel  khackel      2589 Sep 16 10:43 acct.h
--rwxr-xr-x    1 khackel  khackel      1338 Sep 16 10:43 adfs_fs.h
--rwxr-xr-x    1 khackel  khackel       525 Sep 16 10:43 adfs_fs_i.h
-....
-
-* lookup (eg. stat) of a file known to exist fails, but readdir() finds
-  the file as it should
-
-
-Cause
------
-In OCFS, unlike most Unix filesystems, filenames are stored as part of
-the file (inode) instead of in the parent directory inode.  All of the
-file information, including its permissions, name, lock, etc., are
-stored in a sector on disk for that file.  The parent directory merely
-maintains an index on these files to keep them sorted alphabetically.
-These directory blocks can maintain exactly 254 files, so for each
-multiple of 254 files within one directory, there will be another
-alpha-sorted index.
-In some rare cases (eg. a node crash) one of these directory indexes may
-be corrupted.  This results in a directory block search that can no
-longer find some filenames because searches through these blocks are
-done alphabetically.  Functions which still scan all blocks of this
-directory will succeed as normal because the index is not needed for a
-full search.  Ultimately this means that the "lost" files are actually
-still intact on disk and not corrupted.  Only the directory index needs
-to be rebuilt.
-
-
-Solution
---------
-bug3123542 executable:
-
-* The bug3123542 executable is a one-off patch which will "mount" the
-  filesystem, take locks on necessary filesystem structures, make a fix
-  to any affected indices, unlock and unmount.  While it is safe to run
-  this utility (if directed to do so by support), you should attempt to
-  minimize activity on the affected partition and/or directory while
-  running.
-* Use this utility if you are concerned about downtime and cannot afford
-  to bring down the entire cluster to clean up the filesystem.  If the
-  filesystem is already dismounted on all nodes, please see the
-  fsck.ocfs option below.
-* DO NOT run more that one instance of this utility on this node or
-  other nodes in the cluster.
-* DO NOT run any other one-off patch utilities on this node or any other 
-  nodes in the cluster at the same time.
-* DO NOT run fsck.ocfs at the same time as this utility.  (you can and
-  should run fsck.ocfs.ro (readonly) before and after running this patch
-  to verify that the problem is fixed and that no other filesystem
-  corruptions have taken place)
-* This utility requires an autoconfig slot (it defaults to the last one,
-  number 31) and will not be able to run if all slots are filled.  Other
-  nodes will see the utility as a full-fledged node.
-
-
-fsck.ocfs (included as part of OCFS tools):
-
-* The fsck.ocfs command is a full filesystem checker for OCFS.  It does
-  *not* do any filesystem locking and therefore can only be run when the
-  volume in question is dismounted on all nodes.  
-* This utility checks many structures within the filesystem for
-  validity, and can also fix bug 3123542, in addition to several other
-  bugs.
-* A heartbeat check will be performed before running to attempt to
-  prevent the user from making changes while any nodes have this
-  filesystem mounted.  DO NOT circumvent this by mounting on another
-  node immediately after the heartbeat check.  Wait until fsck.ocfs
-  completes before mounting.
-
-
-fsck.ocfs.ro (included as part of OCFS tools):
-
-* This is a readonly version of fsck.ocfs that can be run at any time to
-  detect any of the problems normally found by fsck.ocfs.  Redirect the
-  output of this command to a file to assist support in determining any
-  problems with your filesystem.
-* Can be safely run at any time, but may temporarily do a great deal of
-  I/O against the device.  
-* Sometimes reports false positives for problems.  Filesystem structures
-  are in-flight during some system calls.  Re-run the utility few more
-  times to see if the errors reported are still present.
-
-
-Note about all utilities:
-
-* These utilities require at least read access (and write access for
-  fsck.ocfs and bug3123542) on the device to be checked.
-* For a consistent view of the filesystem, these commands need to use
-  DIRECT-IO to access the device.  With some versions of the linux
-  kernel, this can only be done if you first bind a raw device (see
-  man raw(8) for more details) to the block device.  Also, in some
-  kernel versions, attempting to do DIRECT-IO to a block device will
-  fail, and in other versions it may silently succeed but not actually
-  give you direct access to the device.  It is safest to always bind a
-  raw device to the block device and use this as your target.  Remember
-  to free up the raw device when finished.

Copied: trunk/bugfix/bug3123542-README.txt (from rev 205, trunk/ocfs/bugfix/bug3123542-README.txt)

Deleted: trunk/bugfix/bug3123542.c
===================================================================
--- trunk/ocfs/bugfix/bug3123542.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/bugfix/bug3123542.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,189 +0,0 @@
-#include <libocfs.h>
-
-extern int fd;
-extern ocfs_super *osb;
-extern struct super_block sb;
-extern ocfs_vol_disk_hdr *vdh;
-extern ocfs_file_entry *fe;
-extern __u32 debug_context;
-extern __u32 debug_level;
-extern __u32 debug_exclude;
-extern ocfs_global_ctxt OcfsGlobalCtxt;
-
-
-
-int do_bugfix(void);
-void print_bugfix_string(void);
-bool find_the_bug(ocfs_dir_node *dir);
-int fix_the_bug(ocfs_dir_node *dir, __u64 offset, __u64 lock_id);
-int scan_directory(__u64 top, int *found);
-static int fe_compare_func(const void *m1, const void *m2);
-
-
-__u8 *dirindex = NULL, *idxtmp = NULL;
-ocfs_dir_node *globaldir = NULL;
-
-
-int do_bugfix()
-{
-	int ret;
-	int found = 0;
-
-	if ((dirindex = malloc(256)) == NULL) {
-		return ENOMEM;
-	}
-	if ((idxtmp = malloc(256)) == NULL) {
-		free(dirindex);
-		return ENOMEM;
-	}
-	ret = scan_directory(vdh->root_off, &found);
-	if (dirindex)
-		free(dirindex);
-	
-	if (found)
-		printf("Bad dir index was found %d times.\n", found);
-	else
-		printf("Bad dir index was not found!  OK.\n");
-
-	return ret;
-}
-
-void print_bugfix_string()
-{
-	fprintf(stderr, "\nThis utility fixes bug#3123542, the bad directory index bug.\n");
-}
-
-int scan_directory(__u64 top, int *found)
-{
-	int ret, i;
-	__u64 off;
-	ocfs_dir_node *dir = NULL;
-
-	if ((dir = malloc_aligned(OCFS_DEFAULT_DIR_NODE_SIZE)) == NULL) {
-		fprintf(stderr, "failed to alloc %d bytes!  exiting!\n", OCFS_DEFAULT_DIR_NODE_SIZE);
-		exit(ENOMEM);
-	}
-	memset(dir, 0, OCFS_DEFAULT_DIR_NODE_SIZE);
-
-	off = top;
-	while (1) {
-		ret = ocfs_read_dir_node(osb, dir, off);
-		if (ret < 0) {
-			fprintf(stderr, "error during read of %llu : %s\n", off, strerror(errno));
-			return ret;
-		}
-		
-		if (find_the_bug(dir)) {
-			(*found)++;
-			ret = fix_the_bug(dir, off, top);
-		}
-
-		for (i=0; i < dir->num_ent_used; i++)
-		{
-			ocfs_file_entry *fe;
-			fe = FILEENT(dir, i);
-			if (fe->sync_flags && !(fe->sync_flags & DELETED_FLAGS) &&
-			    	fe->attribs & OCFS_ATTRIB_DIRECTORY)
-			{
-				ret = scan_directory(fe->extents[0].disk_off, found);
-			}
-		}
-
-			
-		if (dir->next_node_ptr == -1)
-			break;
-		else
-			off = dir->next_node_ptr;
-	}
-	if (dir)
-		free_aligned(dir);
-
-	return ret;
-}
-
-bool find_the_bug(ocfs_dir_node *dir)
-{
-	/* check the dir->index integrity */
-	globaldir = dir;
-	memset(dirindex, 0, 256);
-	memcpy(dirindex, dir->index, dir->num_ent_used);
-	qsort(dirindex, dir->num_ent_used, sizeof(__u8), fe_compare_func);
-
-	if (memcmp(dirindex, dir->index, dir->num_ent_used) != 0)
-		return true;
-
-	return false;
-}
-
-int fix_the_bug(ocfs_dir_node *dir, __u64 offset, __u64 lock_id)
-{
-	int ret = 0, tmpret;
-	ocfs_lock_res *lockres = NULL;
-	ocfs_file_entry *lock_fe = NULL;
-   
-	/* if we are changing the block being locked   */
-	/* we need to make sure to use the same buffer */
-	if (offset != lock_id) {
-		memset(fe, 0, 512);
-		lock_fe = fe;
-	} else
-		lock_fe = (ocfs_file_entry *)dir;
-
-	printf("Bad dir index found. Fixing.\n");
-
-	// locking the toplevel dir
-	ret = ocfs_acquire_lock (osb, lock_id, OCFS_DLM_EXCLUSIVE_LOCK, FLAG_DIR, 
-				 &lockres, lock_fe);
-
-	if (ret < 0) {
-		fprintf(stderr, "failed to lock directory\n");
-		goto done;
-	}
-	
-	memcpy(idxtmp, dir->index, 256);
-	memcpy(dir->index, dirindex, dir->num_ent_used);
-	ret = ocfs_write_disk(osb, dir, 512, offset);
-	if (ret == -1) {
-		fprintf(stderr, "failed to write at offset %u/%u\n", offset);
-		memcpy(dir->index, idxtmp, 256);
-	}
-	tmpret = ocfs_release_lock(osb, lock_id, OCFS_DLM_EXCLUSIVE_LOCK, FLAG_DIR, 
-			      lockres, lock_fe);
-	if (tmpret < 0) {
-		fprintf(stderr, "failed to release lock\n");
-		if (ret == 0)
-			ret = tmpret;
-	}
-done:
-	printf("Bad dir index : %s!\n", ret==0 ? "FIXED" : "NOT FIXED");
-	return ret;
-}
-
-static int fe_compare_func(const void *m1, const void *m2)
-{
-	ocfs_file_entry *fe1, *fe2;
-	__u8 idx1, idx2;
-	int ret;
-
-	if (globaldir == NULL) {
-		fprintf(stderr, "globaldir is null!  exiting!\n");
-		exit(EINVAL);
-	}
-
-	idx1 = *(__u8 *)m1;
-	idx2 = *(__u8 *)m2;
-
-	fe1 = (ocfs_file_entry *) ((char *)FIRST_FILE_ENTRY(globaldir) + (idx1 * OCFS_SECTOR_SIZE));
-	fe2 = (ocfs_file_entry *) ((char *)FIRST_FILE_ENTRY(globaldir) + (idx2 * OCFS_SECTOR_SIZE));
-	if (fe1->sync_flags & OCFS_SYNC_FLAG_NAME_DELETED ||
-	    (!(fe1->sync_flags & OCFS_SYNC_FLAG_VALID)) ||
-	    fe2->sync_flags & OCFS_SYNC_FLAG_NAME_DELETED ||
-	    (!(fe2->sync_flags & OCFS_SYNC_FLAG_VALID))) {
-		return 0;
-	}
-	ret = strncmp(fe1->filename, fe2->filename, 255);
-	
-	return -ret;
-}
-
-

Copied: trunk/bugfix/bug3123542.c (from rev 205, trunk/ocfs/bugfix/bug3123542.c)

Deleted: trunk/bugfix/generic.c
===================================================================
--- trunk/ocfs/bugfix/generic.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/bugfix/generic.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,178 +0,0 @@
-#include <libocfs.h>
-
-
-void usage(int argc, char **argv);
-void init_global_context(void);
-void version(char *progname);
-bool disclaimer(void);
-
-
-extern void print_bugfix_string(void);
-extern int do_bugfix(void);
-
-
-int fd = -1;
-ocfs_super *osb = NULL;
-struct super_block sb;
-ocfs_vol_disk_hdr *vdh = NULL;
-ocfs_file_entry *fe = NULL;
-__u32 debug_context = 0;
-__u32 debug_level = 0;
-__u32 debug_exclude = 0;
-ocfs_global_ctxt OcfsGlobalCtxt;
-
-
-
-#define DISCLAIMER_MESSAGE      \
-"WARNING:       This utility fixes a particular bug with OCFS.  Only run this utility \n"\
-"               if directed to do so by Oracle personnel.  \n"\
-"!!! NOTE !!!:  DO NOT run more than one instance of this command, or any other bugfix \n"\
-"               commands at the same time on this volume!  Doing so MAY CORRUPT YOUR \n"\
-"               FILESYSTEM!  Also, please attempt to limit the I/O being performed on \n"\
-"               this partition at the time that you run the command.\n"\
-"\n"\
-"Are you sure you want to run this utility? (yes, [no]) "
-
-
-void usage(int argc, char **argv)
-{
-	fprintf(stderr, "\n");
-	fprintf(stderr, "usage: %s /dev/device\n", argv[0]);
-	fprintf(stderr, "       where /dev/device is a raw device bound to your ocfs block device\n");
-	fprintf(stderr, "       (please see the raw(8) manpage for more information) or an ocfs \n");
-	fprintf(stderr, "       block device which supports direct-I/O\n");
-	fprintf(stderr, "\n");
-	print_bugfix_string();
-}
-
-void init_global_context()
-{
-	char *tmp;
-
-	memset(&OcfsGlobalCtxt, 0, sizeof(ocfs_global_ctxt));
-	OcfsGlobalCtxt.obj_id.type = OCFS_TYPE_GLOBAL_DATA;
-	OcfsGlobalCtxt.obj_id.size = sizeof (ocfs_global_ctxt);
-	OcfsGlobalCtxt.pref_node_num = 31;
-	OcfsGlobalCtxt.node_name = "user-tool";
-	OcfsGlobalCtxt.comm_info.type = OCFS_UDP;
-	OcfsGlobalCtxt.comm_info.ip_addr = "0.0.0.0";
-	OcfsGlobalCtxt.comm_info.ip_port = OCFS_IPC_DEFAULT_PORT;
-	OcfsGlobalCtxt.comm_info.ip_mask = NULL;
-	OcfsGlobalCtxt.comm_info_read = true;
-	memset(&OcfsGlobalCtxt.guid.id.host_id, 'f', HOSTID_LEN);
-	memset(&OcfsGlobalCtxt.guid.id.mac_id,  '0', MACID_LEN);
-
-	tmp = getenv("debug_level");
-	if (tmp)
-		debug_level = atoi(tmp);
-	tmp = getenv("debug_context");
-	if (tmp)
-		debug_context = atoi(tmp);
-	tmp = getenv("debug_exclude");
-	if (tmp)
-		debug_exclude = atoi(tmp);
-}
-
-
-bool disclaimer()
-{
-	char response[10];
-	int i;
-
-	print_bugfix_string();
-	printf(DISCLAIMER_MESSAGE);
-
-	if (fgets(response, 10, stdin) == NULL)
-		return false;
-	
-	for (i=0; i<10; i++)
-		if (response[i] == '\n' || response[i] == '\r')
-			response[i] = '\0';
-
-	if (strcasecmp(response, "yes")==0) {
-		return true;
-	}
-	return false;
-}
-
-
-int main(int argc, char **argv)
-{
-	int ret = 0;
-	bool mounted = false;
-	int flags;
-	struct stat st;
-
-	init_global_context();
-	version(argv[0]);
-
-	if (argc < 2 || stat(argv[1], &st) != 0 ||
-	    !(S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) ) {
-		usage(argc, argv);
-		exit(EINVAL);
-	}
-
-	if (S_ISCHR(st.st_mode))
-		flags = O_RDWR | O_LARGEFILE | O_SYNC;
-	else
-		flags = O_RDWR | O_LARGEFILE | O_DIRECT | O_SYNC;
-
-	if (!disclaimer()) 
-		exit(EINVAL);
-	
-	fd = open(argv[1], flags);
-	if (fd == -1) {
-		usage(argc, argv);
-		exit(EINVAL);
-	}
-	
-	if ((vdh = malloc_aligned(1024)) == NULL) {
-		fprintf(stderr, "failed to alloc %d bytes!  exiting!\n", 1024);
-		exit(ENOMEM);
-	}
-	if ((fe = malloc_aligned(512)) == NULL) {
-		fprintf(stderr, "failed to alloc %d bytes!  exiting!\n", 512);
-		exit(ENOMEM);
-	}
-
-	memset(vdh, 0, 1024);
-	memset(fe, 0, 512);
-	memset(&sb, 0, sizeof(struct super_block));
-	sb.s_dev = fd;
-
-	ret = ocfs_read_disk_header ((__u8 **)&vdh, &sb);
-	if (ret < 0) {
-		fprintf(stderr, "failed to read header\n");
-		goto done;
-	}
-
-	ret = ocfs_mount_volume (&sb, false);
-	if (ret < 0) {
-		fprintf(stderr, "failed to mount\n");
-		goto done;
-	}
-	
-	mounted = true;
-	osb = sb.u.generic_sbp;
-
-	ret = do_bugfix();
-
-
-done:
-	if (mounted) {
-		int tmp;
-		if ((tmp = ocfs_dismount_volume (&sb)) < 0) {
-			fprintf(stderr, "dismount failed, ret = %d\n", tmp);
-			if (ret == 0)
-				ret = tmp;
-		}
-	}
-	if (fe)
-		free_aligned(fe);
-	if (vdh)
-		free_aligned(vdh);
-	if (fd != -1)
-		close(fd);
-
-	exit(ret);
-}

Copied: trunk/bugfix/generic.c (from rev 205, trunk/ocfs/bugfix/generic.c)

Deleted: trunk/bugfix/ver.c
===================================================================
--- trunk/ocfs/bugfix/ver.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/bugfix/ver.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,41 +0,0 @@
-/*
- * ver.c
- *
- * prints version
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#include <stdio.h>
-
-void version(char *progname);
-
-/*
- * version()
- *
- */
-void version(char *progname)
-{
-	printf("%s %s %s (build %s)\n", progname,
-					BUGFIX_BUILD_VERSION,
-					BUGFIX_BUILD_DATE,
-					BUGFIX_BUILD_MD5);
-	return ;
-}				/* version */

Copied: trunk/bugfix/ver.c (from rev 205, trunk/ocfs/bugfix/ver.c)

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2004-08-30 22:26:51 UTC (rev 205)
+++ trunk/configure.in	2004-08-30 22:37:59 UTC (rev 206)
@@ -123,59 +123,12 @@
 AC_SUBST(OCFS_TRACE)
 AC_MSG_RESULT($enable_trace)
 
-COM_ERR_LIBS=
-AC_CHECK_LIB(com_err, com_err, COM_ERR_LIBS=-lcom_err)
-if test "x$COM_ERR_LIBS" = "x"; then
-    AC_MSG_ERROR([Unable to find com_err library])
-fi
-AC_SUBST(COM_ERR_LIBS)
-
-AC_C_BIGENDIAN()
-
-AC_MSG_CHECKING(if tools should be built for OCFS)
-AC_ARG_ENABLE(ocfs, [  --enable-ocfs=[yes/no]    Enable building of tools for OCFS filesystems [default=yes]],,enable_ocfs=yes)
-BUILD_OCFS=
-if test "x$enable_ocfs" = "xyes"; then
-    BUILD_OCFS=yes
-fi
-AC_SUBST(BUILD_OCFS)
-AC_MSG_RESULT($enable_ocfs)
-
-AC_MSG_CHECKING(if tools should be built for OCFS2)
-AC_ARG_ENABLE(ocfs2, [  --enable-ocfs2=[yes/no]    Enable building of tools for OCFS2 filesystems [default=yes]],,enable_ocfs2=yes)
-BUILD_OCFS2=
-if test "x$enable_ocfs2" = "xyes"; then
-    BUILD_OCFS2=yes
-fi
-AC_SUBST(BUILD_OCFS2)
-AC_MSG_RESULT($enable_ocfs2)
-
-AC_MSG_CHECKING(for debug executables)
-AC_ARG_ENABLE(debugexe, [  --enable-debugexe=[yes/no]     Enable debug executables for library source files [default=no]],,enable_debugexe=no)
-OCFS2_DEBUG_EXE=
-if test "x$enable_debugexe" = "xyes"; then
-    OCFS2_DEBUG_EXE=yes
-fi
-AC_SUBST(OCFS2_DEBUG_EXE)
-AC_MSG_RESULT($enable_debugexe)
-
 GLIB_REQUIRED_VERSION=1.2.8
 GTK_REQUIRED_VERSION=1.2.8
 
 AM_PATH_GLIB($GLIB_REQUIRED_VERSION, :,
   AC_MSG_ERROR([Glib $GLIB_REQUIRED_VERSION or better is required.]))
 
-DEBUGOCFS2=
-
-ocfs_tools_save_LIBS=$LIBS
-LIBS="$LIBS -lncurses"
-AC_CHECK_LIB(readline, readline,
-  [AC_CHECK_HEADER(readline/readline.h,
-    DEBUGOCFS2=yes,
-    [AC_MSG_WARN([readline not found, debugfs.ocfs2 will not be built])])],
-  [AC_MSG_WARN([readline not found, debugfs.ocfs2 will not be built])])
-LIBS=$ocfs_tools_save_LIBS
-
 BUILD_OCFSTOOL=
 AC_ARG_ENABLE(ocfstool, [  --enable-ocfstool=[yes/no]       Build GUI frontend [default=yes]],,enable_ocfstool=yes)
 
@@ -193,16 +146,13 @@
 
 AC_OUTPUT([
 Config.make
-ocfs/debugocfs/debugocfs.8
-ocfs/fsck/fsck.ocfs.8
-ocfs/format/mkfs.ocfs.8
-ocfs/format/tuneocfs.8
-ocfs2/debugfs.ocfs2/debugfs.ocfs2.8
-ocfs2/mkfs.ocfs2/mkfs.ocfs2.8
+debugocfs/debugocfs.8
+fsck/fsck.ocfs.8
+format/mkfs.ocfs.8
+format/tuneocfs.8
 ocfs_uid_gen/ocfs_uid_gen.8
 load_ocfs/load_ocfs.8
 load_ocfs/ocfs.conf.5
 ocfstool/ocfstool.8
 vendor/common/ocfs-tools.spec
-ocfs2/libocfs2/ocfs2_err.et
 ])

Copied: trunk/debugocfs (from rev 204, trunk/ocfs/debugocfs)

Deleted: trunk/debugocfs/Cscope.make
===================================================================
--- trunk/ocfs/debugocfs/Cscope.make	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/Cscope.make	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,10 +0,0 @@
-cscope:
-	rm -f cscope.*
-	echo "-k" >> cscope.files
-	echo "-I ../libocfs/Common/inc" >> cscope.files
-	echo "-I ../libocfs/Linux/inc" >> cscope.files
-	find . -name '*.c' -print >>cscope.files
-	find . -name '*.h' -print >>cscope.files
-	find ../libocfs -name '*.h' -print >>cscope.files
-	find ../libocfs -name '*.c' -print >>cscope.files
-	cscope -b

Copied: trunk/debugocfs/Cscope.make (from rev 205, trunk/ocfs/debugocfs/Cscope.make)

Deleted: trunk/debugocfs/Makefile
===================================================================
--- trunk/ocfs/debugocfs/Makefile	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,78 +0,0 @@
-TOPDIR = ../..
-
-include $(TOPDIR)/Preamble.make
-
-ifdef OCFS_DEBUG
-  OPTS = -g
-endif
-
-SBIN_PROGRAMS = debugocfs ocfsextfinder
-
-LIBRARIES = libdebugocfs.a
-
-# Too many warnings in 1.0 branch (cleaned in 2.0)
-#WARNINGS = -Wall -Wstrict-prototypes -Wno-format -Wmissing-prototypes \
-#           -Wmissing-declarations
-
-CFLAGS = $(OPTS) -fno-strict-aliasing $(WARNINGS)
-
-INCLUDES = -I. -I$(TOPDIR)/ocfs/libocfs/Common/inc -I$(TOPDIR)/ocfs/libocfs/Linux/inc -I$(TOPDIR)/ocfs/libocfs
-DEFINES = -DLINUX -DUSERSPACE_TOOL -DDEBUGOCFS
-
-OPTIMIZE = -O2
-
-ifeq ($(OCFS_PROCESSOR),ppc64)
-endif
-ifeq ($(OCFS_PROCESSOR),x86_64)
-  CFLAGS += -m64
-endif
-ifeq ($(OCFS_PROCESSOR),ia64)
-endif
-ifeq ($(OCFS_PROCESSOR),i686)
-  DEFINES += -D__ILP32__
-endif
-ifeq ($(OCFS_PROCESSOR),s390x)
-  DEFINES += -D__LP64__
-endif
-
-CFLAGS += $(OPTIMIZE)
-
-ifdef OCFS_DEBUG
-  DEFINES += -DDEBUG
-endif
-
-extfinder_CFLAGS = $(GLIB_CFLAGS)
-
-test_CFLAGS = $(GLIB_CFLAGS)
-
-CLEAN_FILES = test
-
-MANS = debugocfs.8
-
-VERSION_FILES = debugocfs.c debugocfs.h libdebugocfs.h test.c print.c libdebugocfs.c io.c main.c extfinder.c
-VERSION_SRC = main.c extfinder.c
-VERSION_PREFIX = OCFS
-
-DIST_FILES = $(VERSION_FILES) $(VERSION_SRC) debugocfs.8.in debugocfs.txt
-
-test: test.o libdebugocfs.a
-	$(LINK) -L. -ldebugocfs $(GTK_LIBS)
-
-ocfsextfinder: extfinder.o ../libocfs/libocfs.a
-	$(LINK) $(GLIB_LIBS) -lglib 
-
-debugocfs: print.o debugocfs.o io.o main.o ../libocfs/libocfs.a
-	$(LINK) -pthread -L$(TOPDIR)/ocfs/libocfs -locfs
-
-dbg.o: debugocfs.c
-	$(CC) $(CFLAGS) $(INCLUDES) $(GTK_CFLAGS) -DLIBDEBUGOCFS $(DEFINES) -o $@ -c $<
-
-libdebugocfs.o: libdebugocfs.c
-	$(CC) $(CFLAGS) $(INCLUDES) $(GTK_CFLAGS) -DLIBDEBUGOCFS $(DEFINES) -o $@ -c $<
-
-libdebugocfs.a: io.o dbg.o libdebugocfs.o
-	rm -f $@
-	$(AR) r $@ $^
-	$(RANLIB) $@
-
-include $(TOPDIR)/Postamble.make

Copied: trunk/debugocfs/Makefile (from rev 205, trunk/ocfs/debugocfs/Makefile)
===================================================================
--- trunk/ocfs/debugocfs/Makefile	2004-08-30 22:26:51 UTC (rev 205)
+++ trunk/debugocfs/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -0,0 +1,78 @@
+TOPDIR = ..
+
+include $(TOPDIR)/Preamble.make
+
+ifdef OCFS_DEBUG
+  OPTS = -g
+endif
+
+SBIN_PROGRAMS = debugocfs ocfsextfinder
+
+LIBRARIES = libdebugocfs.a
+
+# Too many warnings in 1.0 branch (cleaned in 2.0)
+#WARNINGS = -Wall -Wstrict-prototypes -Wno-format -Wmissing-prototypes \
+#           -Wmissing-declarations
+
+CFLAGS = $(OPTS) -fno-strict-aliasing $(WARNINGS)
+
+INCLUDES = -I. -I$(TOPDIR)/libocfs/Common/inc -I$(TOPDIR)/libocfs/Linux/inc -I$(TOPDIR)/libocfs
+DEFINES = -DLINUX -DUSERSPACE_TOOL -DDEBUGOCFS
+
+OPTIMIZE = -O2
+
+ifeq ($(OCFS_PROCESSOR),ppc64)
+endif
+ifeq ($(OCFS_PROCESSOR),x86_64)
+  CFLAGS += -m64
+endif
+ifeq ($(OCFS_PROCESSOR),ia64)
+endif
+ifeq ($(OCFS_PROCESSOR),i686)
+  DEFINES += -D__ILP32__
+endif
+ifeq ($(OCFS_PROCESSOR),s390x)
+  DEFINES += -D__LP64__
+endif
+
+CFLAGS += $(OPTIMIZE)
+
+ifdef OCFS_DEBUG
+  DEFINES += -DDEBUG
+endif
+
+extfinder_CFLAGS = $(GLIB_CFLAGS)
+
+test_CFLAGS = $(GLIB_CFLAGS)
+
+CLEAN_FILES = test
+
+MANS = debugocfs.8
+
+VERSION_FILES = debugocfs.c debugocfs.h libdebugocfs.h test.c print.c libdebugocfs.c io.c main.c extfinder.c
+VERSION_SRC = main.c extfinder.c
+VERSION_PREFIX = OCFS
+
+DIST_FILES = $(VERSION_FILES) $(VERSION_SRC) debugocfs.8.in debugocfs.txt
+
+test: test.o libdebugocfs.a
+	$(LINK) -L. -ldebugocfs $(GTK_LIBS)
+
+ocfsextfinder: extfinder.o $(TOPDIR)/libocfs/libocfs.a
+	$(LINK) $(GLIB_LIBS) -lglib 
+
+debugocfs: print.o debugocfs.o io.o main.o $(TOPDIR)/libocfs/libocfs.a
+	$(LINK) -pthread -L$(TOPDIR)/libocfs -locfs
+
+dbg.o: debugocfs.c
+	$(CC) $(CFLAGS) $(INCLUDES) $(GTK_CFLAGS) -DLIBDEBUGOCFS $(DEFINES) -o $@ -c $<
+
+libdebugocfs.o: libdebugocfs.c
+	$(CC) $(CFLAGS) $(INCLUDES) $(GTK_CFLAGS) -DLIBDEBUGOCFS $(DEFINES) -o $@ -c $<
+
+libdebugocfs.a: io.o dbg.o libdebugocfs.o
+	rm -f $@
+	$(AR) r $@ $^
+	$(RANLIB) $@
+
+include $(TOPDIR)/Postamble.make

Deleted: trunk/debugocfs/debugocfs.8.in
===================================================================
--- trunk/ocfs/debugocfs/debugocfs.8.in	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/debugocfs.8.in	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,108 +0,0 @@
-.TH "debugocfs" "1" "November 2003" "Version @VERSION@" "OCFS Manual Pages"
-.SH "NAME"
-debugocfs \- Utility to dump information from an OCFS partition.
-.SH "SYNOPSIS"
-\fBdebugocfs\fR [\-?] [\-h] [\-g] [\-l] [\-v range] [\-p range] [\-d /dir/name] [\-D /dir/name] [\-f /file/name [\-s /path/to/file]] [\-a range] [\-A range] [\-b range] [\-B range] [\-r range] [\-c range] [\-L range] [\-M range] [\-n nodenum] /dev/name
-.SH "DESCRIPTION"
-.PP 
-\fBdebugocfs\fR is a utility used to dump an OCFS file system information. The \fBdebugocfs\fR utility is to be used under support direction.
-.SH "OPTIONS"
-.TP
-\fB\-h\fR 
-Dumps the OCFS header information.
-
-.TP
-\fB\-g\fR 
-Dumps the OCFS bitmap information.
-
-.TP
-\fB\-l\fR 
-Dumps the OCFS full listing of all file entries.
-
-.TP
-\fB\-v\fR 
-Dumps the OCFS vote sector information.
-
-.TP
-\fB\-2\fR 
-Prints 8-byte number as 2 4byte numbers.
-
-.TP
-\fB\-p\fR \fIrange\fR
-Dumps the OCFS publish sector for a given \fIrange\fR.. 
-
-
-.TP
-\fB\-d\fR \fI/dir/name/\fR
-Dumps first ocfs_dir_node structure for a given path "\fI/dir/name\fR".
-
-.TP
-\fB\-D\fR \fI/dir/name\fR
-Dumps all ocfs_dir_node structures for a given path "\fI/dir/name\fR".
-
-.TP
-\fB\-f\fR \fI/file/name\fR
-Dumps ocfs_file_entry structure for a given file "\fI/file/name\fR".
-
-.TP
-\fB\-F\fR \fI/file/name\fR
-Dumps ocfs_file_entry and ocfs_extent_group structures for a given file "\fI/file/name\fR".
-
-.TP
-\fB\-s\fR \fI/path/to/file\fR
-suck file out to a given location "\fI/path/to/file\fR".
-
-.TP
-\fB\-a\fR \fIrange\fR
-Dumps file allocation system file for a given \fIrange\fR.
-
-.TP
-\fB\-A\fR \fIrange\fR
-Dumps dir allocation system file for a given \fIrange\fR.
-
-.TP
-\fB\-b\fR \fIrange\fR
-Dumps file allocation bitmap system file for a given \fIrange\fR.
-
-.TP
-\fB\-B\fR \fIrange\fR
-Dumps dir allocation bitmap system file for a given \fIrange\fR.
-
-.TP
-\fB\-r\fR \fIrange\fR
-Recover log file system file for a given \fIrange\fR.
-
-.TP
-\fB\-c\fR \fIrange\fR
-Cleanup log system file for a given \fIrange\fR.
-
-.TP
-\fB\-L\fR \fIrange\fR
-dumps vol metadata log system file for a given \fIrange\fR.
-
-.TP
-\fB\-M\fR \fIrange\fR
-dumps vol metadata system file for a given \fIrange\fR.
-
-.TP
-\fB\-n\fR \fInodename\fR
-Perform action as node number given
-
-.TP
-\fB/dev/name:\fR 
-Readable bound raw device (/dev/raw/rawxx). One needs to bind a Linux raw character device to the block device (/dev/sdxx) in order to use this program.
-
-.TP
-\fBrange:\fR 
-Node numbers to inspect (0-31), commas and dashes ok (i.e.:\fI0-3,5,14-17\fR).
-.SH "BUGS"
-Stuff.
-
-.SH "SEE ALSO"
-.BR ocfs(5)
-
-.SH "AUTHORS"
-Oracle Corporation
-
-.SH "COPYRIGHT"
-Copyright \(co 2002, 2004 Oracle Corporation

Copied: trunk/debugocfs/debugocfs.8.in (from rev 205, trunk/ocfs/debugocfs/debugocfs.8.in)

Deleted: trunk/debugocfs/debugocfs.c
===================================================================
--- trunk/ocfs/debugocfs/debugocfs.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/debugocfs.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,555 +0,0 @@
-/*
- * debugocfs.c
- *
- * Advanced filesystem debugging/recovery tool and library
- *
- * Copyright (C) 2002 Oracle Corporation.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Author: Kurt Hackel
- */
-
-#include "debugocfs.h"
-#include <time.h>
-
-#ifdef LIBDEBUGOCFS
-#include "glib.h"
-#include "libdebugocfs.h"
-#endif
-
-__u32 debug_context = 0;
-__u32 debug_level = 0;
-__u32 debug_exclude = 0;
-
-ocfs_global_ctxt OcfsGlobalCtxt;
-
-__u32 OcfsDebugCtxt = OCFS_DEBUG_CONTEXT_INIT;
-__u32 OcfsDebugLevel = OCFS_DEBUG_LEVEL_ERROR;
-extern user_args args;
-
-
-/* fills in boolean arr[] (possibly shifted by off) with ranges supplied in str */
-int parse_numeric_range(char *str, int arr[], int min, int max, int off)
-{
-    char *next_range, *dash;
-    int begin, end;
-    char *endptr;
-
-    while (1)
-    {
-	next_range = strsep(&str, ",");
-	if (next_range == NULL || *next_range == '\0')
-	    break;
-	if ((dash = strchr(next_range, '-')) != NULL)
-	{
-	    if (*(dash + 1) == '\0' || strchr(dash + 1, '-') != NULL)
-		return false;
-	    *dash = '\0';
-	    begin = strtol(next_range, &endptr, 10);
-	    if (endptr == next_range || begin < min || begin >= max)
-		return false;
-	    end = strtol(dash + 1, &endptr, 10);
-	    if (endptr == dash + 1 || end < min || end >= max || begin > end)
-		return false;
-	    while (begin <= end)
-		arr[off + begin++] = true;
-	}
-	else
-	{
-	    begin = strtol(next_range, &endptr, 10);
-	    if (begin < min || begin >= max)
-		return false;
-	    arr[off + begin] = true;
-	}
-    }
-    return true;
-}
-
-
-
-
-/* directory walking functions */
-
-void walk_dir_nodes(int fd, __u64 offset, const char *parent, void *buf)
-{
-    ocfs_dir_node *dir;
-    int i;
-    __u64 dirPartOffset;
-
-    dir = (ocfs_dir_node *) malloc_aligned(DIR_NODE_SIZE);
-    dirPartOffset = offset;
-
-    while (1)
-    {
-	if (dirPartOffset == 0)
-	{
-	    /* this is an error, but silently fail */
-	    break;
-	}
-	read_dir_node(fd, dir, dirPartOffset);
-	for (i = 0; i < dir->num_ent_used; i++)
-	{
-	    ocfs_file_entry *fe;
-	    int off = 512;	/* move past the dirnode header */
-
-	    off += (512 * dir->index[i]);
-	    fe = (ocfs_file_entry *) (((void *) dir) + off);
-
-#ifdef LIBDEBUGOCFS
-            handle_one_file_entry(fd, fe, buf);
-#else
-            handle_one_file_entry(fd, fe, (void *)parent);
-#endif
-	}
-	/* is there another directory chained off of this one? */
-	if (dir->next_node_ptr == -1)
-	    break;		// nope, we're done
-	else
-	    dirPartOffset = dir->next_node_ptr;	// keep going
-
-    }
-    free(dir);
-}
-
-void get_file_data_mapping(ocfs_super * vcb, ocfs_file_entry * fe,
-			   filedata * data)
-{
-    int status;
-    ocfs_inode fcb;
-    __s64 lbo;
-    __s64 vbo = 0;
-
-    if (!data)
-	return;
-
-    data->num = 0;
-    data->array = NULL;
-    data->linkname = NULL;
-    data->user = fe->uid;
-    data->group = fe->gid;
-    data->major = data->minor = 0;
-    data->mode = fe->prot_bits;
-    switch (fe->attribs & (~OCFS_ATTRIB_FILE_CDSL))
-    {
-	case OCFS_ATTRIB_DIRECTORY:
-	    data->mode |= S_IFDIR;
-	    break;
-	case OCFS_ATTRIB_CHAR:
-	    data->mode |= S_IFCHR;
-	    data->major = fe->dev_major;
-	    data->minor = fe->dev_minor;
-	    break;
-	case OCFS_ATTRIB_BLOCK:
-	    data->mode |= S_IFBLK;
-	    data->major = fe->dev_major;
-	    data->minor = fe->dev_minor;
-	    break;
-	case OCFS_ATTRIB_FIFO:
-	    data->mode |= S_IFIFO;
-	    break;
-	case OCFS_ATTRIB_SYMLINK:
-	    data->linkname = (char *) calloc(fe->file_size + 1, 1);
-	    status =
-		ocfs_read_disk(vcb, data->linkname, fe->file_size,
-			     fe->extents[0].disk_off);
-	    data->mode |= S_IFLNK;
-	    break;
-	case OCFS_ATTRIB_SOCKET:
-	    data->mode |= S_IFSOCK;
-	    break;
-	default:		// if 0 after &ing with ~OCFS_ATTRIB_FILE_CDSL, it's a file
-	case OCFS_ATTRIB_REG:
-	    if (fe->attribs & OCFS_ATTRIB_FILE_CDSL)
-	    {
-		// do the cdsl sleight-of-hand and overwrite the file entry
-		__u64 offsets[MAX_NODES];
-
-		ocfs_read_disk(vcb, offsets, (MAX_NODES * sizeof(__u64)),
-			     fe->extents[0].disk_off);
-		ocfs_read_disk(vcb, fe, OCFS_SECTOR_SIZE,
-			     offsets[vcb->node_num]);
-	    }
-	    data->mode |= S_IFREG;
-	    fcb.alloc_size = 0;
-	    fcb.file_disk_off = fe->this_sector;
-	    ocfs_extent_map_init(&(fcb.map));
-	    status =
-		ocfs_lookup_file_allocation(vcb, &fcb, vbo, &lbo, fe->file_size,
-					 &data->num, (void *) &data->array);
-	    ocfs_extent_map_destroy(&(fcb.map));
-	    break;
-    }
-
-}
-
-#ifndef LIBDEBUGOCFS
-void traverse_extent(ocfs_super * vcb, ocfs_extent_group * exthdr, int flag)
-{
-	ocfs_extent_group *ext;
-	int i, fd;
-	bool prev_ptr_error;
-
-	if ((ext = malloc_aligned(512)) == NULL) {
-		printf("error: out of memory\n");
-		return ;
-	}
-
-	fd = (int) vcb->sb->s_dev;
-
-	for (i = 0; i < exthdr->next_free_ext; ++i) {
-		if (!exthdr->extents[i].disk_off)
-			continue;
-
-		read_extent(fd, ext, exthdr->extents[i].disk_off);
-
-		if (exthdr->this_ext != ext->up_hdr_node_ptr)
-			prev_ptr_error = true;
-		else
-			prev_ptr_error = false;
-
-		if (flag == EXTENT_HEADER) {
-			if (!IS_VALID_EXTENT_HEADER (ext)) {
-				printf("\tInvalid extent header\n\n");
-				continue;
-			}
-		} else {
-			if (!IS_VALID_EXTENT_DATA (ext)) {
-				printf("\tInvalid extent data\n\n");
-				continue;
-			}
-		}
-
-		print_extent(ext, args.twoFourbyte, prev_ptr_error);
-
-		if (flag == EXTENT_HEADER) {
-			if (ext->granularity)
-				traverse_extent(vcb, ext, EXTENT_HEADER);
-			else
-				traverse_extent(vcb, ext, EXTENT_DATA);
-		}
-	}
-
-	free(ext);
-
-    return ;
-}
-
-void traverse_fe_extents(ocfs_super * vcb, ocfs_file_entry *fe)
-{
-	int i, fd;
-	ocfs_extent_group *ext;
-	int type;
-	bool prev_ptr_error;
-
-	if ((ext = malloc_aligned(512)) == NULL) {
-		printf("error: out of memory\n");
-		return ;
-	}
-
-	fd = (int) vcb->sb->s_dev;
-    
-	for (i = 0; i < fe->next_free_ext; i++) {
-		if (!fe->extents[i].disk_off)
-			continue;
-
-		read_extent(fd, ext, fe->extents[i].disk_off);
-
-		if (fe->this_sector != ext->up_hdr_node_ptr)
-			prev_ptr_error = true;
-		else
-			prev_ptr_error = false;
-
-		if (fe->granularity) {
-			if (!IS_VALID_EXTENT_HEADER (ext)) {
-				printf("\tInvalid extent header\n\n");
-				continue;
-			}
-
- 			print_extent(ext, args.twoFourbyte, prev_ptr_error);
-			type = ext->granularity ? EXTENT_HEADER : EXTENT_DATA;
-			traverse_extent(vcb, ext, type);
-		} else {
-			if (!IS_VALID_EXTENT_DATA (ext)) {
-				printf("\tInvalid extent data\n\n");
-				continue;
-			}
- 			print_extent(ext, args.twoFourbyte, prev_ptr_error);
-		}
-	}
-
-	free(ext);
-}
-#endif
-
-/*
- * for LIBDEBUGOCFS: returns the dir offset for FIND_MODE_DIR 
- *                   or the parent dir offset for FIND_MODE_FILE
- * for executable:   finds and prints either the ocfs_dir_node or
- *                   ocfs_file_entry structure, depending upon mode
- */
-void find_file_entry(ocfs_super * vcb, __u64 offset, const char *parent,
-		     const char *searchFor, int mode, filedata *buf)
-{
-    ocfs_dir_node *dir, *foundDir;
-    int i, fd;
-    char *newname;
-    filedata ret;
-    __u64 dirPartOffset;
-
-    fd = (int) vcb->sb->s_dev;
-    dir = (ocfs_dir_node *) malloc_aligned(DIR_NODE_SIZE);
-    dirPartOffset = offset;
-
-    memset(&ret, 0, sizeof(filedata));
-
-    while (1)
-    {
-	if (dirPartOffset == 0)
-	{
-	    /* this is an error, but silently fail */
-	    break;
-	}
-	read_dir_node(fd, dir, dirPartOffset);
-	for (i = 0; i < dir->num_ent_used; i++)
-	{
-	    ocfs_file_entry *fe;
-	    int off = 512;	/* move past the dirnode header */
-
-	    off += (512 * dir->index[i]);
-	    fe = (ocfs_file_entry *) (((void *) dir) + off);
-
-	    if (!fe->sync_flags || (fe->sync_flags & DELETED_FLAGS))
-		    continue;
-
-	    newname =
-		(char *) malloc_aligned(strlen(parent) + strlen(fe->filename) + 2);
-
-	    if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
-	    {
-		sprintf(newname, "%s%s/", parent, fe->filename);
-		if (strcmp(searchFor, newname) == 0)
-		{
-		    if (mode == FIND_MODE_FILE || mode == FIND_MODE_FILE_EXTENT)
-			ret.off = offset;	// return the first part of the dir chain
-		    else if (mode == FIND_MODE_DIR)
-			ret.off = fe->extents[0].disk_off;
-		    else if (mode == FIND_MODE_FILE_DATA)
-			get_file_data_mapping(vcb, fe, &ret);
-
-#ifndef LIBDEBUGOCFS
-		    printf("\tName = %s\n", newname);
-		    if (mode == FIND_MODE_FILE || mode == FIND_MODE_FILE_EXTENT)
-		    {
-			print_file_entry(fe);
-			if (!fe->local_ext && mode == FIND_MODE_FILE_EXTENT)
-				traverse_fe_extents(vcb, fe);
-		    }
-		    else if (mode == FIND_MODE_DIR)
-		    {
-			__u64 dir_off = fe->extents[0].disk_off;
-			foundDir = (ocfs_dir_node *) malloc_aligned(DIR_NODE_SIZE);
-
-			while(1) {
-				read_dir_node(fd, foundDir, dir_off);
-				print_dir_node(foundDir);
-				if (!args.showDirentAll ||
-				    foundDir->next_node_ptr == INVALID_NODE_POINTER)
-					break;
-				dir_off = foundDir->next_node_ptr;
-				memset(foundDir, 0, DIR_NODE_SIZE);
-				printf("dirinfo:\n");
-			}
-			free(foundDir);
-		    }
-#endif
-		    free(newname);
-		    break;
-		}
-		else if (strstr(searchFor, newname) == searchFor)
-		{
-		    find_file_entry(vcb, fe->extents[0].disk_off, newname,
-				    searchFor, mode, &ret);
-		    free(newname);
-		    break;
-		}
-	    }
-	    else		/* not a directory */
-	    {
-		sprintf(newname, "%s%s", parent, fe->filename);
-		if (strcmp(searchFor, newname) == 0)
-		{
-		    if (mode == FIND_MODE_FILE || mode == FIND_MODE_FILE_EXTENT)
-			ret.off = offset;	// return the first part of the dir chain
-		    else if (mode == FIND_MODE_DIR)
-			ret.off = 0;	// file found, not dir 
-		    else if (mode == FIND_MODE_FILE_DATA)
-			get_file_data_mapping(vcb, fe, &ret);
-
-#ifndef LIBDEBUGOCFS
-		    if (mode == FIND_MODE_DIR)
-		    {
-			printf("found a file named %s, not a directory.\n",
-			       newname);
-			exit(1);
-		    }
-		    printf("\tName = %s\n", newname);
-		    print_file_entry(fe);
-		    if (!fe->local_ext && mode == FIND_MODE_FILE_EXTENT)
-			    traverse_fe_extents(vcb, fe);
-#endif
-		    free(newname);
-		    break;
-		}
-	    }
-	    free(newname);
-	}
-	/* is there another directory chained off of this one? */
-	if (dir->next_node_ptr == -1)
-	    break;		// nope, we're done
-	else
-	    dirPartOffset = dir->next_node_ptr;	// keep going
-    }
-
-    free(dir);
-    if (buf)
-	    memcpy(buf, &ret, sizeof(filedata));
-}
-
-
-int suck_file(ocfs_super * vcb, const char *path, const char *file)
-{
-    int fd, newfd, mode, i, ret = 0;
-    filedata data;
-    mode_t oldmask;
-    ocfs_io_runs *run;
-
-    fd = (int) vcb->sb->s_dev;
-    oldmask = umask(0000);
-
-    memset (&data, 0, sizeof(filedata));
-
-    /* del outfile if it already exists */
-    unlink(file);
-
-    if (access(file, F_OK) == -1)
-    {
-	find_file_entry(vcb, vcb->vol_layout.root_start_off, "/",
-			path, FIND_MODE_FILE_DATA, &data);
-
-#if 0
-    if (1) {
-        filedata *p = &data;
-	int i;
-	printf("\n");
-   	for(i=0; i < p->num; ++i)
-	    printf("do=%u.%u, fo=%u, len=%u\n", HILO(p->array[i].disk_off),
-		   p->array[i].offset, p->array[i].byte_cnt);
-    }
-#endif
-
-	if (S_ISLNK(data.mode) && data.linkname)
-	{
-	    newfd = symlink(data.linkname, file);
-	    free(data.linkname);
-	}
-	else if (S_ISFIFO(data.mode) || S_ISCHR(data.mode) ||
-		 S_ISBLK(data.mode))
-	{
-	    if (S_ISFIFO(data.mode))
-		data.major = data.minor = 0;
-	    newfd = mknod(file, data.mode, makedev(data.major, data.minor));
-	}
-	else if (S_ISSOCK(data.mode))
-	{
-	    // unimplemented...
-	}
-	else if (S_ISDIR(data.mode))
-	    newfd = mkdir(file, data.mode);
-	else if (S_ISREG(data.mode))
-	{
-	    void *filebuf = malloc_aligned(FILE_BUFFER_SIZE);
-	    __u32 remaining, readlen, rndup;
-
-	    if (!filebuf) {
-		    ret = -1;
-		    printf("Error: Out of memory\n");
-		    goto do_close;
-	    }
-
-	    newfd = creat(file, data.mode);
-	    if (newfd != -1)
-	    {
-#ifndef LIBDEBUGOCFS
-	        printf("From %s to %s ", path, file);
-#endif
-		for (i = 0; i < data.num; i++)
-		{
-		    run = (ocfs_io_runs *) & (data.array[i]);
-
-		    // in new file: seek to run->Offset
-		    // in ocfs: read from run->disk_off, run->byte_cnt bytes
-		    remaining = run->byte_cnt;
-		    myseek64(fd, run->disk_off, SEEK_SET);
-		    while (remaining > 0)
-		    {
-			readlen =
-			    remaining <
-			    FILE_BUFFER_SIZE ? remaining : FILE_BUFFER_SIZE;
-			/* rndup is reqd because source is read o_direct */
-			rndup = readlen % 512;
-			rndup = (rndup ? 512 - rndup : 0);
-			readlen += rndup;
-
-			if ((ret = myread(fd, filebuf, readlen)) == -1)
-				goto do_close;
-
-			readlen -= rndup;
-			if ((ret = mywrite(newfd, filebuf, readlen)) == -1)
-				goto do_close;
-
-			remaining -= readlen;
-			ret = 0;
-		    }
-#ifndef LIBDEBUGOCFS
-			printf("."); fflush(stdout);
-#endif
-		}
-#ifndef LIBDEBUGOCFS
-		printf("\n"); fflush(stdout);
-#endif
-	    }
-	}
-
-      do_close:
-	if (newfd != -1)
-	    close(newfd);
-	if (chown(file, data.user, data.group) == -1)
-        {
-#ifndef LIBDEBUGOCFS
-	    printf("chown failed!\n");	// error
-#endif
-        }
-    }
-    else
-    {
-	ret = 1;
-    }
-
-  bail:
-    umask(oldmask);
-    return ret;
-}

Copied: trunk/debugocfs/debugocfs.c (from rev 205, trunk/ocfs/debugocfs/debugocfs.c)

Deleted: trunk/debugocfs/debugocfs.h
===================================================================
--- trunk/ocfs/debugocfs/debugocfs.h	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/debugocfs.h	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,176 +0,0 @@
-/*
- * debugocfs.h
- *
- * Function prototypes for related 'C' file.
- *
- * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Author: Kurt Hackel, Sunil Mushran
- */
-
-#ifndef _DEBUGOCFS_H_
-#define _DEBUGOCFS_H_
-
-#define _LARGEFILE64_SOURCE
-#include <libocfs.h>
-#include <bindraw.h>
-
-#define MAX_NODES  OCFS_MAXIMUM_NODES
-#define MAX_SYSTEM_FILES    (CLEANUP_FILE_BASE_ID + OCFS_MAXIMUM_NODES)	/* 193? */
-#define DIR_NODE_SIZE  (1024 * 128)
-
-
-/* modes for find_file_entry */
-enum 
-{
-    FIND_MODE_DIR,
-    FIND_MODE_FILE,
-    FIND_MODE_FILE_EXTENT,
-    FIND_MODE_FILE_DATA
-};
-
-#define DEFAULT_NODE_NUMBER   (0)
-
-#define OCFSCK_BITMAP_OFF           56320LLU    /* block# 110 */
-#define OCFSCK_PUBLISH_OFF          23552LLU    /* block# 46  */
-#define OCFSCK_VOTE_OFF             39936LLU    /* block# 78  */
-#define OCFSCK_AUTOCONF_OFF         4096LLU     /* block# 8 */
-#define OCFSCK_AUTOCONF_SIZE        17408LLU    /* 34 blocks */
-#define OCFSCK_NEW_CFG_OFF          21504LLU    /* block# 42 */
-#define OCFSCK_DATA_START_OFF       1368064LLU  /* block# 2672 */
-#define OCFSCK_INTERNAL_OFF         OCFSCK_DATA_START_OFF
-#define OCFSCK_ROOT_OFF 	    2416640LLU  /* block# 4720 */
-#define OCFSCK_MIN_MOUNT_POINT_LEN  (strlen("/a"))
-#define OCFSCK_END_SECTOR_BYTES     (1022*512)
-#define OCFSCK_NON_DATA_AREA        (OCFSCK_DATA_START_OFF+OCFSCK_END_SECTOR_BYTES)
-#define OCFSCK_MAX_CLUSTERS         (1024*1024*8)  /* maximum 1mb (8megabits) */
-
-typedef struct _user_args
-{
-    int nodenum;
-    int showHeader;
-    int updHeader;
-    int showBitmap;
-    int showPublish;
-    int showVote;
-    int showListing;
-    int showDirent;
-    int showDirentAll;
-    int showFileent;
-    int showFileext;
-    bool no_rawbind;
-    int twoFourbyte;
-    int showSystemFiles;
-    int suckFile;
-    int publishNodes[MAX_NODES];
-    int voteNodes[MAX_NODES];
-    int systemFiles[MAX_SYSTEM_FILES];
-    char *dirent;
-    char *fileent;
-    char *suckTo;
-}
-user_args;
-
-typedef struct _filedata
-{
-    ocfs_io_runs *array;
-    __u32 num;
-    __u64 off;
-    mode_t mode;
-    uid_t user;
-    gid_t group;
-    unsigned int major;
-    unsigned int minor;
-    char *linkname;
-}
-filedata;
-
-/* print functions */
-void print_dir_node(void *buf);
-void print_disk_lock(void *buf);
-void print_vol_label(void *buf);
-void print_vol_disk_header(void *buf);
-void print_publish_sector(void *buf);
-void print_vote_sector(void *buf);
-void print_file_entry(void *buf);
-void print_extent_ex(void *buf);
-void print_extent(void *buf, int twolongs, bool prev_ptr_error);
-void print_cdsl_offsets(void *buf);
-void print_record(void *rec, int type);
-void print_system_file(int fd, ocfs_vol_disk_hdr * v, int fileid);
-
-/* helpers */
-void print_synch_flags(int flags);
-void print_publish_flags(int type);
-void print_vote_type(int type);
-void print_log_type(int type);
-void print_lock_type(__u8 lock);
-void print___u64_as_bitmap(__u64 x);
-void print_node_pointer(__u64 ptr);
-
-void handle_one_file_entry(int fd, ocfs_file_entry *fe, void *buf);
-
-
-ocfs_super *get_fake_vcb(int fd, ocfs_vol_disk_hdr * hdr, int nodenum);
-void walk_dir_nodes(int fd, __u64 offset, const char *parent, void *buf);
-void find_file_entry(ocfs_super * vcb, __u64 offset, const char *parent,
-		     const char *searchFor, int mode, filedata *buf);
-void traverse_fe_extents(ocfs_super * vcb, ocfs_file_entry *fe);
-void traverse_extent(ocfs_super * vcb, ocfs_extent_group * exthdr, int flag);
-
-#if 0
-void read_vol_disk_header(int fd, ocfs_vol_disk_hdr * v);
-int write_vol_disk_header(int fd, ocfs_vol_disk_hdr * v);
-void read_vote_sector(int fd, ocfs_vote * vs, __u64 offset);
-void read_publish_sector(int fd, ocfs_publish * ps, __u64 offset);
-void read_system_file(int fd, ocfs_vol_disk_hdr * v, int fileid,
-		      ocfs_file_entry * fe);
-void read_dir_node(int fd, ocfs_dir_node * d, __u64 offset);
-void read_extent(int fd, ocfs_extent_group * e, __u64 offset);
-void read_cdsl_data(int fd, void *data, __u64 offset);
-void read_vol_label(int fd, ocfs_vol_label * v);
-loff_t myseek64(int fd, loff_t off, int whence);
-int suck_file(ocfs_super * vcb, const char *path, const char *file);
-
-int write_publish_sector(int fd, ocfs_publish * ps, __u64 offset);
-int write_vote_sector(int fd, ocfs_vote * vs, __u64 offset);
-int write_system_file(int fd, ocfs_vol_disk_hdr * v, int fileid,
-		      ocfs_file_entry * fe);
-int write_vol_disk_header(int fd, ocfs_vol_disk_hdr * v);
-int write_vol_label(int fd, ocfs_vol_label * v);
-int write_dir_node_header(int fd, ocfs_dir_node * d, __u64 offset);
-int write_file_entry(int fd, ocfs_file_entry * f, __u64 offset);
-
-
-int ocfs_lookup_file_allocation(ocfs_super * VCB, ocfs_inode * FCB, __s64 Vbo, __s64 * Lbo, __u32 ByteCount, __u32 * NumIndex, void **Buffer);
-int AdjustAllocation(ocfs_io_runs ** IoRuns, __u32 * ioRunSize);
-bool ocfs_add_extent_map_entry(ocfs_super * VCB, ocfs_extent_map * MCB, __s64 Vbo, __s64 Lbo, __u64 ByteCount);
-int ocfs_update_extent_map(ocfs_super * VCB, ocfs_extent_map * MCB, void *Buffer, __s64 * localVbo, __u64 * remainingLength, __u32 Flag);
-int ocfs_read_sector(ocfs_super * vcb, void *buf, __u64 off);
-
-ocfs_file_entry *ocfs_allocate_file_entry();
-void *ocfs_linux_dbg_alloc(int Size, char *file, int line);
-bool ocfs_lookup_extent_map_entry (ocfs_super * osb, ocfs_extent_map * Map, __s64 Vbo, __s64 * Lbo, __u64 * SectorCount, __u32 * Index);
-bool ocfs_extent_map_lookup (ocfs_extent_map * map, __s64 virtual, __s64 * physical, __s64 * sectorcount, __u32 * index);
-#endif
-
-void usage(void);
-int get_default_vol_hdr(int fd, ocfs_vol_disk_hdr *hdr, __u64 device_size);
-int get_device_size(char *device, __u64 *device_size);
-
-#endif

Copied: trunk/debugocfs/debugocfs.h (from rev 205, trunk/ocfs/debugocfs/debugocfs.h)

Deleted: trunk/debugocfs/debugocfs.txt
===================================================================
--- trunk/ocfs/debugocfs/debugocfs.txt	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/debugocfs.txt	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,533 +0,0 @@
-* introduction
-  * what is ocfs?
-  * on-disk structures and layout
-  * using debugocfs to inspect on-disk structures
-* explanation of features
-  * -h : volume header
-  * -g : global bitmap
-  * -v : vote sector
-  * -p : publish sector
-  * -f : ocfs_file_entry structure
-  * -F : ocfs_file_entry and ocfs_extent_group structures
-  * -d : ocfs_dir_node structure
-  * -a : file allocation system file
-  * -A : dir allocation system file
-  * -b : file allocation bitmap system file
-  * -B : dir allocation bitmap system file
-  * -r : recover log file system file
-  * -c : cleanup log system file
-  * -L : vol metadata log system file
-  * -M : vol metadata system file
-* usage scenarios
-  * Before you get started
-  * Erratic behavior or unable to mount
-  * File size, last modified, etc. for a file is incorrect
-  * Deleted file shows in a directory
-  * Non-deleted file does not show
-  * Single filename shows up more than once
-  * Hang occurs while extending/truncating/removing a datafile
-* Disclaimer
-
-
-
-==============================================================
-
-* introduction
-  * what is ocfs?
-
-The Oracle Clustered Filesystem (ocfs) is an open-source project created
-by Oracle to allow RAC database administrators to more easily create and
-set up clustered databases without having to configure raw partitions.
-Unlike raw partitions, the user is presented with a normal filesystem
-interface, and is able to use most normal filesystem structures such as
-directories, regular files and symlinks (hard links are not currently
-implemented).  Database administration activities that are often
-complicated by the use of raw partitions are simplified by the use of
-ocfs, such as resizing, truncating, adding or deleting datafiles.
-Additionally, ocfs is an extent-based filesystem which allows for large
-contiguous allocations, optimal for files such as oracle datafiles.
-
-There are several differences between ocfs and a normal local filesystem
-(such as ext3) that should be taken into consideration.  While a local
-filesystem is able to keep most metadata and data cached in various
-caches at any point in time, ocfs needs to communicate all metadata
-changes to any other mounted nodes when they occur, and for oracle use,
-will also synchronously commit all data to disk as well.  This limits
-ocfs with respect to use as a general-purpose filesystem because
-accesses to ordinary file metadata such as file size or last modified
-date may need to do an IO in order to fetch the information.  This extra
-IO will slow down such accesses considerably.
-
-Another important consideration is that since ocfs is a clustered
-filesystem, it must not only take local locks when making metadata
-changes (using semaphores, etc), but it must also cooperatively lock
-between nodes using a distributed lock manager.  Meanwhile, for crash
-recovery, ocfs also needs to journal critical changes to disk so that
-filesystem structures are not corrupted.  The lock manager (called a
-DLM) which ocfs uses is a simple lock manager which currently uses only
-the ocfs disk partition itself to communicate using a publish-vote
-mechanism.  Each node intending to lock a piece of metadata on disk will
-publish its intent to lock to a specific location on disk.  Meanwhile,
-all nodes will continuously read other nodes' published information and
-cast a vote regarding whether or not there is a conflict that should
-prevent the requestor from getting the lock.
-
-  * on-disk structures and layout
-
-To ensure proper coordination between nodes, ocfs defines a rigid
-on-disk format and specific on-disk structures.
-
-+-+-----+-----+-----+-----------+-------+-------+----
-| |     |     |     |           |       |       | ...
-+-+-----+-----+-----+-----------+-------+-------+----
- ^   ^     ^     ^        ^         ^       ^     
- |   |     |     |        |         |       |
- |   |     |     |        |         |       +-- dir hierarchy
- |   |     |     |        |         +-- system files (see below)
- |   |     |     |        +-- global bitmap 
- |   |     |     +-- vote sectors (32)
- |   |     +-- publish sectors (32)
- |   +-- autoconfig sectors
- +-- disk header
-
-
-The disk header sector acts as the superblock of an ocfs filesystem,
-storing all of the vital information for properly bootstrapping the
-mount.  The disk header stores pointers to each of the following disk
-structures.  If this should be corrupted, you may be unable to mount the
-filesystem or the filesystem may be corrupted.
-
-The autoconfig sectors are used by ocfs to automatically assign
-identities to new nodes as they attach to an ocfs volume.  There are a
-total of 32 slots available, so each node will receive a nodenum between
-0 and 31.  For a given mount you can look at /proc/ocfs/###/nodenum to
-determine your node's number for that volume.  The ### in this case is a
-sequential mount id (which only has meaning on a single node), and to
-determine the mountpoint for this mount you can dump
-/proc/ocfs/###/mountpoint.  The first node to mount an ocfs volume after
-formatting will always be node zero, and no other nodes are allowed to
-attach to this volume while the ocfs partition is prepared the first
-time.
-
-After the autoconfig sectors, there are 32 publish sectors followed by
-32 vote sectors.  Upon mounting, a node mangager daemon (ex. [ocfsnm-0])
-will be started and will continually update a timestamp in the publish
-sector for this node, as well as read each of the other publish sectors.
-This allows for one daemon to handle both node monitoring (checking if a
-node is dead and needs recovery) and lock management simultaneously, at
-approximately 1/2 second intervals.  If the ocfsnm detects that a node
-has requested a vote for a certain resource, it will find the status of
-that resource on the local node to determine whether or not to allow the
-other node to take the lock.  Once the determination has been made, the
-ocfsnm will write its response into the corresponding vote sector, and
-the process which requested the lock on the other node will collect up
-all responses and decide whether the lock can be taken, cannot be taken,
-or should be retried.
-
-As ocfs is an extent-based filesystem, a bitmap of all extents in the
-filesystem is stored just after the vote sectors.  The extent size is
-chosen at format time, and the maximum number of possible extents is
-bounded at 8 million (since the global bitmap is 1MB max).  When
-choosing a cluster size, one should take into consideration the maximum
-size to which the ocfs partition is likely to grow, and also the degree
-of contiguousness desired.  For instance, a standard ocfs clustersize is
-128 KB, which means that even with a highly fragmented file you will at
-least get 128k of oracle data in one contiguous chunk.  On a 32GB
-partition, you would end up with about 32 thousand total extents with a 
-1mb cluster size, 250 thousand with a 128k cluster size, and 8 million
-with a 4k cluster size.  If you plan on having many small files (not
-recommended) or plan on using autoextended datafiles, you may wish to
-format with a smaller cluster size to maximize the number of total
-extents.  If you plan on having fewer files of large size and intend to
-manually extend these files in large chunks, you should choose a larger 
-cluster size to increase contiguousness.
-
-The system files which follow the global bitmap a laid out as follows:
-
-+---+---+---+---+---+---+---+---+
-|   |   |   |   |   |   |   |   |
-+---+---+---+---+---+---+---+---+
-  ^   ^   ^   ^   ^   ^   ^   ^
-  |   |   |   |   |   |   |   |
-  |   |   |   |   |   |   |   +-- cleanup log
-  |   |   |   |   |   |   +-- recover log
-  |   |   |   |   |   +-- file extent bitmap
-  |   |   |   |   +-- file extent data
-  |   |   |   +-- dir bitmap
-  |   |   +-- dir data
-  |   +-- volume metadata log 
-  +-- volume metadata 
-
-For each system file type there are 32 file entries, one for each
-possible node in the cluster.  The first two types (volume metadata and
-volume metadata log) are not used in the current version of ocfs.
-
-The directory data and directory bitmap system files are used to
-sub-allocate space from the global bitmap for use as directory
-structures.  These structures are always 128k in size.  Space is
-allocated to the directory data file from the global bitmap in chunks, 
-then allocated by checking against the directory bitmap for free bits.
-
-The file extent data and file extent bitmap system files serve a similar
-purpose to the directory system files, except that they sub-allocate in
-512 byte segments.  These structures are used by ocfs for creating
-indirect extent trees for files which are fragmented beyond 3 extents.
-Space is directly allocated to these files from the global bitmap, and
-the file extent bitmap files keep track of free and used 512 byte
-chunks.
-
-The two logfiles together constitute a per-node journalling system. We
-journal filesystem metadata changes so that in the case of a
-catosrophic event (system crash, power outage, etc) we can recover the
-filesystem quickly and cleanly.
-Both logfiles consist of a stream of records. Each one has distinct
-record types, though some record types are shared.
-
-The recover log is filled with records which will be processed in the
-case that we have to abort an operation. In this case, the records in
-the cleanup log pertaining to that operation would be ignored.
-
-The cleanup log is filled with records which will be processed in the
-case that we want to commit an operation. In this case, the records in
-the recover log pertaining to that operation would be ignored.
-
-Each node has two log files, and in the case that a node crashes, one
-of the other live nodes in the cluster will process it's logs in order
-to complete or abort any operations it was doing.
-
-Finally, following the system files, the actual directory hierarchy
-begins:
-
-+---+---+---+        +---+---+
-|   |   |   | ...... |   |   | 
-+---+---+---+        +---+---+
-  ^   ^   ^            ^   ^
-  |   |   |            |   | 
-  |   |   |            |   +-- file entry #255
-  |   |   |            +-- file entry #254
-  |   |   +-- file entry #2
-  |   +-- file entry #1
-  +-- directory header
-
-The entire directory structure is 128k in size, made of 256 512-byte
-entries.  When a directory fills beyond 255 files, another 128k
-structure must be allocated somewhere on disk from the directory
-data/bitmap system files.  This pointer will be chained on to the first
-directory structure using a field in the directory header.  This header
-also contains information about the number of valid file entries, and
-also an alpha-sorted index of filenames within this 128k structure.
-
-Each file entry contains all the information needed to make up a valid
-inode: name, size, type, permissions, etc.  It also contains extent
-information which describes pointers to each of the extents which make 
-up the total allocation for the file.  Three of these extents can exist
-in the file entry itself, and will be migrated to an indirect tree
-structure if the file grows beyond the third extent.
-
-In addition to the fields described, all file entries (including those
-for each system file), each directory header, and some additional
-special sectors used for locking the global bitmap and other structures
-all contain a disk lock structure.  This is the persistent lock
-information used by any process requesting a lock on a filesystem
-structure.  This locking info includes the node number of the current
-lock owner, the lock level, and a bitmap of nodes which have an open
-file handle to a given file entry.
-  
-
-  * using debugocfs to inspect on-disk structures
-
-To debug any hangs or inconsistencies that you may find while using
-ocfs, the debugocfs tool can be used to inspect all of the filesystem
-structures above.  When using this tool, you need to have read access to
-the device on which the filesystem was created.  If you are debugging an
-issue in which you suspect that some degree of caching is preventing a
-node from seeing the most current data (ex. file size does not match
-on two separate nodes), then you should bind a raw device to the block
-device first and run debugocfs on this raw device instead.
-
-       -g: global bitmap
-       -l: full listing of all file entries
-       -v: vote sector
-       -p: publish sector
-       -d: ocfs_dir_node structure for a given path
-       -f: ocfs_file_entry structure for a given file
-       -s: suck file out to a given location
-       -a: file allocation system file
-       -A: dir allocation system file
-       -b: file allocation bitmap system file
-       -B: dir allocation bitmap system file
-       -r: recover log file system file
-       -c: cleanup log system file
-       -L: vol metadata log system file
-       -M: vol metadata system file
-       -n: perform action as node number given
-
-
-* explanation of features
-  * -h : volume header
-Displays the first 2 sectors on an ocfs volume: the vol disk header and
-volume label structures.  The pointers in the disk header (ex.  bitmap_off) 
-should not change after the first mount.
-  * -g : global bitmap
-Shows statistics about the global bitmap and the state of each bit
-within it.
-  * -v : vote sector
-Prints the last vote written out by the selected node.  This will show
-the disk offset (in bytes) to the resource upon which the lock was
-requested, the sequence number of the lock (used to ensure uniqueness),
-the vote cast and the node for which the vote was cast.
-  * -p : publish sector
-Shows any vote request for a particular node (the vote, vote_type, 
-vote_map, seq_num, and dir_ent fields will be set) as well as an updated 
-timestamp for this node.  This timestamp is not actually a date (and 
-debugocfs may erroneously show it as such) but merely a tick count which 
-must continually increment for other nodes to acknowledge that this node 
-is still alive.  When watching the publish and vote sectors for lock 
-requests, the dir_ent field will tell you which disk offset is being 
-requested.
-  * -f : ocfs_file_entry structure
-  * -F : ocfs_file_entry and ocfs_extent_group structures
-Prints several fields for a given inode within the filesystem.  The path
-used for this file should be relative to the mountpoint.  For example,
-if an ocfs filesystem is mounted at /ocfs, the file in question is
-/ocfs/a/b/c, and the filesystem is on device /dev/sda1, you should run 
-"debugocfs -f /a/b/c /dev/sda1".  This will display not only the lock
-state info for the file (curr_master, file_lock, oin_node_map, seq_num),
-but also the normal unix file information such as size, owner,
-permissions, filename, creation/modification date, and file type flags.
-In addition, this command will show information regarding the data
-extents used to piece the file data together (up to 3 extents with
-file_off, num_bytes and disk_off), the alloc_size (the maximum size to
-which the file can grow before more extents need to be added), and the
-local_ext and granularity flags.  If local_ext is true (and granularity
-is -1) then the 3 extents listed point directly to the data.  Using this
-information one could dump num_bytes of data, seeking disk_off bytes into
-the device for each of these extents in order to piece the file data
-together.  If local_ext is false, the granularity will represent the
-number of levels in an indirect tree above the actual pointers to extent
-data.  If the -F option is used (instead of -f), a printout of the
-entire extent tree will be given, which will include the file entry at
-the top of the tree, extent data (EXTDAT) structures at the bottom of
-the tree pointing directly to data, and if necessary some extent header
-(EXTHDR) structures in the middle of the tree pointing to either more
-EXTHDRs or EXTDATs, depending upon the level within the tree.  This
-command may be used on any type of file, including directories.  When
-specifying a directory make sure to use a trailing slash (/).
-Directories will only have one extent listed, and the disk_off for this
-extent will point to the beginning of the actual 128k directory block.
-  * -d : ocfs_dir_node structure
-Shows the header information for a directory (first 512 bytes).  This
-will show the number of valid entries in this 128k block (num_ent_used),
-the pointer to the next block in the directory chain (next_node_ptr, if
-more than 255 file entries), and several fields used for effecient
-deletion and renaming of files (first_del, num_del).  In addition, the
-alphasorted index of filenames will be shown as well as the index_dirty
-flag which shows whether the index needs to be recreated.  The
-alloc_file_off and alloc_node fields are used when a directory is
-deleted to determine to which dir alloc system file to release the
-space.  The node_disk_off field points back up to the file entry for
-this directory.  The syntax for this command is exactly like the -f/-F
-commands, and one should also ensure that the directory name uses a
-trailing slash (/).
-
-  * -a : file allocation system file
-  * -A : dir allocation system file
-  * -b : file allocation bitmap system file
-  * -B : dir allocation bitmap system file
-  * -r : recover log file system file
-  * -c : cleanup log system file
-  * -L : vol metadata log system file
-  * -M : vol metadata system file
-These options show the ocfs_file_entry structure for the requested
-system file for any number of nodes.  The fields shown are exactly the
-same as those in the -f/-F options.  For the bitmap types, special
-bitmap statistics and free/set bit information will also be shown.
-
-
-* usage scenarios
-
-  * Before you get started
-Before you encounter any problems with an ocfs filesystem, it would 
-be wise to inspect the disk header and familiarize yourself with the 
-values shown (or save the output to a file), since they will not 
-change after the first mount.  To print this sector, run:
-  debugocfs -h /dev/device
-For recovery purposes, you may even want to save off this critical
-sector in case it ever becomes corrupted using the following command:
-  dd if=/dev/device of=diskhdr.bak bs=512 count=1
-and if you need to restore this sector:
-  dd if=diskhdr.bak of=/dev/device bs=512 count=1
-
-  * Erratic behavior or unable to mount
-If you are unable to mount an ocfs partition or it seems that there is
-inconsistent behavior with the filesystem, the first thing to check is
-the volume header.  Check the header using this command:
-  debugocfs -h /dev/device
-All of the _off parameters are byte offsets on the device and should be
-within range for that device (should all be less than device_size).  The
-cluster_size, permissions, owner and mountpoint should match the values
-chosen at format time.  The following fields will always be zero:
-serial_num, start_off, root_bitmap_off, root_bitmap_size, root_size,
-dir_node_size, file_node_size.  If any of these fields looks as if it
-has been overwritten or zeroed, you should consider restoring at least
-the first block of the disk as soon as possible.  The output from this
-debugocfs command should be included in a bug report.
-If the header is intact, other structures to check include the cleanup
-and recover log files.  Before running debugocfs, first determine your
-node number from the output of:
-  cat /proc/ocfs/##/mountpoint  and
-  cat /proc/ocfs/##/nodenum
-matching up the mountpoint to determine the proper mount number.  Once
-you have determined your nodenum for this volume, you can run:
-  debugocfs -r nodenum -c nodenum /dev/device
-to inspect the recover and cleanup logs for this node.  Under normal
-circumstances, the file_size for each of these should be zero.  During
-an active transaction this size may increase to as much as about 1MB,
-but if it grows much beyond this the time to complete recovery may be
-very long and seem like a hang.  You can watch this file size over time
-to ensure that it is reducing using a command such as:
-  watch -d "debugocfs -r nodenum -c nodenum /dev/device | grep file_size" 
-You may also specify a list or range of node numbers (ex. 7,8-10).
-
-  * File size, last modified, etc. for a file is incorrect
-Due to the nature of a clustered filesystem it is sometimes a challenge
-to keep the caching that the linux VFS provides from interfering.  You
-may at some point encounter a file which has different inode properties
-on different nodes.  To determine what is actually committed to disk,
-versus what is currently visible in the filesystem, you should first run
-an 'ls -lai filename', and then run:
-  debugocfs -f /path/to/file /dev/device
-on each node.  If the debugocfs information is different between the two
-nodes also, you may need to first bind the device to a raw device first
-in order to see the actual data on disk (this will ensure that an io is
-actually completed, bypassing the linux pagecache).  Read the man(8)
-manpage for info on how to bind a raw device, and make sure to download
-the debugocfs fixed for raw device support (ARU #XXXXXXX).
-Once you have collected all of this information you should submit a bug
-with all of this data and information on what filesystem actions were
-done on this file and on which nodes.  (ex. datafile was created on node
-0, extended by node 1, then truncated by node 0)  The disk should always
-hold the "correct" information, so unmounting the filesystem and
-remounting it is likely to correct such a problem.
-
-  * Deleted file shows in a directory
-  * Non-deleted file does not show
-  * Single filename shows up more than once
-These types of issues suggest that there is a problem with either the
-flags on a file entry or the index of the parent directory.  You will
-have to inspect several different filesystem structures to get a
-complete picture.  First, run:
-  debugocfs -d /parent/directory/ /dev/device    and
-  debugocfs -f /parent/directory/filename /dev/device
-From the '-d' output, if next_node_ptr is INVALID_NODE_POINTER then the
-directory is allocated in only one block (<256 file entries).  Otherwise
-this field will point to the next directory block in the chain.  To dump
-each successive block you can execute:
-  debugocfs -X -h hi -l lo -t ocfs_dir_node /dev/device
-where hi and lo represent the high and low order 32-bit values which
-make up the 64-bit quantity in next_node_ptr (ex. 34629255680 is hi=8,
-lo=269517312).  This can be done for each block in the directory chain
-to find files deeper than the first block.  
-The '-f' output will either show you a normal file entry or it may not
-show any output at all.  If it does not print the file entry this means
-that the filename was not found in any of the indexes of the
-directories.  It may be that the name can still be found somewhere
-within one of the blocks, but the index has been updated to no longer
-include this entry when searching or listing.  If you need to look at
-the raw data in the directory, you can do:
-  dd if=/dev/device of=dirdump bs=512 count=256 skip=<dir offset/512>
-for any/all of the directory blocks.  Or another method that can be used
-is to use the
-  debugocfs -X -h hi -l lo -t ocfs_file_entry /dev/device
-command to "cast" a given disk block to the ocfs_file_entry type.  As an
-example, let's say that the directory block you are looking at is at
-offset 34629255680.  This means that there will be a 512-byte header at
-that offset, followed by 255 512-byte file entries.  Also assume that
-the num_ent_used in this case is 9, and the index looks like 
-"2   4   0   7   3   1   5   6   8".  To look at each file entry in
-order, begin with the dir offset (34629255680), then add 512 to skip
-over the header (34629256192).  This is the location of entry #0, and
-each subsequent entry will follow 512 bytes later.  To examine each of
-the 9 files in this directory you could run (in bash):
-  first=34629256192; hi=0; lo=0; off=0; fourgb=4294967296
-  for i in 2 4 0 7 3 1 5 6 8; do 
-    off=`echo "$first + ($i * 512)" | bc`
-    hi=`echo "$off / $fourgb" | bc`
-    lo=`echo "$off % $fourgb" | bc`
-    debugocfs -X -h $hi -l $lo -t ocfs_file_entry echo $off $hi $lo
-  done
-If you need to inspect file entries which seem to have been deleted (and
-thus do not show up in the index), you can change the for statement to:
-  for ((i=0; i<255; i++)); do ...
-This will allow you to look at every block within the directory
-regardless of whether it is currently valid.  Information to look out
-for include the sync_flags field (should be OCFS_SYNC_FLAG_VALID on a
-normal file entry, may be one of the following for a deleted file: 
-OCFS_SYNC_FLAG_DELETED, OCFS_SYNC_FLAG_MARK_FOR_DELETION, 
-OCFS_SYNC_FLAG_NAME_DELETED) and the modify_time.  This may give you
-some indication of what caused the problem and when it occurred.
-If you encounter a situation where a filename appears more than once
-when doing a readdir (ls) it is very likely that there is a repeated
-entry within the directory index (ex. 2 4 0 7 7 1 5 6 8, 7 repeats).
-This may also manifest itself as a spuriously deleted file since this
-type of corruption would likely wipe out one file entry in order to
-double up another.
-Finally, you may see a problem when doing an 'ls -l' where it seems that
-the readdir() command has correctly returned one or more filenames, but
-the subsequent stat() that ls does on each file will fail on at least
-one of these.  This will show up as stderr output at the top of the 'ls'
-listing similar to:
-  ls: filename: No such file or directory
-This error indicates that the index within a directory block is in need
-of reindexing, and while all the files within the directory are still ok
-and intact, the alphasorted index needs to be resorted.  During certain
-operations on the directory (create, delete, rename) the index_dirty
-flag will get set to indicate that this needs to be recreated, but in
-certain very rare crashes it has been found that this fails to happen.
-
-
-  * Hang occurs while extending/truncating/removing a datafile
-Another common case where database administrators have seen issues when
-running ocfs has been in deadlock conditions or runaway lock requests
-when trying to get an exclusive lock on a datafile.  In some cases this
-has been found to even lock out all future lock requests on that node,
-including such things as doing an 'ls' on a directory.
-To diagnose such an issue, you should first examine the file entry on
-which the hang is happening using the methods above:
-  debugocfs -f /path/to/file /dev/device
-Of particular interest here are the curr_master and file_lock fields.
-The curr_master may be any valid node in the system or may be -1 (or
-INVALID) meaning that noone has ownership of the lock.  The file_lock
-may be one of OCFS_DLM_ENABLE_CACHE_LOCK, OCFS_DLM_EXCLUSIVE_LOCK,
-OCFS_DLM_SHARED_LOCK, or OCFS_DLM_NO_LOCK.  For the current version of
-ocfs, the ENABLE_CACHE and EXCLUSIVE levels should be treated the same,
-meaning that a particular node has an exclusive lock on this resource
-and has full write access to the metadata.  The SHARED lock is only used
-for readdir() operations currently, and NO_LOCK means that there are no
-nodes currently with a lock on this entry.
-Additionally, you will want to look at the publish and vote sectors for
-all nodes that you suspect are involved in the hang.  For instance, if
-you believe that node numbers 0 and 3 are deadlocked on a resource, you
-should run:
-  debugocfs -v 0,3 -p 0,3 /dev/device
-to see which node is requesting votes (in their publish sector) and what
-the other node (the voting node) is responding with.  Unless a node is
-responding with FLAG_VOTE_NODE (in the vote slot for the requesting
-node) or FLAG_VOTE_OIN_UPDATED then the requesting node may be forced to
-continue retrying the lock until the conflict is resolved.  To watch
-these values change over time, try:
-  watch -d --interval=1 "debugocfs -v 0,3 -p 0,3 /dev/device"
-in order to see if the lock sequence number is changing, and whether
-only one node is requesting votes (and starving out others).
-
-
-* Disclaimer
-Note that while all of these techniques can be used to help Oracle
-Support or Engineering determine the root cause of a problem with ocfs,
-one should not attempt to modify an ocfs filesystem by hand, and could
-result in further corruption of the filesystem.  Only attempt such an
-action if specifically asked to by Support.  With that said, it is
-worthwhile to note that it is extremely rare that one will encounter any
-problems whereby an oracle datafile's *data* will actually be corrupted.
-Most hangs, file entry and directory entry corruptions can be repaired,
-if necessary, for the purposes of recovering file data.

Copied: trunk/debugocfs/debugocfs.txt (from rev 205, trunk/ocfs/debugocfs/debugocfs.txt)

Deleted: trunk/debugocfs/extfinder.c
===================================================================
--- trunk/ocfs/debugocfs/extfinder.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/extfinder.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,266 +0,0 @@
-/*
- * extfinder.c
- *
- * Lists the free extent sizes of an ocfs volume
- *
- * Copyright (C) 2003, 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#include "debugocfs.h"
-#include "glib.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-int bmrun_reversesort(const void *a, const void *b);
-void print_global_bitmap_runs(int fd, void *buf);
-int read_vol_disk_header(int fd, ocfs_vol_disk_hdr * v);
-
-int extents_to_print = 0;
-int verbose = 0;
-
-int fd = -1;
-char rawdev[255];
-int rawminor = 0;
-
-typedef struct _bitmap_run
-{
-	int start;
-	int size;
-} bitmap_run;
-
-
-#define MAX_BITMAP_RUNS 10
-
-
-int bmrun_reversesort(const void *a, const void *b)
-{
-	bitmap_run *one, *two;
-	one = (bitmap_run *)a;	
-	two = (bitmap_run *)b;
-	if (one->size < two->size)
-		return 1;
-	else if (one->size == two->size)
-		return 0;
-	else 
-		return -1;
-}
-
-
-void print_global_bitmap_runs(int fd, void *buf)
-{
-//	__u64 dso, cs, num;
-	char *bmbuf = NULL;
-	int bufsz;
-	ocfs_vol_disk_hdr * v = (ocfs_vol_disk_hdr *)buf;
-	int non_sysfile, sysfile;
-	int i;
-	bitmap_run run;
-	GArray *arr = NULL;
-	
-	arr = g_array_new(TRUE, TRUE, sizeof(bitmap_run));
-	if (!arr) {
-		LOG_ERROR("out of memory");
-		goto bail;
-	}
-
-//	dso = v->data_start_off;
-//	cs = v->cluster_size;
-//	num = v->num_clusters;
-//	bufsz = (num+7)/8;
-	bufsz = 1024 * 1024;
-	bmbuf = (char *)malloc_aligned(bufsz); 
-	if (!bmbuf) {
-		LOG_ERROR("out of memory");
-		goto bail;
-	}
-
-	if (lseek64(fd, v->bitmap_off, SEEK_SET) == -1) {
-		LOG_ERROR("%s", strerror(errno));
-		goto bail;
-	}
-		
-	if (read(fd, bmbuf, bufsz) == -1) {
-		LOG_ERROR("%s", strerror(errno));
-		goto bail;
-	}
-
-	if (verbose) {
-		printf("bitmap_off = %llu\n", v->bitmap_off);
-		printf("data_start_off = %llu\n", v->data_start_off);
-		printf("cluster_size = %llu\n", v->cluster_size);
-		printf("num_clusters = %llu\n", v->num_clusters);
-	}
-   
-	sysfile = ((8 * ONE_MEGA_BYTE) / v->cluster_size);
-	non_sysfile = v->num_clusters - sysfile;
-	if (non_sysfile < 0)
-			non_sysfile = 0;
-
-	run.start = -1;
-	run.size = 0;
-	for (i = 0; i < non_sysfile; i++) {
-		if (!test_bit(i, (unsigned long *)bmbuf)) {
-			run.size++;
-			if (run.start==-1)
-				run.start = i;
-		}
-		else {
-			if (run.start != -1 && run.size != 0) {
-				g_array_append_val(arr, run);
-				run.start = -1;
-				run.size = 0;
-			}
-		}
-	}
-
-	if (run.start != -1)
-		g_array_append_val(arr, run);
-
-	printf("Runs of contiguous free space available (decending order)\n");
-	printf("Run #\tLength (KB)\tStarting bit number\n");
-	printf("=====\t===========\t===================\n");
-	if (arr->len > 0) {
-		qsort(arr->data, arr->len, sizeof(bitmap_run), bmrun_reversesort);
-    		for (i = 0; i < (arr->len > extents_to_print ?
-				 extents_to_print : arr->len); i++) {
-			bitmap_run *run = &g_array_index(arr, bitmap_run, i);
-			__u64 kb = (((__u64)run->size) * v->cluster_size) / 1024ULL;
-			printf("%5d\t%11llu\t%-9d\n", i+1, kb, run->start);
-		}
-	}
-bail:
-	if (arr)
-		g_array_free(arr, FALSE);
-
-	if (bmbuf)
-		free_aligned(bmbuf);
-	return ;
-}
-
-int read_vol_disk_header(int fd, ocfs_vol_disk_hdr * v)
-{
-	int ret = -1;
-
-	if (lseek64(fd, 0, SEEK_SET) == -1) {
-		LOG_ERROR("%s", strerror(errno));
-		goto bail;
-	}
-
-	if (read(fd, v, 512) == -1) {
-		LOG_ERROR("%s", strerror(errno));
-		goto bail;
-	}
-
-	if (strncmp(v->signature, "OracleCFS", strlen("OracleCFS")) != 0) {
-		LOG_ERROR("not a valid ocfs partition");
-		goto bail;
-	}
-
-	ret = 0;
-
-bail:
-	return ret;
-}
-
-void usage()
-{
-    printf("usage: extfinder /dev/device\n");
-}
-
-void version(char *prog)
-{
-    printf("%s %s %s (build %s)\n", prog,
-	   OCFS_BUILD_VERSION, OCFS_BUILD_DATE,
-	   OCFS_BUILD_MD5);
-}
-
-void handle_signal(int sig)
-{
-    switch (sig) {
-    case SIGTERM:
-    case SIGINT:
-	if (fd != -1)
-	    close(fd);
-	if (rawminor)
-	    unbind_raw(rawminor);
-	exit(1);
-    }
-}
-
-/* uh, main */
-int main(int argc, char **argv)
-{
-    ocfs_vol_disk_hdr *diskHeader = NULL;
-
-#define INSTALL_SIGNAL(sig)					\
-    do {							\
-	if (signal(sig, handle_signal) == SIG_ERR) {		\
-	    fprintf(stderr, "Could not set " #sig "\n");	\
-	    goto bail;						\
-	}							\
-    } while (0)
-
-    INSTALL_SIGNAL(SIGTERM);
-    INSTALL_SIGNAL(SIGINT);
-
-    init_raw_cleanup_message();
-
-    version(argv[0]);
-
-    if (argc < 2) {
-	usage();
-	goto bail;
-    }
-
-    if (argc==3)
-	extents_to_print = atoi(argv[2]);
-
-    if (extents_to_print <= 0)
-        extents_to_print = MAX_BITMAP_RUNS;
-
-    diskHeader = (ocfs_vol_disk_hdr *) malloc_aligned(512);
-    if (!diskHeader) {
-	    LOG_ERROR("out of memory");
-	    goto bail;
-    }
-
-    if (bind_raw(argv[1], &rawminor, rawdev, sizeof(rawdev)) == -1)
-	    goto bail;
-
-    fd = open(rawdev, O_RDONLY);
-    if (fd == -1) {
-	usage();
-	goto bail;
-    }
-
-    if (read_vol_disk_header(fd, diskHeader) == -1)
-	    goto bail;
-
-    print_global_bitmap_runs(fd, diskHeader);
-
-bail:
-    if (diskHeader)
-	    free_aligned(diskHeader);
-    if (fd != -1)
-	    close(fd);
-    if (rawminor)
-	    unbind_raw(rawminor);
-    exit(0);
-}

Copied: trunk/debugocfs/extfinder.c (from rev 205, trunk/ocfs/debugocfs/extfinder.c)

Deleted: trunk/debugocfs/io.c
===================================================================
--- trunk/ocfs/debugocfs/io.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/io.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,251 +0,0 @@
-/*
- * io.c
- *
- * provides the actual file I/O support in debugocfs and
- * libdebugocfs for specific filesystem structures
- *
- * Copyright (C) 2002 Oracle Corporation.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Author: Kurt Hackel
- */
-
-#include "debugocfs.h"
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-extern int filenum;
-extern user_args args;
-extern __u32 OcfsDebugCtxt;
-extern __u32 OcfsDebugLevel;
-
-int myread(int file, char *buf, __u32 len)
-{
-	int ret = 0;
-	char *p = buf;
-	__u32 remlen = len;
-
-	while(remlen) {
-		ret = read(file, p, remlen);
-		if (ret == -1) {
-			printf("Failed to read: %s\n", strerror(errno));
-			goto bail;
-		}
-		remlen -= ret;
-		p += ret;
-	}
-
-bail:
-	return ret;
-}
-
-int mywrite(int file, char *buf, __u32 len)
-{
-	int ret = 0;
-	char *p = buf;
-	__u32 remlen = len;
-
-	while(remlen) {
-		ret = write(file, p, remlen);
-		if (ret == -1) {
-			printf("Failed to write: %s\n", strerror(errno));
-			goto bail;
-		}
-		remlen -= ret;
-		p += ret;
-	}
-
-bail:
-	return ret;
-}
-
-loff_t myseek64(int fd, loff_t off, int whence)
-{
-    loff_t res;
-
-    if ((res = lseek64(fd, off, whence) == -1))
-    {
-	printf("Failed to lseek to %lld!\n", off);
-    }
-    return res;
-}
-
-void read_publish_sector(int fd, ocfs_publish * ps, __u64 offset)
-{
-    myseek64(fd, offset, SEEK_SET);
-    read(fd, ps, 512);
-}
-
-int write_publish_sector(int fd, ocfs_publish * ps, __u64 offset)
-{
-    int ret;
-    void *sector;
-
-    sector = malloc_aligned(512);
-    memset(sector, 0, 512);
-    memcpy(sector, ps, sizeof(ocfs_publish));
-    myseek64(fd, offset, SEEK_SET);
-    ret = write(fd, sector, 512);
-    free_aligned(sector);
-    return ret;
-}
-
-
-void read_vote_sector(int fd, ocfs_vote * vs, __u64 offset)
-{
-    myseek64(fd, offset, SEEK_SET);
-    read(fd, vs, 512);
-}
-
-int write_vote_sector(int fd, ocfs_vote * vs, __u64 offset)
-{
-    int ret;
-    void *sector;
-
-    sector = malloc_aligned(512);
-    memset(sector, 0, 512);
-    memcpy(sector, vs, sizeof(ocfs_vote));
-    myseek64(fd, offset, SEEK_SET);
-    ret = write(fd, sector, 512);
-    free_aligned(sector);
-    return ret;
-}
-
-void read_system_file(int fd, ocfs_vol_disk_hdr * v, int fileid,
-		      ocfs_file_entry * fe)
-{
-    __u64 diskOffset = (fileid * 512) + v->internal_off;
-
-    myseek64(fd, diskOffset, SEEK_SET);
-    read(fd, fe, 512);
-}
-
-int write_system_file(int fd, ocfs_vol_disk_hdr * v, int fileid,
-		      ocfs_file_entry * fe)
-{
-    int ret;
-    void *sector;
-    __u64 diskOffset = (fileid * 512) + v->internal_off;
-
-    sector = malloc_aligned(512);
-    memset(sector, 0, 512);
-    memcpy(sector, fe, sizeof(ocfs_file_entry));
-    myseek64(fd, diskOffset, SEEK_SET);
-    ret = write(fd, sector, 512);
-    free_aligned(sector);
-    return ret;
-}
-
-void read_vol_disk_header(int fd, ocfs_vol_disk_hdr * v)
-{
-    myseek64(fd, 0, SEEK_SET);
-    //read(fd, v, sizeof(ocfs_vol_disk_hdr));
-    read(fd, v, 512);
-}
-
-int write_vol_disk_header(int fd, ocfs_vol_disk_hdr * v)
-{
-    int ret;
-    void *sector;
-
-    sector = malloc_aligned(512);
-    memset(sector, 0, 512);
-    memcpy(sector, v, sizeof(ocfs_vol_disk_hdr));
-    myseek64(fd, 0, SEEK_SET);
-    ret = write(fd, sector, 512);
-    free_aligned(sector);
-    return ret;
-}
-
-void read_vol_label(int fd, ocfs_vol_label * v)
-{
-    myseek64(fd, 512, SEEK_SET);
-    //read(fd, v, sizeof(ocfs_vol_label));
-    read(fd, v, 512);
-}
-
-int write_vol_label(int fd, ocfs_vol_label * v)
-{
-    int ret;
-    void *sector;
-
-    sector = malloc_aligned(512);
-    memset(sector, 0, 512);
-    memcpy(sector, v, sizeof(ocfs_vol_label));
-    myseek64(fd, 512, SEEK_SET);
-    ret = write(fd, sector, 512);
-    free_aligned(sector);
-    return ret;
-}
-
-void read_extent(int fd, ocfs_extent_group * e, __u64 offset)
-{
-    myseek64(fd, offset, SEEK_SET);
-    if (read(fd, e, 512) != 512)
-        printf("hmm... short read for extent\n");
-}
-
-
-void read_dir_node(int fd, ocfs_dir_node * d, __u64 offset)
-{
-    int err;
-
-    myseek64(fd, offset, SEEK_SET);
-    err = read(fd, d, DIR_NODE_SIZE);
-    if (err == -1)
-	    fprintf(stderr, "read_dir_node: %s\n", strerror(errno));
-    else if (err != DIR_NODE_SIZE)
-	    printf("hmm... short read for dir node\n");
-}
-
-int write_dir_node_header(int fd, ocfs_dir_node * d, __u64 offset)
-{
-    int ret;
-    void *sector;
-
-    sector = malloc_aligned(512);
-    memset(sector, 0, 512);
-    memcpy(sector, d, sizeof(ocfs_dir_node));
-    myseek64(fd, offset, SEEK_SET);
-    ret = write(fd, sector, 512);
-    free_aligned(sector);
-    return ret;
-}
-
-int write_file_entry(int fd, ocfs_file_entry * f, __u64 offset)
-{
-    int ret;
-    void *sector;
-
-    sector = malloc_aligned(512);
-    memset(sector, 0, 512);
-    memcpy(sector, f, sizeof(ocfs_file_entry));
-    myseek64(fd, offset, SEEK_SET);
-    ret = write(fd, sector, 512);
-    free_aligned(sector);
-    return ret;
-}
-
-
-void read_cdsl_data(int fd, void *data, __u64 offset)
-{
-    int len = sizeof(__u64) * MAX_NODES;
-
-    myseek64(fd, offset, SEEK_SET);
-    if (read(fd, data, len) != len)
-	printf("hmm... short read for cdsl data\n");
-}

Copied: trunk/debugocfs/io.c (from rev 205, trunk/ocfs/debugocfs/io.c)

Deleted: trunk/debugocfs/libdebugocfs.c
===================================================================
--- trunk/ocfs/debugocfs/libdebugocfs.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/libdebugocfs.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,404 +0,0 @@
-#include "debugocfs.h"
-#include <time.h>
-#include <sys/raw.h>
-#include "glib.h"
-#include "libdebugocfs.h"
-
-#define FILE_NAME_SIZE 255
-
-/* XXX: Not really thread safe */
-static int rawminor = 0;
-static char rawdev[FILE_NAME_SIZE];
-
-int libocfs_init_raw(void)
-{
-    /* Hmm... is /dev/null really ok? */
-    return bind_raw("/dev/null", &rawminor, rawdev, FILE_NAME_SIZE);
-}
-
-int libocfs_cleanup_raw(void)
-{
-    unbind_raw(rawminor);
-}
-
-static int libocfs_bind_raw (const char *dev)
-{
-    struct raw_config_request rcs;
-    struct stat statbuf;
-    int fd, ret = 0;
-
-    memset(&statbuf, 0, sizeof(struct stat));
-
-    if (stat(dev, &statbuf) == -1)
-	return -1;
-
-    if (MAJOR(statbuf.st_rdev) == 0)
-	return -1;
-
-    fd = open("/dev/rawctl", O_RDWR);
-    if (fd == -1)
-	return -1;
-
-    memset(&rcs, 0, sizeof(struct raw_config_request));
-
-    rcs.raw_minor = rawminor;
-    rcs.block_major = (__u64)MAJOR(statbuf.st_rdev);
-    rcs.block_minor = (__u64)MINOR(statbuf.st_rdev);
-
-    if (ioctl(fd, RAW_SETBIND, &rcs) == -1)
-	ret = -1;
-
-    close (fd);
-
-    return ret;
-}
-
-static int libocfs_init(const char *dev, ocfs_vol_disk_hdr ** dh, gboolean do_bind)
-{
-    int fd;
-
-    if (do_bind)
-    {
-	if (rawminor == 0)
-	    return -1;
-
-	if (libocfs_bind_raw (dev) == -1)
-	    return -1;
-
-	fd = open(rawdev, O_RDONLY);
-    }
-    else
-        fd = open(dev, O_RDONLY);
-
-    if (fd == -1)
-    {
-	return fd;
-    }
-    *dh = (ocfs_vol_disk_hdr *) malloc_aligned(512);
-    read_vol_disk_header(fd, *dh);
-    return fd;
-}
-
-static int libocfs_init_write(const char *dev, ocfs_vol_disk_hdr ** dh)
-{
-    int fd;
-
-    if (rawminor == 0)
-        return -1;
-
-    if (libocfs_bind_raw (dev) == -1)
-        return -1;
-
-    fd = open(rawdev, O_RDWR);
-    if (fd == -1)
-    {
-	return fd;
-    }
-    *dh = (ocfs_vol_disk_hdr *) malloc_aligned(512);
-    read_vol_disk_header(fd, *dh);
-    return fd;
-}
-
-int libocfs_readdir(const char *dev, const char *dir, int recurse,
-		    GArray ** arr)
-{
-    int fd;
-    ocfs_vol_disk_hdr *diskHeader;
-    filedata fil;
-    ocfs_super *vcb;
-
-    if ((fd = libocfs_init(dev, &diskHeader, TRUE)) == -1)
-	return 1;
-
-    if (!arr ||
-	(*arr = g_array_new(TRUE, TRUE, sizeof(libocfs_stat))) == NULL)
-    {
-	free_aligned(diskHeader);
-	close(fd);
-	return 2;
-    }
-
-    memset(&fil, 0, sizeof(filedata));
-    if (strcmp(dir, "/") == 0)
-	fil.off = diskHeader->root_off;
-    else
-    {
-	vcb = get_fake_vcb(fd, diskHeader, DEFAULT_NODE_NUMBER);
-	find_file_entry(vcb, diskHeader->root_off, "/", dir, FIND_MODE_DIR, &fil);
-	free_aligned(vcb);
-    }
-
-    if (fil.off <= 0)
-    {
-	g_array_free(*arr, FALSE);
-	free_aligned(diskHeader);
-	close(fd);
-	return 3;
-    }
-
-    walk_dir_nodes(fd, fil.off, dir, (void *) (*arr));
-
-    close(fd);
-    free_aligned(diskHeader);
-    return 0;
-}
-
-int libocfs_get_bitmap(const char *dev, unsigned char **bmap, int *numbits)
-{
-    int fd;
-    __u64 readlen;
-    ocfs_vol_disk_hdr *diskHeader;
-
-    if (!bmap || !numbits)
-	return 2;
-
-    if ((fd = libocfs_init(dev, &diskHeader, TRUE)) == -1)
-	return 1;
-
-    readlen = 1 << 20;		// now fixed size of 1MB
-    *bmap = (void *) malloc_aligned(readlen);
-
-    myseek64(fd, diskHeader->bitmap_off, SEEK_SET);
-    read(fd, *bmap, readlen);
-
-    *numbits = diskHeader->num_clusters;
-
-    free_aligned(diskHeader);
-    close(fd);
-    return 0;
-}
-
-int libocfs_get_volume_info(const char *dev, libocfs_volinfo ** info)
-{
-    int fd;
-    ocfs_vol_disk_hdr *diskHeader;
-
-    if (!info)
-	return 2;
-
-    if ((fd = libocfs_init(dev, &diskHeader, TRUE)) == -1)
-	return 1;
-
-    *info = (libocfs_volinfo *) malloc(sizeof(libocfs_volinfo));
-    (*info)->major_ver = diskHeader->major_version;
-    (*info)->minor_ver = diskHeader->minor_version;
-    memcpy((*info)->signature, diskHeader->signature, 128);
-    (*info)->signature[127] = '\0';
-    memcpy((*info)->mountpoint, diskHeader->mount_point, 128);
-    (*info)->mountpoint[127] = '\0';
-    (*info)->length = diskHeader->device_size;
-    (*info)->num_extents = diskHeader->num_clusters;
-    (*info)->extent_size = diskHeader->cluster_size;
-    memset((*info)->mounted_nodes, 0, 32);
-    (*info)->protection = diskHeader->prot_bits;
-    (*info)->protection |= S_IFDIR;
-    (*info)->uid = diskHeader->uid;
-    (*info)->gid = diskHeader->gid;
-
-    free_aligned(diskHeader);
-    close(fd);
-    return 0;
-}
-
-int libocfs_is_ocfs_partition(const char *dev)
-{
-    int fd, ret = 0;
-    ocfs_vol_disk_hdr *diskHeader;
-
-    if ((fd = libocfs_init(dev, &diskHeader, FALSE)) == -1)
-	return 0;
-    if (memcmp(diskHeader->signature,
-	       OCFS_VOLUME_SIGNATURE,
-	       strlen(OCFS_VOLUME_SIGNATURE)) == 0)
-	ret = 1;
-    if (diskHeader->major_version >= 9)
-        ret = 0;
-
-    free_aligned(diskHeader);
-    close(fd);
-    return ret;
-}
-
-int libocfs_chown_volume(const char *dev, int protection, int uid, int gid)
-{
-    int fd, ret = 0;
-    ocfs_vol_disk_hdr *diskHeader;
-
-    if ((fd = libocfs_init_write(dev, &diskHeader)) == -1)
-    {
-	ret = 1;
-	goto bail;
-    }
-
-    diskHeader->prot_bits = (protection & 0007777);	// blank out non-permissions
-    diskHeader->uid = uid;
-    diskHeader->gid = gid;
-
-    /* XXX totally, completely, utterly UNSAFE!!!!!!!!!!!!!! XXX */
-    /* no locking at all, need to figure this out */
-    if (write_vol_disk_header(fd, diskHeader) != OCFS_SECTOR_SIZE)
-	ret = 2;
-
-    free_aligned(diskHeader);
-    close(fd);
-  bail:
-    return ret;
-}
-
-
-int get_node_config_data(ocfs_super * vcb, GArray * arr)
-{
-    ocfs_disk_node_config_info *Node;
-    void *buffer;
-    int i, j, ret = 0;
-    libocfs_node libnode;
-    int status;
-    __u32 tmp;
-
-    buffer = malloc_aligned(vcb->vol_layout.node_cfg_size);
-
-    tmp = LO(vcb->vol_layout.node_cfg_size);
-    status =
-	ocfs_read_disk(vcb, buffer, tmp, vcb->vol_layout.node_cfg_off);
-    if (status < 0)
-    {
-	ret = 1;
-	goto bail;
-    }
-
-    for (i = 0; i < OCFS_MAXIMUM_NODES; i++)
-    {
-	// starts at the 3rd sector
-	Node =
-	    (ocfs_disk_node_config_info *) ((char *) buffer +
-					    ((2 + i) * OCFS_SECTOR_SIZE));
-
-	if (!Node)
-	    continue;
-	if (Node->node_name[0] == '\0')
-	    continue;
-
-	memset(&libnode, 0, sizeof(libocfs_node));
-	strncpy(libnode.name, Node->node_name, OCFS_DBGLIB_MAX_NODE_NAME_LENGTH);
-	libnode.slot = i;
-	strncpy(libnode.addr, Node->ipc_config.ip_addr, OCFS_DBGLIB_IP_ADDR_LEN);
-        memcpy(libnode.guid, Node->guid.guid, OCFS_DBGLIB_GUID_LEN);
-	g_array_append_val(arr, libnode);
-    }
-  bail:
-    free_aligned(buffer);
-    return ret;
-}
-
-
-int libocfs_get_node_map(const char *dev, GArray ** arr)
-{
-    int fd, ret = 0;
-    ocfs_vol_disk_hdr *diskHeader;
-    ocfs_super *vcb;
-
-    if ((fd = libocfs_init(dev, &diskHeader, TRUE)) == -1)
-    {
-	ret = 1;
-	goto bail;
-    }
-    vcb = get_fake_vcb(fd, diskHeader, DEFAULT_NODE_NUMBER);
-
-    if (!arr ||
-	(*arr = g_array_new(TRUE, TRUE, sizeof(libocfs_node))) == NULL)
-    {
-	ret = 2;
-	goto free;
-    }
-
-    ret = get_node_config_data(vcb, *arr);
-
-  free:
-    free_aligned(diskHeader);
-    free_aligned(vcb);
-    close(fd);
-  bail:
-    return ret;
-}
-
-int libocfs_dump_file(const char *dev, const char *path, const char *file)
-{
-    return libocfs_dump_file_as_node(dev, path, file, DEFAULT_NODE_NUMBER);
-}
-
-int libocfs_dump_file_as_node(const char *dev, const char *path,
-			      const char *file, int node)
-{
-    int fd, ret = 0;
-    ocfs_vol_disk_hdr *diskHeader;
-    ocfs_super *vcb;
-
-    if ((fd = libocfs_init(dev, &diskHeader, TRUE)) == -1)
-    {
-	ret = 1;
-	goto bail;
-    }
-
-    vcb = get_fake_vcb(fd, diskHeader, node);
-    ret = suck_file(vcb, path, file);
-
-    free_aligned(diskHeader);
-    free_aligned(vcb);
-    close(fd);
-
-  bail:
-    return ret;
-}
-
-
-void handle_one_file_entry(int fd, ocfs_file_entry *fe, void *buf)
-{
-    libocfs_stat st;
-    int j;
-    void *cdslbuf;
-    GArray *arr = (GArray *)buf;
-        
-    memcpy(st.name, fe->filename, 255);
-    st.name[254] = '\0';
-    st.current_master = fe->disk_lock.curr_master;
-    st.size = fe->file_size;
-    st.alloc_size = fe->alloc_size;
-    st.open_map = (fe->disk_lock.oin_node_map & 0x00000000ffffffffULL);	// uh, this is really still just 32 bits
-    st.protection = fe->prot_bits;
-
-    if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
-        st.protection |= S_IFDIR;
-    else if (fe->attribs & OCFS_ATTRIB_CHAR)
-        st.protection |= S_IFCHR;
-    else if (fe->attribs & OCFS_ATTRIB_BLOCK)
-        st.protection |= S_IFBLK;
-    else if (fe->attribs & OCFS_ATTRIB_REG)
-        st.protection |= S_IFREG;
-    else if (fe->attribs & OCFS_ATTRIB_FIFO)
-        st.protection |= S_IFIFO;
-    else if (fe->attribs & OCFS_ATTRIB_SYMLINK)
-        st.protection |= S_IFLNK;
-    else if (fe->attribs & OCFS_ATTRIB_SOCKET)
-        st.protection |= S_IFSOCK;
-        
-    st.uid = fe->uid;
-    st.gid = fe->gid;
-    st.dir_entries = -1;	// TODO: need to implement or throw it out
-        
-    st.attribs = 0;
-    st.cdsl_bitmap = 0;
-#if 0
-    if (fe->attribs & OCFS_ATTRIB_FILE_CDSL)
-    {
-        st.attribs |= OCFS_DBGLIB_ATTRIB_FILE_CDSL;
-        cdslbuf = malloc(sizeof(__u64) * MAX_NODES);
-        read_cdsl_data(fd, cdslbuf, fe->extents[0].disk_off);
-        for (j = 0; j < MAX_NODES; j++)
-            if (*(((__u64 *) cdslbuf) + j) != 0)
-                st.cdsl_bitmap |= (1 << j);
-        free(cdslbuf);
-    }
-#endif
-
-    g_array_append_val(arr, st);
-}

Copied: trunk/debugocfs/libdebugocfs.c (from rev 205, trunk/ocfs/debugocfs/libdebugocfs.c)

Deleted: trunk/debugocfs/libdebugocfs.h
===================================================================
--- trunk/ocfs/debugocfs/libdebugocfs.h	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/libdebugocfs.h	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,89 +0,0 @@
-/*
- * libdebugocfs.h
- *
- * Function prototypes for related 'C' file.
- *
- * Copyright (C) 2002 Oracle Corporation.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Author: Kurt Hackel
- */
-
-#ifndef _LIBDEBUGOCFS_H_
-#define _LIBDEBUGOCFS_H_
-
-#define OCFS_DBGLIB_ATTRIB_FILE_CDSL (0x1)
-
-typedef struct _libocfs_stat
-{
-    char name[255];
-    int current_master;
-    unsigned long long size;
-    unsigned long long alloc_size;
-    unsigned int open_map;
-    int protection;
-    int uid;
-    int gid;
-    int dir_entries;		/* will be -1 if not a dir */
-    int attribs;
-    unsigned int cdsl_bitmap;
-}
-libocfs_stat;
-
-typedef struct _libocfs_volinfo
-{
-    int major_ver;
-    int minor_ver;
-    char signature[128];
-    char mountpoint[128];
-    unsigned long long length;
-    unsigned long long num_extents;
-    int extent_size;
-    char mounted_nodes[32];	/* hardcoded for now! */
-    int protection;
-    int uid;
-    int gid;
-}
-libocfs_volinfo;
-
-#define OCFS_DBGLIB_MAX_NODE_NAME_LENGTH 32
-#define OCFS_DBGLIB_GUID_LEN             32
-#define OCFS_DBGLIB_IP_ADDR_LEN          15
-typedef struct _libocfs_node
-{
-    char name[OCFS_DBGLIB_MAX_NODE_NAME_LENGTH + 1];
-    char addr[OCFS_DBGLIB_IP_ADDR_LEN + 1];
-    int slot;
-    char guid[OCFS_DBGLIB_GUID_LEN + 1];
-}
-libocfs_node;
-
-int libocfs_readdir(const char *dev, const char *dir, int recurse,
-		    GArray ** arr);
-int libocfs_get_bitmap(const char *dev, unsigned char **bmap, int *numbits);
-int libocfs_get_volume_info(const char *dev, libocfs_volinfo ** info);
-int libocfs_is_ocfs_partition(const char *dev);
-int libocfs_chown_volume(const char *dev, int protection, int uid, int gid);
-int libocfs_get_node_map(const char *dev, GArray ** arr);
-int libocfs_dump_file(const char *dev, const char *path, const char *file);
-int libocfs_dump_file_as_node(const char *dev, const char *path,
-			      const char *file, int node);
-
-int libocfs_init_raw(void);
-int libocfs_cleanup_raw(void);
-
-#endif				/* _LIBDEBUGOCFS_H_ */

Copied: trunk/debugocfs/libdebugocfs.h (from rev 205, trunk/ocfs/debugocfs/libdebugocfs.h)

Deleted: trunk/debugocfs/main.c
===================================================================
--- trunk/ocfs/debugocfs/main.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/main.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,735 +0,0 @@
-/*
- * main.c
- *
- * entry point for normal and -X mode debugocfs
- *
- * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Author: Kurt Hackel, Sunil Mushran
- */
-
-#include "debugocfs.h"
-
-/* getopt stuff */
-int getopt(int argc, char *const argv[], const char *optstring);
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-extern __u32 OcfsDebugCtxt;
-extern __u32 OcfsDebugLevel;
-
-void translate_usage(void);
-void do_translate(int argc, char **argv);
-
-/* global stuff */
-int filenum;
-user_args args;
-char rawdev[255];
-int rawminor = 0;
-int fd = -1;
-
-void usage(void)
-{
-    printf("debugocfs: Usage: debugocfs [-?] [-h] [-g] [-l] [-v range] [-p range]\n");
-    printf("           [-d /dir/name] [-f /file/name [-s /path/to/file]] [-a range] [-A range]\n");
-    printf("           [-b range] [-B range] [-r range] [-c range] [-L range] [-M range]\n");
-    printf("           [-n nodenum] /dev/name\n");
-    printf("\n");
-    printf("       -h: volume header\n");
-    printf("       -g: global bitmap\n");
-    printf("       -l: full listing of all file entries\n");
-    printf("       -v: vote sector\n");
-    printf("       -2: print 8-byte number as 2 4-byte numbers\n");
-    printf("       -p: publish sector\n");
-    printf("       -d: first ocfs_dir_node structure for a given path\n");
-    printf("       -D: all ocfs_dir_node structures for a given path\n");
-    printf("       -f: ocfs_file_entry structure for a given file\n");
-    printf("       -F: ocfs_file_entry and ocfs_extent_group structures for a given file\n");
-    printf("       -s: suck file out to a given location\n");
-    printf("       -a: file allocation system file\n");
-    printf("       -A: dir allocation system file\n");
-    printf("       -b: file allocation bitmap system file\n");
-    printf("       -B: dir allocation bitmap system file\n");
-    printf("       -r: recover log file system file\n");
-    printf("       -c: cleanup log system file\n");
-    printf("       -L: vol metadata log system file\n");
-    printf("       -M: vol metadata system file\n");
-    printf("       -n: perform action as node number given\n");
-    printf("       -N: do not bind device with raw\n");
-    printf("/dev/name: readable device\n");
-    printf("    range: node numbers to inspect (0-31), commas and dashes ok\n");
-    printf("            ex. 0-3,5,14-17\n");
-}
-
-void translate_usage(void)
-{
-    printf("Usage: debugocfs -X { -h highoff -l lowoff | -o off } [-N] -t type\n");
-    printf("\n");
-    printf("       highoff/lowoff: 32-bit high and low offsets to data\n");
-    printf("                  off: 64-bit offset to data\n");
-    printf("                 type: one of the following types to cast data to:\n");
-    printf("                         ocfs_vol_label\n");
-    printf("                         ocfs_vol_disk_hdr\n");
-    printf("                         ocfs_dir_node\n");
-    printf("                         ocfs_file_entry\n");
-    printf("                         ocfs_vote\n");
-    printf("                         ocfs_publish\n");
-    printf("                         cdsl_offsets\n");
-}
-
-
-/* special translate mode junk */
-typedef void (*debugocfs_print_func) (void *buf);
-
-void do_translate(int argc, char **argv)
-{
-    int c, ok = true;
-    __u64 off = 0;
-    int size = 0;
-    char *type = NULL;
-    char *p;
-    debugocfs_print_func func;
-    int flags;
-    bool no_rawbind = false;
-
-    while (1)
-    {
-	c = getopt(argc, argv, "N2o:h:l:s:t:");
-	if (c == -1)
-	    break;
-	switch (c)
-	{
-	    case 'o':
-		p = strchr(optarg, '.');
-		if (!p)
-			off = atoll(optarg);
-		else {
-			*p = '\0';
-			off  = ((__u64) strtoul(optarg, NULL, 0)) << 32;
-			off |= strtoul(++p, NULL, 0);
-		}
-		break;
-	    case 'h':
-		off |= ((__u64) strtoul(optarg, NULL, 0)) << 32;
-		ok = !ok;
-		break;
-	    case 'l':
-		off |= strtoul(optarg, NULL, 0);
-		ok = !ok;
-		break;
-	    case 't':
-		type = (char *) strdup(optarg);
-		break;
-	    case 'N':
-		no_rawbind = true;
-		break;
-	    case '2':		/* display 8-byte nums as 2 4-byte nums */
-		args.twoFourbyte = true;
-		break;
-            case '?':
-                translate_usage();
-                exit(1);
-                break;
-	    default:
-		break;
-	}
-    }
-    if (!ok)
-    {
-	printf("Oops. You must give both a high and low part.\n");
-	exit(1);
-    }
-
-    if (type == NULL)
-    {
-	printf ("Oops. You must give a valid type.\n");
-	exit(1);
-    }
-    if (strcasecmp(type, "ocfs_vol_label") == 0)
-    {
-	size = OCFS_ALIGN(sizeof(ocfs_vol_label), 512);
-	func = print_vol_label;
-    }
-    else if (strcasecmp(type, "ocfs_vol_disk_hdr") == 0)
-    {
-        size = OCFS_ALIGN(sizeof(ocfs_vol_disk_hdr), 512);
-	func = print_vol_disk_header;
-    }
-    else if (strcasecmp(type, "ocfs_dir_node") == 0)
-    {
-        size = OCFS_ALIGN(sizeof(ocfs_dir_node), 512);
-        func = print_dir_node;
-    }
-    else if (strcasecmp(type, "ocfs_file_entry") == 0)
-    {
-        size = OCFS_ALIGN(sizeof(ocfs_file_entry), 512);
-        func = print_file_entry;
-    }
-    else if (strcasecmp(type, "ocfs_vote") == 0)
-    {
-        size = OCFS_ALIGN(sizeof(ocfs_vote), 512);
-        func = print_vote_sector;
-    }
-    else if (strcasecmp(type, "ocfs_publish") == 0)
-    {
-        size = OCFS_ALIGN(sizeof(ocfs_publish), 512);
-        func = print_publish_sector;
-    }
-    else if (strcasecmp(type, "cdsl_offsets") == 0)
-    {
-        size = OCFS_ALIGN((sizeof(__u64) * MAX_NODES), 512);
-        func = print_cdsl_offsets;
-    }
-    else if (strcasecmp(type, "ocfs_extent_group") == 0)
-    {
-	    size = OCFS_ALIGN(sizeof(ocfs_extent_group), 512);
-	    func = print_extent_ex;
-    }
-    else
-    {
-	printf ("Oops. You must give a valid type.\n");
-	exit(1);
-    }
-
-    if (!no_rawbind) {
-	    if (bind_raw(argv[optind], &rawminor, rawdev, sizeof(rawdev)) == -1)
-		    goto bail;
-    } else
-	    strncpy(rawdev, argv[optind], sizeof(rawdev));
-
-    flags = O_RDONLY | O_LARGEFILE;
-    fd = open(rawdev, flags);
-    if (fd == -1)
-	goto bail;
-
-    printf("offset: %lld, type: %s\n", off, type);
-
-    {
-	void *buf;
-
-        buf = malloc_aligned(size);
-	if (buf == NULL)
-	{
-	    printf("failed to alloc %d bytes\n", size);
-	    exit(1);
-	}
-	myseek64(fd, off, SEEK_SET);
-
-	printf("seeked ok\n");
-	if (read(fd, buf, size) != -1)
-	{
-	    printf("successful read\n");
-            func(buf);
-	}
-	free(buf);
-    }
-
-bail:
-    if (type)
-	free(type);
-    if (fd != -1)
-	    close(fd);
-    if (rawminor)
-	    unbind_raw(rawminor);
-}
-
-void version(char *prog)
-{
-	printf("%s %s %s (build %s)\n", prog, OCFS_BUILD_VERSION,
-	       OCFS_BUILD_DATE, OCFS_BUILD_MD5);
-}
-
-void handle_signal(int sig)
-{
-    switch (sig) {
-    case SIGTERM:
-    case SIGINT:
-	if (fd != -1)
-	    close(fd);
-	if (rawminor)
-	    unbind_raw(rawminor);
-	exit(1);
-    }
-}
-
-/* uh, main */
-int main(int argc, char **argv)
-{
-    ocfs_vol_label *volLabel = NULL;
-    ocfs_vote *vs = NULL;
-    ocfs_publish *ps = NULL;
-    ocfs_vol_disk_hdr *diskHeader = NULL;
-    int i;
-    ocfs_super *vcb = NULL;
-    char *env;
-    int flags;
-    __u64 device_size = 0;
-    char input[32];
-
-#define INSTALL_SIGNAL(sig)					\
-    do {							\
-	if (signal(sig, handle_signal) == SIG_ERR) {		\
-	    fprintf(stderr, "Could not set " #sig "\n");	\
-	    goto bail;						\
-	}							\
-    } while (0)
-
-    INSTALL_SIGNAL(SIGTERM);
-    INSTALL_SIGNAL(SIGINT);
-
-    init_raw_cleanup_message();
-
-    version(argv[0]);
-
-    if ((env = getenv("dbgctxt")) != NULL)
-        OcfsDebugCtxt = strtol(env, NULL, 16);
-    if ((env = getenv("dbglvl")) != NULL)
-        OcfsDebugLevel = strtol(env, NULL, 16);
-
-    memset(&args, 0, sizeof(user_args));
-    volLabel = (ocfs_vol_label *) malloc_aligned(512);
-    vs = (ocfs_vote *) malloc_aligned(512);
-    ps = (ocfs_publish *) malloc_aligned(512);
-    diskHeader = (ocfs_vol_disk_hdr *) malloc_aligned(512);
-    if (!volLabel || !vs || !ps || !diskHeader) {
-	    LOG_ERROR("out of memory");
-	    goto bail;
-    }
-
-    args.nodenum = -1;
-    while (1)
-    {
-	int off = 0;
-	int c = getopt(argc, argv, "NhHgl2v:p:d:D:f:F:a:A:b:B:b:r:c:L:M:s:n:X");
-
-	if (c == -1)
-	    break;
-	switch (c)
-	{
-	    case 'h':		/* header */
-		args.showHeader = true;
-		break;
-	    case 'H':		/* update header */
-		args.updHeader = true;
-		break;
-	    case 'g':		/* global bitmap */
-		args.showBitmap = true;
-		break;
-	    case 'p':		/* publish 0-31 */
-		args.showPublish = true;
-		if (!parse_numeric_range(optarg, &(args.publishNodes[0]),
-					 0, MAX_NODES, 0))
-		{
-		    usage();
-		    exit(1);
-		}
-		break;
-	    case 'v':		/* vote 0-31 */
-		args.showVote = true;
-		if (!parse_numeric_range(optarg, &(args.voteNodes[0]),
-					 0, MAX_NODES, 0))
-		{
-		    usage();
-		    exit(1);
-		}
-		break;
-	    case 'c':
-		if (!off)
-		    off = OCFS_SYSFILE_TYPE_TO_FILE_NUM(OCFS_CLEANUP_LOG_SYSFILE, 0);
-	    case 'r':
-		if (!off)
-                    off = OCFS_SYSFILE_TYPE_TO_FILE_NUM(OCFS_RECOVER_LOG_SYSFILE, 0);
-	    case 'b':
-		if (!off)
-		    off = OCFS_SYSFILE_TYPE_TO_FILE_NUM(OCFS_FILE_EXTENT_BM_SYSFILE, 0);
-	    case 'a':
-		if (!off)
-	   	    off = OCFS_SYSFILE_TYPE_TO_FILE_NUM(OCFS_FILE_EXTENT_SYSFILE, 0);
-	    case 'B':
-		if (!off)
-		    off = OCFS_SYSFILE_TYPE_TO_FILE_NUM(OCFS_DIR_BM_SYSFILE, 0);
-	    case 'A':
-		if (!off)
-		    off = OCFS_SYSFILE_TYPE_TO_FILE_NUM(OCFS_DIR_SYSFILE, 0);
-	    case 'L':
-		if (!off)
-		    off = OCFS_SYSFILE_TYPE_TO_FILE_NUM(OCFS_VOL_MD_LOG_SYSFILE, 0);
-	    case 'M':
-		if (!off)
-		    off = OCFS_SYSFILE_TYPE_TO_FILE_NUM(OCFS_VOL_MD_SYSFILE, 0);
-
-		if (off==OCFS_INVALID_SYSFILE ||
-                    !parse_numeric_range(optarg, &(args.systemFiles[0]), 0, MAX_NODES, off))
-		{
-		    usage();
-		    exit(1);
-		}
-		args.showSystemFiles = true;
-		break;
-	    case 'l':		/* listing */
-		args.showListing = true;
-		break;
-	    case 'd':		/* dirent */
-		args.showDirent = true;
-		args.dirent = (char *) strdup(optarg);
-		break;
-	    case 'D':		/* direntall */
-		args.showDirentAll = true;
-		args.dirent = (char *) strdup(optarg);
-		break;
-	    case 'f':		/* fileent */
-		args.showFileent = true;
-		args.fileent = (char *) strdup(optarg);
-		break;
-	    case 'F':		/* fileent + extents */
-		args.showFileext = true;
-		args.fileent = (char *) strdup(optarg);
-		break;
-	    case 's':		/* suck */
-		args.suckFile = true;
-		args.suckTo = (char *) strdup(optarg);
-		break;
-	    case 'n':		/* node number */
-		args.nodenum = atoi(optarg);
-		break;
-	    case 'N':
-		args.no_rawbind = true;
-		break;
-	    case 'X':		/* translate */
-		do_translate(argc, argv);
-		exit(0);
-		break;
-	    case '2':		/* display 8-byte nums as 2 4-byte nums */
-		args.twoFourbyte = true;
-		break;
-	    default:
-	    case '?':
-		usage();
-		exit(1);
-		break;
-	}
-    }
-
-    // what should be the default node number? 
-    if (args.nodenum < 0 || args.nodenum >= MAX_NODES)
-	args.nodenum = DEFAULT_NODE_NUMBER;
-
-    if (!(args.showHeader || args.showPublish || args.showVote ||
-	  args.showListing || args.showDirent || args.showFileent ||
-	  args.showFileext || args.showSystemFiles || args.showBitmap ||
-	  args.showDirentAll || args.updHeader))
-    {
-	usage();
-	exit(1);
-    }
-
-    if (args.updHeader) {
-    	if (get_device_size(argv[optind], &device_size) == -1)
-		    goto bail;
-    }
-
-    if (!args.no_rawbind) {
-	    if (bind_raw(argv[optind], &rawminor, rawdev, sizeof(rawdev)) == -1)
-		    goto bail;
-    } else
-	    strncpy(rawdev, argv[optind], sizeof(rawdev));
-
-    if (args.updHeader)
-    	flags = O_RDWR | O_LARGEFILE;
-    else
-    	flags = O_RDONLY | O_LARGEFILE;
-    fd = open(rawdev, flags);
-    if (fd == -1)
-    {
-	usage();
-	goto bail;
-    }
-
-    if (args.updHeader) {
-	if (get_default_vol_hdr(fd, diskHeader, device_size) == -1)
-		goto bail;
-	printf("diskheader:\n");
-	print_vol_disk_header(diskHeader);
-	while (1) {
-		printf("Do you want to write the new volume header to disk (y/N)? ");
-		fgets(input, sizeof(input), stdin);
-		if (toupper(*input) == 'Y') {
-			if (write_vol_disk_header(fd, diskHeader) != OCFS_SECTOR_SIZE) {
-				printf("ERROR updating volume header.\n");
-				goto bail;
-			}
-			printf("Volume header successfully updated.\n");
-			break;
-		} else {
-			printf("Volume header not updated.\n");
-			break;
-		}
-	}
-	goto bail;
-    }
-
-    read_vol_disk_header(fd, diskHeader);
-    if (strncmp(diskHeader->signature, OCFS_VOLUME_SIGNATURE, MAX_VOL_SIGNATURE_LEN)) {
-	    printf("ERROR: Volume header appears to be corrupted.\nRerun with -H.\n");
-	    if (!args.showHeader)
-		    goto bail;
-    }
-
-    read_vol_label(fd, volLabel);
-
-    vcb = get_fake_vcb(fd, diskHeader, args.nodenum);
-    if (!vcb) {
-	    LOG_ERROR("out of memory");
-	    goto bail;
-    }
-
-    if (args.showHeader)
-    {
-	printf("diskheader:\n");
-	print_vol_disk_header(diskHeader);
-	printf("\nvolumelabel:\n");
-	print_vol_label(volLabel);
-	printf("\n");
-    }
-
-    if (args.showBitmap)
-    {
-	printf("global_bitmap:\n");
-	print_global_bitmap(fd, diskHeader);
-	printf("\n");
-    }
-
-    if (args.showPublish)
-    {
-	for (i = 0; i < MAX_NODES; i++)
-	{
-	    if (args.publishNodes[i])
-	    {
-		printf("publish%d:\n", i);
-		read_publish_sector(fd, ps,
-				    diskHeader->publ_off + (__u64) (i * 512));
-		print_publish_sector(ps);
-	    }
-	}
-	printf("\n");
-    }
-    if (args.showVote)
-    {
-	for (i = 0; i < MAX_NODES; i++)
-	{
-	    if (args.voteNodes[i])
-	    {
-		printf("vote%d:\n", i);
-		read_vote_sector(fd, vs,
-				 diskHeader->vote_off + (__u64) (i * 512));
-		print_vote_sector(vs);
-	    }
-	}
-	printf("\n");
-    }
-
-    if (args.showListing)
-    {
-	filenum = 1;
-	printf("filelisting:\n");
-	walk_dir_nodes(fd, diskHeader->root_off, "/", NULL);
-    }
-
-    if (args.showDirent || args.showDirentAll)
-    {
-	printf("dirinfo:\n");
-	if (strcmp(args.dirent, "/") == 0)
-	{
-	    ocfs_dir_node *dir = (ocfs_dir_node *) malloc_aligned(DIR_NODE_SIZE);
-	    __u64 dir_off = diskHeader->root_off;
-
-	    printf("\tName = /\n");
-	    while (1) {
-		    read_dir_node(fd, dir, dir_off);
-		    print_dir_node(dir);
-		    if (!args.showDirentAll || dir->next_node_ptr == INVALID_NODE_POINTER)
-			    break;
-		    dir_off = dir->next_node_ptr;
-		    memset(dir, 0, DIR_NODE_SIZE);
-	    	    printf("dirinfo:\n");
-	    }
-	    free(dir);
-	}
-	else
-	{
-	    find_file_entry(vcb, diskHeader->root_off, "/", args.dirent,
-			    FIND_MODE_DIR, NULL);
-	}
-    }
-
-    if (args.showSystemFiles)
-    {
-	for (i = 0; i < MAX_SYSTEM_FILES; i++)
-	{
-	    if (args.systemFiles[i])
-	    {
-		print_system_file(fd, diskHeader, i);
-	    }
-	}
-    }
-
-    if (args.showFileent || args.showFileext)
-    {
-	if (args.suckFile)
-	{
-	    suck_file(vcb, args.fileent, args.suckTo);
-	    free(args.suckTo);
-	}
-	else
-	{
-	    printf("fileinfo:\n");
-	    if (strcmp(args.fileent, "/") == 0)
-	    {
-		printf("the root directory '/' has no file entry\n");
-		goto bail;
-	    }
-	    else
-	    {
-		find_file_entry(vcb, diskHeader->root_off, "/", args.fileent,
-				(args.showFileext ? FIND_MODE_FILE_EXTENT :
-				 FIND_MODE_FILE), NULL);
-	    }
-	}
-    }
-
-bail:
-    if (volLabel)
-	    free_aligned(volLabel);
-    if (vs)
-	    free_aligned(vs);
-    if (ps)
-	    free_aligned(ps);
-    if (diskHeader)
-	    free_aligned(diskHeader);
-    if (vcb && vcb->sb)
-	    free_aligned(vcb->sb);
-    if (vcb)
-	    free_aligned(vcb);
-    if (fd != -1)
-	    close(fd);
-    if (rawminor)
-	    unbind_raw(rawminor);
-    exit(0);
-}
-
-int get_default_vol_hdr(int fd, ocfs_vol_disk_hdr *hdr, __u64 device_size)
-{
-	__u32 numblks;
-	__u32 blksz;
-	__u32 bitsz;
-	__u64 devsz;
-	char input[64];
-	int valid_vals[] = {4, 8, 16, 32, 64, 128, 256, 512, 1024, 0};
-	int i;
-
-	memset(hdr, 0, 512);
-
-	hdr->minor_version = 2;
-	hdr->major_version = 1;
-	strncpy(hdr->signature, OCFS_VOLUME_SIGNATURE, MAX_VOL_SIGNATURE_LEN);
-	strcpy(hdr->mount_point, "/ocfs");
-	hdr->serial_num = 0;
-	hdr->device_size = device_size;
-	hdr->start_off = 0;
-	hdr->bitmap_off = OCFSCK_BITMAP_OFF;
-	hdr->publ_off = OCFSCK_PUBLISH_OFF;
-	hdr->vote_off = OCFSCK_VOTE_OFF;
-	hdr->root_bitmap_off = 0;
-	hdr->data_start_off = OCFSCK_DATA_START_OFF;
-	hdr->root_bitmap_size = 0;
-	hdr->root_off = OCFSCK_ROOT_OFF;
-	hdr->root_size = 0;
-	hdr->num_nodes = OCFS_MAXIMUM_NODES;
-	hdr->dir_node_size = 0;
-	hdr->file_node_size = 0;
-	hdr->internal_off = OCFSCK_INTERNAL_OFF;
-	hdr->node_cfg_off = OCFSCK_AUTOCONF_OFF;
-	hdr->node_cfg_size = OCFSCK_AUTOCONF_SIZE;
-	hdr->new_cfg_off = OCFSCK_NEW_CFG_OFF;
-	hdr->prot_bits = 0755;
-	hdr->uid = 0;
-	hdr->gid = 0;
-	hdr->excl_mount = -1;
-	hdr->disk_hb = OCFS_MIN_DISKHB;
-	hdr->hb_timeo = OCFS_MIN_HBTIMEO;
-
-	devsz = device_size - OCFSCK_DATA_START_OFF - OCFSCK_END_SECTOR_BYTES;
-
-	while (1) {
-		blksz = 0;
-		printf("What was the block size (in KB) on this device? ");
-		fgets(input, sizeof(input), stdin);
-		blksz = atoi(input);
-
-		for (i = 0; valid_vals[i]; ++i) {
-			if (blksz == valid_vals[i])
-				break;
-		}
-
-		if (!valid_vals[i]) {
-			printf("Invalid block size. Valid values are 4, 8, 16, 32, 64, 128, 256, 512, 1024.\n");
-			continue;
-		}
-
-		printf("Using %uKB block size...\n", blksz);
-		hdr->cluster_size = blksz * 1024;
-
-		hdr->num_clusters = devsz / hdr->cluster_size;
-
-		bitsz = OCFS_ALIGN(((hdr->num_clusters + 7) / 8), OCFS_SECTOR_SIZE);
-		if (bitsz > OCFS_MAX_BITMAP_SIZE) {
-			printf("%dKB block size is too small for this device.\n"
-			       "Please specify a larger value.\n", blksz);
-			continue;
-		} else
-			break;
-	}
-
-	return 0;
-}
-
-int get_device_size(char *device, __u64 *device_size)
-{
-	int fd;
-	__u32 numblks;
-
-	fd = open(device, O_RDONLY | O_LARGEFILE);
-	if (fd == -1) {
-		printf("ERROR: unable to open device %s.\n%s\n", device, strerror(errno));
-		usage();
-		return -1;
-	}
-
-	if (ioctl(fd, BLKGETSIZE, &numblks) == -1) {
-		printf("ERROR: unable to get device size.\n%s\n", strerror(errno));
-		close (fd);
-		return -1;
-	}
-
-	*device_size = numblks;
-	*device_size *= OCFS_SECTOR_SIZE;
-
-	close (fd);
-
-	return 0;
-}

Copied: trunk/debugocfs/main.c (from rev 205, trunk/ocfs/debugocfs/main.c)

Deleted: trunk/debugocfs/print.c
===================================================================
--- trunk/ocfs/debugocfs/print.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/print.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,894 +0,0 @@
-/*
- * print.c
- *
- * stdout printing support for debugocfs
- *
- * Copyright (C) 2002 Oracle Corporation.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Author: Kurt Hackel
- */
-
-#include "debugocfs.h"
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-extern int filenum;
-extern user_args args;
-extern __u32 OcfsDebugCtxt;
-extern __u32 OcfsDebugLevel;
-
-void print_time(__u64 * sec);
-void print_file_attributes(__u32 attribs);
-void print_protection_bits(__u32 prot);
-void print_global_bitmap(int fd, void *buf);
-void print_system_file(int fd, ocfs_vol_disk_hdr * v, int fileid);
-void print_file_data(int fd, ocfs_file_entry * fe);
-void print_alloc_log(ocfs_alloc_log * rec);
-void print_dir_log(ocfs_dir_log * rec);
-void print_recovery_log(ocfs_recovery_log * rec);
-void print_lock_log(ocfs_lock_log * rec);
-void print_bcast_rel_log(ocfs_bcast_rel_log * rec);
-void print_delete_log(ocfs_delete_log * rec);
-void print_free_log(ocfs_free_log * rec);
-void print_extent_rec(ocfs_free_extent_log * rec);
-
-
-typedef __u64 (*bit2off_func)(int bitnum, void *data);
-__u64 global_bm_bitnum_to_offset(int bitnum, void *data);
-void print_bitmap(char *bmbuf, int bmsize, bit2off_func func, void *data);
-
-void print_vol_label(void *buf)
-{
-    ocfs_vol_label *v = (ocfs_vol_label *)buf;
-    print_disk_lock(&v->disk_lock);
-    printf("\tlabel = %s\n", v->label);
-    printf("\tlabel_len = %u\n", v->label_len);
-}
-
-void print_vol_disk_header(void *buf)
-{
-    ocfs_vol_disk_hdr * v = (ocfs_vol_disk_hdr *)buf;
-    printf("\tversion = %u.%u\n", v->major_version, v->minor_version);
-    printf("\tsignature = %s\n", v->signature);
-    printf("\tmount_point = %s\n", v->mount_point);
-    printf("\tserial_num = %llu\n", v->serial_num);
-    printf("\tdevice_size = %llu\n", v->device_size);
-    printf("\tstart_off = %llu\n", v->start_off);
-    printf("\tbitmap_off = %llu\n", v->bitmap_off);
-    printf("\tpubl_off = %llu\n", v->publ_off);
-    printf("\tvote_off = %llu\n", v->vote_off);
-    printf("\troot_bitmap_off = %llu\n", v->root_bitmap_off);
-    printf("\tdata_start_off = %llu\n", v->data_start_off);
-    printf("\troot_bitmap_size = %llu\n", v->root_bitmap_size);
-    printf("\troot_off = %llu\n", v->root_off);
-    printf("\troot_size = %llu\n", v->root_size);
-    printf("\tcluster_size = %llu\n", v->cluster_size);
-    printf("\tnum_nodes = %llu\n", v->num_nodes);
-    printf("\tnum_clusters = %llu\n", v->num_clusters);
-    printf("\tdir_node_size = %llu\n", v->dir_node_size);
-    printf("\tfile_node_size = %llu\n", v->file_node_size);
-    printf("\tinternal_off = %llu\n", v->internal_off);
-    printf("\tnode_cfg_off = %llu\n", v->node_cfg_off);
-    printf("\tnode_cfg_size = %llu\n", v->node_cfg_size);
-    printf("\tnew_cfg_off = %llu\n", v->new_cfg_off);
-    printf("\tprot_bits = 0%o\n", v->prot_bits);
-    printf("\tuid = %u\n", v->uid);
-    printf("\tgid = %u\n", v->gid);
-    printf("\texcl_mount = %d\n", v->excl_mount);
-    printf("\tdisk_hb = %d\n", v->disk_hb);
-    printf("\thb_timeo = %d\n", v->hb_timeo);
-}
-
-__u64 global_bm_bitnum_to_offset(int bitnum, void *data)
-{
-    ocfs_vol_disk_hdr *v = (ocfs_vol_disk_hdr *)data;
-    return (((__u64)bitnum * v->cluster_size) + v->data_start_off);
-}
-
-void print_bitmap(char *bmbuf, int bmsize, bit2off_func func, void *data)
-{    
-    int i;
-    __u64 off;
-
-    printf("\tSET\n");
-    for (i=0; i<bmsize; i++)
-    {
-        off = func(i, data);
-        if (test_bit(i, (unsigned long *)bmbuf))
-        {
-            printf("\t\t%llu (%d)\n", off, i);
-        }
-    }
-    printf("\tUNSET\n");
-    for (i=0; i<bmsize; i++)
-    {
-        off = func(i, data);
-        if (!test_bit(i, (unsigned long *)bmbuf))
-        {
-            printf("\t\t%llu (%d)\n", off, i);
-        }
-    }
-}
-
-void print_global_bitmap(int fd, void *buf)
-{
-    __u64 dso, cs, num;
-    char *bmbuf;
-    int bufsz;
-    ocfs_vol_disk_hdr * v = (ocfs_vol_disk_hdr *)buf;
-
-    dso = v->data_start_off;
-    cs = v->cluster_size;
-    num = v->num_clusters;
-    bufsz = (num+7)/8;
-    bufsz = OCFS_ALIGN(bufsz, 512);
-    bmbuf = (char *)malloc_aligned(bufsz); 
-    myseek64(fd, v->bitmap_off, SEEK_SET);
-    read(fd, bmbuf, bufsz);
-
-    printf("\tbitmap_off = %llu\n", v->bitmap_off);
-    printf("\tdata_start_off = %llu\n", v->data_start_off);
-    printf("\tcluster_size = %llu\n", v->cluster_size);
-    printf("\tnum_clusters = %llu\n", v->num_clusters);
-    print_bitmap(bmbuf, num, global_bm_bitnum_to_offset, v);
-    free_aligned(bmbuf);
-}
-
-void print_dir_node(void *buf)
-{
-    int i;
-    ocfs_dir_node * d = (ocfs_dir_node *)buf;
-
-    print_disk_lock(&d->disk_lock);
-    printf("\talloc_file_off = %llu\n", d->alloc_file_off);
-    printf("\talloc_node = %u\n", d->alloc_node);
-    printf("\tfree_node_ptr = ");
-    print_node_pointer(d->free_node_ptr);
-    printf("\tnode_disk_off = ");
-    print_node_pointer(d->node_disk_off);
-    printf("\tnext_node_ptr = ");
-    print_node_pointer(d->next_node_ptr);
-    printf("\tindx_node_ptr = ");
-    print_node_pointer(d->indx_node_ptr);
-    printf("\tnext_del_ent_node = ");
-    print_node_pointer(d->next_del_ent_node);
-    printf("\thead_del_ent_node = ");
-    print_node_pointer(d->head_del_ent_node);
-    printf("\tfirst_del = %d\n", d->first_del);
-    printf("\tnum_del = %d\n", d->num_del);
-    printf("\tnum_ents = %d\n", d->num_ents);
-    printf("\tdepth = %d\n", d->depth);
-    printf("\tnum_ent_used = %d\n", d->num_ent_used);
-    printf("\tdir_node_flags = %s\n",
-	   d->
-	   dir_node_flags & DIR_NODE_FLAG_ROOT ? "DIR_NODE_FLAG_ROOT" : "");
-    printf("\tsync_flags = 0x%x\n", d->sync_flags);
-    printf("\tindex_dirty = %s\n", d->index_dirty ? "true" : "false");
-    printf("\tbad_off = %d\n", d->bad_off);
-
-    printf("\tindex = ");
-    for (i = 0; i < 256; i++)
-    {
-	if (i % 16 == 0 && i != 0)
-	    printf("\n\t\t");
-	printf("%3u ", d->index[i]);
-    }
-    printf("\n");
-}
-
-void print_file_entry(void *buf)
-{
-    ocfs_file_entry * fe = (ocfs_file_entry *)buf;
-    char fname[OCFS_MAX_FILENAME_LENGTH + 1];
-    int i;
-    ocfs_alloc_ext *ext;
-
-    strncpy(fname, fe->filename, OCFS_MAX_FILENAME_LENGTH);
-    fname[OCFS_MAX_FILENAME_LENGTH] = '\0';
-    print_disk_lock(&fe->disk_lock);
-    printf("\tlocal_ext = %s\n", fe->local_ext ? "true" : "false");
-    printf("\tgranularity = %d\n", fe->granularity);
-    printf("\tfilename = %s\n", fname);
-    printf("\tfilename_len = %d\n", fe->filename_len);
-    if (args.twoFourbyte)
-    	printf("\tfile_size = %u.%u\n", HILO(fe->file_size));
-    else
-    	printf("\tfile_size = %llu\n", fe->file_size);
-    if (args.twoFourbyte)
-        printf("\talloc_size = %u.%u\n", HILO(fe->alloc_size));
-    else
-        printf("\talloc_size = %llu\n", fe->alloc_size);
-    printf("\tattribs = ");
-    print_file_attributes((__u32) fe->attribs);
-    printf("\tprot_bits = ");
-    print_protection_bits((__u32) fe->prot_bits);
-    printf("\tuid = %d\n", fe->uid);
-    printf("\tgid = %d\n", fe->gid);
-    printf("\tcreate_time = ");
-    print_time(&(fe->create_time));
-    printf("\tmodify_time = ");
-    print_time(&(fe->modify_time));
-    printf("\tdir_node_ptr = ");
-    print_node_pointer(fe->dir_node_ptr);
-    printf("\tthis_sector = ");
-    print_node_pointer(fe->this_sector);
-    printf("\tlast_ext_ptr = ");
-    print_node_pointer(fe->last_ext_ptr);
-    printf("\tsync_flags = ");
-    print_synch_flags(fe->sync_flags);
-    printf("\tlink_cnt = %u\n", fe->link_cnt);
-    printf("\tnext_del = %d\n", fe->next_del);
-    printf("\tnext_free_ext = %u\n", fe->next_free_ext);
-
-    for (i = 0; i < OCFS_MAX_FILE_ENTRY_EXTENTS; i++)
-    {
-	ext = &(fe->extents[i]);
-	if (args.twoFourbyte) {
-	    printf("\textent[%d].file_off = %u.%u\n", i, HILO(ext->file_off));
-	    printf("\textent[%d].num_bytes = %u.%u\n", i, HILO(ext->num_bytes));
-	    printf("\textent[%d].disk_off = %u.%u\n", i, HILO(ext->disk_off));
-	} else {
-	    printf("\textent[%d].file_off = %llu\n", i, ext->file_off);
-	    printf("\textent[%d].num_bytes = %llu\n", i, ext->num_bytes);
-	    printf("\textent[%d].disk_off = %llu\n", i, ext->disk_off);
-	}
-    }
-
-    printf("\n");
-}
-
-void print_extent_ex(void *buf)
-{
-	print_extent(buf, 1, args.twoFourbyte);
-}
-
-void print_extent(void *buf, int twolongs, bool prev_ptr_error)
-{
-    ocfs_extent_group * exthdr = (ocfs_extent_group *)buf;
-    char sig[10];
-    int i;
-    __u64 len;
-    char err[200];
-    ocfs_alloc_ext *ext;
-
-#define ERROR_STR	"<========== ERROR"
-
-    strncpy(sig, exthdr->signature, sizeof(sig));
-    printf("\tsignature = %s\n", sig);
-    printf("\tnext_free_ext = %d\n", exthdr->next_free_ext);
-    printf("\tcurr_sect = %u\n", exthdr->curr_sect);
-    printf("\tmax_sects = %u\n", exthdr->max_sects);
-    printf("\ttype = %u\n", exthdr->type);
-    printf("\tgranularity = %d\n", exthdr->granularity);
-    printf("\talloc_node = %u\n", exthdr->alloc_node);
-
-    *err = '\0';
-    if (prev_ptr_error)
-	strcpy(err, ERROR_STR);
-
-    if (twolongs) {
-	printf("\tthis_ext = %u.%u\n", HILO(exthdr->this_ext));
-	printf("\tnext_data_ext = %u.%u\n", HILO(exthdr->next_data_ext));
-	printf("\talloc_file_off = %u.%u\n", HILO(exthdr->alloc_file_off));
-	printf("\tlast_ext_ptr = %u.%u\n", HILO(exthdr->last_ext_ptr));
-	printf("\tup_hdr_node_ptr = %u.%u %s\n", HILO(exthdr->up_hdr_node_ptr), err);
-    } else {
-	printf("\tthis_ext = %llu\n", exthdr->this_ext);
-	printf("\tnext_data_ext = %llu\n", exthdr->next_data_ext);
-	printf("\talloc_file_off = %llu\n", exthdr->alloc_file_off);
-	printf("\tlast_ext_ptr = %llu\n", exthdr->last_ext_ptr);
-	printf("\tup_hdr_node_ptr = %llu %s\n", exthdr->up_hdr_node_ptr, err);
-    }
-
-    len = exthdr->extents[0].file_off;
-
-    for (i = 0; i < OCFS_MAX_DATA_EXTENTS; i++) {
-	ext = &(exthdr->extents[i]);
-	if (ext->file_off == 0)
-		len = 0;
-	*err = '\0';
-        if (len != ext->file_off)
-		sprintf(err, "%s(%llu, %llu)", ERROR_STR, len, len - ext->file_off);
-	if (twolongs) {
-		printf("\textent[%d].file_off = %u.%u %s\n", i, HILO(ext->file_off), err);
-		printf("\textent[%d].num_bytes = %u.%u\n", i, HILO(ext->num_bytes));
-		printf("\textent[%d].disk_off = %u.%u\n", i, HILO(ext->disk_off));
-	} else {
-		printf("\textent[%d].file_off = %llu %s\n", i, ext->file_off, err);
-		printf("\textent[%d].num_bytes = %llu\n", i, ext->num_bytes);
-		printf("\textent[%d].disk_off = %llu\n", i, ext->disk_off);
-	}
-	len += ext->num_bytes;
-    }
-
-    printf("\n");
-}
-
-void print_vote_sector(void *buf)
-{
-    ocfs_vote * vote = (ocfs_vote *)buf;
-    printf("\tseq_num = %llu\n", vote->vote_seq_num);
-    printf("\tdir_ent = %llu\n", vote->dir_ent);
-    printf("\topen_handle = %s\n", vote->open_handle ? "Yes" : "No");
-    {
-	int j;
-
-	for (j = 0; j < MAX_NODES; j++)
-	{
-	    if (args.voteNodes[j])
-	    {
-		printf("\tVote%d = ", j);
-		print_vote_type(vote->vote[j]);
-	    }
-	}
-    }
-    printf("\n");
-}
-
-void print_publish_sector(void *buf)
-{
-    ocfs_publish * pub = (ocfs_publish *)buf;
-    printf("\ttime = ");
-    printf("%u.%u\n", HI(pub->time), LO(pub->time));
-    printf("\tvote = %s\n", pub->vote ? "Yes" : "No");
-    printf("\tdirty = %s\n", pub->dirty ? "Yes" : "No");
-    printf("\tvote_type = ");
-    print_publish_flags(pub->vote_type);
-    printf("\tvote_map = ");
-    print___u64_as_bitmap(pub->vote_map);
-    printf("\tseq_num = %llu\n", pub->publ_seq_num);
-    printf("\tdir_ent = %llu\n", pub->dir_ent);
-    {
-	int j;
-
-	printf("\thbm = ");
-	for (j = 0; j < MAX_NODES; j++)
-	{
-	    if (args.publishNodes[j])
-		printf("%u ", pub->hbm[j]);
-	}
-	printf("\n");
-    }
-    printf("\n");
-}
-
-void print_cdsl_offsets(void *buf)
-{
-    __u64 * off = (__u64 *)buf;
-    int i;
-
-    for (i = 0; i < 32; i++)
-    {
-	printf("\tOffset[%d] = %llu\n", i, off[i]);
-    }
-}
-
-void print_disk_lock(void *buf)
-{
-    ocfs_disk_lock * l = (ocfs_disk_lock *)buf;
-
-    printf("\tcurr_master = ");
-    if (l->curr_master == -1)
-	printf("INVALID_MASTER\n");
-    else
-	printf("%d\n", l->curr_master);
-    printf("\tfile_lock = ");
-    print_lock_type(l->file_lock);
-    printf("\toin_node_map = ");
-    print___u64_as_bitmap(l->oin_node_map);
-    printf("\tseq_num = %llu\n", l->dlock_seq_num);
-}
-
-int ocfs_find_clear_bits (ocfs_alloc_bm * bitmap, __u32 numBits, __u32 offset, __u32 sysonly);
-
-void print_system_file(int fd, ocfs_vol_disk_hdr * v, int fileid)
-{
-    ocfs_super *vcb = NULL;
-    void *buf = NULL;
-    int nodenum, size;
-    __u64 diskoff; 
-    int type = OCFS_INVALID_SYSFILE;
-    ocfs_file_entry *fe = NULL;
-    char *desc;
-    __u64 fileSize, allocSize;
-    int status;
-
-    /* find the physical disk offset */
-    diskoff = (__u64) (fileid * 512) + v->internal_off;
-   
-    type = OCFS_FILE_NUM_TO_SYSFILE_TYPE(fileid);
-    switch (type)
-    {
-        case OCFS_VOL_MD_SYSFILE:
-            desc = "vol_metadata";
-            nodenum = fileid - OCFS_FILE_VOL_META_DATA;
-            break;
-        case OCFS_VOL_MD_LOG_SYSFILE:
-            desc = "vol_metadata_log";
-            nodenum = fileid - OCFS_FILE_VOL_LOG_FILE;
-            break;
-        case OCFS_DIR_SYSFILE:
-            desc = "dir_alloc";
-            nodenum = fileid - OCFS_FILE_DIR_ALLOC;
-            break;
-        case OCFS_DIR_BM_SYSFILE:
-            desc = "dir_alloc_bitmap";
-            nodenum = fileid - OCFS_FILE_DIR_ALLOC_BITMAP;
-            break;
-        case OCFS_FILE_EXTENT_SYSFILE:
-            desc = "file_extent";
-            nodenum = fileid - OCFS_FILE_FILE_ALLOC;
-            break;
-        case OCFS_FILE_EXTENT_BM_SYSFILE:
-            desc = "file_extent_bitmap";
-            nodenum = fileid - OCFS_FILE_FILE_ALLOC_BITMAP;
-            break;
-        case OCFS_RECOVER_LOG_SYSFILE:
-            desc = "recover_log";
-            nodenum = fileid - LOG_FILE_BASE_ID;
-            break;
-        case OCFS_CLEANUP_LOG_SYSFILE:
-            desc = "cleanup_log";
-            nodenum = fileid - CLEANUP_FILE_BASE_ID;
-            break;
-        default:
-	    printf("error!!!!!  bad system file number!\n");
-            return;
-    }
-
-    vcb = get_fake_vcb(fd, v, nodenum);
-    printf("%s_%d:\n", desc, nodenum);
-    printf("\tfile_number = %d\n", fileid);
-    printf("\tdisk_offset = %llu\n", diskoff);
-    if (!ocfs_force_get_file_entry(vcb, &fe, diskoff, true))
-    {   
-        print_file_entry(fe);
-        ocfs_release_file_entry(fe);
-    }
-
-    status = ocfs_get_system_file_size(vcb, fileid, &fileSize, &allocSize);
-    if (status >= 0)
-    {
-        printf("\tfile_size = %d\n", fileSize);
-        printf("\talloc_size = %d\n", allocSize);
-
-        if (type==OCFS_DIR_BM_SYSFILE || type==OCFS_FILE_EXTENT_BM_SYSFILE)
-        {
-	    size = OCFS_ALIGN(allocSize, 512);
-	    buf = (void *) malloc_aligned(size);
-            if (allocSize)
-            {
-	        status = ocfs_read_system_file(vcb, fileid, buf, allocSize, (__u64)0);
-	        if (status >= 0)
-	        {
-		    ocfs_alloc_bm bm;
-		    int freebits, firstclear;
-    
-		    ocfs_initialize_bitmap(&bm, (__u32 *) buf, (__u32) (fileSize * 8));
-		    freebits = ocfs_count_bits(&bm);
-		    firstclear = ocfs_find_clear_bits(&bm, 1, 0, 0);
-    
-		    printf("\tTotalBits = %u\n", ((__u32) fileSize * 8));
-		    printf("\tFreeBits = %u\n", freebits);
-		    printf("\tUsedBits = %u\n", ((__u32) fileSize * 8) - freebits);
-		    printf("\tFirstClearBit = %u\n", firstclear);
-	        }
-            }
-        }
-        /* two types of log files */
-        else if (type==OCFS_CLEANUP_LOG_SYSFILE || type==OCFS_RECOVER_LOG_SYSFILE)
-        {
-	    ocfs_log_record *lr;
-	    ocfs_cleanup_record *cr;
-	    int st;
-            __u64 logsize;
-    
-	    if (fileid < CLEANUP_FILE_BASE_ID)
-	    {
-	        /* LOG_FILE */
-	        nodenum = fileid - LOG_FILE_BASE_ID;
-	        logsize = 512;
-	    }
-	    else
-	    {
-	        /* CLEANUP_FILE */
-	        nodenum = fileid - CLEANUP_FILE_BASE_ID;
-	        logsize = sizeof(ocfs_cleanup_record);
-	        logsize = OCFS_ALIGN(logsize, 512);
-	    }
-    
-	    vcb = get_fake_vcb(fd, v, nodenum);
-	    buf = malloc_aligned(logsize);
-	    memset(buf, 0, logsize);
-            if (allocSize)
-            {
-	        st = ocfs_read_system_file(vcb, (__u32) fileid, buf, logsize, (__u64)0);
-    
-	        if (type == OCFS_RECOVER_LOG_SYSFILE)
-	        {
-	            lr = (ocfs_log_record *) buf;
-	            printf("\tlog_id = %llu\n", lr->log_id);
-	            printf("\tlog_type = ");
-	            print_log_type(lr->log_type);
-	            print_record((void *) &(lr->rec), lr->log_type);
-	        }
-	        else // if (type == OCFS_CLEANUP_LOG_SYSFILE)
-	        {
-	            cr = (ocfs_cleanup_record *) buf;
-	            printf("\tlog_id = %llu\n", cr->log_id);
-	            printf("\tlog_type = ");
-	            print_log_type(cr->log_type);
-	            print_record((void *) &(cr->rec), cr->log_type);
-	        }
-            }
-        }
-        else
-        {
-        }
-    }
-
-    if (buf != NULL)
-	free_aligned(buf);
-    if (vcb != NULL)
-	free(vcb);
-}
-
-
-void print_file_data(int fd, ocfs_file_entry * fe)
-{
-    char buf[101];
-
-    if (fe->local_ext && fe->extents[0].disk_off != 0)
-    {
-	myseek64(fd, fe->extents[0].disk_off, SEEK_SET);
-	read(fd, buf, 100);
-	buf[100] = '\0';
-	printf("\tFileData = %s\n", buf);
-    }
-}
-
-void handle_one_file_entry(int fd, ocfs_file_entry *fe, void *buf)
-{
-    const char *parent = (const char *)buf;
-
-    printf("\tFile%d = %s%s%s\n", filenum++, parent, fe->filename,
-        fe->attribs & OCFS_ATTRIB_DIRECTORY ? "/" : "");
-    if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
-    {
-        if (fe->extents[0].disk_off)
-        {
-            char *newparent = (char *) malloc(strlen(parent) + strlen(fe->filename) + 2);
-            sprintf(newparent, "%s%s/", parent, fe->filename);
-            walk_dir_nodes(fd, fe->extents[0].disk_off, newparent, NULL);
-            free(newparent);
-        }
-    }
-}
-
-/* helper functions for pretty-printing various flags */
-
-void print_node_pointer(__u64 ptr)
-{
-    if (ptr == INVALID_NODE_POINTER)
-	printf("INVALID_NODE_POINTER\n");
-    else {
-        if (args.twoFourbyte)
-	    printf("%u.%u\n", HILO(ptr));
-	else
-	    printf("%llu\n", ptr);
-    }
-}
-
-void print___u64_as_bitmap(__u64 x)
-{
-    int pos = 0;
-
-    while (pos < 32)
-    {
-	printf("%d", (x & (1 << pos)) ? 1 : 0);
-	pos++;
-    }
-    printf("\n");
-}
-
-void print_time(__u64 * sec)
-{
-    printf("%s", ctime((const time_t *) sec));
-}
-
-
-void print_lock_type(__u8 lock)
-{
-    if (lock == OCFS_DLM_NO_LOCK)
-        printf("OCFS_DLM_NO_LOCK\n");
-    else if (lock == OCFS_DLM_EXCLUSIVE_LOCK)
-        printf("OCFS_DLM_EXCLUSIVE_LOCK\n");
-    else if (lock == OCFS_DLM_SHARED_LOCK)
-        printf("OCFS_DLM_SHARED_LOCK\n");
-    else if (lock == OCFS_DLM_ENABLE_CACHE_LOCK)
-        printf("OCFS_DLM_ENABLE_CACHE_LOCK\n");
-    else
-        printf("UNKNOWN LOCK TYPE\n");
-}
-
-void print_file_attributes(__u32 attribs)
-{
-    if (attribs & OCFS_ATTRIB_DIRECTORY)
-	printf("OCFS_ATTRIB_DIRECTORY ");
-    if (attribs & OCFS_ATTRIB_FILE_CDSL)
-	printf("OCFS_ATTRIB_FILE_CDSL ");
-    if (attribs & OCFS_ATTRIB_CHAR)
-	printf("OCFS_ATTRIB_CHAR ");
-    if (attribs & OCFS_ATTRIB_BLOCK)
-	printf("OCFS_ATTRIB_BLOCK ");
-    if (attribs & OCFS_ATTRIB_REG)
-	printf("OCFS_ATTRIB_REG ");
-    if (attribs & OCFS_ATTRIB_FIFO)
-	printf("OCFS_ATTRIB_FIFO ");
-    if (attribs & OCFS_ATTRIB_SYMLINK)
-	printf("OCFS_ATTRIB_SYMLINK ");
-    if (attribs & OCFS_ATTRIB_SOCKET)
-	printf("OCFS_ATTRIB_SOCKET ");
-
-    printf("\n");
-}
-
-void print_vote_type(int type)
-{
-    if (type & FLAG_VOTE_NODE)
-	printf("FLAG_VOTE_NODE ");
-    if (type & FLAG_VOTE_OIN_UPDATED)
-	printf("FLAG_VOTE_OIN_UPDATED ");
-    if (type & FLAG_VOTE_OIN_ALREADY_INUSE)
-	printf("FLAG_VOTE_OIN_ALREADY_INUSE ");
-    if (type & FLAG_VOTE_UPDATE_RETRY)
-	printf("FLAG_VOTE_UPDATE_RETRY ");
-    if (type & FLAG_VOTE_FILE_DEL)
-	printf("FLAG_VOTE_FILE_DEL ");
-
-    printf("(0x%08x)", type);
-
-    printf("\n");
-}
-
-void print_log_type(int type)
-{
-    if (type == LOG_TYPE_DISK_ALLOC)
-        printf("LOG_TYPE_DISK_ALLOC\n");
-    else if (type == LOG_TYPE_DIR_NODE)
-        printf("LOG_TYPE_DIR_NODE\n");
-    else if (type == LOG_TYPE_RECOVERY)
-        printf("LOG_TYPE_RECOVERY\n");
-    else if (type == LOG_CLEANUP_LOCK)
-        printf("LOG_CLEANUP_LOCK\n");
-    else if (type == LOG_TYPE_TRANS_START)
-        printf("LOG_TYPE_TRANS_START\n");
-    else if (type == LOG_TYPE_TRANS_END)
-        printf("LOG_TYPE_TRANS_END\n");
-    else if (type == LOG_RELEASE_BDCAST_LOCK)
-        printf("LOG_RELEASE_BDCAST_LOCK\n");
-    else if (type == LOG_DELETE_ENTRY)
-        printf("LOG_DELETE_ENTRY\n");
-    else if (type == LOG_MARK_DELETE_ENTRY)
-        printf("LOG_MARK_DELETE_ENTRY\n");
-    else if (type == LOG_FREE_BITMAP)
-        printf("LOG_FREE_BITMAP\n");
-    else if (type == LOG_UPDATE_EXTENT)
-        printf("LOG_UPDATE_EXTENT\n");
-    else if (type == LOG_DELETE_NEW_ENTRY)
-        printf("LOG_DELETE_NEW_ENTRY\n");
-    else
-        printf("unknown log type (%d)\n", type);
-}
-
-void print_alloc_log(ocfs_alloc_log * rec)
-{
-    printf("\tlength = %llu\n", rec->length);
-    printf("\tfile_off = %llu\n", rec->file_off);
-    printf("\ttype = %u\n", rec->type);
-    printf("\tnode_num = %u\n", rec->node_num);
-}
-
-void print_dir_log(ocfs_dir_log * rec)
-{
-    printf("\torig_off = %llu\n", rec->orig_off);
-    printf("\tsaved_off = %llu\n", rec->saved_off);
-    printf("\tlength = %llu\n", rec->length);
-}
-
-void print_recovery_log(ocfs_recovery_log * rec)
-{
-    printf("\tnode_num = %llu\n", rec->node_num);
-}
-
-void print_lock_log(ocfs_lock_log * rec)
-{
-    int i;
-
-    printf("\tnum_lock_upds = %u\n", rec->num_lock_upds);
-    for (i = 0; i < rec->num_lock_upds && i < LOCK_UPDATE_LOG_SIZE; i++)
-    {
-	printf("\torig_off[%d] = %llu\n", i, rec->lock_upd[i].orig_off);
-	printf("\tnew_off[%d] = %llu\n", i, rec->lock_upd[i].new_off);
-    }
-}
-void print_bcast_rel_log(ocfs_bcast_rel_log * rec)
-{
-    printf("\tlock_id = %llu\n", rec->lock_id);
-}
-
-void print_delete_log(ocfs_delete_log * rec)
-{
-    printf("\tnode_num = %llu\n", rec->node_num);
-    printf("\tent_del = %llu\n", rec->ent_del);
-    printf("\tparent_dirnode_off = %llu\n", rec->parent_dirnode_off);
-    printf("\tflags = %u\n", rec->flags);
-}
-
-void print_free_log(ocfs_free_log * rec)
-{
-    int i;
-
-    printf("\tnum_free_upds = %u\n", rec->num_free_upds);
-    for (i = 0; i < rec->num_free_upds && i < FREE_LOG_SIZE; i++)
-    {
-	printf("\tlength = %llu\n", rec->free_bitmap[i].length);
-	printf("\tfile_off = %llu\n", rec->free_bitmap[i].file_off);
-	printf("\ttype = %u\n", rec->free_bitmap[i].type);
-	printf("\tnode_num = %u\n", rec->free_bitmap[i].node_num);
-    }
-}
-void print_extent_rec(ocfs_free_extent_log * rec)
-{
-    printf("\tindex = %u\n", rec->index);
-    printf("\tdisk_off = %llu\n", rec->disk_off);
-}
-
-void print_record(void *rec, int type)
-{
-    switch (type)
-    {
-	case LOG_TYPE_DISK_ALLOC:
-	    print_alloc_log((ocfs_alloc_log *) rec);
-	    break;
-	case LOG_TYPE_DIR_NODE:
-	    print_dir_log((ocfs_dir_log *) rec);
-	    break;
-	case LOG_TYPE_RECOVERY:
-	    print_recovery_log((ocfs_recovery_log *) rec);
-	    break;
-	case LOG_CLEANUP_LOCK:
-	    print_lock_log((ocfs_lock_log *) rec);
-	    break;
-	case LOG_RELEASE_BDCAST_LOCK:
-	    print_bcast_rel_log((ocfs_bcast_rel_log *) rec);
-	    break;
-	case LOG_DELETE_ENTRY:
-	case LOG_MARK_DELETE_ENTRY:
-	    print_delete_log((ocfs_delete_log *) rec);
-	    break;
-	case LOG_FREE_BITMAP:
-	    print_free_log((ocfs_free_log *) rec);
-	    break;
-	case LOG_UPDATE_EXTENT:
-	    print_extent_rec((ocfs_free_extent_log *) rec);
-	    break;
-
-	case LOG_TYPE_TRANS_START:
-	case LOG_TYPE_TRANS_END:
-	default:
-	    /* print nothing */
-	    break;
-    }
-}
-
-void print_synch_flags(int flags)
-{
-    if (flags == 0)
-    {
-	printf("OCFS_SYNC_FLAG_DELETED\n");
-	return;
-    }
-    if (flags & OCFS_SYNC_FLAG_VALID)
-	printf("OCFS_SYNC_FLAG_VALID ");
-    if (flags & OCFS_SYNC_FLAG_CHANGE)
-	printf("OCFS_SYNC_FLAG_CHANGE ");
-    if (flags & OCFS_SYNC_FLAG_MARK_FOR_DELETION)
-	printf("OCFS_SYNC_FLAG_MARK_FOR_DELETION ");
-    if (flags & OCFS_SYNC_FLAG_NAME_DELETED)
-	printf("OCFS_SYNC_FLAG_NAME_DELETED ");
-
-    printf("\n");
-}
-
-void print_publish_flags(int type)
-{
-    if (type & FLAG_FILE_CREATE)
-	printf("FLAG_FILE_CREATE ");
-    if (type & FLAG_FILE_EXTEND)
-	printf("FLAG_FILE_EXTEND ");
-    if (type & FLAG_FILE_DELETE)
-	printf("FLAG_FILE_DELETE ");
-    if (type & FLAG_FILE_RENAME)
-	printf("FLAG_FILE_RENAME ");
-    if (type & FLAG_FILE_UPDATE)
-	printf("FLAG_FILE_UPDATE ");
-    if (type & FLAG_FILE_CREATE_DIR)
-	printf("FLAG_FILE_CREATE_DIR ");
-    if (type & FLAG_FILE_UPDATE_OIN)
-	printf("FLAG_FILE_UPDATE_OIN ");
-    if (type & FLAG_FILE_RELEASE_MASTER)
-	printf("FLAG_FILE_RELEASE_MASTER ");
-    if (type & FLAG_CHANGE_MASTER)
-	printf("FLAG_CHANGE_MASTER ");
-    if (type & FLAG_ADD_OIN_MAP)
-	printf("FLAG_ADD_OIN_MAP ");
-    if (type & FLAG_DIR)
-	printf("FLAG_DIR ");
-    if (type & FLAG_DEL_NAME)
-	printf("FLAG_DEL_NAME ");
-    if (type & FLAG_RESET_VALID)
-	printf("FLAG_RESET_VALID ");
-    if (type & FLAG_FILE_RELEASE_CACHE)
-	printf("FLAG_FILE_RELEASE_CACHE ");
-    if (type & FLAG_FILE_CREATE_CDSL)
-	printf("FLAG_FILE_CREATE_CDSL ");
-    if (type & FLAG_FILE_DELETE_CDSL)
-	printf("FLAG_FILE_DELETE_CDSL ");
-    if (type & FLAG_FILE_CHANGE_TO_CDSL)
-	printf("FLAG_FILE_CHANGE_TO_CDSL ");
-    if (type & FLAG_FILE_TRUNCATE)
-	printf("FLAG_FILE_TRUNCATE ");
-
-    printf("(0x%08x)", type);
-
-    printf("\n");
-}
-
-void print_protection_bits(__u32 prot)
-{
-    if (prot & S_ISUID)
-	printf("S_ISUID ");
-    if (prot & S_ISGID)
-	printf("S_ISGID ");
-    if (prot & S_ISVTX)
-	printf("S_ISVTX ");
-    if (prot & S_IRUSR)
-	printf("S_IRUSR ");
-    if (prot & S_IWUSR)
-	printf("S_IWUSR ");
-    if (prot & S_IXUSR)
-	printf("S_IXUSR ");
-    if (prot & S_IRGRP)
-	printf("S_IRGRP ");
-    if (prot & S_IWGRP)
-	printf("S_IWGRP ");
-    if (prot & S_IXGRP)
-	printf("S_IXGRP ");
-    if (prot & S_IROTH)
-	printf("S_IROTH ");
-    if (prot & S_IWOTH)
-	printf("S_IWOTH ");
-    if (prot & S_IXOTH)
-	printf("S_IXOTH ");
-
-    printf("\n");
-}
-
-

Copied: trunk/debugocfs/print.c (from rev 205, trunk/ocfs/debugocfs/print.c)

Deleted: trunk/debugocfs/test.c
===================================================================
--- trunk/ocfs/debugocfs/test.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/debugocfs/test.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,87 +0,0 @@
-/*
- * test.c
- *
- * 
- *
- * Copyright (C) 2002 Oracle Corporation.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Author: Kurt Hackel
- *
- * gcc -o test test.c `pkg-config --cflags --libs glib` -ldebugocfs -locfsusr -L. -L../../ocfs2/ -g
- */
-
-#include <glib.h>
-#include <stdio.h>
-#include "libdebugocfs.h"
-
-int main(int argc, char **argv)
-{
-    int ret, i;
-    GArray *arr;
-
-    if (argc < 3)
-    {
-	fprintf(stderr, "usage: test /dev/path /dir/to/read/\n");
-	exit(1);
-    }
-
-    ret = libocfs_readdir(argv[1], argv[2], TRUE, &arr);
-    printf("ret=%d arraysize=%d\n", ret, arr->len);
-    if (ret == 0)
-    {
-	for (i = 0; i < arr->len; i++)
-	{
-	    libocfs_stat *x;
-
-	    x = (libocfs_stat *) (arr->data + (sizeof(libocfs_stat) * i));
-	    printf("name=%s size=%llu\n", x->name, x->size);
-	}
-    }
-    g_array_free(arr, TRUE);
-
-    ret = libocfs_get_node_map(argv[1], &arr);
-    printf("ret=%d arraysize=%d\n", ret, arr->len);
-
-    if (ret == 0)
-    {
-	for (i = 0; i < arr->len; i++)
-	{
-	    libocfs_node *x;
-
-	    x = (libocfs_node *) (arr->data + (sizeof(libocfs_node) * i));
-	    printf("name='%s' ip=%s slot=%d guid='%s'\n", x->name,
-		   x->addr, x->slot, x->guid);
-	}
-    }
-    g_array_free(arr, TRUE);
-
-
-
-}
-
-#if 0
-33 typedef struct _libocfs_node 34
-{
-    35 char name[MAX_NODE_NAME_LENGTH + 1];
-    36 int num_addrs;
-    37 char **addrs;		// array of char[16]
-    38 int slot;
-  39}
-libocfs_node;
-
-#endif

Copied: trunk/debugocfs/test.c (from rev 205, trunk/ocfs/debugocfs/test.c)

Copied: trunk/format (from rev 204, trunk/ocfs/format)

Deleted: trunk/format/Cscope.make
===================================================================
--- trunk/ocfs/format/Cscope.make	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/format/Cscope.make	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,9 +0,0 @@
-.PHONY: cscope
-cscope:
-	rm -f cscope.*
-	echo "-k" >> cscope.files
-	echo "-I inc" >> cscope.files
-	find . -maxdepth 2 -name '*.c' -print >>cscope.files
-	find . -maxdepth 2 -name '*.h' -print >>cscope.files
-	find ../libocfs -name '*.h' -print >>cscope.files
-	cscope -b

Copied: trunk/format/Cscope.make (from rev 205, trunk/ocfs/format/Cscope.make)

Deleted: trunk/format/Makefile
===================================================================
--- trunk/ocfs/format/Makefile	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/format/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,71 +0,0 @@
-TOPDIR = ../..
-
-include $(TOPDIR)/Preamble.make
-
-WARNINGS = -Wall -Wstrict-prototypes -Wno-format -Wmissing-prototypes \
-           -Wmissing-declarations
-
-ifdef OCFS_DEBUG
-OPTS = -g
-endif
-
-CFLAGS = $(OPTS) -fno-strict-aliasing $(WARNINGS) -pthread $(GLIB_CFLAGS)
-
-SBIN_PROGRAMS = mkfs.ocfs mounted.ocfs tuneocfs
-
-INCLUDES = -I$(TOPDIR)/ocfs/libocfs/Common/inc -I$(TOPDIR)/ocfs/libocfs/Linux/inc -Iinc -I$(TOPDIR)/ocfs/libocfs
-DEFINES = -DLINUX -DUSERSPACE_TOOL -DFORMAT_OCFS
-
-OPTIMIZE = -O2
-
-ifeq ($(OCFS_PROCESSOR),x86_64)
-  CFLAGS += -m64
-endif
-ifeq ($(OCFS_PROCESSOR),ia64)
-endif
-ifeq ($(OCFS_PROCESSOR),i686)
-  DEFINES += -D__ILP32__
-endif
-ifeq ($(OCFS_PROCESSOR),s390x)
-  DEFINES += -D__LP64__
-endif
-
-CFLAGS += $(OPTIMIZE)
-
-VERSION_FILES = format.c frmtport.c inc/format.h inc/frmtport.h journal.c mounted.c system.c tune.c inc/tune.h inc/jfs_compat.h inc/kernel-jbd.h inc/kernel-list.h
-VERSION_SRC = frmtport.c
-VERSION_PREFIX = OCFS
-
-DIST_RULES = dist-incdir
-
-MANS = mkfs.ocfs.8 tuneocfs.8
-
-INSTALL_RULES = install-sbin-links install-man-links
-
-install-sbin-links: install-sbin-programs
-	cd $(DESTDIR)$(sbindir) \
-	&& rm -f resizeocfs \
-	&& $(LN_S) tuneocfs resizeocfs
-
-install-man-links: install-mans
-	cd $(DESTDIR)$(mandir)/man8 \
-	&& rm -f resizeocfs.8 \
-	&& $(LN_S) tuneocfs.8 resizeocfs.8
-
-DIST_FILES = $(VERSION_FILES) $(VERSION_SRC) mkfs.ocfs.8.in tuneocfs.8.in
-
-vpath ocfsheartbeat.c $(TOPDIR)/ocfs/libocfs/Common
-
-mkfs.ocfs: format.o frmtport.o journal.o system.o
-	$(LINK) -L$(TOPDIR)/ocfs/libocfs -locfs
-
-mounted.ocfs: mounted.o frmtport.o
-	$(LINK) -L$(TOPDIR)/ocfs/libocfs -locfs
-
-tuneocfs: tune.o frmtport.o
-	$(LINK) -L$(TOPDIR)/ocfs/libocfs -locfs
-
-dist-incdir:
-	$(TOPDIR)/mkinstalldirs $(DIST_DIR)/inc
-
-include $(TOPDIR)/Postamble.make

Copied: trunk/format/Makefile (from rev 205, trunk/ocfs/format/Makefile)
===================================================================
--- trunk/ocfs/format/Makefile	2004-08-30 22:26:51 UTC (rev 205)
+++ trunk/format/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -0,0 +1,71 @@
+TOPDIR = ..
+
+include $(TOPDIR)/Preamble.make
+
+WARNINGS = -Wall -Wstrict-prototypes -Wno-format -Wmissing-prototypes \
+           -Wmissing-declarations
+
+ifdef OCFS_DEBUG
+OPTS = -g
+endif
+
+CFLAGS = $(OPTS) -fno-strict-aliasing $(WARNINGS) -pthread $(GLIB_CFLAGS)
+
+SBIN_PROGRAMS = mkfs.ocfs mounted.ocfs tuneocfs
+
+INCLUDES = -I$(TOPDIR)/libocfs/Common/inc -I$(TOPDIR)/libocfs/Linux/inc -Iinc -I$(TOPDIR)/libocfs
+DEFINES = -DLINUX -DUSERSPACE_TOOL -DFORMAT_OCFS
+
+OPTIMIZE = -O2
+
+ifeq ($(OCFS_PROCESSOR),x86_64)
+  CFLAGS += -m64
+endif
+ifeq ($(OCFS_PROCESSOR),ia64)
+endif
+ifeq ($(OCFS_PROCESSOR),i686)
+  DEFINES += -D__ILP32__
+endif
+ifeq ($(OCFS_PROCESSOR),s390x)
+  DEFINES += -D__LP64__
+endif
+
+CFLAGS += $(OPTIMIZE)
+
+VERSION_FILES = format.c frmtport.c inc/format.h inc/frmtport.h journal.c mounted.c system.c tune.c inc/tune.h inc/jfs_compat.h inc/kernel-jbd.h inc/kernel-list.h
+VERSION_SRC = frmtport.c
+VERSION_PREFIX = OCFS
+
+DIST_RULES = dist-incdir
+
+MANS = mkfs.ocfs.8 tuneocfs.8
+
+INSTALL_RULES = install-sbin-links install-man-links
+
+install-sbin-links: install-sbin-programs
+	cd $(DESTDIR)$(sbindir) \
+	&& rm -f resizeocfs \
+	&& $(LN_S) tuneocfs resizeocfs
+
+install-man-links: install-mans
+	cd $(DESTDIR)$(mandir)/man8 \
+	&& rm -f resizeocfs.8 \
+	&& $(LN_S) tuneocfs.8 resizeocfs.8
+
+DIST_FILES = $(VERSION_FILES) $(VERSION_SRC) mkfs.ocfs.8.in tuneocfs.8.in
+
+vpath ocfsheartbeat.c $(TOPDIR)/libocfs/Common
+
+mkfs.ocfs: format.o frmtport.o journal.o system.o $(TOPDIR)/libocfs/libocfs.a
+	$(LINK) -L$(TOPDIR)/libocfs -locfs
+
+mounted.ocfs: mounted.o frmtport.o $(TOPDIR)/libocfs/libocfs.a
+	$(LINK) -L$(TOPDIR)/libocfs -locfs
+
+tuneocfs: tune.o frmtport.o $(TOPDIR)/libocfs/libocfs.a
+	$(LINK) -L$(TOPDIR)/libocfs -locfs
+
+dist-incdir:
+	$(TOPDIR)/mkinstalldirs $(DIST_DIR)/inc
+
+include $(TOPDIR)/Postamble.make

Deleted: trunk/format/format.c
===================================================================
--- trunk/ocfs/format/format.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/format/format.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,1066 +0,0 @@
-/*
- * format.c
- *
- * ocfs format utility
- *
- * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Neeraj Goyal, Suchit Kaura, Kurt Hackel, Sunil Mushran,
- *          Manish Singh, Wim Coekaerts
- */
-
-#include <format.h>
-#include <signal.h>
-#include <libgen.h>
-
-ocfs_alloc_bm global_bm;
-char *bm_buf = NULL;
-int bm_size = 0;
-
-bool in_data_blocks = false;
-bool format_intr = false;
-
-ocfs_options opts = {
-	.device = "",
-	.block_size = 0,
-	.clear_data_blocks = false,
-	.force_op = false,
-	.gid = 0,
-	.volume_label = "",
-	.mount_point = "",
-	.query_only = false,
-	.perms = 0755,
-	.quiet = false,
-	.uid = 0,
-	.print_progress = false,
-	.slot_num = OCFS_INVALID_NODE_NUM,
-	.device_size = 0 
-};
-
-#define OCFS_MKFS_V2 "mkfs.ocfs2"
-int major_version = OCFS_MAJOR_VERSION;
-int minor_version = OCFS_MINOR_VERSION;
-__u64 sect_count = 0;
-__u64 format_size = 0;
-int rawminor = 0;
-char rawdev[FILE_NAME_SIZE];
-int file = 0;
-
-char *usage_string =
-"usage: %s -b block-size [-C] [-F] [-g gid] [-h] -L volume-label "
-"-m mount-path [-n] [-p permissions] [-q] [-u uid] [-V] device\n\n"
-"	-b Block size in kilo bytes\n"
-"	-C Clear all data blocks\n"
-"	-F Force format existing OCFS volume\n"
-"	-g GID for the root directory\n"
-"	-h Help\n"
-"	-L Volume label\n"
-"	-m Path where this device will be mounted\n"
-"	-n Query only\n"
-"	-p Permissions for the root directory\n"
-"	-q Quiet execution\n"
-"	-u UID for the root directory\n"
-"	-V Print version and exit\n";
-
-
-/*
- * main()
- *
- */
-int main(int argc, char **argv)
-{
-    ocfs_vol_disk_hdr *volhdr = NULL;
-    __u32 sect_size = OCFS_SECTOR_SIZE;
-    __u64 vol_size = 0;
-    char vol_id[MAX_VOL_ID_LENGTH];
-    __u64 offset;
-    __u64 publ_off = 0;
-    __u64 data_start_off = 0;
-    bool ocfs_vol = false;
-    __u32 nodemap = 0;
-    char *node_names[OCFS_MAXIMUM_NODES];
-    char *base;
-    char *progname = NULL;
-
-#define INSTALL_SIGNAL(sig) 						\
-	do { 								\
-		if (signal(sig, HandleSignal) == SIG_ERR) {		\
-			fprintf(stderr, "Could not set " #sig "\n");	\
-			goto bail;					\
-		}							\
-	} while(0)
-
-    INSTALL_SIGNAL(SIGTERM);
-    INSTALL_SIGNAL(SIGINT);
-    
-    init_raw_cleanup_message();
-
-    if (!(volhdr = (ocfs_vol_disk_hdr *) MemAlloc(sect_size)))
-	    goto bail;
-    else
-	    memset(volhdr, 0, sect_size);
-
-    progname = strdup(argv[0]);
-    if (!progname)
-	    goto bail;
-    base = basename(progname);
-    if (!base)
-	    goto bail;
-
-    if (strcmp(base, OCFS_MKFS_V2) == 0) {
-	    major_version = OCFS2_MAJOR_VERSION;
-	    minor_version = OCFS2_MINOR_VERSION;
-    }
-    free (progname);
-
-    /* Read the options */
-    if (!ReadOptions(argc, argv))
-	goto bail;
-
-    /* Validate the options */
-    if (!ValidateOptions())
-	goto bail;
-
-    /* Generate Volume ID */
-    if (!GenerateVolumeID(vol_id, sizeof(vol_id)))
-	goto bail;
-
-    /* Open the supplied disk */
-    if (!(file = OpenDisk(opts.device)))
-	goto bail;
-
-    /* Get the partition Information */
-    if (!(GetDiskGeometry(file, &vol_size, &sect_size)))
-	goto bail;
-
-    if (opts.device_size) {
-	if (opts.device_size > vol_size) {
-		fprintf(stderr, "Error: Size specified is larger "
-			"than the device size.\nAborting.\n");
-		goto bail;
-	} else
-		vol_size = opts.device_size;
-    }
-	    
-    if (vol_size < OCFS_MIN_VOL_SIZE) {
-	fprintf(stderr, "Error: %s at %lluMB is smaller than %uMB.\n"
-		"Aborting.\n", opts.device, (vol_size/(1024*1024)),
-	       	(OCFS_MIN_VOL_SIZE/(1024*1024)));
-	goto bail;
-    }
-
-    /* close and reopen after binding to raw */
-    safeclose(file);
-
-    /* bind device to raw */
-    if (bind_raw(opts.device, &rawminor, rawdev, sizeof(rawdev)))
-	goto bail;
-
-    /* Open the supplied disk */
-    if (!(file = OpenDisk(rawdev)))
-	goto bail;
-
-    /* Initialize the DiskHeader structure */
-    if (!(InitVolumeDiskHeader(volhdr, sect_size, vol_size, &data_start_off)))
-	goto bail;
-
-#ifdef DEBUG
-	ShowDiskHdrVals(volhdr);
-#endif
-
-     /* query_only option bails you here */
-    if (opts.query_only)
-	goto bail;
-
-    /* OCFS formatted disks will not be overwritten without the -f option */
-    if (!CheckForceFormat(file, &publ_off, &ocfs_vol, sect_size))
-	goto bail;
-
-    /* If valid ocfs volume, check for any heart beating node(s) */
-    if (ocfs_vol) {
-	if (!check_heart_beat(&file, rawdev, volhdr, &nodemap, sect_size))
-		goto bail;
-	if (nodemap) {
-		/* Exit as device is mounted on some node */
-		get_node_names(file, volhdr, node_names, sect_size);
-		printf("%s mounted on nodes:", opts.device);
-		print_node_names(node_names, nodemap);
-		printf("Aborting.\n");
-		goto bail;
-	}
-    }
-
-    if (opts.clear_data_blocks)
-	    format_size = (volhdr->device_size / sect_size) -
-		    		OCFS_NUM_END_SECTORS;
-    else
-	    format_size = CLEAR_DATA_BLOCK_SIZE + (data_start_off / sect_size);
-
-    /* Clear the Volume header in the first sector of the volume */
-    PRINT_PROGRESS();
-    PRINT_VERBOSE("Clearing volume header sectors...");
-    fflush(stdout);
-    offset = volhdr->start_off;
-    if (!ClearSectors(file, offset, 1, sect_size))
-	goto bail;
-
-    /* Write the Volume Label in the 2nd and 3rd sectors */
-    offset = volhdr->start_off + sect_size;
-    if (!WriteVolumeLabel(file, vol_id, sizeof(vol_id), offset, sect_size))
-	goto bail;
-
-    /* Clear sectors 4 to 8 */
-    offset = volhdr->start_off + (3 * sect_size);
-    if (!ClearSectors(file, offset, 5, sect_size))
-	goto bail;
-
-    sect_count += 8;
-    PRINT_VERBOSE("\rCleared volume header sectors                 \n");
-
-    /* Initialize Node config header */
-    PRINT_PROGRESS();
-    PRINT_VERBOSE("Clearing node config sectors...");
-    fflush(stdout);
-    offset = volhdr->node_cfg_off;
-    if (!InitNodeConfHdr(file, offset, sect_size))
-	goto bail;
-
-    /* Clear Node config info */
-    offset = volhdr->node_cfg_off + (2 * sect_size);
-    if (!ClearSectors(file, offset, OCFS_MAXIMUM_NODES, sect_size))
-	goto bail;
-
-    /* Clear NewConf */
-    offset = volhdr->node_cfg_off + volhdr->node_cfg_size;
-    if (!ClearSectors(file, offset, 1, sect_size))
-	goto bail;
-    offset += sect_size;
-    if (!InitNodeConfHdr(file, offset, sect_size))
-	goto bail;
-    offset += (2 * sect_size);
-    if (!ClearSectors(file, offset, 1, sect_size))
-	goto bail;
-    fsync(file);
-
-    sect_count += OCFS_MAXIMUM_NODES + 6;
-    PRINT_VERBOSE("\rCleared node config sectors                 \n");
-
-    /* Clear Publish Sectors */
-    PRINT_PROGRESS();
-    PRINT_VERBOSE("Clearing publish sectors...");
-    fflush(stdout);
-    if (!ClearSectors(file, volhdr->publ_off, OCFS_MAXIMUM_NODES, sect_size))
-	goto bail;
-    fsync(file);
-
-    sect_count += OCFS_MAXIMUM_NODES;
-    PRINT_VERBOSE("\rCleared publish sectors                     \n");
-
-    /* Clear Vote Sectors */
-    PRINT_PROGRESS();
-    PRINT_VERBOSE("Clearing vote sectors...");
-    fflush(stdout);
-    if (!ClearSectors(file, volhdr->vote_off, OCFS_MAXIMUM_NODES, sect_size))
-	goto bail;
-    fsync(file);
-
-    sect_count += OCFS_MAXIMUM_NODES;
-    PRINT_VERBOSE("\rCleared vote sectors                        \n");
-
-    /* Clear the Bitmap */
-    PRINT_PROGRESS();
-    PRINT_VERBOSE("Clearing bitmap sectors...");
-    fflush(stdout);
-    if (!ClearBitmap(file, volhdr))
-	goto bail;
-    fsync(file);
-
-    sect_count += (OCFS_MAX_BITMAP_SIZE / sect_size);
-    PRINT_VERBOSE("\rCleared bitmap sectors                      \n");
-
-    /* Clear OCFS_NUM_FREE_SECTORS */
-    PRINT_PROGRESS();
-    fflush(stdout);
-    offset = volhdr->bitmap_off + OCFS_MAX_BITMAP_SIZE;
-    if (!ClearSectors(file, offset, OCFS_NUM_FREE_SECTORS, sect_size))
-	goto bail;
-    fsync(file);
-
-    sect_count += OCFS_NUM_FREE_SECTORS;
-
-    /* Clear the data blocks */
-    if (!ClearDataBlocks(file, volhdr, sect_size))
-	goto bail;
-    fsync(file);
-
-    /* Create the root directory */
-    PRINT_VERBOSE("Writing root directory and system files...");
-    fflush(stdout);
-    if (!ocfs_create_root_directory (file, volhdr))
-        goto bail;
-    fsync(file);
-    PRINT_PROGRESS();
-    PRINT_VERBOSE("\rWrote root directory and system files       \n");
-
-    /* Write the changes to the global bitmap */    
-    PRINT_VERBOSE("Updating global bitmap...");
-    fflush(stdout);
-    if (!SetSeek(file, volhdr->bitmap_off))
-	goto bail;
-    if (!Write(file, bm_size, bm_buf))
-        goto bail;
-    fsync(file);
-    PRINT_PROGRESS();
-    PRINT_VERBOSE("\rUpdated global bitmap                       \n");
-
-    /* Write corresponding change to bitmap lock (for statfs) */
-    if (!ocfs_update_bm_lock_stats(file))
-        goto bail;
-    fsync(file);
-	
-
-    /* Write volume header */
-    PRINT_VERBOSE("Writing volume header...");
-    fflush(stdout);
-    sigblock(sigmask(SIGINT));   /* blocking ctrl-c */
-    offset = volhdr->start_off;
-    if (!WriteVolumeHdr(file, volhdr, offset, sect_size))
-	goto bail;
-
-    sect_count = format_size;
-    PRINT_PROGRESS();
-    PRINT_VERBOSE("\rWrote volume header                         \n");
-    fflush(stdout);
-
-  bail:
-    safefree(bm_buf);
-    safefree(volhdr);
-    safeclose(file);
-    unbind_raw(rawminor);
-    return 0;
-}				/* main */
-
-
-/*
- * CheckForceFormat()
- *
- */
-int CheckForceFormat(int file, __u64 *publ_off, bool *ocfs_vol, __u32 sect_size)
-{
-	__u32 len;
-	char *buf;
-	int ret = 0;
-	ocfs_vol_disk_hdr *volhdr = NULL;
-	char format;
-
-	len = sect_size;
-	if (!(buf = (char *) MemAlloc(len)))
-		goto bail;
-	else
-		memset(buf, 0, len);
-
-	/* Seek to 1st sector */
-	if (!SetSeek(file, 0))
-		goto bail;
-
-	/* Read the Information of first sector on disk */
-	if (!(Read(file, len, buf)))
-		goto bail;
-
-	volhdr = (ocfs_vol_disk_hdr *) buf;
-
-	if ((!memcmp(volhdr->signature, OCFS_VOLUME_SIGNATURE,
-		     strlen(OCFS_VOLUME_SIGNATURE)))) {
-		*ocfs_vol = true;
-    		*publ_off = volhdr->publ_off;
-	} else {
-		*ocfs_vol = false;
-		*publ_off = (__u64) 0;
-	}
-
-	/* Ensure forceformat flag is set to prevent overwriting */
-	if (*ocfs_vol) {
-		if (opts.force_op)
-			ret = 1;
-		else {
-			if (opts.print_progress) {
-				fprintf(stderr, "Error: Use -F to format "
-					"existing OCFS volume.\n");
-				goto bail;
-			}
-			printf("Format existing OCFS volume (y/N): ");
-			format = getchar();
-			if (format == 'y' || format == 'Y')
-				ret = 1;
-			else
-				printf("Aborting.\n");
-		}
-	} else
-		ret = 1;
-
-      bail:
-	safefree(buf);
-	return ret;
-}				/* CheckForceFormat */
-
-
-/*
- * WriteVolumeHdr()
- *
- */
-int WriteVolumeHdr(int file, ocfs_vol_disk_hdr * volhdr, __u64 offset,
-		   __u32 sect_size)
-{
-    int ret = 0;
-
-    if (!SetSeek(file, offset))
-	goto bail;
-
-    if (!Write(file, sect_size, (void *) volhdr))
-	goto bail;
-
-    ret = 1;
-  bail:
-    return ret;
-}				/* WriteVolumeHdr */
-
-
-/*
- * WriteVolumeLabel()
- *
- */
-int WriteVolumeLabel(int file, char *volid, __u32 volidlen, __u64 offset,
-		     __u32 sect_size)
-{
-    ocfs_vol_label *pLabel;
-    __u32 len;
-    char *buf;
-    int ret = 0;
-
-    len = 2 * sect_size;
-    if (!(buf = (char *) MemAlloc(len)))
-	goto bail;
-    else
-	memset(buf, 0, len);
-
-    /* Populate volume label */
-    InitVolumeLabel((ocfs_vol_label *) buf, sect_size, volid, volidlen);
-
-    /* Set the bitmap lock to invalid_master */
-    pLabel = (ocfs_vol_label *) (buf + sect_size);
-    pLabel->disk_lock.curr_master = -1;
-
-    if (!SetSeek(file, offset))
-	goto bail;
-
-    if (!Write(file, len, buf))
-	goto bail;
-
-    ret = 1;
-  bail:
-    safefree(buf);
-    return ret;
-}				/* WriteVolumeLabel */
-
-
-/*
- * InitNodeConfHdr()
- *
- */
-int InitNodeConfHdr(int file, __u64 offset, __u32 sect_size)
-{
-    __u32 len;
-    char *buf;
-    int ret = 0;
-
-    len = 2 * sect_size;
-    if (!(buf = (char *) MemAlloc(len)))
-	goto bail;
-    else
-	memset(buf, 0, len);
-
-    /* Set node config header */
-    SetNodeConfigHeader((ocfs_node_config_hdr *) buf);
-
-    /* Set the File pointer to node config sector */
-    if (!SetSeek(file, offset))
-	goto bail;
-
-    if (!(Write(file, len, buf)))
-	goto bail;
-
-    ret = 1;
-  bail:
-    safefree(buf);
-    return ret;
-}				/* InitNodeConfHdr */
-
-
-/*
- * ClearSectors()
- *
- */
-int ClearSectors(int file, __u64 strtoffset, __u32 noofsects, __u32 sect_size)
-{
-    __u32 len;
-    char *buf = NULL;
-    __u32 i;
-    int ret = 0;
-
-    len = sect_size;
-    if (!(buf = (char *) MemAlloc(len)))
-	goto bail;
-    else
-	memset(buf, 0, len);
-
-    if (!SetSeek(file, strtoffset))
-	goto bail;
-
-    for (i = 0; i < noofsects; ++i)
-    {
-	if (!Write(file, len, buf))
-	    goto bail;
-    }
-
-    ret = 1;
-  bail:
-    safefree(buf);
-    return ret;
-}				/* ClearSectors */
-
-
-/*
- * ClearBitmap()
- *
- */
-int ClearBitmap(int file, ocfs_vol_disk_hdr * volhdr)
-{
-    __u32 len;
-    char *buf = NULL;
-    int ret = 0;
-
-    len = OCFS_MAX_BITMAP_SIZE;
-    if (!(buf = (char *) MemAlloc(len)))
-	goto bail;
-    else
-	memset(buf, 0, len);
-
-    /* Initialize the bitmap on disk */
-    if (!SetSeek(file, volhdr->bitmap_off))
-	goto bail;
-
-    if (!(Write(file, len, buf)))
-	goto bail;
-
-    ret = 1;
-  bail:
-    safefree(buf);
-    return ret;
-}				/* ClearBitmap */
-
-
-/*
- * ClearDataBlocks()
- *
- */
-int ClearDataBlocks(int file, ocfs_vol_disk_hdr * volhdr, __u32 sect_size)
-{
-	__u64 blocks = 0;
-	__u64 bytes = 0;
-	__u64 len;
-	__u64 offset;
-	__u64 i;
-	char *buf = NULL;
-	int ret = 0;
-
-	len = CLEAR_DATA_BLOCK_SIZE * sect_size;
-	if (!(buf = (char *) MemAlloc(len)))
-		goto bail;
-	else
-		memset(buf, 0, len);
-
-	offset = volhdr->device_size - volhdr->data_start_off;
-	blocks = offset / len;
-	bytes = offset % len;
-
-	offset = volhdr->data_start_off;
-	if (!SetSeek(file, offset))
-		goto bail;
-
-	if (!opts.clear_data_blocks) {
-		PRINT_PROGRESS();
-		PRINT_VERBOSE("Clearing data block...");
-		fflush (stdout);
-		/* clear first 1M of data blocks */
-		if (!(Write(file, len, buf)))
-			goto bail;
-		fsync(file);
-		PRINT_VERBOSE("\rCleared data block              \n");
-		fflush (stdout);
-		sect_count += CLEAR_DATA_BLOCK_SIZE;
-		ret = 1;
-		goto bail;
-	}
-
-	if (blocks) {
-		in_data_blocks = true;
-		for (i = 0; i < blocks; i++, offset += len) {
-			PRINT_PROGRESS();
-			PRINT_VERBOSE("\rClearing data block %llu of %llu",
-				      i, blocks);
-			fflush(stdout);
-			if (!(Write(file, len, buf)))
-				goto bail;
-			if (!(i % 20))
-				fsync(file);
-			sect_count += CLEAR_DATA_BLOCK_SIZE;
-			if (format_intr)
-				break;
-		}
-	}
-
-	if (!format_intr && bytes) {
-		if (!(Write(file, bytes, buf)))
-			goto bail;
-	}
-
-	PRINT_PROGRESS();
-
-	if (format_intr)
-		printf("\nFormatting interrupted..... volume may "
-		       "not be usable                    \n");
-	else
-		PRINT_VERBOSE("\rCleared data blocks                         "
-			      "                 \n");
-	fflush(stdout);
-
-	ret = 1;
-      bail:
-	safefree(buf);
-	return ret;
-}				/* ClearDataBlocks */
-
-
-/*
- * ReadOptions()
- *
- */
-int ReadOptions(int argc, char **argv)
-{
-	int i;
-	int ret = 1;
-	char *p;
-	__u64 fac = 1;
-	long double size;
-
-	if (argc < 2) {
-		version(argv[0]);
-		usage(argv[0]);
-		ret = 0;
-		goto bail;
-	}
-
-	for (i = 1; i < argc && ret; i++) {
-		switch(*argv[i]) {
-		case '-':
-			switch(*++argv[i]) {
-			case 'b':	/* block size */
-				++i;
-				if (i < argc && argv[i])
-					opts.block_size = atoi(argv[i]);
-				else {
-					fprintf(stderr, "Invalid block size.\n"
-						"Aborting.\n");
-					ret = 0;
-				}
-				break;
-
-			case 'C':	/* clear all data blocks */
-				opts.clear_data_blocks = true;
-				break;
-
-			case 'F':	/* force format */
-				opts.force_op = true;
-				break;
-
-			case 'g':	/* gid */
-				++i;
-				if (i < argc && argv[i])
-					opts.gid = get_gid(argv[i]);
-				else {
-					fprintf(stderr, "Invalid group id.\n"
-						"Aborting.\n");
-					ret = 0;
-				}
-				break;
-
-			case 'L':	/* volume label */
-				++i;
-				if (i < argc && argv[i])
-					strncpy(opts.volume_label, argv[i],
-						MAX_VOL_LABEL_LEN);
-				else {
-					fprintf(stderr,"Invalid volume label.\n"
-						"Aborting.\n");
-					ret = 0;
-				}
-				break;
-
-			case 'h':       /* help */
-				version(argv[0]);
-				usage(argv[0]);
-				ret = 0;
-				break;
-
-			case 'm':	/* mount point */
-				++i;
-				if (i < argc && argv[i])
-					strncpy(opts.mount_point, argv[i],
-						FILE_NAME_SIZE);
-				else {
-					fprintf(stderr,"Invalid mount point.\n"
-						"Aborting.\n");
-					ret = 0;
-				}
-				break;
-
-			case 'n':	/* query */
-				opts.query_only = true;
-				break;
-
-			case 'p':	/* permissions */
-				++i;
-				if (i < argc && argv[i]) {
-					opts.perms = strtoul(argv[i],
-								  NULL, 8);
-					opts.perms &= 0007777;
-				} else {
-					fprintf(stderr,"Invalid permissions.\n"
-						"Aborting.\n");
-					ret = 0;
-				}
-				break;
-
-			case 'q':	/* quiet */
-				opts.quiet = true;
-				break;
-
-			case 'S':	/* device size */
-				++i;
-				if (i < argc && argv[i]) {
-					size = strtold(argv[i], &p);
-					if (p)
-						MULT_FACTOR(*p, fac);
-					opts.device_size = (__u64)(size * fac);
-				} else {
-					fprintf(stderr,"Invalid size.\n"
-						"Aborting.\n");
-					ret = 0;
-				}
-				break;
-
-			case 'u':	/* uid */
-				++i;
-				if (i < argc && argv[i])
-					opts.uid = get_uid(argv[i]);
-				else {
-					fprintf(stderr,"Invalid user id.\n"
-						"Aborting.\n");
-					ret = 0;
-				}
-				break;
-
-			case 'V':	/* print version */
-				version(argv[0]);
-				ret = 0;
-				break;
-
-			case 'x':	/* used for debugocfs */
-				opts.print_progress = true;
-				break;
-
-			default:
-				ret = 0;
-				break;
-			}
-			break;
-
-		default:
-			strncpy(opts.device, argv[i], FILE_NAME_SIZE);
-			break;
-		}
-	}
-
-      bail:
-	return ret;
-}				/* ReadOptions */
-
-
-/*
- * InitVolumeDiskHeader()
- *
- */
-int InitVolumeDiskHeader(ocfs_vol_disk_hdr *volhdr, __u32 sect_size, __u64 vol_size,
-			 __u64 * data_start_off)
-{
-    __u64 DataSize = 0;
-    __u64 num_blocks = 0;
-    __u32 VolHdrSize = 0;
-    __u32 NodeConfSize = 0;
-    __u32 NewConfSize = 0;
-    __u32 PublishSize = 0;
-    __u32 VoteSize = 0;
-    __u32 BitmapSize = 0;
-    __u64 BegFreeSize = 0;
-    __u64 EndFreeSize = 0;
-    __u32 tmpbitmap;
-    __u32 block_size = opts.block_size;
-    char *MountPoint = opts.mount_point;
-
-/*
-**                 node_cfg_off                  publ_off
-** start_off            |                            |
-**  |                   |              new_cfg_off   |
-**  |Sector    Sector   |                      |     |
-**  V  0         1-7    V                      V     V
-**  ----------------------------------------------------------------------- ...
-**  |       |  |  |  |  |   |                  |     |                    |
-**  |Volume |  |  |  |  | 2 |OCFS_MAXIMUM_NODES|  4  | OCFS_MAXIMUM_NODES |
-**  |Header | 1| 2| 3|  |sct|sectors           | sct | sectors            |
-**  |       |  |  |  |  |   |                  |     |                    |
-**  ----------------------------------------------------------------------- ...
-**          |  |  |  |   <--- node_cfg_size -->
-**          |  |  |  V
-**          V  |  |  Not Used(4,5,6,7)
-**   VolLabel+ |  V
-**    VOL_LOCK | NMMAP+
-**             V   NMLOCK
-**    BitMap Lock
-**
-**                  
-**                    bitmap_off
-** vote_off               |                                     data_start_off 
-**   |                    |                                              |
-**   V                    V                                              V
-** ..--------------------------------------------------------------------- ...
-**   |                    |                      |                       |
-**   | OCFS_MAXIMUM_NODES | OCFS_MAX_BITMAP_SIZE | OCFS_NUM_FREE_SECTORS |
-**   | sectors            | sectors              | sectors               |
-**   |                    |                      |                       |
-** ..--------------------------------------------------------------------- ...
-**
-**
-** If we define OCFS_MAX_DIRECTORY_ENTRIES to be 5000 files and keep 1024
-** sectors free. The total disk space required by Ocfs is appx. 3MB.
-*/
-
-    memset(volhdr, 0, sizeof(ocfs_vol_disk_hdr));
-
-    volhdr->minor_version = minor_version;
-    volhdr->major_version = major_version;
-
-    memcpy(volhdr->signature, OCFS_VOLUME_SIGNATURE,
-	   strlen(OCFS_VOLUME_SIGNATURE));
-    strncpy(volhdr->mount_point, MountPoint, MAX_MOUNT_POINT_LEN - 1);
-
-    volhdr->device_size = vol_size;
-    volhdr->start_off = 0;
-    volhdr->num_nodes = OCFS_MAXIMUM_NODES;
-    volhdr->root_size = 0;
-    volhdr->cluster_size = (block_size * 1024);
-
-    /* uid/gid/perms */
-    volhdr->uid = opts.uid;
-    volhdr->gid = opts.gid;
-    volhdr->prot_bits = opts.perms;
-    volhdr->excl_mount = NOT_MOUNTED_EXCLUSIVE;
-
-    /* Calculate various sizes */
-    VolHdrSize = 8 * sect_size;
-    NodeConfSize = (2 + volhdr->num_nodes) * sect_size;
-    NewConfSize = 4 * sect_size;
-    PublishSize = volhdr->num_nodes * sect_size;
-    VoteSize = volhdr->num_nodes * sect_size;
-    BitmapSize = OCFS_MAX_BITMAP_SIZE;
-    BegFreeSize = OCFS_NUM_FREE_SECTORS * sect_size;
-    EndFreeSize = OCFS_NUM_END_SECTORS * sect_size;
-
-    /* Fill in volhdr */
-    volhdr->node_cfg_off = volhdr->start_off + VolHdrSize;
-    volhdr->node_cfg_size = NodeConfSize;
-    volhdr->new_cfg_off = volhdr->node_cfg_off + NodeConfSize;
-    volhdr->publ_off = volhdr->new_cfg_off + NewConfSize;
-    volhdr->vote_off = volhdr->publ_off + PublishSize;
-    volhdr->bitmap_off = volhdr->vote_off + VoteSize;
-    volhdr->root_off = 0;
-    volhdr->root_bitmap_off = 0;
-    volhdr->root_bitmap_size = 0;
-    volhdr->data_start_off = volhdr->bitmap_off + BitmapSize + BegFreeSize;
-#define OCFS_DATA_START_ALIGN		4096
-    volhdr->data_start_off = OCFS_ALIGN(volhdr->data_start_off,
-				       	OCFS_DATA_START_ALIGN);
-
-    /* calculate number of data blocks */
-    *data_start_off = volhdr->data_start_off;
-    DataSize = volhdr->device_size - volhdr->data_start_off - EndFreeSize;
-
-    num_blocks = DataSize / volhdr->cluster_size;
-    tmpbitmap = OCFS_BUFFER_ALIGN(((num_blocks + 7) / 8), sect_size);
-    if (tmpbitmap > BitmapSize)
-    {
-	fprintf(stderr, "%dKB block size is too small to format "
-		"the entire disk.\nPlease specify a larger value.\n",
-		block_size);
-	return 0;
-    }
-
-    volhdr->num_clusters = num_blocks;
-
-    // don't bother reading from disk
-    return ocfs_init_global_alloc_bm ((__u32)num_blocks, file, NULL);
-}				/* InitVolumeDiskHeader */
-
-
-/*
- * InitVolumeLabel()
- *
- * Populate ocfs_vol_label
- */
-void InitVolumeLabel(ocfs_vol_label * vollbl, __u32 sect_size, char *id,
-		     __u32 id_len)
-{
-    /* Set the volume label */
-    strcpy(vollbl->label, opts.volume_label);
-    vollbl->label_len = strlen(opts.volume_label);
-
-    /* Set the volume id */
-    memcpy(vollbl->vol_id, id, id_len);
-    vollbl->vol_id_len = id_len;
-
-    /* Set the volume lock to invalid_master */
-    vollbl->disk_lock.curr_master = -1;
-
-    return;
-}				/* InitVolumeLabel */
-
-
-/*
- * SetNodeConfigHeader()
- *
- */
-void SetNodeConfigHeader(ocfs_node_config_hdr * nodehdr)
-{
-    strcpy(nodehdr->signature, NODE_CONFIG_HDR_SIGN);
-
-    nodehdr->version = NODE_CONFIG_VER;
-    nodehdr->num_nodes = 0;
-    nodehdr->disk_lock.curr_master = -1;
-    nodehdr->last_node = 0;
-
-    return;
-}				/* SetNodeConfigHeader */
-
-
-/*
- * ShowDiskHdrVals()
- *
- */
-void ShowDiskHdrVals(ocfs_vol_disk_hdr * voldiskhdr)
-{
-    printf("signature        = %s\n"
-	   "mount_point      = %s\n"
-	   "serial_num       = %llu\n"
-	   "device_size      = %llu\n"
-	   "num_nodes        = %llu\n"
-	   "cluster_size     = %llu\n"
-	   "num_clusters     = %llu\n"
-	   "start_off        = %llu\n"
-	   "node_cfg_off     = %llu\n"
-	   "node_cfg_size    = %llu\n"
-	   "new_cfg_off      = %llu\n"
-	   "publ_off         = %llu\n"
-	   "vote_off         = %llu\n"
-	   "bitmap_off       = %llu\n"
-	   "root_bitmap_off  = %llu\n"
-	   "root_bitmap_size = %llu\n"
-	   "data_start_off   = %llu\n"
-	   "root_off         = %llu\n"
-	   "root_size        = %llu\n"
-	   "dir_node_size    = %llu\n"
-	   "file_node_size   = %llu\n"
-	   "internal_off     = %llu\n"
-	   "uid              = %u\n"
-	   "gid              = %u\n"
-	   "prot_bits        = %u\n"
-	   "excl_mount       = %d\n",
-	   voldiskhdr->signature,
-	   voldiskhdr->mount_point,
-	   voldiskhdr->serial_num,
-	   voldiskhdr->device_size,
-	   voldiskhdr->num_nodes,
-	   voldiskhdr->cluster_size,
-	   voldiskhdr->num_clusters,
-	   voldiskhdr->start_off,
-	   voldiskhdr->node_cfg_off,
-	   voldiskhdr->node_cfg_size,
-	   voldiskhdr->new_cfg_off,
-	   voldiskhdr->publ_off,
-	   voldiskhdr->vote_off,
-	   voldiskhdr->bitmap_off,
-	   voldiskhdr->root_bitmap_off,
-	   voldiskhdr->root_bitmap_size,
-	   voldiskhdr->data_start_off,
-	   voldiskhdr->root_off,
-	   voldiskhdr->root_size,
-	   voldiskhdr->dir_node_size,
-	   voldiskhdr->file_node_size,
-	   voldiskhdr->internal_off,
-	   voldiskhdr->uid,
-	   voldiskhdr->gid,
-	   voldiskhdr->prot_bits,
-	   voldiskhdr->excl_mount);
-    fflush(stdout);
-
-    return;
-}				/* ShowDiskHdrVals */
-
-
-/*
- * HandleSignal()
- */
-void HandleSignal(int sig)
-{
-	switch (sig) {
-	case SIGTERM:
-	case SIGINT:
-		if (in_data_blocks && opts.clear_data_blocks) {
-			signal(SIGTERM, SIG_IGN);
-			signal(SIGINT, SIG_IGN);
-			format_intr = true;
-		} else {
-			fprintf(stderr, "\nError: Volume not formatted due " 
-				"to interruption.\n");
-    			safeclose(file);
-    			unbind_raw(rawminor);
-			exit(1);
-		}
-		break;
-	}
-} /* HandleSignal */
-
-

Copied: trunk/format/format.c (from rev 205, trunk/ocfs/format/format.c)

Deleted: trunk/format/frmtport.c
===================================================================
--- trunk/ocfs/format/frmtport.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/format/frmtport.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,637 +0,0 @@
-/*
- * frmtport.c
- *
- * ocfs format utility functions
- *
- * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Neeraj Goyal, Suchit Kaura, Kurt Hackel, Sunil Mushran,
- *          Manish Singh, Wim Coekaerts
- */
-
-#include <format.h>
-
-ocfs_global_ctxt OcfsGlobalCtxt;
-__u32 debug_context = 0;
-__u32 debug_level = 0;
-__u32 debug_exclude = 0;
-
-extern char *usage_string;
-extern ocfs_options opts;
-
-/*
- * MemAlloc()
- *
- */
-void *MemAlloc(__u32 size)
-{
-    void *buf = NULL;
-
-    if (!(buf = malloc_aligned(size)))
-	fprintf(stderr, "Error allocating %u bytes of memory.\n", size);
-
-    return buf;
-}				/* MemAlloc */
-
-/*
- * OpenDisk()
- *
- */
-int OpenDisk(char *device)
-{
-    int file;
-    mode_t oldmode;
-
-    oldmode = umask(0000);
-    file = open(device, O_RDWR | O_CREAT, 0777);
-    umask(oldmode);
-    if (file == -1)
-    {
-	fprintf(stderr, "Error opening device %s.\n%s\n", device,
-		strerror(errno));
-	file = 0;
-    }
-
-    return file;
-}				/* OpenDisk */
-
-
-/*
- * GetDiskGeometry()
- *
- */
-int GetDiskGeometry(int file, __u64 * vollength, __u32 * sect_size)
-{
-    /* SM: should be signed... struct hd_struct.nr_sects */
-    /* MS: the above only applies to 2.4.9 */
-    unsigned long devicesize;
-    int ret = 0;
-
-    if (ioctl(file, BLKGETSIZE, &devicesize) == -1)
-    {
-	fprintf(stderr, "Error reading size of %s device.\n%s\n", opts.device,
-		strerror(errno));
-	goto bail;
-    }
-
-#if defined(USE_SECTOR_SIZE_IOCTL)
-    if (ioctl(file, BLKSSZGET, sect_size) == -1)
-    {
-	fprintf(stderr, "Error reading the sector size for %s device.\n%s\n",
-		opts.device, strerror(errno));
-	goto bail;
-    }
-#else
-    *sect_size = OCFS_SECTOR_SIZE;
-#endif
-
-    if (devicesize && *sect_size)
-    {
-	*vollength = devicesize;
-	*vollength *= *sect_size;
-	ret = 1;
-    }
-    else
-	fprintf(stderr, "Invalid device specified %s\n", opts.device);
-
-  bail:
-    return ret;
-}				/* GetDiskGeometry */
-
-
-/*
- * SetSeek()
- *
- */
-int SetSeek(int file, __u64 offset)
-{
-    off_t ext_offset;
-    int ret = 0;
-
-    ext_offset = (off_t) offset;
-
-    if (lseek(file, ext_offset, SEEK_SET) == -1)
-	fprintf(stderr, "Error setting file pointer to (%u).\n%s\n",
-		ext_offset, strerror(errno));
-    else
-	ret = 1;
-
-    return ret;
-}				/* SetSeek */
-
-
-/*
- * Read()
- *
- */
-int Read(int file, __u32 size, char *buf)
-{
-    int ret = 0;
-
-    if (read(file, buf, size) == -1)
-	fprintf(stderr, "Error reading device %s.\n%s\n",
-		opts.device, strerror(errno));
-    else
-	ret = 1;
-
-    return ret;
-}				/* Read */
-
-
-/*
- * Write()
- *
- */
-int Write(int file, __u32 size, char *buf)
-{
-    int ret = 0;
-
-    if (write(file, buf, size) == -1)
-	fprintf(stderr, "Error writing to device %s.\n%s\n", opts.device,
-		strerror(errno));
-    else
-	ret = 1;
-
-    return ret;
-}				/* Write */
-
-
-/*
- * GenerateVolumeID()
- *
- * Volume id is used by ocfs to identify the volume in ipc messages.
- */
-int GenerateVolumeID(char *volid, int volidlen)
-{
-    int ret = 0;
-
-    if (volidlen < MAX_VOL_ID_LENGTH)
-    {
-	fprintf(stderr, "internal error [%s], [%d]\n", __FILE__, __LINE__);
-	goto bail;
-    }
-
-    /* Read random bytes */
-    if (!GetRandom(volid, volidlen))
-	goto bail;
-
-    ret = 1;
-
-  bail:
-    return ret;
-}				/* GenerateVolumeID */
-
-/*
- * version()
- *
- */
-void version(char *progname)
-{
-	printf("%s %s %s (build %s)\n", progname,
-					OCFS_BUILD_VERSION,
-					OCFS_BUILD_DATE,
-					OCFS_BUILD_MD5);
-	return;
-}				/* version */
-
-/*
- * usage()
- *
- */
-void usage(char *progname)
-{
-	printf(usage_string, progname);
-	return ;
-}				/* usage */
-
-
-/*
- * ValidateOptions()
- *
- */
-int ValidateOptions(void)
-{
-	int valid_vals[] = {4, 8, 16, 32, 64, 128, 256, 512, 1024, 0};
-	int i;
-
-	if (opts.device[0] == '\0') {
-		fprintf(stderr, "Error: Device not specified.\n");
-		return 0;
-	}
-
-	for (i = 0; valid_vals[i]; ++i) {
-		if (opts.block_size == valid_vals[i])
-			break;
-	}
-
-	if (!valid_vals[i]) {
-		fprintf(stderr, "Error: Invalid block size.\n");
-		return 0;
-	}
-
-	if (opts.query_only)
-		return 1;
-
-	if (opts.volume_label[0] == '\0') {
-		fprintf(stderr, "Error: Volume label not specified.\n");
-		return 0;
-	}
-
-	if (opts.mount_point[0] == '\0') {
-		fprintf(stderr, "Error: Mount point not specified.\n");
-		return 0;
-	}
-
-	return 1;
-}				/* ValidateOptions */
-
-
-/*
- * GetRandom()
- *
- * Returns random bytes of length randlen in buffer randbuf.
- */
-int GetRandom(char *randbuf, int randlen)
-{
-    int randfd = 0;
-    int ret = 0;
-    int readlen = 0;
-    int len = 0;
-
-    if ((randfd = open("/dev/urandom", O_RDONLY)) == -1)
-    {
-	fprintf(stderr, "Error opening /dev/urandom.\n%s\n", strerror(errno));
-	goto bail;
-    }
-
-    if (randlen > 0)
-    {
-	while (readlen < randlen)
-	{
-	    if ((len =
-		 read(randfd, randbuf + readlen, randlen - readlen)) == -1)
-	    {
-		fprintf(stderr, "Error reading /dev/urandom.\n%s\n",
-			strerror(errno));
-		goto bail;
-	    }
-	    readlen += len;
-	}
-    }
-
-    ret = 1;
-
-  bail:
-    if (randfd > 0)
-	close(randfd);
-
-    return ret;
-}				/* GetRandom */
-
-
-/*
- * ReadPublish()
- *
- */
-int ReadPublish(int file, __u64 publ_off, __u32 sect_size, void **buf)
-{
-	int ret = 0;
-	__u32 pub_len;
-
-	pub_len = OCFS_MAXIMUM_NODES * sect_size;
-
-	/* Alloc memory to read publish sectors */
-	if (!*buf) {
-		if (!(*buf = MemAlloc(pub_len)))
-			goto bail;
-	}
-
-	if (!SetSeek(file, publ_off))
-		goto bail;
-
-	/* read OCFS_MAXIMUM_NODES sectors starting publ_off */
-	if (!(Read(file, pub_len, *buf)))
-		goto bail;
-
-	ret = 1;
-
-      bail:
-	return ret;
-}				/* ReadPubllish */
-
-
-/*
- * get_uid()
- *
- */
-uid_t get_uid(char *id)
-{
-	struct passwd *pw = NULL;
-	uid_t uid = 0;
-
-	if (isdigit(*id))
-		uid = atoi(id);
-	else {
-		pw = getpwnam(id);
-		if (pw)
-			uid = pw->pw_uid;
-	}
-
-	return uid;
-}				/* get_uid */
-
-
-/*
- * get_gid()
- *
- */
-uid_t get_gid(char *id)
-{
-	struct group *gr = NULL;
-	gid_t gid = 0;
-
-	if (isdigit(*id))
-		gid = atoi(id);
-	else {
-		gr = getgrnam(id);
-		if (gr)
-			gid = gr->gr_gid;
-	}
-
-	return gid;
-}				/* get_gid */
-
-
-/*
- * read_sectors()
- *
- */
-int read_sectors(int file, __u64 strtoffset, __u32 noofsects, __u32 sect_size,
-		 void *buf)
-{
-	__u32 i;
-	char *p;
-	int ret = 0;
-
-	if (!SetSeek(file, strtoffset))
-		goto bail;
-
-	for (i = 0, p = buf; i < noofsects; ++i, p += sect_size) {
-		if (!Read(file, sect_size, p))
-			goto bail;
-	}
-
-	ret = 1;
-
-      bail:
-	return ret;
-}				/* read_sectors */
-
-
-/*
- * write_sectors()
- *
- */
-int write_sectors(int file, __u64 strtoffset, __u32 noofsects, __u32 sect_size,
-		  void *buf)
-{
-	__u32 i;
-	char *p;
-	int ret = 0;
-
-	if (!SetSeek(file, strtoffset))
-		goto bail;
-
-	for (i = 0, p = buf; i < noofsects; ++i, p += sect_size) {
-		if (!Write(file, sect_size, (void *)p))
-			goto bail;
-	}
-
-	ret = 1;
-
-      bail:
-	return ret;
-}				/* write_sectors */
-
-
-/*
- * validate_volume_size()
- *
- */
-int validate_volume_size(__u64 given_vol_size, __u64 actual_vol_size)
-{
-	int ret = 0;
-	char str1[100], str2[100];
-
-	if (given_vol_size < OCFS_MIN_VOL_SIZE) {
-		num_to_str(given_vol_size, str1);
-		num_to_str(OCFS_MIN_VOL_SIZE, str2);
-		fprintf(stderr, "The size specified, %s, is smaller than "
-			"the minimum size, %s.\nAborting.\n", str1, str2);
-		goto bail;
-	}
-
-	if (given_vol_size > actual_vol_size) {
-		num_to_str(given_vol_size, str1);
-		num_to_str(actual_vol_size, str2);
-		fprintf(stderr, "The size specified, %s, is larger than "
-			"the device size, %s.\nAborting.\n",
-			str1, str2);
-		goto bail;
-	}
-
-	ret = 1;
-
-      bail:
-	return ret;
-}				/* validate_volume_size */
-
-
-/*
- * num_to_str()
- *
- */
-void num_to_str(__u64 num, char *numstr)
-{
-	__u64 newnum;
-	int i = 0;
-	char append[] = " KMGT";
-	int len;
-
-	len = strlen(append);
-
-	for (i = 0, newnum = num; i < len && newnum > 1023; ++i)
-		newnum /= (__u64)1024;
-
-	sprintf(numstr, "%llu%c", newnum, append[i]);
-
-	return ;
-}				/* num_to_str */
-
-
-/*
- * is_ocfs_volume()
- *
- */
-int is_ocfs_volume(int file, ocfs_vol_disk_hdr *volhdr, bool *ocfs_vol,
-		   __u32 sect_size)
-{
-	char *buf;
-	int ret = 0;
-
-	buf = (char *)volhdr;
-	memset(buf, 0, sect_size);
-
-	if (!SetSeek(file, 0))
-		goto bail;
-
-	if (!(Read(file, sect_size, buf)))
-		goto bail;
-
-	volhdr = (ocfs_vol_disk_hdr *) buf;
-
-	if ((!memcmp(volhdr->signature, OCFS_VOLUME_SIGNATURE,
-		     strlen(OCFS_VOLUME_SIGNATURE))))
-		*ocfs_vol = true;
-	else
-		*ocfs_vol = false;
-
-	ret = 1;
-
-      bail:
-	return ret;
-}				/* is_ocfs_volume */
-
-/*
- * check_heart_beat()
- *
- */
-int check_heart_beat(int *file, char *device, ocfs_vol_disk_hdr *volhdr,
-		     __u32 *nodemap, __u32 sect_size)
-{
-	char *publish = NULL;
-	ocfs_super osb;
-	int ret = 0;
-	int i;
-	int waittime;
-
-	memset (&osb, 0, sizeof(ocfs_super));
-
-	if (!ReadPublish(*file, volhdr->publ_off, sect_size, (void **)&publish))
-		goto bail;
-
-	/* alloc osb and pop sect_size */
-	osb.sect_size = sect_size;
-
-        /* call ocfs_update_publish_map(first_time = true) */
-	ocfs_update_publish_map (&osb, (void *)publish, true);
-
-	/* sleep(OCFS_NM_HEARTBEAT_TIME * 10) */
-	PRINT_VERBOSE("Checking heart beat on volume ");
-	waittime = (OCFS_NM_HEARTBEAT_TIME/1000);
-	waittime = (waittime ? waittime : 1);
-	for (i = 0; i < OCFS_HBT_WAIT; ++i) {
-		PRINT_VERBOSE(".");
-		fflush(stdout);
-		sleep(waittime);
-	}
-   
-	/* Close and re-open device to force disk read */
-	safeclose(*file);
-	if (!(*file = OpenDisk(device)))
-		goto bail;
-
-	memset (publish, 0, sect_size);
-	if (!ReadPublish(*file, volhdr->publ_off, sect_size, (void **)&publish))
-		goto bail;
-
-	/* call ocfs_update_publish_map(first_time = false) */
-	ocfs_update_publish_map (&osb, (void *)publish, false);
-
-	PRINT_VERBOSE("\r                                                \r");
-	fflush(stdout);
-
-	*nodemap = LO(osb.publ_map);
-
-	ret = 1;
-      bail:
-	safefree(publish);
-	return ret;
-}				/* check_heart_beat */
-
-/*
- * get_node_names()
- *
- */
-int get_node_names(int file, ocfs_vol_disk_hdr *volhdr, char **node_names,
-		   __u32 sect_size)
-{
-	char *buf = NULL;
-	char *p;
-	int len;
-	int ret = 0;
-	int i;
-	ocfs_disk_node_config_info *conf;
-
-	len = volhdr->node_cfg_size;
-	if (!(buf = (char *) MemAlloc(len)))
-		goto bail;
-	else
-		memset(buf, 0, len);
-
-	if (!SetSeek(file, volhdr->node_cfg_off))
-		goto bail;
-
-	if (!(Read(file, len, buf)))
-		goto bail;
-
-	p = buf + (sect_size * 2);
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i, p += sect_size) {
-		conf = (ocfs_disk_node_config_info *)p;
-		if (conf->node_name[0])
-			node_names[i] = strdup(conf->node_name);
-	}
-
-	ret = 1;
-      bail:
-	safefree(buf);
-	return ret;
-}				/* get_node_names */
-
-
-/*
- * print_node_names()
- *
- */
-void print_node_names(char **node_names, __u32 nodemap)
-{
-	int i, j;
-	char comma = '\0';
-
-	for (j = 1, i = 0; i < OCFS_MAXIMUM_NODES; ++i, j <<= 1) {
-		if (nodemap & j) {
-			if (node_names[i])
-				printf("%c %s", comma, node_names[i]);
-			else
-				printf("%c %d", comma, i);
-			comma = ',';
-		}
-	}
-	printf("\n");
-}				/* print_node_names */
-

Copied: trunk/format/frmtport.c (from rev 205, trunk/ocfs/format/frmtport.c)

Copied: trunk/format/inc (from rev 205, trunk/ocfs/format/inc)

Deleted: trunk/format/journal.c
===================================================================
--- trunk/ocfs/format/journal.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/format/journal.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,41 +0,0 @@
-/* MUST BE BEFORE format.h */
-#include "kernel-list.h"
-
-#include <format.h>
-#include <signal.h>
-#include <libgen.h>
-
-#include <glib.h>
-
-#include "kernel-jbd.h"
-
-int ocfs_replacement_journal_create(int file, __u64 journal_off)
-{
-	int status = 0;
-	journal_superblock_t *sb;
-
-	/* zero out all 8mb and stamp this little sb header on it */
-	sb = (journal_superblock_t *) MemAlloc(OCFS_JOURNAL_DEFAULT_SIZE);
-	if (sb == NULL)
-		return 0;
-	
-	memset(sb, 0, OCFS_JOURNAL_DEFAULT_SIZE);
-
-	sb->s_header.h_magic	 = g_htonl(JFS_MAGIC_NUMBER);
-	sb->s_header.h_blocktype = g_htonl(JFS_SUPERBLOCK_V2);
-	sb->s_blocksize	= g_htonl(512);
-	sb->s_maxlen	= g_htonl(OCFS_JOURNAL_DEFAULT_SIZE / 512);
-	sb->s_first	= g_htonl(1);
-	sb->s_start     = g_htonl(1);
-	sb->s_sequence  = g_htonl(1);
-	sb->s_errno     = g_htonl(0);
-
-	if (SetSeek(file, journal_off)) {
-                if (Write(file, OCFS_JOURNAL_DEFAULT_SIZE, (void *) sb)) {
-			status = 1;
-			fsync(file);
-		}
-	}
-	safefree(sb);
-	return status;
-}

Copied: trunk/format/journal.c (from rev 205, trunk/ocfs/format/journal.c)

Deleted: trunk/format/mkfs.ocfs.8.in
===================================================================
--- trunk/ocfs/format/mkfs.ocfs.8.in	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/format/mkfs.ocfs.8.in	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,72 +0,0 @@
-.TH "mkfs.ocfs" "1" "November 2003" "Version @VERSION@" "OCFS Manual Pages"
-.SH "NAME"
-mkfs.ocfs \- Build an OCFS file system.
-.SH "SYNOPSIS"
-\fBmkfs.ocfs\fR \-b block\-size [\-C] [\-F] [\-g gid] [\-h] \-L volume\-label \-m mount\-path [\-n] [\-p permissions] [\-q] [\-u uid] [\-V] device
-.SH "DESCRIPTION"
-.PP 
-\fBmkfs.ocfs\fR is used to build an OCFS file system on a device, usually a partition in a shared disk. \fBmkfs.ocfs\fR will not format a partition if a node has it mounted to prevent data loss. After the filesystem is formatted, it needs to be exclusively mounted by node 0, for the first time. After the first mount, all subsequent mounts can be performed in parallel.
-.SH "OPTIONS"
-.TP
-\fB\-b\fR \fIblocksize\fR
-Block size in kilo bytes. The size of the blocksize (4k\-1M) will determine the maximum filesystem size possible for the OCFS (32Gb\-8Tb).
-
-.TP
-\fB\-C\fR 
-Clear all data blocks. Use this option only if it is really necessary to clear all blocks. This will slow down the process.
-
-.TP
-\fB\-F\fR 
-Force format. Use this option only if formatting an existing OCFS partition.
-
-.TP
-\fB\-g\fR \fIgid\fR 
-Set the \fIgid\fR for the root directory. On mount time, it will automatcially
-assign the \fIgid\fR specified by this parameter to the mount point. One may
-use the \fIgid\fR or the group name (i.e.:1011 or \fIdba\fR).
-
-.TP
-\fB\-h\fR 
-Help. 
-
-.TP
-\fB\-L\fR \fIVolume label\fR
-Volume label. Allows mount of the file system using LABEL=<Volume Label> instead of device name.
-
-.TP
-\fB\-m\fR \fImount point\fR
-Mount point where the formatted device will be mounted.
-
-.TP
-\fB\-n\fR 
-Query only. Will not build the filesystem.
-
-.TP
-\fB\-p\fR \fINNNN\fR
-Permissions \fINNNN\fR for the root directory. On mount, it will automatcially assign the permission specified by this parameter to the mount point.
-
-.TP
-\fB\-q\fR 
-Quiet execution.
-
-.TP
-\fB\-u\fR \fIuid\fR
-Set the \fIuid\fR for the root directory. On mount time, it will automatcially
-assign \fIuid\fR specified by this parameter to the mount point. One can use
-the \fIuid\fR or the username (i.e.:1011 or \fIoracle\fR).
-
-.TP
-\fB\-V\fR 
-Print version and exit.
-
-.SH "BUGS"
-Stuff.
-
-.SH "SEE ALSO"
-.BR ocfs(5)
-
-.SH "AUTHORS"
-Oracle Corporation
-
-.SH "COPYRIGHT"
-Copyright \(co 2002, 2004 Oracle Corporation

Copied: trunk/format/mkfs.ocfs.8.in (from rev 205, trunk/ocfs/format/mkfs.ocfs.8.in)

Deleted: trunk/format/mounted.c
===================================================================
--- trunk/ocfs/format/mounted.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/format/mounted.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,226 +0,0 @@
-/*
- * mounted.c
- *
- * ocfs mount detect utility
- *
- * Copyright (C) 2003, 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Sunil Mushran
- */
-
-#include <format.h>
-#include <signal.h>
-
-ocfs_options opts = {
-	.device = "",
-	.block_size = 0,
-	.clear_data_blocks = false,
-	.force_op = false,
-	.gid = 0,
-	.volume_label = "",
-	.mount_point = "",
-	.query_only = false,
-	.perms = 0755,
-	.quiet = false,
-	.uid = 0,
-	.print_progress = false,
-	.slot_num = OCFS_INVALID_NODE_NUM,
-	.device_size = 0
-};
-
-char *usage_string = "usage: %s <device>\n";
-int file = 0;
-int rawminor = 0;
-char rawdev[FILE_NAME_SIZE];
-
-#undef PRINT_VERBOSE
-#define PRINT_VERBOSE(f, a...)	do { if (true) printf(f, ##a); \
-				} while (0)
-
-int get_vol_label(int file, ocfs_vol_label *vollabel, __u32 sect_size);
-void handle_signal(int sig);
-int read_options(int argc, char **argv);
-
-/*
- * main()
- *
- */
-int main(int argc, char **argv)
-{
-	ocfs_vol_disk_hdr *volhdr = NULL;
-	ocfs_vol_label *vollbl = NULL;
-	__u32 sect_size = OCFS_SECTOR_SIZE;
-	__u64 vol_size = 0;
-	__u32 i;
-	bool ocfs_vol = false;
-	char *node_names[OCFS_MAXIMUM_NODES];
-	__u32 nodemap = 0;
-
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
-		node_names[i] = NULL;
-
-#define INSTALL_SIGNAL(sig) 						\
-	do { 								\
-		if (signal(sig, handle_signal) == SIG_ERR) {		\
-			fprintf(stderr, "Could not set " #sig "\n");	\
-			goto bail;					\
-		}							\
-	} while(0)
-
-	INSTALL_SIGNAL(SIGTERM);
-	INSTALL_SIGNAL(SIGINT);
-
-	init_raw_cleanup_message();
-
-	if (!read_options(argc, argv))
-		goto bail;
-
-	if (!(file = OpenDisk(opts.device)))
-		goto bail;
-
-	if (!(GetDiskGeometry(file, &vol_size, &sect_size)))
-		goto bail;
-
-	volhdr = MemAlloc(sect_size);
-	vollbl = MemAlloc(sect_size);
-	if (!volhdr || !vollbl)
-		goto bail;
-	else {
-		memset(volhdr, 0, sect_size);
-		memset(vollbl, 0, sect_size);
-	}
-
-	/* close and open after binding to raw */
-	safeclose(file);
-
-	if (bind_raw(opts.device, &rawminor, rawdev, sizeof(rawdev)))
-		goto bail;
-	
-	if (!(file = OpenDisk(rawdev)))
-		goto bail;
-
-	if (!is_ocfs_volume(file, volhdr, &ocfs_vol, sect_size))
-		goto bail;
-
-	if (!ocfs_vol) {
-		fprintf(stderr, "Error: %s is not an ocfs volume.\n", opts.device);
-		goto bail;
-	}
-
-	printf("Device: %s\n", opts.device);
-
-	if (get_vol_label(file, vollbl, sect_size)) {
-		printf("Label : %s\n", vollbl->label);
-		printf("Id    : ");
-		for (i = 0; i < vollbl->vol_id_len; ++i)
-			printf("%02X", vollbl->vol_id[i]);
-		printf("\n");
-	}
-
-	if (!check_heart_beat(&file, rawdev, volhdr, &nodemap, sect_size)) {
-		fprintf(stderr, "Error detecting heartbeat on volume.\n");
-		goto bail;
-	}
-
-	if (!nodemap) {
-		printf("Nodes : Not mounted\n");
-		goto bail;
-	}
-
-	get_node_names(file, volhdr, node_names, sect_size);
-
-	printf("Nodes :");
-	print_node_names(node_names, nodemap);
-
-bail:
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
-		safefree(node_names[i]);
-
-	safefree(volhdr);
-	safefree(vollbl);
-	safeclose(file);
-	unbind_raw(rawminor);
-	return 0;
-}				/* main */
-
-
-/*
- * get_vol_label()
- *
- */
-int get_vol_label(int file, ocfs_vol_label *vollbl, __u32 sect_size)
-{
-	int ret = 0;
-
-	if (!SetSeek(file, sect_size))
-		goto bail;
-
-	if (!(Read(file, sect_size, (char *)vollbl)))
-		goto bail;
-
-	ret = 1;
-bail:
-	return ret;
-}				/* get_vol_label */
-
-
-/*
- * handle_signal()
- */
-void handle_signal(int sig)
-{
-	switch (sig) {
-	case SIGTERM:
-	case SIGINT:
-		fprintf(stderr, "\nInterrupted.\n");
-		safeclose(file);
-		unbind_raw(rawminor);
-		exit(1);
-		break;
-	}
-}				/* handle_signal */
-
-
-/*
- * read_options()
- *
- * mounted.ocfs <device>
- *
- */
-int read_options(int argc, char **argv)
-{
-	int ret = 0;
-
-	if (argc < 2) {
-		version(argv[0]);
-		usage(argv[0]);
-		goto bail;
-	}
-
-	strncpy(opts.device, argv[1], FILE_NAME_SIZE);
-	if (strlen(opts.device))
-		ret = 1;
-	else {
-		version(argv[0]);
-		usage(argv[0]);
-	}
-
-      bail:
-	return ret;
-}				/* read_options */
-

Copied: trunk/format/mounted.c (from rev 205, trunk/ocfs/format/mounted.c)

Deleted: trunk/format/system.c
===================================================================
--- trunk/ocfs/format/system.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/format/system.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,462 +0,0 @@
-
-/*
- * system.c
- *
- * creates system files and root dir during format
- *
- * Copyright (C) 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel
- *
- */
-
-#include <format.h>
-#include <signal.h>
-#include <libgen.h>
-
-extern ocfs_alloc_bm global_bm;
-extern char *bm_buf;
-extern int bm_size;
-extern int major_version;
-extern int minor_version;
-
-static int ocfs_create_root_file_entry(int file, ocfs_vol_disk_hdr *volhdr);
-static int ocfs_create_bitmap_file_entry(int file, ocfs_vol_disk_hdr *volhdr);
-
-typedef struct _ocfs_file_entry_v2
-{
-	ocfs_disk_lock disk_lock;       // DISKLOCK
-	__u8 signature[8];              // CHAR[8]
-	bool local_ext;		        // BOOL
-	__u8 next_free_ext;             // NUMBER RANGE(0,OCFS_MAX_FILE_ENTRY_EXTENTS) 
-	__s8 next_del;                  // DIRNODEINDEX
-	__s32 granularity;	        // NUMBER RANGE(-1,3)
-	__u8 filename[OCFS_MAX_FILENAME_LENGTH];  // CHAR[OCFS_MAX_FILENAME_LENGTH]
-	__u16 filename_len;               // NUMBER RANGE(0,OCFS_MAX_FILENAME_LENGTH)
-	__u64 file_size;                  // NUMBER RANGE(0,ULONG_LONG_MAX)
-	__u64 alloc_size;		        // NUMBER RANGE(0,ULONG_LONG_MAX)
-	__u64 create_time;                // DATE
-	__u64 modify_time;	        // DATE
-	ocfs_alloc_ext extents[OCFS_MAX_FILE_ENTRY_EXTENTS];  // EXTENT[OCFS_MAX_FILE_ENTRY_EXTENTS]
-	__u64 dir_node_ptr;               // NUMBER RANGE(0,ULONG_LONG_MAX)
-	__u64 this_sector;                // NUMBER RANGE(0,ULONG_LONG_MAX)
-	__u64 last_ext_ptr;               /* NUMBER RANGE(0,ULONG_LONG_MAX)
-					     Points to the last
-					     allocated extent */
-	__u32 sync_flags;		  // NUMBER RANGE(0,0)
-	__u32 link_cnt;                   // NUMBER RANGE(0,UINT_MAX)
-	__u32 attribs;                    // ATTRIBS
-	__u32 prot_bits;                  // PERMS
-	__u32 uid;                        // UID
-	__u32 gid;                        // GID
-	__u16 dev_major;                  // NUMBER RANGE(0,65535)   
-	__u16 dev_minor;                  // NUMBER RANGE(0,65535)
-        __u8 fe_reserved1[4];		  // UNUSED
-	union {
-		__u64 fe_private;
-		__u64 child_dirnode;		  // NUMBER RANGE(0,ULONG_LONG_MAX)
-		struct _bitinfo {
-			__u32 used_bits;
-			__u32 total_bits;
-		} bitinfo;
-	} u;
-/* sizeof(fe) = 496 bytes */
-} ocfs_file_entry_v2;
-
-int ocfs_init_global_alloc_bm (__u32 num_bits, int file, ocfs_vol_disk_hdr *volhdr)
-{
-	int ret = 0;
-
-	bm_size = (__u32) OCFS_SECTOR_ALIGN (num_bits / 8);
-	bm_buf = MemAlloc(bm_size);
-	if (bm_buf == NULL)
-		return 0;
-	memset(bm_buf, 0, bm_size);
-	ocfs_initialize_bitmap (&global_bm, bm_buf, num_bits);
-
-	ret = 1;
-	if (volhdr) {
-    		if (!SetSeek(file, volhdr->bitmap_off) ||
-		    !Read(file, bm_size, bm_buf))
-			ret = 0;
-	}
-
-	return ret;
-}
-
-/* in version 1, this is a ocfs_bitmap_lock.
-   in version 2, this is an ocfs_file_entry which uses
-   alloc_size for total bits, and file_size for used bits. */
-int ocfs_update_bm_lock_stats(int file)
-{
-	int status = 0;
-	void *buf = NULL;
-
-	buf = MemAlloc(OCFS_SECTOR_SIZE);
-	if (buf == NULL)
-		goto bail;
-	
-	if (!SetSeek(file, OCFS_BITMAP_LOCK_OFFSET))
-		goto bail;
-
-	if (!Read(file, OCFS_SECTOR_SIZE, buf))
-		goto bail;
-
-	if (major_version == OCFS_MAJOR_VERSION) {
-		ocfs_bitmap_lock *bm_lock = (ocfs_bitmap_lock *) buf;
-		memset(buf, 0, OCFS_SECTOR_SIZE);  // why?
-        	bm_lock->used_bits = ocfs_count_bits(&global_bm);
-	} else if (major_version == OCFS2_MAJOR_VERSION) {
-		ocfs_file_entry_v2 *fe = (ocfs_file_entry_v2 *) buf;
-		fe->u.bitinfo.used_bits = ocfs_count_bits(&global_bm);
-	}
-
-	if (SetSeek(file, OCFS_BITMAP_LOCK_OFFSET)) {
-		if (Write(file, OCFS_SECTOR_SIZE, buf)) {
-			status = 1;
-    			fsync(file);
-		}
-	}
-bail:	
-	safefree(buf);
-	return status;
-}
-
-__u32 ocfs_alloc_from_global_bitmap (__u64 file_size, ocfs_vol_disk_hdr *volhdr)
-{
-	__u32 startbit = 0, numbits = 0;
-
-	file_size = OCFS_ALIGN(file_size, volhdr->cluster_size);
-	numbits = (__u32) (file_size / volhdr->cluster_size);
-
-	startbit = ocfs_find_clear_bits (&global_bm, numbits, 0, 0);
-	if (startbit != (__u32)-1)
-		ocfs_set_bits (&global_bm, startbit, numbits);
-	return startbit;
-}
-
-
-int ocfs_create_root_directory (int file, ocfs_vol_disk_hdr * volhdr)
-{
-	int status = 0;
-	__u64 orphan_off = 0ULL, journal_off = 0ULL;
-	__u32 i, j, fileid, bit, root_bit;
-       	__u32 max = (major_version == OCFS2_MAJOR_VERSION) ? 
-		OCFS_JOURNAL_SYSFILE : OCFS_CLEANUP_LOG_SYSFILE;
-	ocfs_dir_node *dir = NULL;
-	ocfs_file_entry *fe = NULL;
-	__u64 data_off;
-
-	fe = MemAlloc(512);
-	if (fe == NULL)
-		goto bail;
-
-	dir = MemAlloc(OCFS_DEFAULT_DIR_NODE_SIZE);
-	if (dir == NULL)
-		goto bail;
-
-	/* reserve system file bits in global */
-	bit = ocfs_alloc_from_global_bitmap (ONE_MEGA_BYTE, volhdr);
-	if (bit == (__u32) -1)
-		goto bail;
-
-	volhdr->internal_off = (bit * volhdr->cluster_size) + volhdr->data_start_off;
-
-	/* reserve root dir bits in global */
-	root_bit = ocfs_alloc_from_global_bitmap (OCFS_DEFAULT_DIR_NODE_SIZE, volhdr);
-	if (root_bit == (__u32)-1)
-		goto bail;
-	
-	volhdr->root_off = (root_bit * volhdr->cluster_size) + volhdr->data_start_off;
-	ocfs_init_dirnode(dir, volhdr->root_off);
-	dir->dir_node_flags |= DIR_NODE_FLAG_ROOT;
-
-	if (!SetSeek(file, volhdr->root_off))
-		goto bail;
-	if (!Write(file, OCFS_DEFAULT_DIR_NODE_SIZE, (void *) dir))
-		goto bail;
-	fsync(file);
-
-	/* for v2, need to reserve space for orphan dirs: 32 x 128k */
-	/* and space for first 4 journals: 4 x 8mb */
-	if (major_version == OCFS2_MAJOR_VERSION) {
-		bit = ocfs_alloc_from_global_bitmap (32*OCFS_DEFAULT_DIR_NODE_SIZE, volhdr);
-		if (bit == (__u32)-1)
-			goto bail;
-		orphan_off = (bit * volhdr->cluster_size) + volhdr->data_start_off;
-		bit = ocfs_alloc_from_global_bitmap (4*OCFS_JOURNAL_DEFAULT_SIZE, volhdr);
-		if (bit == (__u32)-1)
-			goto bail;
-		journal_off = (bit * volhdr->cluster_size) + volhdr->data_start_off;
-	}
-
-	/* create all appropriate system file types for this ocfs version */
-	/* v2 will create orphan, journal, and local alloc + v1 types */
-	for (i = 0; i < OCFS_MAXIMUM_NODES; i++) {
-		for (j = OCFS_VOL_MD_SYSFILE; j <= max; j++) {
-			fileid = (j*OCFS_MAXIMUM_NODES) + i;
-			data_off = 0ULL;
-
-			// only first 4 journals allocated
-			// all others must use tuneocfs
-			if (j == OCFS_JOURNAL_SYSFILE) {
-				if (i < 4)
-					data_off = journal_off;
-			} else if (j == OCFS_ORPHAN_DIR_SYSFILE)
-				data_off = orphan_off;
-
-			if (!ocfs_init_sysfile (file, volhdr, fileid, fe, data_off))
-				goto bail;
-		}
-		orphan_off += OCFS_DEFAULT_DIR_NODE_SIZE;
-		journal_off += OCFS_JOURNAL_DEFAULT_SIZE;
-	}
-
-	if (major_version == OCFS2_MAJOR_VERSION) {
-		if (!ocfs_create_root_file_entry(file, volhdr))
-			goto bail;
-		if (!ocfs_create_bitmap_file_entry(file, volhdr))
-			goto bail;
-	}
-	
-	status = 1;
-
-bail:
-	safefree (dir);
-	safefree (fe);
-	return status;
-}
-
-#define OCFS_ROOT_FILE_ENTRY_OFF (3 * OCFS_SECTOR_SIZE)
-
-static int ocfs_create_root_file_entry(int file, ocfs_vol_disk_hdr *volhdr)
-{
-	int ret = 0;
-	ocfs_file_entry_v2 *fe;
-
-	fe = MemAlloc(OCFS_SECTOR_SIZE);
-	if (fe == NULL)
-		goto bail;
-	
-	memset(fe, 0, OCFS_SECTOR_SIZE);
-	strcpy(&fe->filename[0], "root");
-	fe->filename_len = strlen(fe->filename);
-	fe->local_ext = true;
-	fe->granularity = -1;
-	strcpy (fe->signature, OCFS_FILE_ENTRY_SIGNATURE);
-	SET_VALID_BIT (fe->sync_flags);
-	fe->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
-	fe->last_ext_ptr = 0;
-        fe->next_del = INVALID_DIR_NODE_INDEX;
-	fe->this_sector = OCFS_ROOT_FILE_ENTRY_OFF;
-	fe->alloc_size = 0ULL;
-	fe->file_size = 0ULL;
-	fe->next_free_ext = 0;
-	fe->uid = volhdr->uid;
-	fe->gid = volhdr->gid;
-	fe->prot_bits = volhdr->prot_bits;
-        fe->attribs = OCFS_ATTRIB_DIRECTORY;
-	fe->u.child_dirnode = volhdr->root_off;
-
-	if (!SetSeek(file, OCFS_ROOT_FILE_ENTRY_OFF))
-		goto bail;
-	if (!Write(file, OCFS_SECTOR_SIZE, (void *) fe))
-		goto bail;
-	fsync(file);
-	ret = 1;
-bail:
-	safefree (fe);
-	return ret;
-}
-
-static int ocfs_create_bitmap_file_entry(int file, ocfs_vol_disk_hdr *volhdr)
-{
-	int ret = 0;
-	ocfs_file_entry_v2 *fe;
-
-	fe = MemAlloc(OCFS_SECTOR_SIZE);
-	if (fe == NULL)
-		goto bail;
-	
-	memset(fe, 0, OCFS_SECTOR_SIZE);
-	strcpy(&fe->filename[0], "global-bitmap");
-	fe->filename_len = strlen(fe->filename);
-	fe->local_ext = true;
-	fe->granularity = -1;
-	strcpy (fe->signature, OCFS_FILE_ENTRY_SIGNATURE);
-	SET_VALID_BIT (fe->sync_flags);
-	fe->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
-	fe->last_ext_ptr = 0;
-        fe->next_del = INVALID_DIR_NODE_INDEX;
-	fe->this_sector = OCFS_BITMAP_LOCK_OFFSET;
-	fe->alloc_size = OCFS_MAX_BITMAP_SIZE;		// max possible bytes in bitmap
-	fe->file_size = (volhdr->num_clusters + 7) / 8;	// valid bytes in actual bitmap
-	fe->next_free_ext = 0;
-	fe->uid = volhdr->uid;
-	fe->gid = volhdr->gid;
-	fe->prot_bits = volhdr->prot_bits;
-	fe->u.bitinfo.used_bits = 0;			// used bits in bitmap
-	fe->u.bitinfo.total_bits = volhdr->num_clusters;// total valid bits in bitmap
-
-       	fe->extents[0].disk_off = volhdr->bitmap_off;
-       	fe->extents[0].file_off = 0ULL;
-       	fe->extents[0].num_bytes = OCFS_MAX_BITMAP_SIZE;
-	fe->next_free_ext = 1;
-	
-	if (!SetSeek(file, OCFS_BITMAP_LOCK_OFFSET))
-		goto bail;
-	if (!Write(file, OCFS_SECTOR_SIZE, (void *) fe))
-		goto bail;
-	fsync(file);
-	ret = 1;
-bail:
-	safefree (fe);
-	return ret;
-}
-
-
-void ocfs_init_dirnode(ocfs_dir_node *dir, __u64 disk_off)
-{
-	memset(dir, 0, OCFS_DEFAULT_DIR_NODE_SIZE);
-	strcpy (dir->signature, OCFS_DIR_NODE_SIGNATURE);
-	dir->num_ents = 254;
-	dir->node_disk_off = disk_off;
-	dir->alloc_file_off = disk_off;
-	dir->alloc_node = OCFS_INVALID_NODE_NUM;
-	dir->free_node_ptr = INVALID_NODE_POINTER;
-	dir->next_node_ptr = INVALID_NODE_POINTER;
-	dir->indx_node_ptr = INVALID_NODE_POINTER;
-	dir->next_del_ent_node = INVALID_NODE_POINTER;
-	dir->head_del_ent_node = INVALID_NODE_POINTER;
-	dir->first_del = INVALID_DIR_NODE_INDEX;
-	dir->index_dirty = 0;
-	DISK_LOCK_CURRENT_MASTER (dir) = OCFS_INVALID_NODE_NUM;
-}
-
-int ocfs_init_sysfile (int file, ocfs_vol_disk_hdr *volhdr, __u32 file_id, 
-			      ocfs_file_entry *fe, __u64 data)
-{
-	int status = 0;
-	char *filename;
-	ocfs_local_alloc *alloc;
-	__u64 off;
-//	__u32 orphan_bit;
-	ocfs_dir_node *orphan_dir = NULL;
-	__u8 next_free_ext = 0;
-
-	memset (fe, 0, 512);
-	filename = &(fe->filename[0]);	
-	off = (file_id * OCFS_SECTOR_SIZE) + volhdr->internal_off;
-
-	if ((file_id >= OCFS_FILE_DIR_ALLOC) &&
-	    (file_id < (OCFS_FILE_DIR_ALLOC + 32))) {
-		sprintf (filename, "%s%d", OCFS_DIR_FILENAME, file_id);
-	} else if ((file_id >= OCFS_FILE_DIR_ALLOC_BITMAP) &&
-		   (file_id < (OCFS_FILE_DIR_ALLOC_BITMAP + 32))) {
-		sprintf (filename, "%s%d", OCFS_DIR_BITMAP_FILENAME, file_id);
-	} else if ((file_id >= OCFS_FILE_FILE_ALLOC) &&
-		   (file_id < (OCFS_FILE_FILE_ALLOC + 32))) {
-		sprintf (filename, "%s%d", OCFS_FILE_EXTENT_FILENAME, file_id);
-	} else if ((file_id >= OCFS_FILE_FILE_ALLOC_BITMAP) &&
-		   (file_id < (OCFS_FILE_FILE_ALLOC_BITMAP + 32))) {
-		sprintf (filename, "%s%d", OCFS_FILE_EXTENT_BITMAP_FILENAME,
-			 file_id);
-	} else if ((file_id >= LOG_FILE_BASE_ID)
-		   && (file_id < (LOG_FILE_BASE_ID + 32))) {
-		sprintf (filename, "%s%d", OCFS_RECOVER_LOG_FILENAME, file_id);
-	} else if ((file_id >= CLEANUP_FILE_BASE_ID) &&
-		   (file_id < (CLEANUP_FILE_BASE_ID + 32))) {
-		sprintf (filename, "%s%d", OCFS_CLEANUP_LOG_FILENAME, file_id);
-	} else if ((file_id >= OCFS_FILE_VOL_META_DATA) &&
-		   (file_id < (OCFS_FILE_VOL_META_DATA + 32))) {
-		sprintf (filename, "%s", "VolMetaDataFile");
-	} else if ((file_id >= OCFS_FILE_VOL_LOG_FILE) &&
-		   (file_id < (OCFS_FILE_VOL_LOG_FILE + 32))) {
-		sprintf (filename, "%s", "VolMetaDataLogFile");
-	} else if ((file_id >= OCFS_VOL_BITMAP_FILE) &&
-		   (file_id < (OCFS_VOL_BITMAP_FILE + 32))) {
-		// markf likes to be special ;-)
-		alloc = (ocfs_local_alloc *) fe;
-	        strcpy (alloc->signature, OCFS_LOCAL_ALLOC_SIGNATURE);
-	        alloc->this_sector = off;
-	        alloc->node_num = file_id - OCFS_VOL_BITMAP_FILE;
-		goto do_write;
-	} else if ((file_id >= OCFS_ORPHAN_DIR) &&
-		   (file_id < (OCFS_ORPHAN_DIR + 32))) {
-		// hackery
-		ocfs_file_entry_v2 *fev2 = (ocfs_file_entry_v2 *)fe;
-
-		sprintf(filename, "%s%d", OCFS_ORPHAN_DIR_FILENAME, file_id);
-	        fev2->attribs = OCFS_ATTRIB_DIRECTORY;
-	        fev2->next_del = INVALID_DIR_NODE_INDEX;
-	        fev2->u.child_dirnode = data;
-
-		orphan_dir = (ocfs_dir_node *) MemAlloc(OCFS_DEFAULT_DIR_NODE_SIZE);
-		if (orphan_dir == NULL)
-			return 0;
-//		orphan_bit = (__u32)((data - volhdr->data_start_off) / volhdr->cluster_size);
-		ocfs_init_dirnode(orphan_dir, data);
-		DISK_LOCK_CURRENT_MASTER (orphan_dir) = file_id - OCFS_ORPHAN_DIR;
-		DISK_LOCK_FILE_LOCK (orphan_dir) = OCFS_DLM_ENABLE_CACHE_LOCK;
-		orphan_dir->dir_node_flags |= DIR_NODE_FLAG_ORPHAN;
-		
-		if (SetSeek(file, data))
-	                if (Write(file, OCFS_DEFAULT_DIR_NODE_SIZE, (void *) orphan_dir)) {
-				status = 1;
-				fsync(file);
-			}
-		safefree(orphan_dir);
-		if (!status)
-			return status;
-	} else if ((file_id >= OCFS_JOURNAL_FILE) && 
-		   (file_id < (OCFS_JOURNAL_FILE + 32))) {
-		sprintf(filename, "%s%d", OCFS_JOURNAL_FILENAME, file_id);
-		
-		// first 4 will have 8mb, rest will have nothing yet
-		if (data) {
-			fe->alloc_size = OCFS_JOURNAL_DEFAULT_SIZE;
-			fe->file_size = OCFS_JOURNAL_DEFAULT_SIZE;
-	        	fe->extents[0].disk_off = data;
-	        	fe->extents[0].file_off = 0ULL;
-	        	fe->extents[0].num_bytes = OCFS_JOURNAL_DEFAULT_SIZE;
-			next_free_ext = 1;
-			if (!ocfs_replacement_journal_create(file, data))
-				return 0;
-		}
-	} else {
-		fprintf(stderr, "eeeeek! fileid=%d\n", file_id);
-		exit(1);
-	}
-
-	fe->local_ext = true;
-	fe->granularity = -1;
-	strcpy (fe->signature, OCFS_FILE_ENTRY_SIGNATURE);
-	SET_VALID_BIT (fe->sync_flags);
-	fe->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
-	fe->last_ext_ptr = 0;
-	fe->this_sector = off;
-	fe->next_free_ext = next_free_ext;
-
-do_write:
-	if (SetSeek(file, off))
-		if (Write(file, OCFS_SECTOR_SIZE, (void *) fe)) {
-			status = 1;
-			fsync(file);
-		}
-	return status;
-}

Copied: trunk/format/system.c (from rev 205, trunk/ocfs/format/system.c)

Deleted: trunk/format/tune.c
===================================================================
--- trunk/ocfs/format/tune.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/format/tune.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,1004 +0,0 @@
-/*
- * tune.c
- *
- * ocfs tune utility
- *
- * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Sunil Mushran
- */
-
-#include <format.h>
-#include <tune.h>
-
-/* getopt stuff */
-int getopt(int argc, char *const argv[], const char *optstring);
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-void init_global_context(void);
-int create_orphan_dirs(ocfs_vol_disk_hdr *volhdr, bool *update, int fd);
-int ocfs_init_orphan_dir(ocfs_super *osb, int node_num, char *filename);
-
-ocfs_super *osb = NULL;
-struct super_block sb;
-ocfs_vol_disk_hdr *vdh = NULL;
-ocfs_global_ctxt OcfsGlobalCtxt;
-
-ocfs_options opts = {
-	.device = "",
-	.block_size = 0,
-	.clear_data_blocks = false,
-	.force_op = false,
-	.gid = -1,
-	.volume_label = "",
-	.mount_point = "",
-	.query_only = false,
-	.perms = -1,
-	.quiet = false,
-	.uid = -1,
-	.print_progress = false,
-	.slot_num = OCFS_INVALID_NODE_NUM,
-	.device_size = 0,
-	.list_nodes = false,
-	.convert = -1,
-	.disk_hb = 0,
-	.hb_timeo = 0
-};
-
-bool ignore_signal = false;
-int file = 0;
-int rawminor = 0;
-char rawdev[FILE_NAME_SIZE];
-
-char *usage_string =
-"usage: %s [-d ms] [-F] [-g gid] [-h] [-l] [-n] [-N nodenum] [-p permissions] "
-"[-q] [-S size] [-t ms] [-u uid] [-V] device\n\n"
-"	-d disk heartbeat in ms\n"
-"	-F Force resize existing OCFS volume\n"
-"	-g Group ID for the root directory\n"
-"	-h Help\n"
-"	-l List all the node config slots\n"
-"	-n Query only\n"
-"	-N Node config slot be to be cleared\n"
-"	-p Permissions for the root directory\n"
-"	-q Quiet execution\n"
-"	-S Volume size, e.g., 50G (M for mega, G for giga, T for tera)\n"
-"	-t heartbeat timeout in ms\n"
-"	-u User ID for the root directory\n"
-"	-c Convert filesystem versions\n"
-"	-V Print version and exit\n";
-
-/*
- * main()
- *
- */
-int main(int argc, char **argv)
-{
-	ocfs_vol_disk_hdr *volhdr = NULL;
-	ocfs_node_config_hdr *node_hdr = NULL;
-	ocfs_disk_node_config_info *node_info = NULL;
-	__u32 sect_size = OCFS_SECTOR_SIZE;
-	__u64 vol_size = 0;
-	__u64 offset;
-	bool ocfs_vol = false;
-	char proceed;
-	bool update = false;
-	char *node_names[OCFS_MAXIMUM_NODES];
-	__u32 nodemap = 0;
-	int i;
-	__u64 cfg_hdr_off = 0;
-	__u64 cfg_node_off = 0;
-	__u64 new_cfg_off = 0;
-
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
-		node_names[i] = NULL;
-
-#define INSTALL_SIGNAL(sig) 						\
-	do { 								\
-		if (signal(sig, handle_signal) == SIG_ERR) {		\
-			fprintf(stderr, "Could not set " #sig "\n");	\
-			goto bail;					\
-		}							\
-	} while(0)
-
-	INSTALL_SIGNAL(SIGTERM);
-	INSTALL_SIGNAL(SIGINT);
-
-	init_raw_cleanup_message();
-
-	/* Read the options */
-	if (!read_options(argc, argv))
-		goto bail;
-
-	/* Validate the options */
-	if (!validate_options(argv[0]))
-		goto bail;
-
-	/* Open the disk */
-	if (!(file = OpenDisk(opts.device)))
-		goto bail;
-
-	/* Allocate mem */
-	volhdr = MemAlloc(OCFS_SECTOR_SIZE);
-	node_hdr = MemAlloc(OCFS_SECTOR_SIZE);
-	node_info = MemAlloc(OCFS_SECTOR_SIZE);
-	if (!volhdr || !node_hdr || !node_info)
-		goto bail;
-
-	/* Is this an existing ocfs volume */
-	if (!is_ocfs_volume(file, volhdr, &ocfs_vol, sect_size))
-		goto bail;
-
-
-	/* Abort if not an ocfs volume */
-	if (!ocfs_vol) {
-		fprintf(stderr, "%s is not an ocfs volume.\nAborting.\n",
-			opts.device);
-		goto bail;
-	}
-
-	if (opts.list_nodes) {
-		print_node_cfgs(file, volhdr, sect_size);
-		goto bail;
-	}
-
-	/* Get the partition Information */
-	if (!(GetDiskGeometry(file, &vol_size, &sect_size)))
-		goto bail;
-
-	if (opts.device_size) {
-		if (!(validate_volume_size(opts.device_size, vol_size)))
-			goto bail;
-		vol_size = opts.device_size;
-	}
-
-	/* close and open after binding to raw */
-	safeclose(file);
-
-	/* bind device to raw */
-	if (bind_raw(opts.device, &rawminor, rawdev, sizeof(rawdev)))
-		goto bail;
-
-	/* Open the disk */
-	if (!(file = OpenDisk(rawdev)))
-		goto bail;
-
-	/* read volume header */
-	if (!read_sectors(file, 0, 1, sect_size, (void *)volhdr))
-		goto bail;
-
-	/* Update node cfgs */
-	if (IS_VALID_NODE_NUM(opts.slot_num)) {
-		cfg_hdr_off = volhdr->node_cfg_off;
-		cfg_node_off = volhdr->node_cfg_off + (2 + opts.slot_num) * sect_size;
-		new_cfg_off = volhdr->new_cfg_off + sect_size;
-
-		if (!(update_node_cfg(file, volhdr, cfg_hdr_off, cfg_node_off,
-				      new_cfg_off, node_hdr, node_info,
-				      sect_size, &update)))
-			goto bail;
-	}
-
-	/* Update volume disk header */
-	if (opts.gid != -1 || opts.uid != -1 || opts.perms != -1 ||
-	    opts.device_size || opts.convert != -1 || opts.disk_hb || opts.hb_timeo) {
-		if (!(update_volume_header(file, volhdr, sect_size, vol_size,
-					   &update)))
-			goto bail;
-	}
-
-	if (!update) {
-		printf("No changes made to the volume.\nAborting.\n");
-		goto bail;
-	}
-
-	/* query_only option bails you here */
-	if (opts.query_only) {
-		printf("Changes not written to disk.\n");
-		goto bail;
-	}
-
-	if (!opts.force_op) {
-		printf("Proceed (y/N): ");
-		proceed = getchar();
-		if (toupper(proceed) != 'Y') {
-			printf("Aborting operation.\n");
-			goto bail;
-		}
-	}
-
-	/* Check for heartbeat for any write operation */
-	if (!check_heart_beat(&file, rawdev, volhdr, &nodemap, sect_size))
-		goto bail;
-
-	if (nodemap) {
-		/* Exit as device is mounted on some node */
-		get_node_names(file, volhdr, node_names, sect_size);
-		printf("%s mounted on nodes:", opts.device);
-		print_node_names(node_names, nodemap);
-		printf("Aborting.\n");
-		goto bail;
-	}
-
-	/* do not allow interrupts */
-	ignore_signal = true;
-
-	/* Write node cfgs */
-	if (IS_VALID_NODE_NUM(opts.slot_num)) {
-		if (!write_sectors(file, cfg_hdr_off, 1, sect_size,
-				   (void *)node_hdr))
-			goto bail;
-		if (!write_sectors(file, cfg_node_off, 1, sect_size,
-				   (void *)node_info))
-			goto bail;
-		if (!write_sectors(file, new_cfg_off, 1, sect_size,
-				   (void *)node_hdr))
-			goto bail;
-	}
-
-	/* Make orphaned inode dirs for version 2 upgrade. Do this
-	 * before the header is updated as libocfs is looking for a
-	 * 1.2 versioned filesystem! */
-	if (opts.convert == OCFS2_MAJOR_VERSION) {
-		if (create_orphan_dirs(volhdr, &update, file))
-			goto bail;
-	}
-
-	/* Write volume disk header */
-	if (opts.gid != -1 || opts.uid != -1 || opts.perms != -1 ||
-	    opts.device_size || opts.convert != -1 || opts.disk_hb || opts.hb_timeo) {
-		offset = volhdr->start_off;
-		if (!write_sectors(file, offset, 1, sect_size, (void *)volhdr))
-			goto bail;
-	}
-
-	printf("Changes written to disk.\n");
-
-bail:
-	safefree(volhdr);
-	safefree(node_hdr);
-	safefree(node_info);
-
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
-		safefree(node_names[i]);
-
-	safeclose(file);
-	unbind_raw(rawminor);
-	return 0;
-}				/* main */
-
-
-/*
- * read_options()
- *
- * "usage: %s [-d ms] [-F] [-g gid] [-h] [-l] [-n] [-N nodenum] [-p permissions] "
- * "[-q] [-S size] [-t ms] [-u uid] [-V] device\n\n"
- *
- */
-int read_options(int argc, char **argv)
-{
-	int ret = 1;
-	int c;
-	char *p;
-	__u64 fac = 1;
-	long double size;
-
-	if (argc < 2) {
-		version(argv[0]);
-		usage(argv[0]);
-		ret = 0;					  
-		goto bail;
-	}
-
-	while(1) {
-		c = getopt(argc, argv, "CFhlnqVd:g:N:p:S:t:u:");
-		if (c == -1)
-			break;
-
-		switch (c) {
-		case 'd':	/* disk heartbeat */
-			opts.disk_hb = strtoul(optarg, NULL, 0);
-			break;
-
-		case 'C':	/* clear all data blocks */
-			opts.clear_data_blocks = true;
-			break;
-
-		case 'F':	/* force resize */
-			opts.force_op = true;
-			break;
-
-		case 'g':	/* gid */
-			opts.gid = get_gid(optarg);
-			break;
-
-		case 'h':	/* help */
-			version(argv[0]);
-			usage(argv[0]);
-			ret = 0;
-			break;
-
-		case 'l':	/* list node configs */
-			opts.list_nodes = true;
-			break;
-
-		case 'n':	/* query */
-			opts.query_only = true;
-			break;
-
-		case 'N':	/* node cfg slot */
-			opts.slot_num = atoi(optarg);
-			break;
-
-		case 'p':	/* permissions */
-			opts.perms = strtoul(optarg, NULL, 8);
-			opts.perms &= 0007777;
-			break;
-
-		case 'q':	/* quiet */
-			opts.quiet = true;
-			break;
-
-		case 'S':	/* device size */
-			size = strtold(optarg, &p);
-			if (p)
-				MULT_FACTOR(*p, fac);
-			opts.device_size = (__u64)(size * fac);
-			break;
-
-		case 't':	/* node timeout */
-			opts.hb_timeo = strtoul(optarg, NULL, 0);
-			break;
-
-		case 'u':	/* uid */
-			opts.uid = get_uid(optarg);
-			break;
-
-		case 'V':	/* print version */
-			version(argv[0]);
-			ret = 0;
-			break;
-
-		case 'x':	/* used for debugocfs */
-			opts.print_progress = true;
-			break;
-
-		case 'c':	/* convert */
-			opts.convert = atoi(optarg);
-			if (opts.convert == OCFS_MAJOR_VERSION) {
-				fprintf(stderr, "Conversion to V1 ocfs not yet supported.\nAborting.\n");
-				ret = 0;
-			} else if (opts.convert < OCFS_MAJOR_VERSION || opts.convert > OCFS2_MAJOR_VERSION) {
-				fprintf(stderr, "Invalid version.\nAborting.\n");
-				ret = 0;
-			}
-			break;
-
-		default:
-			break;
-		}
-	}
-
-	if (ret && optind < argc && argv[optind])
-			strncpy(opts.device, argv[optind], FILE_NAME_SIZE);
-
-bail:
-	return ret;
-}				/* read_options */
-
-
-/*
- * validate_options()
- *
- */
-bool validate_options(char *progname)
-{
-	__u32 miss_cnt;
-	__u32 min_hbt;
-
-	if (opts.device[0] == '\0') {
-		fprintf(stderr, "Error: Device not specified.\n");
-		usage(progname);
-		return 0;
-	}
-
-	if (opts.slot_num != OCFS_INVALID_NODE_NUM) {
-		if (opts.slot_num < 0 || opts.slot_num >= OCFS_MAXIMUM_NODES) {
-			fprintf(stderr, "Error: Node config slot should be "
-				"between 0 and 31.\n");
-			return 0;
-		}
-	}
-
-	if (opts.disk_hb && !IS_VALID_DISKHB(opts.disk_hb)) {
-		fprintf(stderr, "Error: Disk heartbeat should be between %d "
-			"and %d.\n", OCFS_MIN_DISKHB, OCFS_MAX_DISKHB);
-		return 0;
-	}
-
-	if (opts.hb_timeo && !IS_VALID_HBTIMEO(opts.hb_timeo)) {
-		fprintf(stderr, "Error: Node timeout should be between %d "
-			"and %d.\n", OCFS_MIN_HBTIMEO, OCFS_MAX_HBTIMEO);
-		return 0;
-	}
-
-	if (opts.disk_hb || opts.hb_timeo) {
-		if (!(opts.disk_hb && opts.hb_timeo)) {
-			fprintf(stderr, "Error: Both node timeout and disk "
-				"heartbeat need to be specified.\n");
-		       	return 0;
-		}
-
-		miss_cnt = opts.hb_timeo / opts.disk_hb;
-		if (miss_cnt < MIN_MISS_COUNT_VALUE) {
-			min_hbt = opts.disk_hb * MIN_MISS_COUNT_VALUE;
-			fprintf(stderr, "Error: For %d ms disk heartbeat, "
-			       	"node timeout cannot be less than %d ms.\n",
-			       	opts.disk_hb, min_hbt);
-			return 0;
-		}
-	}
-
-	return 1;
-}				/* validate_options */
-
-
-/*
- * update_volume_header()
- *
- */
-int update_volume_header(int file, ocfs_vol_disk_hdr *volhdr, __u32 sect_size,
-			 __u64 vol_size, bool *update)
-{
-	int ret = 1;
-
-	if (opts.uid != -1) {
-		if (getpwuid(opts.uid)) {
-			printf("Changing uid from %d to %d\n", volhdr->uid,
-			       opts.uid);
-			volhdr->uid = opts.uid;
-			*update = true;
-		} else {
-			fprintf (stderr, "Error: Invalid uid %d\n", opts.uid); 
-			ret = 0;
-			goto bail;
-		}
-	}
-
-	if (opts.gid != -1) {
-		if (getgrgid(opts.gid)) {
-			printf("Changing gid from %d to %d\n", volhdr->gid,
-			       opts.gid);
-			volhdr->gid = opts.gid;
-			*update = true;
-		} else {
-			fprintf (stderr, "Error: Invalid gid %d\n", opts.gid); 
-			ret = 0;
-			goto bail;
-		}
-	}
-
-	if (opts.perms != -1) {
-		if (opts.perms >= 0000 && opts.perms <= 07777) {
-			printf("Changing permissions from 0%o to 0%o\n",
-			       volhdr->prot_bits, opts.perms);
-			volhdr->prot_bits = opts.perms;
-			*update = true;
-		} else {
-			fprintf (stderr, "Error permissions 0%o\n", opts.perms);
-			ret = 0;
-			goto bail;
-		}
-	}
-
-	if (opts.device_size) {
-		ret = process_new_volsize(file, volhdr, sect_size, vol_size,
-					  update);
-		if (ret)
-			*update = true;
-	}
-
-	if (opts.convert != -1) {
-		if (opts.convert == OCFS_MAJOR_VERSION) {
-			volhdr->minor_version = OCFS_MINOR_VERSION;
-			volhdr->major_version = OCFS_MAJOR_VERSION;
-		} else if (opts.convert == OCFS2_MAJOR_VERSION) {
-			volhdr->minor_version = OCFS2_MINOR_VERSION;
-			volhdr->major_version = OCFS2_MAJOR_VERSION;
-		} else {
-			fprintf (stderr, "Error: Invalid version %d\n", 
-				 opts.convert); 
-			ret = 0;
-			goto bail;
-		}
-		*update = true;
-	}
-
-	if (opts.disk_hb) {
-		printf("Changing disk heartbeat from %u ms to %u ms\n",
-		       volhdr->disk_hb, opts.disk_hb);
-		volhdr->disk_hb = opts.disk_hb;
-		*update = true;
-	}
-
-	if (opts.hb_timeo) {
-		printf("Changing node timeout from %u ms to %u ms\n",
-		       volhdr->hb_timeo, opts.hb_timeo);
-		volhdr->hb_timeo = opts.hb_timeo;
-		*update = true;
-	}
-
-bail:
-	return ret;
-}				/* update_volume_header */
-
-/*
- * update_node_cfg()
- *
- */
-int update_node_cfg(int file, ocfs_vol_disk_hdr *volhdr, __u64 cfg_hdr_off,
-		    __u64 cfg_node_off, __u64 new_cfg_off,
-		    ocfs_node_config_hdr *node_hdr,
-		    ocfs_disk_node_config_info *node_info, __u32 sect_size,
-		    bool *update)
-{
-	bool ret = 0;
-	ocfs_guid guid;
-
-	if (!read_sectors(file, cfg_hdr_off, 1, sect_size, (void *)node_hdr))
-		goto bail;
-
-	if (!read_sectors(file, cfg_node_off, 1, sect_size, (void *)node_info))
-		goto bail;
-
-	memset(&guid, 0, sizeof(ocfs_guid));
-
-	if (memcmp(&node_info->guid, &guid, sizeof(guid))) {
-		printf("Clearing node number %d used by node %s\n",
-		       opts.slot_num, node_info->node_name);
-		node_hdr->num_nodes--;
-		node_hdr->cfg_seq_num++;
-		memset(node_info, 0, sizeof(ocfs_disk_node_config_info));
-		*update = true;
-	} else {
-		fprintf(stderr, "Node number %d is not in use\n",
-		       	opts.slot_num);
-	}
-
-	ret = 1;
-bail:
-	return ret;
-}				/* update_node_cfg */
-
-/*
- * handle_signal()
- */
-void handle_signal(int sig)
-{
-	switch (sig) {
-	case SIGTERM:
-	case SIGINT:
-		if (!ignore_signal) {
-			fprintf(stderr, "\nOperation interrupted.\nAborting.\n");
-			safeclose(file);
-			unbind_raw(rawminor);
-			exit(1);
-		}
-		else
-		{
-			signal(sig, handle_signal);
-		}
-		break;
-	}
-}				/* handle_signal */
-
-/*
- * print_node_cfgs()
- *
- */
-int print_node_cfgs(int file, ocfs_vol_disk_hdr *volhdr, __u32 sect_size)
-{
-	char *buf = NULL;
-	char *p;
-	int len;
-	int ret = 0;
-	int i;
-	ocfs_disk_node_config_info *conf;
-
-	len = volhdr->node_cfg_size;
-	if (!(buf = (char *) MemAlloc(len)))
-		goto bail;
-	else
-		memset(buf, 0, len);
-
-	if (!SetSeek(file, volhdr->node_cfg_off))
-		goto bail;
-
-	if (!(Read(file, len, buf)))
-		goto bail;
-
-	p = buf + (sect_size * 2);
-
-	printf ("%2s %-32s %-15s %-7s %-s\n", "#", "Name", "IP Address", "IP Port", "Node GUID");
-	printf ("%2s %-32s %-15s %-7s %-s\n", "=", "================================",
-	       	"===============", "=======", "================================");
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i, p += sect_size) {
-		conf = (ocfs_disk_node_config_info *)p;
-		if (!conf->node_name[0])
-			continue;
-		printf ("%2d %-32s %-15s %-7d %*s\n", i, conf->node_name,
-		       	conf->ipc_config.ip_addr, conf->ipc_config.ip_port,
-		       	GUID_LEN, conf->guid.guid);
-	}
-
-	ret = 1;
-      bail:
-	safefree(buf);
-	return ret;
-}				/* print_node_cfgs */
-
-
-/*
- * process_new_volsize()
- *
- */
-int process_new_volsize(int file, ocfs_vol_disk_hdr *volhdr, __u32 sect_size,
-		       	__u64 vol_size, bool *update)
-{
-	__u64 end_free_sz;
-	__u64 new_data_sz;
-	__u64 old_num_blks, new_num_blks;
-	__u64 max_vol_sz, min_vol_sz;
-	__u8 *bitmap = NULL;
-	__u32 num_sectors;
-	__u32 new_bitmap_sz;
-	__u32 old_num_bytes, new_num_bytes;
-	__u32 i;
-	__u32 byte_ind, bit_ind;
-	__u8 *p;
-	int ret = 0;
-	char str1[100], str2[100];
-
-	if (vol_size > volhdr->device_size) {
-		end_free_sz = OCFS_NUM_END_SECTORS * sect_size;
-		new_data_sz = vol_size - volhdr->data_start_off - end_free_sz;
-
-		new_num_blks = (__u64)(new_data_sz / volhdr->cluster_size);
-		old_num_blks = volhdr->num_clusters;
-
-		if (new_num_blks == old_num_blks) {
-			fprintf(stderr, "No change in number of blocks (%llu)."
-				"\nAborting.\n", old_num_blks);
-			goto bail;
-		}
-
-		new_bitmap_sz = OCFS_BUFFER_ALIGN(((new_num_blks + 7) / 8),
-						  sect_size);
-		if (new_bitmap_sz > OCFS_MAX_BITMAP_SIZE) {
-			max_vol_sz = OCFS_MAX_BITMAP_SIZE * 8 *
-				     volhdr->cluster_size;
-			max_vol_sz += volhdr->data_start_off + end_free_sz;
-
-			num_to_str(volhdr->cluster_size, str1);
-			num_to_str(max_vol_sz, str2);
-			fprintf(stderr, "With a %s block size, the max "
-				"volume size can be %s.\nAborting.\n",
-				str1, str2);
-			goto bail;
-		}
-
-		if (!opts.quiet) {
-			printf("Increasing volume size from %llu bytes to %llu bytes.\n",
-			       volhdr->device_size, vol_size);
-			printf("Increasing number of blocks from %llu to %llu."
-			       "\n", volhdr->num_clusters, new_num_blks);
-		}
-
-		volhdr->device_size = vol_size;
-		volhdr->num_clusters = new_num_blks;
-		*update = true;
-
-	} else if (vol_size < volhdr->device_size) {
-		end_free_sz = OCFS_NUM_END_SECTORS * sect_size;
-		new_data_sz = vol_size - volhdr->data_start_off - end_free_sz;
-
-		new_num_blks = new_data_sz / volhdr->cluster_size;
-		old_num_blks = volhdr->num_clusters;
-
-		if (new_num_blks == old_num_blks) {
-			fprintf(stderr, "No change in number of blocks (%llu)."
-				"\nAborting.\n", old_num_blks);
-			goto bail;
-		}
-
-		if (!(bitmap = (char *) MemAlloc(OCFS_MAX_BITMAP_SIZE)))
-			goto bail;
-
-		/* read the bitmap */
-		num_sectors = OCFS_MAX_BITMAP_SIZE / sect_size;
-		if (!read_sectors(file, volhdr->bitmap_off, num_sectors,
-				  sect_size, (void *)bitmap))
-			goto bail;
-
-#define GET_LAST_BYTE(num_bytes, num_blocks)		\
-		do {					\
-			num_bytes = (num_blocks) / 8;	\
-			if ((num_blocks) % 8)		\
-				++(num_bytes);		\
-		} while (0)
-
-		GET_LAST_BYTE(new_num_bytes, new_num_blks);
-		GET_LAST_BYTE(old_num_bytes, old_num_blks);
-
-		for (i = old_num_bytes, p = bitmap + old_num_bytes;
-		     i > new_num_bytes - 1; --i, --p)
-			if (*p)
-				break;
-
-		byte_ind = i;
-		if (byte_ind > new_num_bytes - 1) {
-			char x = 0x80;
-			for (i = 8; i > 0; --i, x >>= 1) {
-				if (*p & x)
-					break;
-			}
-
-			bit_ind = i;
-
-			min_vol_sz = (byte_ind - 1) * 8 * volhdr->cluster_size;
-			min_vol_sz += bit_ind * volhdr->cluster_size;
-			min_vol_sz += volhdr->data_start_off + end_free_sz;
-
-			fprintf(stderr, "Due to disk usage, the volume size "
-				"cannot be smaller than %llu bytes.\nAborting.\n",
-				min_vol_sz);
-			goto bail;
-		}
-
-		if (!opts.quiet) {
-			printf("Decreasing volume size from %llu bytes to %llu bytes.\n",
-			       volhdr->device_size, vol_size);
-			printf("Decreasing number of blocks from %llu to %llu."
-			       "\n", volhdr->num_clusters, new_num_blks);
-		}
-
-		volhdr->device_size = vol_size;
-		volhdr->num_clusters = new_num_blks;
-		*update = true;
-	}
-
-	ret = 1;
-
-bail:
-	safefree(bitmap);
-	return ret;
-}				/* process_new_volsize */
-
-void init_global_context()
-{
-	char *tmp;
-
-	memset(&OcfsGlobalCtxt, 0, sizeof(ocfs_global_ctxt));
-	OcfsGlobalCtxt.obj_id.type = OCFS_TYPE_GLOBAL_DATA;
-	OcfsGlobalCtxt.obj_id.size = sizeof (ocfs_global_ctxt);
-	OcfsGlobalCtxt.pref_node_num = 31;
-	OcfsGlobalCtxt.node_name = "user-tool";
-	OcfsGlobalCtxt.comm_info.type = OCFS_UDP;
-	OcfsGlobalCtxt.comm_info.ip_addr = "0.0.0.0";
-	OcfsGlobalCtxt.comm_info.ip_port = OCFS_IPC_DEFAULT_PORT;
-	OcfsGlobalCtxt.comm_info.ip_mask = NULL;
-	OcfsGlobalCtxt.comm_info_read = true;
-	memset(&OcfsGlobalCtxt.guid.id.host_id, 'f', HOSTID_LEN);
-	memset(&OcfsGlobalCtxt.guid.id.mac_id,  '0', MACID_LEN);
-
-	tmp = getenv("debug_level");
-	if (tmp)
-		debug_level = atoi(tmp);
-	tmp = getenv("debug_context");
-	if (tmp)
-		debug_context = atoi(tmp);
-	tmp = getenv("debug_exclude");
-	if (tmp)
-		debug_exclude = atoi(tmp);
-}
-
-
-/* these are needed for the function below as they are used in OCFS2 */
-#define  OCFS_DEFAULT_DIR_NODE_SECTS (256)
-#define  OCFS_ORPHAN_DIR_FILENAME          "OrphanDir"
-#define  DIR_NODE_FLAG_ORPHAN         0x2
-#define  OCFS_SECTOR_SIZE 512
-enum {
-    OCFS2_INVALID_SYSFILE = -1,
-    OCFS2_VOL_MD_SYSFILE = 0,
-    OCFS2_VOL_MD_LOG_SYSFILE,
-    OCFS2_DIR_SYSFILE,
-    OCFS2_DIR_BM_SYSFILE,
-    OCFS2_FILE_EXTENT_SYSFILE,
-    OCFS2_FILE_EXTENT_BM_SYSFILE,
-    OCFS2_RECOVER_LOG_SYSFILE,
-    OCFS2_CLEANUP_LOG_SYSFILE,
-    OCFS2_VOL_BM_SYSFILE,
-    OCFS2_ORPHAN_DIR_SYSFILE,
-    OCFS2_NUM_SYSFILES
-};
-#define OCFS_ORPHAN_DIR              (OCFS2_ORPHAN_DIR_SYSFILE     * OCFS_MAXIMUM_NODES)
-
-int ocfs_init_orphan_dir(ocfs_super *osb, int node_num, char *filename)
-{
-	int status = 0;
-	__u64 offset = 0;
-	ocfs_file_entry *fe = NULL;
-	__u32 file_id;
-	__u64 bitmap_off;
-	__u64 file_off = 0;
-	ocfs_dir_node *new_dir = NULL;
-	__u64 numsects;
-
-	LOG_ENTRY_ARGS ("(node_num = %u)\n", node_num);
-
-	memset(filename, 0, OCFS_MAX_FILENAME_LENGTH);
-
-	/* I prefer to just use node_num, but we should prolly be consistent
-	 * with the rest of the system files. */
-	file_id = OCFS_ORPHAN_DIR + node_num;
-	offset = (file_id * osb->sect_size) + osb->vol_layout.root_int_off;
-	sprintf(filename, "%s%d", OCFS_ORPHAN_DIR_FILENAME, file_id);
-
-	/* Alright, allocate and create the dirnode */
-	status = ocfs_alloc_node_block (osb, OCFS_DEFAULT_DIR_NODE_SIZE, 
-					&bitmap_off, &file_off, &numsects, 
-					osb->node_num, DISK_ALLOC_DIR_NODE);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto leave;
-	}
-
-	new_dir = (ocfs_dir_node *) malloc_aligned(OCFS_DEFAULT_DIR_NODE_SIZE);
-	if (!new_dir) {
-		status = -ENOMEM;
-		goto leave;
-	}
-	memset(new_dir, 0, OCFS_DEFAULT_DIR_NODE_SIZE);
-
-	ocfs_initialize_dir_node (osb, new_dir, bitmap_off, file_off, 
-				  osb->node_num);
-	DISK_LOCK_CURRENT_MASTER (new_dir) = node_num;
-	DISK_LOCK_FILE_LOCK (new_dir) = OCFS_DLM_ENABLE_CACHE_LOCK;
-	new_dir->dir_node_flags |= DIR_NODE_FLAG_ORPHAN;
-
-	status = ocfs_write_force_disk(osb, new_dir, 
-				       OCFS_DEFAULT_DIR_NODE_SIZE, bitmap_off);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto leave;
-	}
-
-	/* Alright, now setup the file entry. */
-	fe = malloc_aligned(osb->sect_size);
-	if (!fe) {
-		status = -ENOMEM;
-		goto leave;
-	}
-	memset (fe, 0, osb->sect_size);
-
-	fe->local_ext = true;
-	fe->granularity = -1;
-	strcpy (fe->signature, OCFS_FILE_ENTRY_SIGNATURE);
-	fe->next_free_ext = 0;
-	memcpy (fe->filename, filename, strlen (filename));
-	(fe->filename)[strlen (filename)] = '\0';
-	SET_VALID_BIT (fe->sync_flags);
-	fe->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
-	fe->this_sector = offset;
-	fe->last_ext_ptr = 0;
-
-	/* do we do this or leave it like all the other sysfiles (0) */
-	fe->attribs = OCFS_ATTRIB_DIRECTORY;
-
-	fe->alloc_size = osb->vol_layout.dir_node_size;
-	fe->extents[0].disk_off = bitmap_off;
-	fe->file_size = osb->vol_layout.dir_node_size;
-	fe->next_del = INVALID_DIR_NODE_INDEX;
-
-	status = ocfs_write_force_disk(osb, fe, osb->sect_size, offset);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto leave;
-	}
-
-leave:
-	if (fe)
-		free_aligned(fe);
-
-	if (new_dir)
-		free_aligned(new_dir);
-
-	LOG_EXIT_STATUS(status);
-	return(status);
-}
-
-int create_orphan_dirs(ocfs_vol_disk_hdr *volhdr, bool *update, int fd)
-{
-	int i;
-	int ret = 0;
-	bool mounted = false;
-	char *filename = NULL;
-
-	init_global_context();
-
-	if ((vdh = malloc_aligned(1024)) == NULL) {
-		fprintf(stderr, "failed to alloc %d bytes!  exiting!\n", 1024);
-		ret = ENOMEM;
-		goto done;
-	}
-
-	memset(vdh, 0, 1024);
-	memset(&sb, 0, sizeof(struct super_block));
-	sb.s_dev = fd;
-
-	ret = ocfs_read_disk_header ((__u8 **)&vdh, &sb);
-	if (ret < 0) {
-		fprintf(stderr, "failed to read header\n");
-		goto done;
-	}
-
-	ret = ocfs_mount_volume (&sb, false);
-	if (ret < 0) {
-		fprintf(stderr, "failed to mount\n");
-		goto done;
-	}
-	mounted = true;
-	osb = sb.u.generic_sbp;
-
-	filename = malloc(OCFS_MAX_FILENAME_LENGTH);
-	if (!filename) {
-		fprintf(stderr, "failed to alloc %d bytes!  exiting!\n", 
-			OCFS_MAX_FILENAME_LENGTH);
-		ret = ENOMEM;
-		goto done;
-	}
-
-	for(i = 0; i < OCFS_MAXIMUM_NODES; i++) {
-		ret = ocfs_init_orphan_dir(osb, i, filename);
-		if (ret < 0) {
-			fprintf(stderr,"Could not create orphan directory!\n");
-			ret = ENOMEM;
-			goto done;
-		}
-		*update = true;
-	}
-done:
-	if (mounted) {
-		int tmp;
-		if ((tmp = ocfs_dismount_volume (&sb)) < 0) {
-			fprintf(stderr, "dismount failed, ret = %d\n", tmp);
-			if (ret == 0)
-				ret = tmp;
-		}
-	}
-
-	if (vdh)
-		free_aligned(vdh);
-
-	if (filename)
-		free(vdh);
-		
-	return(ret);
-}

Copied: trunk/format/tune.c (from rev 205, trunk/ocfs/format/tune.c)

Deleted: trunk/format/tuneocfs.8.in
===================================================================
--- trunk/ocfs/format/tuneocfs.8.in	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/format/tuneocfs.8.in	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,72 +0,0 @@
-.TH "tuneocfs" "19" "January 2004" "Version @VERSION@" "OCFS Manual Pages"
-.SH "NAME"
-tuneocfs \- Change Filesystem Metadata and resize existing OCFS volume.
-.SH "SYNOPSIS"
-\fBtuneocfs\fR [\-F] [\-g gid] [\-h] [\-l] [\-n] [\-N nodenum] [\-p permissions] [\-q] [\-S size] [\-u uid] [\-V] device
-.SH "DESCRIPTION"
-.PP 
-\fBtuneocfs\fR is used to maintain metadata information in an OCFS file system or to resize it. This command should be used carefully as it may affect applications that have access to the filesystem.
-.SH "OPTIONS"
-.TP
-\fB\-F\fR 
-Force resize existing OCFS volume.
-
-.TP
-\fB\-g\fR \fIgid\fR 
-Change the group ID for the root directory. On mount time, it will
-automatically assign the \fIgid\fR specified by this parameter to the mount
-point. One may use the \fIgid\fR or the group name(i.e:1011 or \fIdba\fR).
-
-.TP
-\fB\-h\fR 
-Help. 
-
-.TP
-\fB\-l\fR 
-List all the node config slots. With this command, one can list all nodes that once mounted the specified OCFS device.
-
-.TP
-\fB\-n\fR 
-Query only. Will not perform any change to the filesystem.
-
-.TP
-\fB\-N\fR \fInodenum\fR
-Node config slot be to be cleared. This is used to remove a specific node that
-used to be part of the cluster from the used slots list. Only one slot can be
-cleared at a time.
-
-.TP
-\fB\-p\fR \fINNNN\fR
-Permissions \fINNNN\fR for the root directory. On mount, it will automatcially
-assign the permission specified by this parameter to the mount point.
-
-.TP
-\fB\-q\fR 
-Quiet execution.
-
-.TP
-\fB\-S\fR \fIsize\fR
-Volume \fIsize\fR for the root directory, e.g., 50G (M for mega, G for giga, T
-for tera).
-
-.TP
-\fB\-u\fR \fIuid\fR
-Change the user ID owner of the root directory. On mount time, it will
-automatcially assign \fIuid\fR specified by this parameter to the mount
-point. One may use the \fIuid\fR or the username (i.e.:1011 or \fIoracle\fR).
-
-.TP
-\fB\-V\fR 
-Print version and exit.
-
-.SH "BUGS"
-Stuff.
-
-.SH "SEE ALSO"
-.BR ocfs(5)
-
-.SH "AUTHORS"
-Oracle Corporation
-
-.SH "COPYRIGHT"
-Copyright \(co 2002, 2004 Oracle Corporation

Copied: trunk/format/tuneocfs.8.in (from rev 205, trunk/ocfs/format/tuneocfs.8.in)

Copied: trunk/fsck (from rev 204, trunk/ocfs/fsck)

Deleted: trunk/fsck/Cscope.make
===================================================================
--- trunk/ocfs/fsck/Cscope.make	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/Cscope.make	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,10 +0,0 @@
-cscope:
-	rm -f cscope.*
-	echo "-k" >> cscope.files
-	echo "-I ../libocfs/Common/inc" >> cscope.files
-	echo "-I ../libocfs/Linux/inc" >> cscope.files
-	find . -name '*.c' -print >>cscope.files
-	find . -name '*.h' -print >>cscope.files
-	find ../libocfs -name '*.h' -print >>cscope.files
-	find ../libocfs -name '*.c' -print >>cscope.files
-	cscope -b

Copied: trunk/fsck/Cscope.make (from rev 205, trunk/ocfs/fsck/Cscope.make)

Deleted: trunk/fsck/Makefile
===================================================================
--- trunk/ocfs/fsck/Makefile	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,76 +0,0 @@
-TOPDIR = ../..
-
-include $(TOPDIR)/Preamble.make
-
-MANS = fsck.ocfs.8
-
-SBIN_PROGRAMS = fsck.ocfs blked.ocfs
-DIST_FILES = mkgetconst fsck.h classes.h  defaults.h fsck_print.h layout.h sig.h verify.h mkgetconst classes.c parse fsck.ocfs.8.in
-
-ifdef OCFS_DEBUG
-  OPTS = -g
-endif
-
-WARNINGS = -Wall -Wstrict-prototypes -Wno-format -Wmissing-prototypes \
-           -Wmissing-declarations
-
-LIBOCFS_LIBS = -L$(TOPDIR)/ocfs/libocfs -locfs
-LIBOCFS_CFLAGS = -pthread -I$(TOPDIR)/ocfs/libocfs
-
-CFLAGS = $(OPTS) -fno-strict-aliasing $(WARNINGS) $(LIBOCFS_CFLAGS)
-INCLUDES = -I. -I$(TOPDIR)/ocfs/libocfs/Common/inc -I$(TOPDIR)/ocfs/libocfs/Linux/inc
-
-DEFINES = -DLINUX -DUSERSPACE_TOOL -DSHOW_INVALID_VALUES -DFSCK_OCFS
-
-OPTIMIZE = -O2
-
-ifeq ($(OCFS_PROCESSOR),x86_64)
-  CFLAGS += -m64
-endif
-ifeq ($(OCFS_PROCESSOR),ia64)
-endif
-ifeq ($(OCFS_PROCESSOR),i686)
-  DEFINES += -D__ILP32__
-endif
-ifeq ($(OCFS_PROCESSOR),s390x)
-  DEFINES += -D__LP64__
-endif
-
-CFLAGS += $(OPTIMIZE)
-
-ifdef OCFS_DEBUG
-  DEFINES += -DDEBUG
-endif
-
-GLIB_OBJS = verify.o fsck_io.o class_print.o class_rw.o fsck_print.o sig.o layout.o defaults.o utils.o
-
-## FIXME: make real later
-VERSION_FILES = fsck.c verify.c fsck_io.c class_print.c class_rw.c fsck_print.c sig.c layout.c defaults.c ver.c parse.c utils.c blked.c
-VERSION_SRC = ver.c
-VERSION_PREFIX = FSCK
-
-parse: parse.c
-	gcc $(INCLUDES) -D_GNU_SOURCE parse.c -o $@
-
-classes.c: parse
-	export COMMON_HEADERS=$(TOPDIR)/ocfs/libocfs/Common/inc; cat $(TOPDIR)/ocfs/libocfs/Common/inc/ocfsdisk.h $(TOPDIR)/ocfs/libocfs/Common/inc/ocfsvol.h | ./parse > $@
-
-classes.o: classes.c
-	$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) $(GLIB_CFLAGS) -o $@ -c $<
-
-fsck.o: fsck.c
-	$(CC) $(CFLAGS) $(INCLUDES) $(GLIB_CFLAGS) $(DEFINES) -DUSE_MALLOC_ALIGNED $(VERMAGIC) -o $@ -c $<
-
-blked.o: blked.c
-	$(CC) $(CFLAGS) $(INCLUDES) $(GLIB_CFLAGS) $(DEFINES) -DUSE_MALLOC_ALIGNED $(VERMAGIC) -o $@ -c $<
-
-$(GLIB_OBJS): %.o: %.c
-	$(CC) $(CFLAGS) $(INCLUDES) $(GLIB_CFLAGS) $(DEFINES) -DUSE_MALLOC_ALIGNED $(VERMAGIC) -o $@ -c $<
-
-fsck.ocfs: classes.o fsck.o $(GLIB_OBJS) ver.o
-	$(LINK) $(GLIB_LIBS) $(LIBOCFS_LIBS)
-
-blked.ocfs: classes.o blked.o $(GLIB_OBJS) ver.o
-	$(LINK) $(GLIB_LIBS) $(LIBOCFS_LIBS)
-
-include $(TOPDIR)/Postamble.make

Copied: trunk/fsck/Makefile (from rev 205, trunk/ocfs/fsck/Makefile)
===================================================================
--- trunk/ocfs/fsck/Makefile	2004-08-30 22:26:51 UTC (rev 205)
+++ trunk/fsck/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -0,0 +1,76 @@
+TOPDIR = ..
+
+include $(TOPDIR)/Preamble.make
+
+MANS = fsck.ocfs.8
+
+SBIN_PROGRAMS = fsck.ocfs blked.ocfs
+DIST_FILES = mkgetconst fsck.h classes.h  defaults.h fsck_print.h layout.h sig.h verify.h mkgetconst classes.c parse fsck.ocfs.8.in
+
+ifdef OCFS_DEBUG
+  OPTS = -g
+endif
+
+WARNINGS = -Wall -Wstrict-prototypes -Wno-format -Wmissing-prototypes \
+           -Wmissing-declarations
+
+LIBOCFS_LIBS = -L$(TOPDIR)/libocfs -locfs
+LIBOCFS_CFLAGS = -pthread -I$(TOPDIR)/libocfs
+
+CFLAGS = $(OPTS) -fno-strict-aliasing $(WARNINGS) $(LIBOCFS_CFLAGS)
+INCLUDES = -I. -I$(TOPDIR)/libocfs/Common/inc -I$(TOPDIR)/libocfs/Linux/inc
+
+DEFINES = -DLINUX -DUSERSPACE_TOOL -DSHOW_INVALID_VALUES -DFSCK_OCFS
+
+OPTIMIZE = -O2
+
+ifeq ($(OCFS_PROCESSOR),x86_64)
+  CFLAGS += -m64
+endif
+ifeq ($(OCFS_PROCESSOR),ia64)
+endif
+ifeq ($(OCFS_PROCESSOR),i686)
+  DEFINES += -D__ILP32__
+endif
+ifeq ($(OCFS_PROCESSOR),s390x)
+  DEFINES += -D__LP64__
+endif
+
+CFLAGS += $(OPTIMIZE)
+
+ifdef OCFS_DEBUG
+  DEFINES += -DDEBUG
+endif
+
+GLIB_OBJS = verify.o fsck_io.o class_print.o class_rw.o fsck_print.o sig.o layout.o defaults.o utils.o
+
+## FIXME: make real later
+VERSION_FILES = fsck.c verify.c fsck_io.c class_print.c class_rw.c fsck_print.c sig.c layout.c defaults.c ver.c parse.c utils.c blked.c
+VERSION_SRC = ver.c
+VERSION_PREFIX = FSCK
+
+parse: parse.c
+	gcc $(INCLUDES) -D_GNU_SOURCE parse.c -o $@
+
+classes.c: parse
+	export COMMON_HEADERS=$(TOPDIR)/libocfs/Common/inc; cat $(TOPDIR)/libocfs/Common/inc/ocfsdisk.h $(TOPDIR)/libocfs/Common/inc/ocfsvol.h | ./parse > $@
+
+classes.o: classes.c
+	$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) $(GLIB_CFLAGS) -o $@ -c $<
+
+fsck.o: fsck.c
+	$(CC) $(CFLAGS) $(INCLUDES) $(GLIB_CFLAGS) $(DEFINES) -DUSE_MALLOC_ALIGNED $(VERMAGIC) -o $@ -c $<
+
+blked.o: blked.c
+	$(CC) $(CFLAGS) $(INCLUDES) $(GLIB_CFLAGS) $(DEFINES) -DUSE_MALLOC_ALIGNED $(VERMAGIC) -o $@ -c $<
+
+$(GLIB_OBJS): %.o: %.c
+	$(CC) $(CFLAGS) $(INCLUDES) $(GLIB_CFLAGS) $(DEFINES) -DUSE_MALLOC_ALIGNED $(VERMAGIC) -o $@ -c $<
+
+fsck.ocfs: classes.o fsck.o $(GLIB_OBJS) ver.o
+	$(LINK) $(GLIB_LIBS) $(LIBOCFS_LIBS)
+
+blked.ocfs: classes.o blked.o $(GLIB_OBJS) ver.o
+	$(LINK) $(GLIB_LIBS) $(LIBOCFS_LIBS)
+
+include $(TOPDIR)/Postamble.make

Deleted: trunk/fsck/blked.c
===================================================================
--- trunk/ocfs/fsck/blked.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/blked.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,455 +0,0 @@
-/*
- * blked.c
- *
- * ocfs file system block editor
- *
- * Copyright (C) 2003, 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Sunil Mushran
- */
-
-#include "fsck.h"
-
-#define MAX_EXTENTS	2048
-#define OCFS_HBT_WAIT	10
-
-int prn_len = 1;
-int cnt_err = 0;
-int cnt_wrn = 0;
-int cnt_obj = 0;
-bool int_err = false;
-bool prn_err = false;
-
-__u32 OcfsDebugCtxt = 0;
-__u32 OcfsDebugLevel = 0;
-__u32 debug_context = 0;
-__u32 debug_level = 0;
-__u32 debug_exclude = 0;
-
-bool never_mounted = false;
-__u32 fs_version = 0;
-
-__u32 fs_num;
-
-ocfs_global_ctxt OcfsGlobalCtxt;
-ocfsck_context ctxt;
-extern void version(char *progname);
-void handle_signal(int sig);
-int parse_blked_cmdline(int argc, char **argv);
-int blked_initialize(char **buf);
-bool verify_params(void);
-int edit_structure(ocfs_disk_structure *s, char *buf, int idx, int *changed,
-		   char *option);
-
-char *usage_str = 
-"usage: blked.ocfs [OPTIONS] device\n"
-"	-n No hearbeat check\n"
-"	-V Version";
-
-/*
- * parse_blked_cmdline()
- *
- */
-int parse_blked_cmdline(int argc, char **argv)
-{
-	int c;
-	int ret = -1;
-	char *p;
-
-	ctxt.no_hb_chk = false;
-	ctxt.write_changes = false;
-	ctxt.verbose = false;
-
-	if (argc < 2) {
-		usage();
-		goto bail;
-	}
-
-	while (1) {
-		c = getopt(argc, argv, "nwvV?h:l:o:");
-
-		if (c == -1)
-			break;
-
-		switch (c) {
-		case 'o':
-			p = strchr(optarg, '.');
-			if (!p)
-				ctxt.offset = atoll(optarg);
-			else {
-				*p = '\0';
-				ctxt.offset  = ((__u64) strtoul(optarg, NULL, 0)) << 32;
-				ctxt.offset |= strtoul(++p, NULL, 0);
-			}
-			break;
-		case 'h':
-			ctxt.offset |= ((__u64) strtoul(optarg, NULL, 0)) << 32;
-			break;
-		case 'l':
-			ctxt.offset |= strtoul(optarg, NULL, 0);
-			break;
-		case 'n':
-			ctxt.no_hb_chk = true;
-			break;
-		case 'w':
-			ctxt.write_changes = true;
-			break;
-		case 'v':
-			ctxt.verbose = true;
-			break;
-		case 'V':
-			version(argv[0]);
-			goto bail;
-		default:
-		case '?':
-			usage();
-			goto bail;
-		}
-	}
-
-	if (ctxt.write_changes)
-		ctxt.no_hb_chk = false;
-
-	ret = 0;
-bail:
-	return ret;
-}				/* parse_blked_cmdline */
-
-/*
- * blked_initialize()
- *
- */
-int blked_initialize(char **buf)
-{
-	int ret = -1;
-	int fd;
-
-	if (ctxt.write_changes)
-		ctxt.flags = O_RDWR | O_LARGEFILE | O_SYNC;
-	else
-		ctxt.flags = O_RDONLY | O_LARGEFILE;
-
-	if (bind_raw(ctxt.device, &ctxt.raw_minor, ctxt.raw_device, sizeof(ctxt.raw_device)))
-		goto bail;
-
-	if (ctxt.verbose)
-		CLEAR_AND_PRINT("Bound %s to %s", ctxt.device, ctxt.raw_device);
-
-	if ((fd = myopen(ctxt.raw_device, ctxt.flags)) == -1) {
-		LOG_ERROR("Error opening %s.\n%s.", ctxt.raw_device,
-			  strerror(errno));
-		goto bail;
-	} else
-		ctxt.fd = fd;
-
-	if ((ctxt.hdr = malloc_aligned(OCFS_SECTOR_SIZE)) == NULL) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	if ((*buf = malloc_aligned(OCFS_SECTOR_SIZE)) == NULL) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-
-	/* Read the super block */
-	if (read_one_sector(fd, (char *)ctxt.hdr, 0, 0) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	/* Get the device size */
-	if (get_device_size(fd) == -1) {
-		LOG_ERROR("unable to get the device size. exiting");
-		goto bail;
-	}
-
-	ret = 0;
-
-bail:
-	return ret;
-}				/* blked_initialize */
-
-/*
- * verify_params()
- *
- */
-bool verify_params(void)
-{
-	bool ret = false;
-
-	if (ctxt.offset % OCFS_SECTOR_SIZE) {
-		LOG_ERROR("invalid offset. exiting");
-		goto bail;
-	}
-
-	ret = true;
-bail:
-	return ret;
-}				/* verify_params */
-
-/*
- * main()
- *
- */
-int main(int argc, char **argv)
-{
-	int i, changed;
-	char *buf = NULL;
-	ocfs_disk_structure *s;
-	ocfs_layout_t *l;
-	__u64 blocknum;
-	char option = '\0';
-
-	memset(&ctxt, 0, sizeof(ctxt));
-	init_global_context();
-
-#define INSTALL_SIGNAL(sig)						\
-	do {								\
-		if (signal(sig, handle_signal) == SIG_ERR) {		\
-		    fprintf(stderr, "Could not set " #sig "\n");	\
-		    goto bail;						\
-		}							\
-	} while (0)
-
-	INSTALL_SIGNAL(SIGTERM);
-	INSTALL_SIGNAL(SIGINT);
-
-	init_raw_cleanup_message();
-
-	if (parse_blked_cmdline(argc, argv) == -1)
-		goto bail;
-
-	if (!verify_params)
-		goto bail;
-
-	if (optind >= argc) {
-		usage();
-		goto bail;
-	}
-
-	version(argv[0]);
-
-	strncpy(ctxt.device, argv[optind], OCFS_MAX_FILENAME_LENGTH);
-
-	if (blked_initialize(&buf) == -1) {
-		goto bail;
-	}
-
-	/* Exit if not an OCFS volume */
-	if (memcmp(ctxt.hdr->signature, OCFS_VOLUME_SIGNATURE,
-		   strlen(OCFS_VOLUME_SIGNATURE))) {
-		printf("%s: bad signature in super block\n", ctxt.device);
-		goto bail;
-	}
-#if 0
-	/* Exit if heartbeat detected */
-	if (!ctxt.no_hb_chk) {
-		if (!check_heart_beat(&ctxt.fd, OCFSCK_PUBLISH_OFF,
-				      OCFS_SECTOR_SIZE))
-			goto quiet_bail;
-	}
-#endif
-
-	if (read_one_sector(ctxt.fd, buf, ctxt.offset, 0) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	blocknum = ctxt.offset/OCFS_SECTOR_SIZE;
-
-	l = &(ocfs_header_layout[ocfs_header_layout_sz - 1]);
-	if (blocknum < l->block + l->num_blocks) {
-		for (i = 0; i < ocfs_header_layout_sz; ++i) {
-			option = '\0';
-			l = &(ocfs_header_layout[i]);
-			if ((s = l->kind) == NULL || s->cls == NULL ||
-			    s->read == NULL || s->write == NULL)
-			       	continue;
-			if (blocknum >= l->block &&
-			    blocknum < l->block + l->num_blocks) {
-				s->output(buf, 0, NULL, stdout);
-				while (ctxt.write_changes) {
-					changed = 0;
-					if (edit_structure(s, buf, 0, &changed, &option) != -1)
-						continue;
-
-					if (!changed)
-						break;
-
-					if ((confirm_changes(ctxt.offset, s, buf, 0, NULL)) == -1)
-						LOG_PRINT("Abort write");
-
-					break;
-				}
-			}
-		}
-	} else {
-		s = find_matching_struct(buf, 0);
-		if (s) {
-			s->output(buf, 0, NULL, stdout);
-			while (ctxt.write_changes) {
-				changed = 0;
-				if (edit_structure(s, buf, 0, &changed, &option) != -1)
-					continue;
-
-				if (!changed)
-					break;
-
-				if ((confirm_changes(ctxt.offset, s, buf, 0, NULL)) == -1)
-					LOG_PRINT("Abort write");
-
-				break;
-			}
-		} else
-			LOG_ERROR("unknown structure");
-	}
-
-bail:
-	myclose(ctxt.fd);
-
-	unbind_raw(ctxt.raw_minor);
-
-	free_aligned(buf);
-	free_aligned(ctxt.hdr);
-	exit(0);
-}				/* main */
-
-/*
- * edit_structure()
- *
- */
-int edit_structure(ocfs_disk_structure *s, char *buf, int idx, int *changed, char *option)
-{
-	int ret = 0;
-	int fld;
-	ocfs_class *cls;
-	ocfs_class_member *m;
-	GString *cur;
-	GString *dflt;
-	char *newval = NULL;
-	char *bad;
-	char *loc;
-
-	if ((newval = malloc(USER_INPUT_MAX)) == NULL) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	*changed = 0;
-	cls = s->cls;
-	*option = '\0';
-
-	while (1) {
-		cur = dflt = NULL;
-		bad = NULL;
-	
-		LOG_PRINT("choose a field to edit (1-%d) or 'q' to quit) : ", cls->num_members);
-		if (fgets(newval, USER_INPUT_MAX, stdin) == NULL) {
-			ret = -1;
-			break;
-		}
-
-		if ((loc = rindex(newval, '\n')) != NULL)
-			*loc = '\0';
-
-	       	if (strcasecmp(newval, "q") == 0 || strcasecmp(newval, "quit") == 0) {
-			*option = tolower(*newval);
-			ret = -1;
-			break;
-		}
-
-		fld = strtol(newval, &bad, 10);
-		fld--;
-
-		if (bad == newval || IS_INVALID_FIELD_NUM(cls, fld)) {
-			ret = 0;
-			LOG_ERROR("bad field number");
-			break;
-		}
-	
-		// show current value and default value	
-		m = &(cls->members[fld]);
-		if (m->to_string(&cur, buf, &(m->type))==-1) {
-			ret = -1;
-			LOG_ERROR("to_string failed");
-			break;
-		}
-
-		if (s->defaults(buf, &dflt, idx, fld)==-1) {
-			ret = -1;
-			LOG_ERROR("defaults failed");
-			break;
-		}
-
-		LOG_PRINT("%s : %s (default=%s)\n", m->name,
-			  cur ? cur->str : "", dflt ? dflt->str : "");
-
-		// get new value and validate it
-		if (fgets(newval, USER_INPUT_MAX, stdin) == NULL) {
-			ret = -1;
-			break;
-		}
-
-		if ((loc = rindex(newval, '\n')) != NULL)
-			*loc = '\0';
-
-	       	if (strcasecmp(newval, "q")==0 || strcasecmp(newval, "quit")==0) {
-			ret = -1;
-			break;
-		}
-
-		if (strcmp(newval, "?")==0 || strcasecmp(newval, "help")==0) {
-			char *help = m->helptext(&(m->type));
-			printf("%s\n", help);
-			free(help);
-			ret = 0;
-			break;
-		}
-
-		if ((ret = m->from_string(newval, buf, &(m->type))) == -1) {
-			LOG_ERROR("bad entry");
-			ret = -1;
-			break;
-		}
-
-		(*changed)++;
-		
-		if (dflt) {
-			g_string_free(dflt, true);
-			dflt = NULL;
-		}
-
-		if (cur) {
-			g_string_free(cur, true);
-			cur = NULL;
-		}
-	}
-
-	if (dflt)
-		g_string_free(dflt, true);
-
-	if (cur)
-		g_string_free(cur, true);
-
-bail:
-	safefree(newval);
-
-	return ret;
-}				/* edit_structure */

Copied: trunk/fsck/blked.c (from rev 205, trunk/ocfs/fsck/blked.c)

Deleted: trunk/fsck/class_print.c
===================================================================
--- trunk/ocfs/fsck/class_print.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/class_print.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,97 +0,0 @@
-/*
- * class_print.c
- *
- * generic print for structures in ocfs file system check utility
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#include "fsck.h"
-
-/*
- * print_class_member()
- *
- */
-int print_class_member(char *buf, ocfs_class *cl, ocfs_class_member *mbr,
-		       FILE *out, bool bad)
-{
-	GString *gs = NULL;
-	int ret;
-	char *inval_str = "";
-
-	ret = mbr->to_string(&gs, buf, &mbr->type);
-
-	if (ret != 0 || bad)
-		inval_str = "<INVALID VALUE> ";
-	    
-	fprintf(out, "%s: %s%s", mbr->name, inval_str, gs==NULL ? "NULL" : gs->str);
-	if (gs)
-		g_string_free(gs, true);
-	
-	return ret;
-}				/* print_class_member */
-
-/*
- * _print_class()
- *
- */
-int _print_class(char *buf, ocfs_class *cl, FILE *out, bool num, GHashTable *ht)
-{
-	int ret = 0, i, bad;
-
-	bad = 0;
-	fprintf(out, "\n%s\n=================================\n", cl->name);
-	for (i=0; i<cl->num_members; i++)
-	{
-		bool fail = false;
-		ocfs_class_member *mbr = &(cl->members[i]);
-
-		if (ht)
-			fail = (g_hash_table_lookup(ht, GINT_TO_POINTER(i)) != NULL);
-		if (num)
-			fprintf(out, "%3d. ", i+1);
-
-		if (print_class_member(buf, cl, mbr, out, fail) != 0)
-		{
-			bad++;
-			ret = -1;
-		}
-		fprintf(out, "\n");
-	}
-
-	if (ret == -1)
-		LOG_ERROR("%d bad fields total", bad);
-
-	return ret;
-}				/* _print_class */
-
-extern ocfsck_context ctxt;
-
-/*
- * print_class()
- *
- */
-int print_class(char *buf, ocfs_class *cl, FILE *out, GHashTable *ht)
-{
-	if (ctxt.write_changes)
-		return _print_class(buf, cl, out, true, ht);
-	else
-		return _print_class(buf, cl, out, false, ht);
-}				/* print_class */

Copied: trunk/fsck/class_print.c (from rev 205, trunk/ocfs/fsck/class_print.c)

Deleted: trunk/fsck/class_rw.c
===================================================================
--- trunk/ocfs/fsck/class_rw.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/class_rw.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,1900 +0,0 @@
-/*
- * class_rw.c
- *
- * reader-writer functions for each type
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-/*****************************************************
-   Implement a type reader-writer function for each type
-
-   Create some kind of type array[] for each class or
-   change the one i already have
-
-   Develop an opaque iterator object that deals with running
-   thru each thing in this type array for editing class
-
-   Process:
-
-   * Verify the whole structure at once: this should
-     probably return the number of bad fields, should
-     probably pass the opaque structure, maybe the
-     opaque can hold each of the suggested values for
-     each bad entry?
-
-   * Iterate w/the opaque thru the print() function,
-     showing something for each messed up field
-
-   * Should the edit() iterate thru all of them?, or
-     know to get at one by index# ??
- 
-*****************************************************/
-
-#include "fsck.h"
-#include "classes.h"  
-
-// for now, ultraslow-nonhashed-stinkyperformance
-// eh, who cares
-ocfs_class_member * find_class_member(ocfs_class *cl, const char *name, int *idx)
-{
-	int i;
-	ocfs_class_member *ret;
-
-	*idx = -1;
-	for (i=0; i < cl->num_members; i++)
-	{
-		ret = &(cl->members[i]);
-		if (strcmp(ret->name, name)==0)
-		{
-			*idx = i;
-			return ret;
-		}
-	}
-	return NULL;
-}
-	
-	
-// ATTRIBS: __u32
-int _attribs_valid(void *top, typeinfo *info)
-{
-	__u32 attribs = G_STRUCT_MEMBER(__u32, top, info->off);
-	if (!(attribs & (OCFS_ATTRIB_DIRECTORY| OCFS_ATTRIB_FILE_CDSL| OCFS_ATTRIB_CHAR|
-			 OCFS_ATTRIB_BLOCK| OCFS_ATTRIB_REG| OCFS_ATTRIB_FIFO|
-			 OCFS_ATTRIB_SYMLINK| OCFS_ATTRIB_SOCKET)) &&
-	    attribs != 0)
-	{
-		return -1;
-	}
-	return 0;
-}
-
-int _attribs_to_string_u32(GString **retval, void *top, typeinfo *info)
-{
-	__u32 attribs;
-	
-	attribs = G_STRUCT_MEMBER(__u32, top, info->off);
-	if (_attribs_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", attribs);
-#endif
-		return -1;
-	}
-
-	*retval = g_string_new("");
-	if (attribs & OCFS_ATTRIB_FILE_CDSL)
-		g_string_append(*retval, "cdsl ");
-
-	switch (attribs & ~OCFS_ATTRIB_FILE_CDSL)
-	{
-		case OCFS_ATTRIB_DIRECTORY:
-			g_string_append(*retval, "directory");
-			break;
-		case OCFS_ATTRIB_CHAR:
-			g_string_append(*retval, "character device");
-			break;
-		case OCFS_ATTRIB_BLOCK:
-			g_string_append(*retval, "block device");
-			break;
-		case OCFS_ATTRIB_FIFO:
-			g_string_append(*retval, "fifo");
-			break;
-		case OCFS_ATTRIB_SYMLINK:
-			g_string_append(*retval, "symlink");
-			break;
-		case OCFS_ATTRIB_SOCKET:
-			g_string_append(*retval, "socket");
-			break;
-		default:
-		case OCFS_ATTRIB_REG:
-			g_string_append(*retval, "regular file");
-			break;
-	}
-	
-	return 0;
-}
-
-int _string_to_attribs_u32(char *newval, void *top, typeinfo *info)
-{
-	__u32 attribs = 0;
-
-	if (strcasecmp(newval, "dir")==0)
-		attribs |= OCFS_ATTRIB_DIRECTORY;
-	else if (strcasecmp(newval, "char")==0)
-		attribs |= OCFS_ATTRIB_CHAR;
-	else if (strcasecmp(newval, "block")==0)
-		attribs |= OCFS_ATTRIB_BLOCK;
-	else if (strcasecmp(newval, "reg")==0)
-		attribs |= OCFS_ATTRIB_REG;
-	else if (strcasecmp(newval, "fifo")==0)
-		attribs |= OCFS_ATTRIB_FIFO;
-	else if (strcasecmp(newval, "symlink")==0)
-		attribs |= OCFS_ATTRIB_SYMLINK;
-	else if (strcasecmp(newval, "socket")==0)
-		attribs |= OCFS_ATTRIB_SOCKET;
-	else if (strcasecmp(newval, "cdsl-dir")==0)
-		attribs |= (OCFS_ATTRIB_DIRECTORY|OCFS_ATTRIB_FILE_CDSL);
-	else if (strcasecmp(newval, "cdsl-reg")==0)
-		attribs |= (OCFS_ATTRIB_REG|OCFS_ATTRIB_FILE_CDSL);
-	else
-		return -1;
-
-	G_STRUCT_MEMBER(__u32, top, info->off) = attribs;
-	return 0;
-}
-
-char * _get_attribs_helptext(typeinfo *info)
-{
-	return strdup("one of: dir char block reg fifo symlink socket cdsl-dir cdsl-reg");
-}
-
-
-// BOOL: __s32 __u8 bool
-int _bool_valid(void *top, typeinfo *info)
-{
-	__s32 b = G_STRUCT_MEMBER(__s32, top, info->off);
-	if (b != 0 && b != 1)
-		return -1;
-	return 0;
-}
-
-int _bool_to_string_s32(GString **retval, void *top, typeinfo *info)
-{
-	__s32 val = 0;
-
-	val = G_STRUCT_MEMBER(__s32, top, info->off);
-	if (_bool_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%d", val);
-#endif
-		return -1;
-	}
-	*retval = g_string_new("");
-	g_string_append(*retval, val ? "TRUE" : "FALSE");
-
-	return 0;
-}
-
-int _string_to_bool_s32(char *newval, void *top, typeinfo *info)
-{
-	__s32 val;
-
-	if (strcasecmp(newval, "true")==0)
-		val = 1;
-	else if (strcasecmp(newval, "false")==0)
-		val = 0;
-	else
-		return -1;
-
-	G_STRUCT_MEMBER(__s32, top, info->off) = val;
-
-	return 0;
-}
-
-int _bool_to_string_u8(GString **retval, void *top, typeinfo *info)
-{
-	__u8 val = 0;
-
-	val = G_STRUCT_MEMBER(__u8, top, info->off);
-	if (_bool_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", val);
-#endif
-		return -1;
-	}
-	*retval = g_string_new("");
-	g_string_append(*retval, val ? "TRUE" : "FALSE");
-
-	return 0;
-}
-
-int _string_to_bool_u8(char *newval, void *top, typeinfo *info)
-{
-	__u8 val;
-
-	if (strcasecmp(newval, "true")==0)
-		val = 1;
-	else if (strcasecmp(newval, "false")==0)
-		val = 0;
-	else
-		return -1;
-
-	G_STRUCT_MEMBER(__u8, top, info->off) = val;
-
-	return 0;
-}
-
-int _bool_to_string_bool(GString **retval, void *top, typeinfo *info)
-{
-	return _bool_to_string_s32(retval, top, info);
-}
-
-int _string_to_bool_bool(char *newval, void *top, typeinfo *info)
-{
-	return _string_to_bool_s32(newval, top, info);
-}
-
-char * _get_bool_helptext(typeinfo *info)
-{
-	return strdup("TRUE or FALSE");
-}
-
-
-// CLUSTERSIZE: __u64 
-int _clustersize_valid(void *top, typeinfo *info)
-{
-	__u64 cs = G_STRUCT_MEMBER(__u64, top, info->off);
-	if (cs==4096 || cs==8192 || cs==16384 || cs==32768 ||
-	    cs==65536 || cs==131072 || cs==262144 ||
-	    cs==524288 || cs==1048576)
-	{
-		return 0;
-	}
-	return -1;
-}
-
-int _clustersize_to_string_u64(GString **retval, void *top, typeinfo *info)
-{
-	__u64 csize;
-	
-	csize = G_STRUCT_MEMBER(__u64, top, info->off);
-
-	if (_clustersize_valid(top, info) != -1)
-	{
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%llu", csize);
-		return 0;
-	}
-
-#ifdef SHOW_INVALID_VALUES
-	*retval = g_string_new("");
-	g_string_sprintf(*retval, "%llu", csize);
-#endif
-	return -1;
-}
-
-int _string_to_clustersize_u64(char *newval, void *top, typeinfo *info)
-{
-	__u64 csize;
-	
-	csize = strtoull (newval, NULL, 10);
-	if (csize==4096 || csize==8192 || csize==16384 || csize==32768 ||
-	    csize==65536 || csize==131072 || csize==262144 ||
-	    csize==524288 || csize==1048576)
-	{
-		G_STRUCT_MEMBER(__u64, top, info->off) = csize;
-		return 0;
-	}
-
-	return -1;
-}
-
-char * _get_clustersize_helptext(typeinfo *info)
-{
-	return strdup("one of 4096,8192,16384,32768,65536,131072,262144,524288,1048576");
-}
-
-
-
-// DATE: __u64
-int _date_valid(void *top, typeinfo *info)
-{
-	return 0;
-}
-
-int _date_to_string_u64(GString **retval, void *top, typeinfo *info)
-{
-	__u64 sec;
-	char *t, *t2;
-
-	sec = G_STRUCT_MEMBER(__u64, top, info->off);
-	if (_date_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%llu", sec);
-#endif
-		return -1;
-	}
-	*retval = g_string_new("");
-	t = ctime((time_t *) &sec);
-	t2 = t;
-	while (*t2)
-	{
-       		if (*t2=='\n' || *t2=='\r')
-			*t2 = ' ';
-		t2++;
-	}
-	g_string_append(*retval, t);
-	return 0;
-}
-
-int _string_to_date_u64(char *newval, void *top, typeinfo *info)
-{
-	__u64 sec;
-	struct tm t;
-	int ret = -1;
-	char mo[4];
-	int d, y, h, mi, s, i;
-	char *months[] = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", 
-			   "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" };
-
-	memset(&t, 0, sizeof(struct tm));
-
-	if (sscanf(newval, "%3s %d %d %d:%d:%d", mo, &d, &y, &h, &mi, &s) == 6)
-	{
-		g_strup(mo);
-		if (d<=31 && y>=1900 && h<=23 && mi<=59 && s<=59)
-		{
-			for (i=0; i<12; i++)
-			{
-				if (strcmp(mo, months[i])==0)
-				{
-					t.tm_mon = i+1;
-					t.tm_sec = s;
-					t.tm_min = mi;
-					t.tm_hour = h;
-					t.tm_year = y-1900;
-					sec = mktime(&t);
-					G_STRUCT_MEMBER(__u64, top, info->off) = sec;
-					ret = 0;
-				}
-			}
-		}
-	}
-
-	return ret;
-}
-
-char * _get_date_helptext(typeinfo *info)
-{
-	return strdup("Jan 28 2003 22:30:32");
-}
-
-
-// DIRFLAG: __u8
-int _dirflag_valid(void *top, typeinfo *info)
-{
-	__u8 flag = G_STRUCT_MEMBER(__u8, top, info->off);
-	if (flag != 0 && flag != DIR_NODE_FLAG_ROOT)
-		return -1;
-	return 0;			
-}
-
-int _dirflag_to_string_u8(GString **retval, void *top, typeinfo *info)
-{
-	__u8 flag;
-	flag = G_STRUCT_MEMBER(__u8, top, info->off);
-	if (_dirflag_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", flag);
-#endif
-		return -1;
-	}
-	*retval = g_string_new("");
-	g_string_append(*retval, flag & DIR_NODE_FLAG_ROOT ? "DIR_NODE_FLAG_ROOT" : "");
-	return 0;
-}
-
-int _string_to_dirflag_u8(char *newval, void *top, typeinfo *info)
-{
-	__u8 flag=0;
-
-	if (strcasecmp(newval, "DIR_NODE_FLAG_ROOT")==0)
-		flag |= DIR_NODE_FLAG_ROOT;
-
-	G_STRUCT_MEMBER(__u8, top, info->off) = flag;
-	return 0;
-}
-
-char * _get_dirflag_helptext(typeinfo *info)
-{
-	return strdup("DIR_NODE_FLAG_ROOT or NONE");
-}
-
-
-// DIRINDEX: __u8[256]
-int _dirindex_valid(void *top, typeinfo *info)
-{
-	// this one is tough since we don't want duplicate
-	// values, but we don't know the upper bound here
-	// so we can't check
-	if (info->array_size != 256)
-		return -1;
-	
-	return 0;	
-}
-
-int _dirindex_to_string_u8(GString **retval, void *top, typeinfo *info)
-{
-	int i;
-	__u8 *buf = NULL;
-	__u8 *arr;
-
-	if (info->array_size <= 0)
-		return -1;
-
-	arr =  G_STRUCT_MEMBER_P(top, info->off);
-
-	if (_dirindex_valid(top, info) == -1) {
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "[%u, ...]", arr[0]);
-#endif
-		return -1;
-	}
-
-	if ((buf = malloc(info->array_size + 1)) == NULL) {
-		LOG_ERROR("unable to allocate %d bytes of memory",
-			  info->array_size + 1);
-		goto bail;
-	}
-
-	memcpy(buf, arr, info->array_size);
-
-	*retval = g_string_new("");
-	for (i=0; i<info->array_size; i++) {
-		g_string_sprintfa((*retval), "%d ", buf[i]);
-	}
-
-      bail:
-	free(buf);
-	return 0;
-}
-
-int _string_to_dirindex_u8(char *newval, void *top, typeinfo *info)
-{
-	int ret = -1;
-	char **arr;
-	__u8 index[256];
-	int i;
-
-	memset(&(index[0]), 0, 256);
-	arr = g_strsplit(newval, ":", 0);
-
-	for (i=0; i<256; i++)
-	{  
-		int tmp;
-		if (arr[i]==NULL)
-			break;
-	        tmp = atoi(arr[i]);
-		if (tmp<0 || tmp>255)
-			goto bail;
-		index[i] = (__u8)tmp;
-	}
-	memcpy(G_STRUCT_MEMBER(__u8 *, top, info->off), index, 256);
-	ret = 0;
-
-bail:
-	g_strfreev(arr);
-	return ret;
-}
-
-char * _get_dirindex_helptext(typeinfo *info)
-{
-	return strdup("a string like 5:7:1:2:4:255:... with each index between 0 and 255");
-}
-
-
-// DIRNODEINDEX: __s8 __u8
-int _dirnodeindex_valid(void *top, typeinfo *info)
-{
-	return 0;
-}
-
-int _dirnodeindex_to_string_s8(GString **retval, void *top, typeinfo *info)
-{
-	__s8 idx;
-	idx = G_STRUCT_MEMBER(__s8, top, info->off);
-	if (_dirnodeindex_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%d", idx);
-#endif
-		return -1;
-	}
-	*retval = g_string_new("");
-	if (idx==INVALID_DIR_NODE_INDEX)
-		g_string_append(*retval, "INVALID_DIR_NODE_INDEX");
-	else
-		g_string_sprintf(*retval, "%d", idx);
-	return 0;
-}
-
-int _string_to_dirnodeindex_s8(char *newval, void *top, typeinfo *info)
-{
-	int tmp;
-	char *ptr;
-
-	if (strcasecmp(newval, "INVALID_DIR_NODE_INDEX")==0)
-		tmp = INVALID_DIR_NODE_INDEX;
-	else
-	{
-		tmp = strtol(newval, &ptr, 10);
-		if (ptr==newval || tmp<-1 || tmp>255)
-			return -1;
-	}
-
-	G_STRUCT_MEMBER(__s8, top, info->off) = (__s8)tmp;
-	return 0;
-}
-
-/* the signed and unsigned are the same?!  
- * why yes!  because we like to put -1 into the unsigned one too!
- * /me pokes eyes out
- */
-int _dirnodeindex_to_string_u8(GString **retval, void *top, typeinfo *info)
-{
-	return _dirnodeindex_to_string_s8(retval, top, info);
-}
-
-int _string_to_dirnodeindex_u8(char *newval, void *top, typeinfo *info)
-{
-	return _string_to_dirnodeindex_s8(newval, top, info);
-}
-
-char * _get_dirnodeindex_helptext(typeinfo *info)
-{
-	if (info->is_signed)
-		return strdup("some number between -1 and 255, or INVALID_DIR_NODE_INDEX");
-	else
-		return strdup("some number between 0 and 255, or INVALID_DIR_NODE_INDEX");
-}
-
-
-
-// DISKPTR: __s64 __u64
-int _diskptr_valid(void *top, typeinfo *info)
-{
-	if (info->is_signed)
-	{
-		__s64 s = G_STRUCT_MEMBER(__s64, top, info->off);
-		if (s != INVALID_NODE_POINTER && (s % 512))
-			return -1;
-	}
-	else
-	{
-		__u64 u = G_STRUCT_MEMBER(__u64, top, info->off);
-		if (u != INVALID_NODE_POINTER && (u % 512))
-			return -1;
-	}
-	return 0;
-}
-
-// more junk here: (I think) it's really always a __u64 with -1 being a special case :(
-int _diskptr_to_string_s64(GString **retval, void *top, typeinfo *info)
-{
-	__s64 ptr;
-	ptr = G_STRUCT_MEMBER(__s64, top, info->off);
-	if (_diskptr_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u.%u", HILO(ptr));
-#endif
-		return -1;
-	}
-	*retval = g_string_new("");
-	if (ptr==INVALID_NODE_POINTER)
-		g_string_append(*retval, "INVALID_NODE_POINTER");
-	else
-		g_string_sprintf(*retval, "%u.%u", HILO(ptr));
-	return 0;
-}
-
-int _string_to_diskptr_s64(char *newval, void *top, typeinfo *info)
-{
-	__s64 ptr;
-	char *bad;
-
-	if (strcasecmp(newval, "INVALID_NODE_POINTER")==0)
-		ptr = INVALID_NODE_POINTER;
-	else
-	{
-		ptr = strtoll(newval, &bad, 10);
-		if (bad==newval || ptr<-1)
-			return -1;
-	}	
-	G_STRUCT_MEMBER(__s64, top, info->off) = ptr;
-	return 0;
-}
-
-int _diskptr_to_string_u64(GString **retval, void *top, typeinfo *info)
-{
-	return _diskptr_to_string_s64(retval, top, info);
-}
-
-int _string_to_diskptr_u64(char *newval, void *top, typeinfo *info)
-{
-	return _string_to_diskptr_s64(newval, top, info);
-}
-
-char * _get_diskptr_helptext(typeinfo *info)
-{
-	return strdup("a 64-bit offset, or INVALID_NODE_POINTER");
-}
-
-
-// EXTENTTYPE: __u32
-int _extenttype_valid(void *top, typeinfo *info)
-{
-	__u32 type = G_STRUCT_MEMBER(__u32, top, info->off);
-	if (type != OCFS_EXTENT_DATA && type != OCFS_EXTENT_HEADER)
-		return -1;
-	return 0;
-}
-
-int _extenttype_to_string_u32(GString **retval, void *top, typeinfo *info)
-{
-	__u32 type;
-	type = G_STRUCT_MEMBER(__u32, top, info->off);
-
-	if (_extenttype_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", type);
-#endif
-		return -1;
-	}
-
-	if (type == OCFS_EXTENT_DATA)
-		*retval = g_string_new("OCFS_EXTENT_DATA");
-	else
-		*retval = g_string_new("OCFS_EXTENT_HEADER");
-
-	return 0;
-}
-
-int _string_to_extenttype_u32(char *newval, void *top, typeinfo *info)
-{
-	__u32 type;
-
-	if (strcasecmp(newval, "OCFS_EXTENT_HEADER")==0)
-		type = OCFS_EXTENT_HEADER;
-	else if (strcasecmp(newval, "OCFS_EXTENT_DATA")==0)
-		type = OCFS_EXTENT_DATA;
-	else 
-		return -1;
-
-	G_STRUCT_MEMBER(__u32, top, info->off) = type;
-
-	return 0;
-}
-
-char * _get_extenttype_helptext(typeinfo *info)
-{
-	return strdup("OCFS_EXTENT_HEADER or OCFS_EXTENT_DATA");
-}
-
-
-// FILEFLAG: __u32
-int _fileflag_valid(void *top, typeinfo *info)
-{
-	__u32 flag = G_STRUCT_MEMBER(__u32, top, info->off);
-	if (flag!=0 && ! (flag & (FLAG_FILE_CREATE|FLAG_FILE_EXTEND|
-				  FLAG_FILE_DELETE|FLAG_FILE_RENAME|
-				  FLAG_FILE_UPDATE|FLAG_FILE_CREATE_DIR|
-				  FLAG_FILE_UPDATE_OIN|FLAG_FILE_RELEASE_MASTER|
-				  FLAG_FILE_RELEASE_CACHE|FLAG_FILE_CREATE_CDSL|
-				  FLAG_FILE_DELETE_CDSL|FLAG_FILE_CHANGE_TO_CDSL|
-				  FLAG_FILE_TRUNCATE|FLAG_FILE_ACQUIRE_LOCK|
-				  FLAG_FILE_RELEASE_LOCK)))
-		return -1;
-	return 0;
-}
-
-int _fileflag_to_string_u32(GString **retval, void *top, typeinfo *info)
-{
-	__u32 flag;
-
-	flag = G_STRUCT_MEMBER(__u32, top, info->off);
-	if (_fileflag_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", flag);
-#endif
-		return -1;
-	}
-	    
-	*retval = g_string_new("");
-	if (flag & FLAG_FILE_CREATE)
-		g_string_append(*retval, "FLAG_FILE_CREATE ");
-	if (flag & FLAG_FILE_EXTEND)
-		g_string_append(*retval, "FLAG_FILE_EXTEND ");
-	if (flag & FLAG_FILE_DELETE)
-		g_string_append(*retval, "FLAG_FILE_DELETE ");
-	if (flag & FLAG_FILE_RENAME)
-		g_string_append(*retval, "FLAG_FILE_RENAME ");
-	if (flag & FLAG_FILE_UPDATE)
-		g_string_append(*retval, "FLAG_FILE_UPDATE ");
-	if (flag & FLAG_FILE_CREATE_DIR)
-		g_string_append(*retval, "FLAG_FILE_CREATE_DIR ");
-	if (flag & FLAG_FILE_UPDATE_OIN)
-		g_string_append(*retval, "FLAG_FILE_UPDATE_OIN ");
-	if (flag & FLAG_FILE_RELEASE_MASTER)
-		g_string_append(*retval, "FLAG_FILE_RELEASE_MASTER ");
-	if (flag & FLAG_FILE_RELEASE_CACHE)
-		g_string_append(*retval, "FLAG_FILE_RELEASE_CACHE ");
-	if (flag & FLAG_FILE_CREATE_CDSL)
-		g_string_append(*retval, "FLAG_FILE_CREATE_CDSL ");
-	if (flag & FLAG_FILE_DELETE_CDSL)
-		g_string_append(*retval, "FLAG_FILE_DELETE_CDSL ");
-	if (flag & FLAG_FILE_CHANGE_TO_CDSL)
-		g_string_append(*retval, "FLAG_FILE_CHANGE_TO_CDSL ");
-	if (flag & FLAG_FILE_TRUNCATE)
-		g_string_append(*retval, "FLAG_FILE_TRUNCATE ");
-	if (flag & FLAG_FILE_ACQUIRE_LOCK)
-		g_string_append(*retval, "FLAG_FILE_ACQUIRE_LOCK");
-	if (flag & FLAG_FILE_RELEASE_LOCK)
-		g_string_append(*retval, "FLAG_FILE_RELEASE_LOCK");
-	if ((*retval)->len > 0)
-		g_string_truncate(*retval, (*retval)->len - 1);
-
-	return 0;
-}
-
-int _string_to_fileflag_u32(char *newval, void *top, typeinfo *info)
-{
-	int ret = -1;
-	char **arr, **p;
-	__u32 flag;
-
-	flag = 0;
-	p = arr = g_strsplit(newval, " ", 0);
-
-	while (*arr!=NULL)
-	{  
-		if (strcasecmp(*arr, "FLAG_FILE_CREATE")==0)
-			flag |= FLAG_FILE_CREATE;
-		else if (strcasecmp(*arr, "FLAG_FILE_EXTEND")==0)
-			flag |= FLAG_FILE_EXTEND;
-		else if (strcasecmp(*arr, "FLAG_FILE_DELETE")==0)
-			flag |= FLAG_FILE_DELETE;
-		else if (strcasecmp(*arr, "FLAG_FILE_RENAME")==0)
-			flag |= FLAG_FILE_RENAME;
-		else if (strcasecmp(*arr, "FLAG_FILE_UPDATE")==0)
-			flag |= FLAG_FILE_UPDATE;
-		else if (strcasecmp(*arr, "FLAG_FILE_CREATE_DIR")==0)
-			flag |= FLAG_FILE_CREATE_DIR;
-		else if (strcasecmp(*arr, "FLAG_FILE_UPDATE_OIN")==0)
-			flag |= FLAG_FILE_UPDATE_OIN;
-		else if (strcasecmp(*arr, "FLAG_FILE_RELEASE_MASTER")==0)
-			flag |= FLAG_FILE_RELEASE_MASTER;
-		else if (strcasecmp(*arr, "FLAG_FILE_RELEASE_CACHE")==0)
-			flag |= FLAG_FILE_RELEASE_CACHE;
-		else if (strcasecmp(*arr, "FLAG_FILE_CREATE_CDSL")==0)
-			flag |= FLAG_FILE_CREATE_CDSL;
-		else if (strcasecmp(*arr, "FLAG_FILE_DELETE_CDSL")==0)
-			flag |= FLAG_FILE_DELETE_CDSL;
-		else if (strcasecmp(*arr, "FLAG_FILE_CHANGE_TO_CDSL")==0)
-			flag |= FLAG_FILE_CHANGE_TO_CDSL;
-		else if (strcasecmp(*arr, "FLAG_FILE_TRUNCATE")==0)
-			flag |= FLAG_FILE_TRUNCATE;
-		else if (strcasecmp(*arr, "FLAG_FILE_ACQUIRE_LOCK")==0)
-			flag |= FLAG_FILE_ACQUIRE_LOCK;
-		else if (strcasecmp(*arr, "FLAG_FILE_RELEASE_LOCK")==0)
-			flag |= FLAG_FILE_RELEASE_LOCK;
-		arr++;
-	}
-	G_STRUCT_MEMBER(__u32, top, info->off) = flag;
-	ret = 0;
-	g_strfreev(p);
-	return ret;
-}
-
-char * _get_fileflag_helptext(typeinfo *info)
-{
-	return strdup("one or more of: FLAG_FILE_CREATE FLAG_FILE_EXTEND "
-		      "FLAG_FILE_DELETE FLAG_FILE_RENAME FLAG_FILE_UPDATE "
-		      "FLAG_FILE_CREATE_DIR FLAG_FILE_UPDATE_OIN "
-		      "FLAG_FILE_RELEASE_MASTER FLAG_FILE_RELEASE_CACHE "
-		      "FLAG_FILE_CREATE_CDSL FLAG_FILE_DELETE_CDSL "
-		      "FLAG_FILE_CHANGE_TO_CDSL FLAG_FILE_TRUNCATE "
-		      "FLAG_FILE_ACQUIRE_LOCK FLAG_FILE_RELEASE_LOCK");
-}
-
-// GID: __u32
-int _gid_valid(void *top, typeinfo *info)
-{
-#ifdef ARE_WE_SURE_WE_WANT_TO_DO_THIS
-	struct group *gr;
-	__u32 id = G_STRUCT_MEMBER(__u32, top, info->off);
-
-	gr = getgrgid(id);
-	if (gr == NULL)
-		return -1;
-#endif
-	return 0;
-}
-
-int _gid_to_string_u32(GString **retval, void *top, typeinfo *info)
-{
-	__u32 id;
-	struct group *gr;
-
-	*retval = g_string_new("");
-	id = G_STRUCT_MEMBER(__u32, top, info->off);
-	
-	if (_gid_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", id);
-#endif
-		return -1;
-	}
-	gr = getgrgid(id);
-	g_string_sprintf(*retval, "%u (%s)", id,
-			 gr ? gr->gr_name : "unknown group id");
-	return 0;
-}
-
-int _string_to_gid_u32(char *newval, void *top, typeinfo *info)
-{
-	__u32 id;
-	char *bad = NULL;
-	struct group *gr;
-
-	gr = getgrnam(newval);
-	if (gr == NULL)
-	{
-		id = strtoul(newval, &bad, 10);
-		if (bad == newval)
-			return -1;
-	}
-	else
-		id = gr->gr_gid;
-
-	G_STRUCT_MEMBER(__u32, top, info->off) = id;
-	return 0;
-}
-
-char * _get_gid_helptext(typeinfo *info)
-{
-	return strdup("a numeric gid");
-}
-
-// UID: __u32
-int _uid_valid(void *top, typeinfo *info)
-{
-#ifdef ARE_WE_SURE_WE_WANT_TO_DO_THIS
-	struct passwd *pw;
-	__u32 id =  G_STRUCT_MEMBER(__u32, top, info->off);
-
-	pw = getpwuid(id);
-	if (pw == NULL)
-		return -1;
-#endif
-	return 0;
-}
-
-int _uid_to_string_u32(GString **retval, void *top, typeinfo *info)
-{
-	__u32 id;
-	struct passwd *pw;
-
-	*retval = g_string_new("");
-	id = G_STRUCT_MEMBER(__u32, top, info->off);
-	if (_uid_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", id);
-#endif
-		return -1;
-	}
-	pw = getpwuid(id);
-	g_string_sprintf(*retval, "%u (%s)", id,
-			 pw ? pw->pw_name : "unknown user id");
-	return 0;
-}
-
-int _string_to_uid_u32(char *newval, void *top, typeinfo *info)
-{
-	__u32 id;
-	char *bad = NULL;
-	struct passwd *pw;
-
-	pw = getpwnam(newval);
-	if (pw == NULL)
-	{
-		id = strtoul(newval, &bad, 10);
-		if (bad == newval)
-			return -1;
-	}
-	else
-		id = pw->pw_uid;
-
-	G_STRUCT_MEMBER(__u32, top, info->off) = id;
-	return 0;
-}
-
-char * _get_uid_helptext(typeinfo *info)
-{
-	return strdup("a numeric uid");
-}
-
-// LOCKLEVEL: __u8
-int _locklevel_valid(void *top, typeinfo *info)
-{
-	__u8 lvl = G_STRUCT_MEMBER(__u8, top, info->off);
-	if (lvl != OCFS_DLM_SHARED_LOCK && lvl != OCFS_DLM_EXCLUSIVE_LOCK &&
-	    lvl != OCFS_DLM_ENABLE_CACHE_LOCK && lvl != OCFS_DLM_NO_LOCK)
-		return -1;
-	return 0;
-}
-
-int _locklevel_to_string_u8(GString **retval, void *top, typeinfo *info)
-{
-	__u8 lvl;
-
-	lvl = G_STRUCT_MEMBER(__u8, top, info->off);
-	if (_locklevel_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", lvl);
-#endif
-		return -1;
-	}
-
-	*retval = g_string_new("");
-	switch (lvl)
-	{
-		case OCFS_DLM_ENABLE_CACHE_LOCK:
-			g_string_append(*retval, "OCFS_DLM_ENABLE_CACHE_LOCK");
-			break;
-		case OCFS_DLM_EXCLUSIVE_LOCK: 
-			g_string_append(*retval, "OCFS_DLM_EXCLUSIVE_LOCK");
-			break;
-		case OCFS_DLM_SHARED_LOCK:
-			g_string_append(*retval, "OCFS_DLM_SHARED_LOCK");
-			break;
-		case OCFS_DLM_NO_LOCK:
-			g_string_append(*retval, "OCFS_DLM_NO_LOCK");
-			break;
-	}
-	return 0;
-}
-
-int _string_to_locklevel_u8(char *newval, void *top, typeinfo *info)
-{
-	__u8 lvl; 
-
-	if (strcasecmp(newval, "OCFS_DLM_NO_LOCK")==0)
-		lvl = OCFS_DLM_NO_LOCK;
-	else if (strcasecmp(newval, "OCFS_DLM_SHARED_LOCK")==0)
-		lvl = OCFS_DLM_SHARED_LOCK;
-	else if (strcasecmp(newval, "OCFS_DLM_EXCLUSIVE_LOCK")==0)
-		lvl = OCFS_DLM_EXCLUSIVE_LOCK;
-	else if (strcasecmp(newval, "OCFS_DLM_ENABLE_CACHE_LOCK")==0)
-		lvl = OCFS_DLM_ENABLE_CACHE_LOCK;
-	else
-		return -1;
-	
-	G_STRUCT_MEMBER(__u8, top, info->off) = lvl;
-	return 0;
-
-}
-
-char * _get_locklevel_helptext(typeinfo *info)
-{
-	return strdup("one of OCFS_DLM_ENABLE_CACHE_LOCK OCFS_DLM_EXCLUSIVE_LOCK "
-		      "OCFS_DLM_SHARED_LOCK OCFS_DLM_NO_LOCK");
-}
-
-// NODEBITMAP: __u64
-int _nodebitmap_valid(void *top, typeinfo *info)
-{
-	__u64 bm = G_STRUCT_MEMBER(__u64, top, info->off);
-	// should have nothing in the upper 32 bits
-	if (bm & 0xffffffff00000000ULL)
-		return -1;
-	return 0;
-}
-
-int _nodebitmap_to_string_u64(GString **retval, void *top, typeinfo *info)
-{
-	__u64 bm;
-	int pos;
-
-	bm = G_STRUCT_MEMBER(__u64, top, info->off);
-
-	if (_nodebitmap_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%llu", bm);
-#endif
-		return -1;
-	}
-
-	*retval = g_string_new("");	
-	for (pos=0; pos<32; pos++)
-		g_string_sprintfa(*retval, "%d", (bm & (1 << pos)) ? 1 : 0);
-
-	return 0;
-}
-
-int _string_to_nodebitmap_u64(char *newval, void *top, typeinfo *info)
-{
-	__u64 bm;
-	char *bad = NULL;
-
-	bm = strtol(newval, &bad, 2);
-	if (bad == newval)
-		return -1;
-	G_STRUCT_MEMBER(__u64, top, info->off) = bm;
-	return 0;
-}
-
-char * _get_nodebitmap_helptext(typeinfo *info)
-{
-	return strdup("a 32-node binary map like: "
-		      "01101010011101010101010100101100");
-}
-
-// NODENUM: __u32 __s32
-int _nodenum_valid(void *top, typeinfo *info)
-{
-	__s32 snum = G_STRUCT_MEMBER(__s32, top, info->off);
-	__u32 unum = G_STRUCT_MEMBER(__u32, top, info->off);
-
-	if (info->is_signed)
-	{
-		if (snum < OCFS_INVALID_NODE_NUM || snum > 31)
-			return -1;
-	}
-	else
-	{
-		if (unum > 31 && unum != OCFS_INVALID_NODE_NUM)
-			return -1;
-	}
-			
-	return 0;
-}
-
-int _nodenum_to_string_u32(GString **retval, void *top, typeinfo *info)
-{
-	__u32 num;
-
-	num = G_STRUCT_MEMBER(__u32, top, info->off);
-	if (_nodenum_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", num);
-#endif
-		return -1;
-	}
-
-	*retval = g_string_new("");
-	if (num == OCFS_INVALID_NODE_NUM)
-		g_string_append(*retval, "OCFS_INVALID_NODE_NUM");
-	else
-		g_string_sprintf(*retval, "%u", num);
-
-	return 0;
-}
-
-int _string_to_nodenum_u32(char *newval, void *top, typeinfo *info)
-{
-	__u32 num;
-	char *bad = NULL;
-
-	if (strcasecmp(newval, "OCFS_INVALID_NODE_NUM")==0)
-		num = OCFS_INVALID_NODE_NUM;
-	else
-		num = strtoul(newval, &bad, 10);
-	if (bad == newval || num<0 || num>31)
-		return -1;
-	G_STRUCT_MEMBER(__u32, top, info->off) = num;
-	return 0;
-}
-
-int _nodenum_to_string_s32(GString **retval, void *top, typeinfo *info)
-{
-	__s32 num;
-
-	num = G_STRUCT_MEMBER(__s32, top, info->off);
-	if (_nodenum_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%d", num);
-#endif
-		return -1;
-	}
-
-	*retval = g_string_new("");
-	if (num == OCFS_INVALID_NODE_NUM)
-		g_string_append(*retval, "OCFS_INVALID_NODE_NUM");
-	else
-		g_string_sprintf(*retval, "%d", num);
-
-	return 0;
-}
-
-int _string_to_nodenum_s32(char *newval, void *top, typeinfo *info)
-{
-	__s32 num;
-	char *bad = NULL;
-
-	if (strcasecmp(newval, "OCFS_INVALID_NODE_NUM")==0)
-		num = OCFS_INVALID_NODE_NUM;
-	else
-		num = strtol(newval, &bad, 10);
-	if (bad == newval || num<-1 || num>31)
-		return -1;
-	G_STRUCT_MEMBER(__s32, top, info->off) = num;
-	return 0;
-}
-
-char * _get_nodenum_helptext(typeinfo *info)
-{
-	return strdup("a node number between 0 and 31, or OCFS_INVALID_NODE_NUM");
-}
-
-// PERMS: __u32
-int _perms_valid(void *top, typeinfo *info)
-{
-	return 0;	
-}
-
-int _perms_to_string_u32(GString **retval, void *top, typeinfo *info)
-{
-	__u32 mode;
-
-	mode = G_STRUCT_MEMBER(__u32, top, info->off);
-	if (_perms_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", mode);
-#endif
-		return -1;
-	}
-
-	*retval = g_string_sized_new(10);
-	g_string_append_c(*retval, '-');
-	g_string_append_c(*retval, mode & S_IRUSR ? 'r' : '-');
-	g_string_append_c(*retval, mode & S_IWUSR ? 'w' : '-');
-	if (mode & S_ISUID)
-		g_string_append_c(*retval, mode & S_IXUSR ? 's' : 'S');
-	else
-		g_string_append_c(*retval, mode & S_IXUSR ? 'x' : '-');
-	
-	g_string_append_c(*retval, mode & S_IRGRP ? 'r' : '-');
-	g_string_append_c(*retval, mode & S_IWGRP ? 'w' : '-');
-	if (mode & S_ISGID)
-		g_string_append_c(*retval, mode & S_IXGRP ? 's' : 'S');
-	else
-		g_string_append_c(*retval, mode & S_IXGRP ? 'x' : '-');
-	
-	g_string_append_c(*retval, mode & S_IROTH ? 'r' : '-');
-	g_string_append_c(*retval, mode & S_IWOTH ? 'w' : '-');
-	if (mode & S_ISVTX)
-		g_string_append_c(*retval, mode & S_IXOTH ? 't' : 'T');
-	else
-		g_string_append_c(*retval, mode & S_IXOTH ? 'x' : '-');
-	return 0;
-}
-
-int _string_to_perms_u32(char *newval, void *top, typeinfo *info)
-{
-	int mode = 0;
-
-	if (strlen(newval)!=10) 
-		return -1;
-
-	if (newval[1] == 'r')
-		mode |= S_IRUSR;
-	if (newval[2] == 'w')
-		mode |= S_IWUSR;
-	if (newval[3] == 'x' || newval[3] == 's')
-		mode |= S_IXUSR;
-	if (newval[3] == 's' || newval[3] == 'S')
-		mode |= S_ISUID;
-
-	if (newval[4] == 'r')
-		mode |= S_IRGRP;
-	if (newval[5] == 'w')
-		mode |= S_IWGRP;
-	if (newval[6] == 'x' || newval[6] == 's')
-		mode |= S_IXGRP;
-	if (newval[6] == 's' || newval[6] == 'S')
-		mode |= S_ISGID;
-
-	if (newval[7] == 'r')
-		mode |= S_IROTH;
-	if (newval[8] == 'w')
-		mode |= S_IWOTH;
-	if (newval[9] == 'x' || newval[9] == 't')
-		mode |= S_IXOTH;
-	if (newval[9] == 't' || newval[9] == 'T')
-		mode |= S_ISVTX;
-
-	G_STRUCT_MEMBER(__u32, top, info->off) = mode;
-
-	return 0;
-}
-
-char * _get_perms_helptext(typeinfo *info)
-{
-	return 	strdup("-rwxrwxrwx  (filetype ignored; x,s,S,t,T allowed)");
-}
-
-// SYNCFLAG: __u32 __u8
-int _syncflag_valid(void *top, typeinfo *info)
-{
-	__u32 sync = G_STRUCT_MEMBER(__u32, top, info->off);
-	if (sync !=0 && !(sync & (OCFS_SYNC_FLAG_VALID|
-				  OCFS_SYNC_FLAG_CHANGE|
-				  OCFS_SYNC_FLAG_MARK_FOR_DELETION|
-				  OCFS_SYNC_FLAG_NAME_DELETED)))
-		return -1;
-	return 0;
-}
-
-int _syncflag_to_string_u32(GString **retval, void *top, typeinfo *info)
-{
-	__u32 sync;
-	sync = G_STRUCT_MEMBER(__u32, top, info->off);
-	if (_syncflag_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", sync);
-#endif
-		return -1;
-	}
-	
-	*retval = g_string_new("");
-	if (sync == OCFS_SYNC_FLAG_DELETED)
-		g_string_append(*retval, "deleted");
-	if (sync & OCFS_SYNC_FLAG_VALID)
-		g_string_append(*retval, "valid ");
-	if (sync & OCFS_SYNC_FLAG_CHANGE)
-		g_string_append(*retval, "change ");
-	if (sync & OCFS_SYNC_FLAG_MARK_FOR_DELETION)
-		g_string_append(*retval, "mark-del ");
-	if (sync & OCFS_SYNC_FLAG_NAME_DELETED)
-		g_string_append(*retval, "name-del ");
-	return 0;
-}
-
-int _string_to_syncflag_u32(char *newval, void *top, typeinfo *info)
-{
-	__u32 sync = 0;
-	int ret = -1;
-	char **arr, **p;
-
-	p = arr = g_strsplit(newval, " ", 0);
-
-	while (*arr != NULL)
-	{
-		if (strcasecmp(*arr, "deleted")==0)
-			sync |= OCFS_SYNC_FLAG_DELETED;
-		else if (strcasecmp(*arr, "valid")==0)
-			sync |= OCFS_SYNC_FLAG_VALID;
-		else if (strcasecmp(*arr, "change")==0)
-			sync |= OCFS_SYNC_FLAG_CHANGE;
-		else if (strcasecmp(*arr, "mark-del")==0)
-			sync |= OCFS_SYNC_FLAG_MARK_FOR_DELETION;
-		else if (strcasecmp(*arr, "name-del")==0)
-			sync |= OCFS_SYNC_FLAG_NAME_DELETED;
-		else
-			goto bail;
-		arr++;
-	}
-	G_STRUCT_MEMBER(__u32, top, info->off) = sync;
-	ret = 0;
-bail:
-	g_strfreev(p);
-	return ret;
-}
-
-int _syncflag_to_string_u8(GString **retval, void *top, typeinfo *info)
-{
-	__u8 sync;
-	sync = G_STRUCT_MEMBER(__u8, top, info->off);
-	if (_syncflag_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", sync);
-#endif
-		return -1;
-	}
-
-	*retval = g_string_new("");
-	if (sync == OCFS_SYNC_FLAG_DELETED)
-		g_string_append(*retval, "deleted");
-	if (sync & OCFS_SYNC_FLAG_VALID)
-		g_string_append(*retval, "valid ");
-	if (sync & OCFS_SYNC_FLAG_CHANGE)
-		g_string_append(*retval, "change ");
-	if (sync & OCFS_SYNC_FLAG_MARK_FOR_DELETION)
-		g_string_append(*retval, "mark-del ");
-	if (sync & OCFS_SYNC_FLAG_NAME_DELETED)
-		g_string_append(*retval, "name-del ");
-	return 0;
-}
-
-int _string_to_syncflag_u8(char *newval, void *top, typeinfo *info)
-{
-	__u8 sync = 0;
-	int ret = -1;
-	char **arr, **p;
-
-	sync = 0;
-	p = arr = g_strsplit(newval, " ", 0);
-
-	while (*arr != NULL)
-	{
-		if (strcasecmp(*arr, "deleted")==0)
-			sync |= OCFS_SYNC_FLAG_DELETED;
-		else if (strcasecmp(*arr, "valid")==0)
-			sync |= OCFS_SYNC_FLAG_VALID;
-		else if (strcasecmp(*arr, "change")==0)
-			sync |= OCFS_SYNC_FLAG_CHANGE;
-		else if (strcasecmp(*arr, "mark-del")==0)
-			sync |= OCFS_SYNC_FLAG_MARK_FOR_DELETION;
-		else if (strcasecmp(*arr, "name-del")==0)
-			sync |= OCFS_SYNC_FLAG_NAME_DELETED;
-		else
-			goto bail;
-		arr++;
-	}
-	G_STRUCT_MEMBER(__u8, top, info->off) = sync;
-	ret = 0;
-bail:
-	g_strfreev(p);
-	return ret;
-
-}
-
-char * _get_syncflag_helptext(typeinfo *info)
-{
-	return strdup("one or more of: deleted valid change mark-del name-del");
-}
-
-// CHAR ARRAY: __u8[]
-int _char_array_valid(void *top, typeinfo *info)
-{
-	return 0;
-}
-
-int _char_array_to_string_u8(GString **retval, void *top, typeinfo *info)
-{
-	char *buf = NULL;
-	__u8 *arr;
-
-	if (info->array_size <= 0)
-		return -1;
-	arr =  G_STRUCT_MEMBER_P(top, info->off);
-	if (_char_array_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "[ %u, ... ]", arr[0]);
-#endif
-		return -1;
-	}
-	
-	if ((buf = malloc(info->array_size + 1)) == NULL) {
-		LOG_ERROR("unable to allocate %d bytes of memory",
-			  info->array_size + 1);
-		goto bail;
-	}
-
-	memcpy(buf, arr, info->array_size);
-	buf[ info->array_size ] = '\0';
-	*retval = g_string_new(buf);
-
-      bail:
-	free(buf);
-	return 0;
-}
-
-int _string_to_char_array_u8(char *newval, void *top, typeinfo *info)
-{
-	char *buf;
-	if (info->array_size <= 0)
-		return -1;
-
-	buf = G_STRUCT_MEMBER_P(top, info->off);
-	strncpy(buf, newval, info->array_size);
-	buf[info->array_size - 1] = '\0';
-	return 0;
-}
-
-char * _get_char_array_helptext(typeinfo *info)
-{
-	return g_strdup_printf("a string with maximum length %d",
-			       info->array_size - 1);
-}
-
-// HEX ARRAY: __u8[]
-int _hex_array_valid(void *top, typeinfo *info)
-{
-	return 0;
-}
-
-int _hex_array_to_string_u8(GString **retval, void *top, typeinfo *info)
-{
-	char *buf = NULL;
-	char *p;
-	int i;
-	__u8 *arr;
-
-	if (info->array_size <= 0)
-		return -1;
-	arr =  G_STRUCT_MEMBER_P(top, info->off);
-	if (_char_array_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "[ %X, ... ]", arr[0]);
-#endif
-		return -1;
-	}
-	
-	if ((buf = malloc(2 * info->array_size + 1)) == NULL) {
-		LOG_ERROR("unable to allocate %d bytes of memory",
-			  info->array_size + 1);
-		goto bail;
-	}
-
-	for (i = 0, p = buf; i < info->array_size; ++i, p += 2)
-		sprintf(p, "%2X", arr[i]);
-	buf[ 2 * info->array_size ] = '\0';
-	*retval = g_string_new(buf);
-
-      bail:
-	free(buf);
-	return 0;
-}
-
-int _string_to_hex_array_u8(char *newval, void *top, typeinfo *info)
-{
-	unsigned char *buf;
-	unsigned char tb[3];
-	int i;
-	unsigned char *p;
-
-	if (info->array_size <= 0)
-		return -1;
-
-	buf = G_STRUCT_MEMBER_P(top, info->off);
-
-	tb[2] = '\0';
-	for (i = 0, p = newval; i < info->array_size; ++i, ++p) {
-		tb[0] = *p;
-		tb[1] = *(++p);
-		buf[i] = strtoul(tb, NULL, 16);
-	}
-
-	return 0;
-}
-
-char * _get_hex_array_helptext(typeinfo *info)
-{
-	return g_strdup_printf("a hex string with maximum length %d",
-			       info->array_size);
-}
-
-// NUMBER RANGE: __s32 __u8 __u16 __u32 __u64
-int _number_range_valid(void *top, typeinfo *info) 
-{
-	if (info->is_signed)
-	{
-		__s64 num, hi, lo;
-		switch (info->type_size)
-		{
-		case 1:
-			num = G_STRUCT_MEMBER(__s8, top, info->off);
-			hi = (__s8)(info->hi & 0xffLL);
-			lo = (__s8)(info->lo & 0xffLL);
-			break;
-		case 2:
-			num = G_STRUCT_MEMBER(__s16, top, info->off);
-			hi = (__s16)(info->hi & 0xffffLL);
-			lo = (__s16)(info->lo & 0xffffLL);
-			break;
-		case 4:
-			num = G_STRUCT_MEMBER(__s32, top, info->off);
-			hi = (__s32)(info->hi & 0xffffffffLL);
-			lo = (__s32)(info->lo & 0xffffffffLL);
-			break;
-		case 8:
-			num = G_STRUCT_MEMBER(__s64, top, info->off);
-			hi = (__s64)info->hi;
-			lo = (__s64)info->lo;
-			break;
-		default:
-			return -1;
-			break;
-		}
-		if (num < lo || num > hi)
-			return -1;
-	}
-	else
-	{
-		__u64 num, hi, lo;
-		switch (info->type_size)
-		{
-		case 1:
-			num = G_STRUCT_MEMBER(__u8, top, info->off);
-			hi = (__u8)(info->hi & 0xffLL);
-			lo = (__u8)(info->lo & 0xffLL);
-			break;
-		case 2:
-			num = G_STRUCT_MEMBER(__u16, top, info->off);
-			hi = (__u16)(info->hi & 0xffffLL);
-			lo = (__u16)(info->lo & 0xffffLL);
-			break;
-		case 4:
-			num = G_STRUCT_MEMBER(__u32, top, info->off);
-			hi = (__u32)(info->hi & 0xffffffffLL);
-			lo = (__u32)(info->lo & 0xffffffffLL);
-			break;
-		case 8:
-			num = G_STRUCT_MEMBER(__u64, top, info->off);
-			hi = (__u64)info->hi;
-			lo = (__u64)info->lo;
-			break;
-		default:
-			return -1;
-			break;
-		}
-		if (num < lo || num > hi)
-			return -1;
-
-	}
-	return 0;
-}
-
-int _number_range_to_string_s32(GString **retval, void *top,
-				typeinfo *info)
-{
-	__s32 num;
-
-	num = G_STRUCT_MEMBER(__s32, top, info->off);
-	if (_number_range_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%d", num);
-#endif
-		return -1;
-	}
-	*retval = g_string_new("");
-	g_string_sprintfa(*retval, "%d", num);
-	return 0;
-}
-
-int _string_to_number_range_s32(char *newval, void *top, typeinfo *info)
-{
-	__s32 num, hi, lo;
-	char *bad = NULL;
-
-	hi = (__s32)(info->hi & 0xffffffffULL);
-	lo = (__s32)(info->lo & 0xffffffffULL);
-	
-	num = strtol(newval, &bad, 10);
-	if (bad == newval || num < lo || num > hi)
-		return -1;
-	G_STRUCT_MEMBER(__s32, top, info->off) = num;
-	return 0;
-}
-
-int _number_range_to_string_u8(GString **retval, void *top, typeinfo *info)
-{
-	__u8 num;
-
-	num = G_STRUCT_MEMBER(__u8, top, info->off);
-	if (_number_range_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", num);
-#endif
-		return -1;
-	}
-	
-	*retval = g_string_new("");
-	g_string_sprintfa(*retval, "%u", num);
-	return 0;
-}
-
-int _string_to_number_range_u8(char *newval, void *top, typeinfo *info)
-{
-	__u32 tmp;
-	__u8 hi, lo;
-	char *bad = NULL;
-
-	hi = (__u8)(info->hi & 0xffULL);
-	lo = (__u8)(info->lo & 0xffULL);
-	
-	tmp = strtoul(newval, &bad, 10);
-	if (bad == newval || tmp < lo || tmp > hi)
-		return -1;
-	G_STRUCT_MEMBER(__u8, top, info->off) = tmp;
-	return 0;
-}
-
-int _number_range_to_string_u16(GString **retval, void *top, typeinfo *info)
-{
-	__u16 num;
-
-	num = G_STRUCT_MEMBER(__u16, top, info->off);
-	if (_number_range_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", num);
-#endif
-		return -1;
-	}
-	
-	*retval = g_string_new("");
-	g_string_sprintfa(*retval, "%u", num);
-	return 0;
-}
-
-int _string_to_number_range_u16(char *newval, void *top, typeinfo *info)
-{
-	__u32 tmp;
-	__u16 hi, lo;
-	char *bad = NULL;
-
-	hi = (__u16)(info->hi & 0xffffULL);
-	lo = (__u16)(info->lo & 0xffffULL);
-	
-	tmp = strtoul(newval, &bad, 10);
-	if (bad == newval || tmp < lo || tmp > hi)
-		return -1;
-	G_STRUCT_MEMBER(__u16, top, info->off) = tmp;
-	return 0;
-}
-
-int _number_range_to_string_u32(GString **retval, void *top, typeinfo *info)
-{
-	__u32 num;
-
-	num = G_STRUCT_MEMBER(__u32, top, info->off);
-	if (_number_range_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%u", num);
-#endif
-		return -1;
-	}
-	
-	*retval = g_string_new("");
-	g_string_sprintfa(*retval, "%u", num);
-	return 0;
-}
-
-int _string_to_number_range_u32(char *newval, void *top, typeinfo *info)
-{
-	__u32 tmp, hi, lo;
-	char *bad = NULL;
-
-	hi = (__u32)(info->hi & 0xffffffffULL);
-	lo = (__u32)(info->lo & 0xffffffffULL);
-	
-	tmp = strtoul(newval, &bad, 10);
-	if (bad == newval || tmp < lo || tmp > hi)
-		return -1;
-	G_STRUCT_MEMBER(__u32, top, info->off) = tmp;
-	return 0;
-}
-
-int _number_range_to_string_u64(GString **retval, void *top, typeinfo *info)
-{
-	__u64 num;
-
-	num = G_STRUCT_MEMBER(__u64, top, info->off);
-	if (_number_range_valid(top, info) == -1)
-	{
-#ifdef SHOW_INVALID_VALUES
-		*retval = g_string_new("");
-		g_string_sprintf(*retval, "%llu", num);
-#endif
-		return -1;
-	}
-	*retval = g_string_new("");
-	g_string_sprintfa(*retval, "%llu", num);
-	return 0;
-}
-
-int _string_to_number_range_u64(char *newval, void *top, typeinfo *info)
-{
-	__u64 tmp;
-	char *bad = NULL;
-
-	tmp = strtoull(newval, &bad, 10);
-	if (bad == newval || tmp < info->lo || tmp > info->hi)
-		return -1;
-	G_STRUCT_MEMBER(__u64, top, info->off) = tmp;
-	return 0;
-}
-
-char * _get_number_range_helptext(typeinfo *info)
-{
-	if (info->is_signed)
-		return g_strdup_printf("a number between %d and %d (inclusive)", 
-				       (__s32)(info->lo & 0xffffffffULL), 
-				       (__s32)(info->hi & 0xffffffffULL));
-	else
-		return g_strdup_printf("a number between %llu and %llu (inclusive)",
-				       info->lo, info->hi);
-}
-
-// VOTEFLAG: __u8[32]
-int _voteflag_array_valid(void *top, typeinfo *info)
-{
-	int i;
-	__u8 *arr;
-	if (info->array_size != 32)
-		return -1;
-
-	arr = G_STRUCT_MEMBER_P(top, info->off);
-	for (i=0; i<info->array_size; i++)
-	{
-		if (arr[i] != 0 &&
-		    arr[i] != FLAG_VOTE_NODE &&
-		    arr[i] != FLAG_VOTE_OIN_UPDATED &&
-		    arr[i] != FLAG_VOTE_OIN_ALREADY_INUSE &&
-		    arr[i] != FLAG_VOTE_UPDATE_RETRY &&
-		    arr[i] != FLAG_VOTE_FILE_DEL)
-			return -1;
-	}
-	return 0;
-}
-
-int _voteflag_array_to_string_u8(GString **retval, void *top, typeinfo *info)
-{
-	__u8 *arr;
-	int i;
-
-	if (info->array_size <= 0)
-		return -1;
-
-        arr = G_STRUCT_MEMBER_P(top, info->off);
-	if (_voteflag_array_valid(top, info) == -1)
-		goto fail;
-
-	*retval = g_string_new("");
-	for (i=0; i<info->array_size; i++)
-	{
-		if (i!=0)
-			g_string_append(*retval, " ");
-		if (arr[i] & FLAG_VOTE_NODE)
-			g_string_append(*retval, "vote");
-		else if (arr[i] & FLAG_VOTE_OIN_UPDATED)
-			g_string_append(*retval, "updated");
-		else if (arr[i] & FLAG_VOTE_OIN_ALREADY_INUSE)
-			g_string_append(*retval, "inuse");
-		else if (arr[i] & FLAG_VOTE_UPDATE_RETRY)
-			g_string_append(*retval, "retry");
-		else if (arr[i] & FLAG_VOTE_FILE_DEL)
-			g_string_append(*retval, "delete");
-		else if (arr[i] == 0)
-			g_string_append(*retval, "none");
-	}
-
-	return 0;
-fail:
-#ifdef SHOW_INVALID_VALUES
-	{
-		int j;
-		for (j=0; j<info->array_size; j++)
-		{
-			if (j!=0)
-				g_string_append(*retval, ":");
-			g_string_sprintfa(*retval, "%u", arr[j]);
-		}
-	}
-#else
-	g_string_free(*retval, true);
-#endif
-	return -1;
-}
-
-int _string_to_voteflag_array_u8(char *newval, void *top, typeinfo *info)
-{
-	__u8 *flag;
-	int ret = -1, i;
-	char **arr;
-	
-	if (info->array_size <= 0)
-		return -1;
-
-	flag = G_STRUCT_MEMBER(__u8 *, top, info->off);
-	arr = g_strsplit(newval, " ", 0);
-	
-	for (i=0; i<info->array_size && arr[i]!=NULL; i++)
-	{
-		flag[i] = 0;
-		if (strcasecmp(arr[i], "vote")==0)
-			flag[i] |= FLAG_VOTE_NODE;
-		else if (strcasecmp(arr[i], "updated")==0)
-			flag[i] |= FLAG_VOTE_OIN_UPDATED;
-		else if (strcasecmp(arr[i], "inuse")==0)
-			flag[i] |= FLAG_VOTE_OIN_ALREADY_INUSE;
-		else if (strcasecmp(arr[i], "retry")==0)
-			flag[i] |= FLAG_VOTE_UPDATE_RETRY;
-		else if (strcasecmp(arr[i], "delete")==0)
-			flag[i] |= FLAG_VOTE_FILE_DEL;
-		else if (strcasecmp(arr[i], "none")==0 || atoi(arr[i])==0)
-			flag[i] = 0;
-		else
-			goto bail;
-
-	}
-	ret = 0;
-bail:
-	g_strfreev(arr);
-	return ret;
-}
-
-char * _get_voteflag_array_helptext(typeinfo *info)
-{
-	return g_strdup_printf("one flag for each node (up to %d): "
-			       "none vote updated inuse retry delete "
-			       "(space-delimited)",
-			       info->array_size);
-}
-

Copied: trunk/fsck/class_rw.c (from rev 205, trunk/ocfs/fsck/class_rw.c)

Deleted: trunk/fsck/classes.h
===================================================================
--- trunk/ocfs/fsck/classes.h	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/classes.h	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,186 +0,0 @@
-/*
- * classes.h
- *
- * Function prototypes, macros, etc. for related 'C' files
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#ifndef _CLASSES_H
-#define _CLASSES_H
-
-
-typedef struct _typeinfo
-{
-	int off;
-	int array_size;
-	int type_size;
-	bool is_signed;
-	__u64 lo;
-	__u64 hi;
-} typeinfo;
-
-typedef struct _ocfs_class_member
-{
-	char *name;
-	char *flavor;
-	typeinfo type;
-	int (*valid) (void *, typeinfo *);
-	int (*to_string) (GString **, void *, typeinfo *);
-	int (*from_string) (char *, void *, typeinfo *);
-	char * (*helptext) (typeinfo *);
-} ocfs_class_member;
-
-typedef struct _ocfs_class
-{
-	char *name;
-	int num_members;
-	ocfs_class_member *members;
-} ocfs_class;
-
-ocfs_class_member * find_class_member(ocfs_class *cl, const char *name, int *idx);
-
-extern ocfs_class ocfs_alloc_ext_class;
-extern ocfs_class ocfs_publish_class;
-extern ocfs_class ocfs_vote_class;
-extern ocfs_class ocfs_file_entry_class;
-extern ocfs_class ocfs_dir_node_class;
-extern ocfs_class ocfs_extent_group_class;
-extern ocfs_class ocfs_vol_disk_hdr_class;
-extern ocfs_class ocfs_disk_lock_class;
-extern ocfs_class ocfs_vol_label_class;
-extern ocfs_class ocfs_ipc_config_info_class;
-extern ocfs_class ocfs_guid_class;
-extern ocfs_class ocfs_disk_node_config_info_class;
-extern ocfs_class ocfs_node_config_hdr_class;
-
-int _attribs_valid(void *top, typeinfo *info);
-int _bool_valid(void *top, typeinfo *info);
-int _clustersize_valid(void *top, typeinfo *info);
-int _date_valid(void *top, typeinfo *info);
-int _dirflag_valid(void *top, typeinfo *info);
-int _dirindex_valid(void *top, typeinfo *info);
-int _dirnodeindex_valid(void *top, typeinfo *info);
-int _diskptr_valid(void *top, typeinfo *info);
-int _extenttype_valid(void *top, typeinfo *info);
-int _fileflag_valid(void *top, typeinfo *info);
-int _gid_valid(void *top, typeinfo *info);
-int _uid_valid(void *top, typeinfo *info);
-int _locklevel_valid(void *top, typeinfo *info);
-int _nodebitmap_valid(void *top, typeinfo *info);
-int _nodenum_valid(void *top, typeinfo *info);
-int _perms_valid(void *top, typeinfo *info);
-int _syncflag_valid(void *top, typeinfo *info);
-int _char_array_valid(void *top, typeinfo *info);
-int _hex_array_valid(void *top, typeinfo *info);
-int _number_range_valid(void *top, typeinfo *info) ;
-int _voteflag_array_valid(void *top, typeinfo *info);
-
-int _attribs_to_string_u32(GString **retval, void *top, typeinfo *info);
-int _string_to_attribs_u32(char *newval, void *top, typeinfo *info);
-char * _get_attribs_helptext(typeinfo *info);
-int _bool_to_string_s32(GString **retval, void *top, typeinfo *info);
-int _string_to_bool_s32(char *newval, void *top, typeinfo *info);
-int _bool_to_string_u8(GString **retval, void *top, typeinfo *info);
-int _string_to_bool_u8(char *newval, void *top, typeinfo *info);
-int _bool_to_string_bool(GString **retval, void *top, typeinfo *info);
-int _string_to_bool_bool(char *newval, void *top, typeinfo *info);
-char * _get_bool_helptext(typeinfo *info);
-int _clustersize_to_string_u64(GString **retval, void *top, typeinfo *info);
-int _string_to_clustersize_u64(char *newval, void *top, typeinfo *info);
-char * _get_clustersize_helptext(typeinfo *info);
-int _date_to_string_u64(GString **retval, void *top, typeinfo *info);
-int _string_to_date_u64(char *newval, void *top, typeinfo *info);
-char * _get_date_helptext(typeinfo *info);
-int _dirflag_to_string_u8(GString **retval, void *top, typeinfo *info);
-int _string_to_dirflag_u8(char *newval, void *top, typeinfo *info);
-char * _get_dirflag_helptext(typeinfo *info);
-int _dirindex_to_string_u8(GString **retval, void *top, typeinfo *info);
-int _string_to_dirindex_u8(char *newval, void *top, typeinfo *info);
-char * _get_dirindex_helptext(typeinfo *info);
-int _dirnodeindex_to_string_s8(GString **retval, void *top, typeinfo *info);
-int _string_to_dirnodeindex_s8(char *newval, void *top, typeinfo *info);
-int _dirnodeindex_to_string_u8(GString **retval, void *top, typeinfo *info);
-int _string_to_dirnodeindex_u8(char *newval, void *top, typeinfo *info);
-char * _get_dirnodeindex_helptext(typeinfo *info);
-int _diskptr_to_string_s64(GString **retval, void *top, typeinfo *info);
-int _string_to_diskptr_s64(char *newval, void *top, typeinfo *info);
-int _diskptr_to_string_u64(GString **retval, void *top, typeinfo *info);
-int _string_to_diskptr_u64(char *newval, void *top, typeinfo *info);
-char * _get_diskptr_helptext(typeinfo *info);
-int _extenttype_to_string_u32(GString **retval, void *top, typeinfo *info);
-int _string_to_extenttype_u32(char *newval, void *top, typeinfo *info);
-char * _get_extenttype_helptext(typeinfo *info);
-int _fileflag_to_string_u32(GString **retval, void *top, typeinfo *info);
-int _string_to_fileflag_u32(char *newval, void *top, typeinfo *info);
-char * _get_fileflag_helptext(typeinfo *info);
-int _gid_to_string_u32(GString **retval, void *top, typeinfo *info);
-int _string_to_gid_u32(char *newval, void *top, typeinfo *info);
-char * _get_gid_helptext(typeinfo *info);
-int _uid_to_string_u32(GString **retval, void *top, typeinfo *info);
-int _string_to_uid_u32(char *newval, void *top, typeinfo *info);
-char * _get_uid_helptext(typeinfo *info);
-int _locklevel_to_string_u8(GString **retval, void *top, typeinfo *info);
-int _string_to_locklevel_u8(char *newval, void *top, typeinfo *info);
-char * _get_locklevel_helptext(typeinfo *info);
-int _nodebitmap_to_string_u64(GString **retval, void *top, typeinfo *info);
-int _string_to_nodebitmap_u64(char *newval, void *top, typeinfo *info);
-char * _get_nodebitmap_helptext(typeinfo *info);
-int _nodenum_to_string_u32(GString **retval, void *top, typeinfo *info);
-int _string_to_nodenum_u32(char *newval, void *top, typeinfo *info);
-int _nodenum_to_string_s32(GString **retval, void *top, typeinfo *info);
-int _string_to_nodenum_s32(char *newval, void *top, typeinfo *info);
-char * _get_nodenum_helptext(typeinfo *info);
-int _perms_to_string_u32(GString **retval, void *top, typeinfo *info);
-int _string_to_perms_u32(char *newval, void *top, typeinfo *info);
-char * _get_perms_helptext(typeinfo *info);
-int _syncflag_to_string_u32(GString **retval, void *top, typeinfo *info);
-int _string_to_syncflag_u32(char *newval, void *top, typeinfo *info);
-int _syncflag_to_string_u8(GString **retval, void *top, typeinfo *info);
-int _string_to_syncflag_u8(char *newval, void *top, typeinfo *info);
-char * _get_syncflag_helptext(typeinfo *info);
-int _char_array_to_string_u8(GString **retval, void *top, typeinfo *info);
-int _string_to_char_array_u8(char *newval, void *top, typeinfo *info);
-char * _get_char_array_helptext(typeinfo *info);
-int _hex_array_to_string_u8(GString **retval, void *top, typeinfo *info);
-int _string_to_hex_array_u8(char *newval, void *top, typeinfo *info);
-char * _get_hex_array_helptext(typeinfo *info);
-int _number_range_to_string_s32(GString **retval, void *top, typeinfo *info);
-int _string_to_number_range_s32(char *newval, void *top, typeinfo *info);
-int _number_range_to_string_u8(GString **retval, void *top, typeinfo *info);
-int _string_to_number_range_u8(char *newval, void *top, typeinfo *info);
-int _number_range_to_string_u16(GString **retval, void *top, typeinfo *info);
-int _string_to_number_range_u16(char *newval, void *top, typeinfo *info);
-int _number_range_to_string_u32(GString **retval, void *top, typeinfo *info);
-int _string_to_number_range_u32(char *newval, void *top, typeinfo *info);
-int _number_range_to_string_u64(GString **retval, void *top, typeinfo *info);
-int _string_to_number_range_u64(char *newval, void *top, typeinfo *info);
-char * _get_number_range_helptext(typeinfo *info);
-int _voteflag_array_to_string_u8(GString **retval, void *top, typeinfo *info);
-int _string_to_voteflag_array_u8(char *newval, void *top, typeinfo *info);
-char * _get_voteflag_array_helptext(typeinfo *info);
-int _extent_array_to_string(GString **retval, void *top, typeinfo *info);
-int _string_to_extent_array(char *newval, void *top, typeinfo *info);
-char * _get_extent_array_helptext(typeinfo *info);
-int _disklock_to_string(GString **retval, void *top, typeinfo *info);
-int _string_to_disklock(char *newval, void *top, typeinfo *info);
-char * _get_disklock_helptext(typeinfo *info);
-
-#endif /* _CLASSES_H */

Copied: trunk/fsck/classes.h (from rev 205, trunk/ocfs/fsck/classes.h)

Deleted: trunk/fsck/defaults.c
===================================================================
--- trunk/ocfs/fsck/defaults.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/defaults.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,107 +0,0 @@
-/*
- * defaults.c
- *
- * defaults for structures in ocfs file system check utility
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#include "fsck.h"
-
-int get_nodecfghdr_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-
-int get_nodecfginfo_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-
-int get_cleanup_log_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_dir_alloc_bitmap_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_dir_alloc_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_vol_disk_header_defaults  (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_disk_lock_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_file_alloc_bitmap_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_file_alloc_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_publish_sector_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_recover_log_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_vol_metadata_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_vol_metadata_log_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_vol_label_defaults  (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_vote_sector_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_dir_node_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_file_entry_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_extent_header_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-int get_extent_data_defaults (char *buf, GString **out, int idx, int fld)
-{
-	return 0;
-}
-
-

Copied: trunk/fsck/defaults.c (from rev 205, trunk/ocfs/fsck/defaults.c)

Deleted: trunk/fsck/defaults.h
===================================================================
--- trunk/ocfs/fsck/defaults.h	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/defaults.h	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,49 +0,0 @@
-/*
- * defaults.h
- *
- * Function prototypes, macros, etc. for related 'C' files
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#ifndef DEFAULTS_H
-#define DEFAULTS_H
-
-int get_nodecfghdr_defaults (char *buf, GString **out, int idx, int fld);
-int get_nodecfginfo_defaults (char *buf, GString **out, int idx, int fld);
-int get_cleanup_log_defaults (char *buf, GString **out, int idx, int fld);
-int get_dir_alloc_bitmap_defaults (char *buf, GString **out, int idx, int fld);
-int get_dir_alloc_defaults (char *buf, GString **out, int idx, int fld);
-int get_vol_disk_header_defaults  (char *buf, GString **out, int idx, int fld);
-int get_disk_lock_defaults (char *buf, GString **out, int idx, int fld);
-int get_file_alloc_bitmap_defaults (char *buf, GString **out, int idx, int fld);
-int get_file_alloc_defaults (char *buf, GString **out, int idx, int fld);
-int get_publish_sector_defaults (char *buf, GString **out, int idx, int fld);
-int get_recover_log_defaults (char *buf, GString **out, int idx, int fld);
-int get_vol_metadata_defaults (char *buf, GString **out, int idx, int fld);
-int get_vol_metadata_log_defaults (char *buf, GString **out, int idx, int fld);
-int get_vol_label_defaults  (char *buf, GString **out, int idx, int fld);
-int get_vote_sector_defaults (char *buf, GString **out, int idx, int fld);
-int get_dir_node_defaults (char *buf, GString **out, int idx, int fld);
-int get_file_entry_defaults (char *buf, GString **out, int idx, int fld);
-int get_extent_header_defaults (char *buf, GString **out, int idx, int fld);
-int get_extent_data_defaults (char *buf, GString **out, int idx, int fld);
-
-#endif /* DEFAULTS_H */

Copied: trunk/fsck/defaults.h (from rev 205, trunk/ocfs/fsck/defaults.h)

Deleted: trunk/fsck/fsck.c
===================================================================
--- trunk/ocfs/fsck/fsck.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/fsck.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,529 +0,0 @@
-/*
- * fsck.c
- *
- * ocfs file system check utility
- *
- * Copyright (C) 2003, 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#include "fsck.h"
-
-int prn_len = 1;
-int cnt_err = 0;
-int cnt_wrn = 0;
-int cnt_obj = 0;
-bool int_err = false;
-bool prn_err = false;
-
-__u32 OcfsDebugCtxt = 0;
-__u32 OcfsDebugLevel = 0;
-__u32 debug_context = 0;
-__u32 debug_level = 0;
-__u32 debug_exclude = 0;
-
-bool never_mounted = false;
-__u32 fs_version = 0;
-
-__u32 fs_num = 0;
-
-ocfs_global_ctxt OcfsGlobalCtxt;
-ocfsck_context ctxt;
-extern void version(char *progname);
-
-int edit_structure(ocfs_disk_structure *s, char *buf, int idx, int *changed, char *option);
-
-char *usage_str = 
-"usage: fsck.ocfs [OPTIONS] device\n"
-"	-n No hearbeat check\n"
-"	-w Writeable\n"
-"	-V Version\n"
-"	-v Verbose\n"
-"	-q Quiet";
-
-/*
- * parse_fsck_cmdline()
- *
- */
-int parse_fsck_cmdline(int argc, char **argv)
-{
-	int off;
-	int c;
-	int ret = -1;
-
-	ctxt.write_changes = false;
-	ctxt.no_hb_chk = false;
-	ctxt.verbose = false;
-	ctxt.modify_all = false;
-	ctxt.quiet = false;
-	ctxt.dev_is_file = false;
-
-	if (argc < 2) {
-		usage();
-		goto bail;
-	}
-
-	while (1) {
-		off = 0;
-		c = getopt(argc, argv, "wnVvmqf?");
-
-		if (c == -1)
-			break;
-
-		switch (c) {
-		case 'w':
-			ctxt.write_changes = true;
-			break;
-		case 'n':
-			ctxt.no_hb_chk = true;
-			break;
-		case 'm':
-			ctxt.modify_all = true;
-			break;
-		case 'v':
-			ctxt.verbose = true;
-			break;
-		case 'q':
-			ctxt.quiet = true;
-			break;
-		case 'f':
-			ctxt.dev_is_file = true;
-			break;
-		case 'V':
-			version(argv[0]);
-			goto bail;
-		default:
-		case '?':
-			usage();
-			goto bail;
-		}
-	}
-
-	if (ctxt.modify_all)
-		ctxt.verbose = true;
-
-	if (ctxt.write_changes)
-		ctxt.no_hb_chk = false;
-
-	if (ctxt.dev_is_file)
-		ctxt.no_hb_chk = true;
-
-	ret = 0;
-bail:
-	return ret;
-}				/* parse_fsck_cmdline */
-
-/*
- * edit_structure()
- *
- */
-int edit_structure(ocfs_disk_structure *s, char *buf, int idx, int *changed, char *option)
-{
-	int ret = 0;
-	int fld;
-	ocfs_class *cls;
-	ocfs_class_member *m;
-	GString *cur;
-	GString *dflt;
-	char *newval = NULL;
-	char *bad;
-	char *loc;
-
-	if ((newval = malloc(USER_INPUT_MAX)) == NULL) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	*changed = 0;
-	cls = s->cls;
-	*option = '\0';
-
-	while (1) {
-		cur = dflt = NULL;
-		bad = NULL;
-	
-		printf("choose a field to edit (1-%d, 's' to step, "
-		       "'n' for next, 'd' for dirnode or 'q' to quit) : ", cls->num_members);
-		if (fgets(newval, USER_INPUT_MAX, stdin) == NULL) {
-			ret = -1;
-			break;
-		}
-
-		if ((loc = rindex(newval, '\n')) != NULL)
-			*loc = '\0';
-
-	       	if (strcasecmp(newval, "q") == 0 || strcasecmp(newval, "quit") == 0 ||
-		    strcasecmp(newval, "n") == 0 || strcasecmp(newval, "next") == 0 ||
-		    strcasecmp(newval, "s") == 0 || strcasecmp(newval, "step") == 0 ||
-		    strcasecmp(newval, "d") == 0 || strcasecmp(newval, "dirnode") == 0)  {
-			*option = tolower(*newval);
-			ret = -1;
-			break;
-		}
-
-		fld = strtol(newval, &bad, 10);
-		fld--;
-
-		if (bad == newval || IS_INVALID_FIELD_NUM(cls, fld)) {
-			ret = 0;
-			LOG_ERROR("bad field number");
-			break;
-		}
-	
-		/* show current value and default value	*/
-		m = &(cls->members[fld]);
-		if (m->to_string(&cur, buf, &(m->type))==-1) {
-			ret = -1;
-			LOG_ERROR("to_string failed");
-			break;
-		}
-
-		if (s->defaults(buf, &dflt, idx, fld)==-1) {
-			ret = -1;
-			LOG_ERROR("defaults failed");
-			break;
-		}
-
-		printf("%s : %s (default=%s)\n", m->name, 
-		       cur ? cur->str : "", 
-		       dflt ? dflt->str : "");
-
-		/* get new value and validate it */
-		if (fgets(newval, USER_INPUT_MAX, stdin) == NULL) {
-			ret = -1;
-			break;
-		}
-
-		if ((loc = rindex(newval, '\n')) != NULL)
-			*loc = '\0';
-
-	       	if (strcasecmp(newval, "q")==0 || strcasecmp(newval, "quit")==0) {
-			ret = -1;
-			break;
-		}
-
-		if (strcmp(newval, "?")==0 || strcasecmp(newval, "help")==0) {
-			char *help = m->helptext(&(m->type));
-			printf("%s\n", help);
-			free(help);
-			ret = 0;
-			break;
-		}
-
-		if ((ret = m->from_string(newval, buf, &(m->type))) == -1) {
-			LOG_ERROR("bad entry");
-			ret = -1;
-			break;
-		}
-
-		(*changed)++;
-		
-		if (dflt) {
-			g_string_free(dflt, true);
-			dflt = NULL;
-		}
-
-		if (cur) {
-			g_string_free(cur, true);
-			cur = NULL;
-		}
-	}
-
-	if (dflt)
-		g_string_free(dflt, true);
-
-	if (cur)
-		g_string_free(cur, true);
-
-bail:
-	safefree(newval);
-
-	return ret;
-}				/* edit_structure */
-
-
-/*
- * fsck_initialize()
- *
- */
-int fsck_initialize(char **buf)
-{
-	int ret = -1;
-	int fd;
-
-	if (ctxt.write_changes)
-		ctxt.flags = O_RDWR | O_LARGEFILE | O_SYNC;
-	else
-		ctxt.flags = O_RDONLY | O_LARGEFILE;
-
-	if (!ctxt.dev_is_file) {
-		if (bind_raw(ctxt.device, &ctxt.raw_minor, ctxt.raw_device, sizeof(ctxt.raw_device)))
-			goto bail;
-		if (ctxt.verbose)
-			CLEAR_AND_PRINT("Bound %s to %s", ctxt.device, ctxt.raw_device);
-	} else
-		strncpy(ctxt.raw_device, ctxt.device, sizeof(ctxt.raw_device));
-
-	if ((fd = myopen(ctxt.raw_device, ctxt.flags)) == -1) {
-		LOG_ERROR("Error opening %s.\n%s.", ctxt.raw_device,
-			  strerror(errno));
-		goto bail;
-	} else
-		ctxt.fd = fd;
-
-	if ((ctxt.hdr = malloc_aligned(OCFS_SECTOR_SIZE)) == NULL) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	if ((ctxt.vol_bm = malloc_aligned(VOL_BITMAP_BYTES)) == NULL) {
-		LOG_INTERNAL();
-		goto bail;
-	} else
-		memset(ctxt.vol_bm, 0, VOL_BITMAP_BYTES);
-
-	if ((*buf = malloc_aligned(OCFS_SECTOR_SIZE)) == NULL) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	/* Seek to the first block */
-	if (myseek64(fd, 0, SEEK_SET) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	/* Read the super block */
-	if (myread(fd, (char *)ctxt.hdr, OCFS_SECTOR_SIZE) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	/* Get the device size */
-	if (get_device_size(fd) == -1) {
-		LOG_ERROR("unable to get the device size. exiting");
-		goto bail;
-	}
-
-	ctxt.vol_bm_data = g_array_new(false, true, sizeof(bitmap_data));
-	ctxt.dir_bm_data = g_array_new(false, true, sizeof(bitmap_data));
-	ctxt.ext_bm_data = g_array_new(false, true, sizeof(bitmap_data));
-	ctxt.filenames = g_array_new(false, true, sizeof(str_data));
-
-	ret = 0;
-
-bail:
-	return ret;
-}				/* fsck_initialize */
-
-
-/*
- * main()
- *
- */
-int main(int argc, char **argv)
-{
-	int i;
-	int ret;
-	__u64 off;
-	char *buf = NULL;
-	char option = '\0';
-	ocfs_disk_structure *s;
-	ocfs_layout_t *l;
-	int j;
-	GHashTable *bad = NULL;
-	str_data *fn;
-
-	memset(&ctxt, 0, sizeof(ctxt));
-	init_global_context();
-
-#define INSTALL_SIGNAL(sig)						\
-	do {								\
-		if (signal(sig, handle_signal) == SIG_ERR) {		\
-		    fprintf(stderr, "Could not set " #sig "\n");	\
-		    goto bail;						\
-		}							\
-	} while (0)
-
-	INSTALL_SIGNAL(SIGTERM);
-	INSTALL_SIGNAL(SIGINT);
-
-	init_raw_cleanup_message();
-
-	if (parse_fsck_cmdline(argc, argv) == -1)
-		goto quiet_bail;
-
-	if (optind >= argc) {
-		usage();
-		goto quiet_bail;
-	}
-
-	version(argv[0]);
-
-	strncpy(ctxt.device, argv[optind], OCFS_MAX_FILENAME_LENGTH);
-
-	if (fsck_initialize(&buf) == -1) {
-		goto quiet_bail;
-	}
-
-	/* Exit if not an OCFS volume */
-	if (memcmp(ctxt.hdr->signature, OCFS_VOLUME_SIGNATURE,
-		   strlen(OCFS_VOLUME_SIGNATURE))) {
-		printf("%s: bad signature in super block\n", ctxt.device);
-		goto quiet_bail;
-	}
-
-	/* Exit if heartbeat detected */
-	if (!ctxt.no_hb_chk) {
-		if (!check_heart_beat(&ctxt.fd, OCFSCK_PUBLISH_OFF,
-				      OCFS_SECTOR_SIZE))
-			goto quiet_bail;
-	}
-
-	/* Check ocfs volume header blocks */
-	for (i = 0; i < ocfs_header_layout_sz; i++) {
-		option = '\0';
-		l = &(ocfs_header_layout[i]);
-		if ((s = l->kind) == NULL || s->cls == NULL ||
-		    s->read == NULL || s->write == NULL) {
-			continue;
-		}
-
-		CLEAR_AND_PRINT("Checking %s...", l->name);
-
-		ret = 0;
-		for (j = 0; j < l->num_blocks; j++) {
-			bad = NULL;
-			off = BLOCKS2BYTES((l->block+j));
-
-			ret = read_print_struct(s, buf, off, j, &bad);
-			if (ret == -2)
-				break;
-			if (ret != -1 && !ctxt.modify_all)
-				continue;
-#if 0
-			while (ctxt.write_changes) {
-				changed = 0;
-				if (edit_structure(s, buf, j, &changed, &option) != -1)
-					continue;
-
-				if (!changed)
-					break;
-
-				if ((ret = confirm_changes(off, s, buf, j, bad)) == -1)
-					LOG_PRINT("Abort write");
-
-				break;
-			}
-#endif
-
-			if (bad)
-				g_hash_table_destroy(bad);
-
-			if (option == 's')
-				continue;
-
-			else if (option == 'n' || option == 'd' || option == 'q')
-				break;
-		}
-
-		if (i == 0 && never_mounted == true) {
-			LOG_PRINT("Volume has never been mounted on any node. Exiting");
-			goto bail;
-		}
-
-		if (option == 'q' || option == 'd')
-			break;
-
-		if (ret < 0 && s == &diskhdr_t) {
-			LOG_ERROR("Volume header bad. Exiting");
-			goto bail;
-		}
-	}
-
-	if (option == 'q')
-		goto bail;
-
-	CLEAR_AND_PRINT("Checking Directories and Files...");
-	traverse_dir_nodes(ctxt.fd, ctxt.hdr->root_off, "/");
-
-	CLEAR_AND_PRINT("Checking Global Bitmap...");
-	if (check_global_bitmap(ctxt.fd) == -1)
-		LOG_ERROR("Global bitmap check failed");
-
-	CLEAR_AND_PRINT("Checking Extent Bitmap...");
-	if (check_node_bitmaps(ctxt.fd, ctxt.ext_bm_data, ctxt.ext_bm,
-			       ctxt.ext_bm_sz, "extent") == -1)
-		LOG_ERROR("Extent bitmap check failed");
-
-	CLEAR_AND_PRINT("Checking Directory Bitmap...");
-	if (check_node_bitmaps(ctxt.fd, ctxt.dir_bm_data, ctxt.dir_bm,
-			       ctxt.dir_bm_sz, "directory") == -1)
-		LOG_ERROR("Directory bitmap check failed");
-
-bail:
-	if (!int_err) {
-		if (cnt_err == 0)
-			CLEAR_AND_PRINT("%s: clean, %d objects, %u/%llu "
-					"blocks", ctxt.device, cnt_obj,
-				       	ctxt.vol_bm_data->len,
-				       	ctxt.hdr->num_clusters);
-		else
-			CLEAR_AND_PRINT("%s: %d errors, %d objects, %u/%llu "
-					"blocks", ctxt.device, cnt_err, cnt_obj,
-					ctxt.vol_bm_data->len,
-					ctxt.hdr->num_clusters);
-	}
-
-quiet_bail:
-	myclose(ctxt.fd);
-
-	unbind_raw(ctxt.raw_minor);
-
-	printf("\n");
-
-	if (ctxt.vol_bm_data)
-		g_array_free(ctxt.vol_bm_data, true);
-
-	if (ctxt.dir_bm_data)
-		g_array_free(ctxt.dir_bm_data, true);
-
-	if (ctxt.ext_bm_data)
-		g_array_free(ctxt.ext_bm_data, true);
-
-	if (ctxt.filenames) {
-		for (i = 0; i < ctxt.filenames->len; ++i) {
-			fn = &(g_array_index(ctxt.filenames, str_data, i));
-			safefree(fn->str);
-		}
-		g_array_free(ctxt.filenames, true);
-	}
-
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
-		free_aligned(ctxt.dir_bm[i]);
-
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
-		free_aligned(ctxt.ext_bm[i]);
-
-	free_aligned(buf);
-	free_aligned(ctxt.hdr);
-	free_aligned(ctxt.vol_bm);
-
-	exit(0);
-}				/* main */

Copied: trunk/fsck/fsck.c (from rev 205, trunk/ocfs/fsck/fsck.c)

Deleted: trunk/fsck/fsck.h
===================================================================
--- trunk/ocfs/fsck/fsck.h	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/fsck.h	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,312 +0,0 @@
-/*
- * fsck.h
- *
- * Function prototypes, macros, etc. for related 'C' files
- *
- * Copyright (C) 2003, 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#ifndef FSCK_H
-#define FSCK_H
-
-#define _GNU_SOURCE
-
-#define _LARGEFILE64_SOURCE
-
-#include <stdio.h>
-#include <time.h>
-#include <sys/stat.h>
-#include <glib.h>
-#include <unistd.h>
-#include <string.h>
-#include <grp.h>
-#include <pwd.h>
-#include <sys/types.h>
-#include <asm/types.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/wait.h>
-
-#include <libocfs.h>
-#include <bindraw.h>
-
-#include "classes.h"
-#include "sig.h"
-#include "fsck_print.h"
-#include "verify.h"
-#include "defaults.h"
-#include "layout.h"
-
-extern bool prn_err;
-extern bool int_err;
-extern int  cnt_err;
-extern int cnt_wrn;
-
-
-#define MAX_EXTENTS	2048
-#define OCFS_HBT_WAIT	10
-
-#define MAX_NODES			OCFS_MAXIMUM_NODES
-#define MAX_SYSTEM_FILES		(CLEANUP_FILE_BASE_ID + OCFS_MAXIMUM_NODES) /* 193? */
-#define DIR_NODE_SIZE			(1024 * 128)
-#define IS_INVALID_FIELD_NUM(c,n)	((n) >= (c)->num_members || (n) < 0)
-#define USER_INPUT_MAX			1024
-#define BITS_PER_BYTE			8
-#define VOL_BITMAP_BYTES		(1024 * 1024)
-
-#define DISK_OFF_TO_BIT_NUMBER(off)      \
-		((off - ctxt.hdr->data_start_off) >> ctxt.cluster_size_bits)
-#define BIT_NUMBER_TO_DISK_OFF(num)      \
-		((num << ctxt.cluster_size_bits) + ctxt.hdr->data_start_off)
-#define NUM_BYTES_TO_NUM_BITS(bytes)     \
-		(bytes >> ctxt.cluster_size_bits)
-#define MAX_BITS                         \
-		(ctxt.hdr->num_clusters * BITS_PER_BYTE)
-
-#define safefree(a)		\
-do {				\
-	if (a)			\
-		free(a);	\
-	(a) = NULL;		\
-} while (0)
-
-#define LOG_INTERNAL()						\
-	do {							\
-		prn_err = true; int_err = true;			\
-		fprintf(stdout, "\nINTERNAL ERROR: ");		\
-		fprintf(stdout, "%s, %d", __FILE__, __LINE__);	\
-		fflush(stdout);					\
-	} while (0)
-
-/* override libocfs definition */
-#undef LOG_ERROR
-#define LOG_ERROR(fmt, arg...)					\
-	do {							\
-		prn_err = true; cnt_err++;			\
-		fprintf(stdout, "\nERROR: ");			\
-		fprintf(stdout, fmt, ## arg);			\
-		fprintf(stdout, ", %s, %d", __FILE__, __LINE__);\
-		fflush(stdout);					\
-	} while (0)
-
-#define LOG_WARNING(fmt, arg...)				\
-	do {							\
-		prn_err = true; cnt_wrn++;			\
-		fprintf(stdout, "\nWARNING: ");			\
-		fprintf(stdout, fmt, ## arg);			\
-		fflush(stdout);					\
-	} while (0)
-
-#define LOG_PRINT(fmt, arg...)					\
-	do {							\
-		prn_err = true;					\
-		fprintf(stdout, "\n");				\
-		fprintf(stdout, fmt, ## arg);			\
-		fflush(stdout);					\
-	} while (0)
-
-#define CLEAR_AND_PRINT(fmt, arg...)					\
-do {									\
-	if (!ctxt.quiet) {						\
-		gchar *_a = g_strdup_printf(fmt, ## arg);		\
-		if (ctxt.verbose)					\
-			printf("\n%s\n", _a);				\
-		else {							\
-			int _j = strlen(_a);				\
-			int _l = prn_len - _j;				\
-			char _n = (prn_err ? '\n' : '\r');		\
-			if (_l > 0) {					\
-				gchar *_s = g_strnfill(_l, ' ');	\
-				printf("%c%s%s", _n, _a, _s);		\
-				prn_len = _j;				\
-				free(_s);				\
-			} else						\
-				prn_len = printf("%c%s", _n, _a);	\
-			prn_err = false;				\
-		}							\
-		free(_a);						\
-	}								\
-} while (0)
-
-typedef struct _filedata
-{
-    ocfs_io_runs *array;
-    __u32 num;
-    mode_t mode;
-    uid_t user;
-    gid_t group;
-    unsigned int major;
-    unsigned int minor;
-    char *linkname;
-} filedata;
-
-
-void usage(void);
-void handle_signal(int sig);
-void init_global_context(void);
-int parse_fsck_cmdline(int argc, char **argv);
-int confirm_changes(__u64 off, ocfs_disk_structure *s, char *buf, int idx,
-		    GHashTable *bad);
-int read_print_struct(ocfs_disk_structure *s, char *buf, __u64 off, int idx,
-		      GHashTable **bad);
-void *mem_alloc(int len);
-int fsck_initialize(char **buf);
-int comp_nums(const void *q1, const void *q2);
-int comp_bits(const void *q1, const void *q2);
-void find_unset_bits(__u8 *vol_bm, char *bitmap);
-void find_set_bits(__u8 *vol_bm, char *bitmap);
-int check_global_bitmap(int fd);
-int check_node_bitmaps(int fd, GArray *bm_data, __u8 **node_bm,
-		       __u32 *node_bm_sz, char *str);
-void handle_one_cdsl_entry(int fd, ocfs_file_entry *fe, __u64 offset);
-int handle_leaf_extents (int fd, ocfs_alloc_ext *arr, int num, __u32 node,
-			 __u64 parent_offset);
-void traverse_dir_nodes(int fd, __u64 offset, char *path);
-void check_file_entry(int fd, ocfs_file_entry *fe, __u64 offset, int slot,
-		      bool systemfile, char *path);
-void traverse_extent(int fd, ocfs_extent_group * exthdr, int flag, void *buf,
-		     int *indx);
-void traverse_fe_extents(int fd, ocfs_file_entry *fe, void *buf, int *indx);
-int traverse_local_extents(int fd, ocfs_file_entry *fe);
-int check_next_data_ext(ocfs_file_entry *fe, void *buf, int indx);
-int check_fe_last_data_ext(ocfs_file_entry *fe, void *buf, int indx);
-int get_device_size(int fd);
-int check_heart_beat(int *file, __u64 publ_off, __u32 sect_size);
-int read_publish(int file, __u64 publ_off, __u32 sect_size, void **buf);
-int get_node_names(int file, ocfs_vol_disk_hdr *volhdr, char **node_names,
-		   __u32 sect_size);
-void print_node_names(char **node_names, __u32 nodemap);
-void print_gbl_alloc_errs(void);
-void print_bit_ranges(GArray *bits, char *str1, char *str2);
-void print_filenames(GArray *files);
-
-////////////////////////
-void ocfs_extent_map_init (ocfs_extent_map * map);
-
-void ocfs_extent_map_destroy (ocfs_extent_map * map);
-
-#define ocfs_extent_map_get_count(map)  ((map)->count)
-
-bool ocfs_extent_map_add (ocfs_extent_map * map, __s64 virtual,
-			  __s64 physical, __s64 sectors);
-
-void ocfs_extent_map_remove (ocfs_extent_map * map, __s64 virtual,
-			     __s64 sectors);
-
-bool ocfs_extent_map_lookup (ocfs_extent_map * map, __s64 virtual,
-			     __s64 * physical, __s64 * sectors, __u32 * index);
-
-bool ocfs_extent_map_next_entry (ocfs_extent_map * map, __u32 index,
-				 __s64 * virtual, __s64 * physical,
-				 __s64 * sectors);
-//////////////////////
-
-
-enum {
-	bm_extent,
-	bm_dir,
-	bm_symlink,
-	bm_filedata,
-	bm_global
-};
-
-typedef struct _bitmap_data
-{
-	__u32 bitnum;
-	__s32 alloc_node;
-	__u64 fss_off;		/* file system structure offset */
-	__u64 parent_off;	/* offset of the fs structure housing the extent */
-	__u32 fnum;
-} bitmap_data;
-
-typedef struct _str_data
-{
-	__u32 num;
-	char *str;
-} str_data;
-
-typedef struct _ocfsck_context
-{
-	char device[OCFS_MAX_FILENAME_LENGTH];
-	char raw_device[OCFS_MAX_FILENAME_LENGTH];
-	int raw_minor;
-	int flags;
-	int fd;
-	ocfs_super *vcb;
-	bool write_changes;
-	bool verbose;
-	bool modify_all;
-	bool quiet;
-	bool no_hb_chk;
-	bool dev_is_file;
-	ocfs_vol_disk_hdr *hdr;
-	__u8 *vol_bm;
-	__u8 *dir_bm[OCFS_MAXIMUM_NODES];
-	__u8 *ext_bm[OCFS_MAXIMUM_NODES];
-	__u32 dir_bm_sz[OCFS_MAXIMUM_NODES];
-	__u32 ext_bm_sz[OCFS_MAXIMUM_NODES];
-	__u64 device_size;
-	__u64 offset;
-	int cluster_size_bits;
-	GArray *vol_bm_data;
-	GArray *dir_bm_data;
-	GArray *ext_bm_data;
-	GArray *filenames;
-} ocfsck_context;
-
-//int ocfs_lookup_file_allocation (ocfs_super * osb, ocfs_inode * oin,
-//				 __s64 Vbo, __s64 * Lbo, __u32 sectors);
-
-loff_t myseek64(int fd, loff_t off, int whence);
-int myread(int file, char *buf, __u32 len);
-int mywrite(int file, char *buf, __u32 len);
-int myopen(char *path, int flags);
-void myclose(int file);
-void read_system_file(int fd, ocfs_vol_disk_hdr * v, int fileid,
-		      ocfs_file_entry * fe);
-int write_system_file(int fd, ocfs_vol_disk_hdr * v, int fileid,
-		      ocfs_file_entry * fe);
-void read_cdsl_data(int fd, void *data, __u64 offset);
-
-int ocfs_find_clear_bits (ocfs_alloc_bm * bitmap, __u32 numBits,
-			  __u32 offset, __u32 sysonly);
-
-int print_class_member(char *buf, ocfs_class *cl, ocfs_class_member *mbr,
-		       FILE *out, bool bad);
-int _print_class(char *buf, ocfs_class *cl, FILE *out, bool num, GHashTable *ht);
-int print_class(char *buf, ocfs_class *cl, FILE *out, GHashTable *ht);
-bitmap_data * add_bm_data(__u64 start, __u64 len, __s32 alloc_node, 
-			  __u64 parent_offset, int type);
-int add_str_data(GArray *sd, __u32 num, char *str);
-
-int read_one_sector(int fd, char *buf, __u64 offset, int idx);
-int write_one_sector(int fd, char *buf, __u64 offset, int idx);
-int read_dir_node(int fd, char *buf, __u64 offset, int idx);
-int write_dir_node (int fd, char *buf, __u64 offset, int idx);
-int read_volume_bitmap (int fd, char *buf, __u64 offset, int idx);
-int write_volume_bitmap (int fd, char *buf, __u64 offset, int idx);
-
-int check_dir_index (char *dirbuf, __u64 dir_offset);
-int check_num_del (char *dirbuf, __u64 dir_offset);
-int fix_num_del (char *dirbuf, __u64 dir_offset);
-int fix_fe_offsets(char *dirbuf, __u64 dir_offset);
-
-#endif /* FSCK_H */

Copied: trunk/fsck/fsck.h (from rev 205, trunk/ocfs/fsck/fsck.h)

Deleted: trunk/fsck/fsck.ocfs.8.in
===================================================================
--- trunk/ocfs/fsck/fsck.ocfs.8.in	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/fsck.ocfs.8.in	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,39 +0,0 @@
-.TH "fsck.ocfs" "1" "November 2003" "Version @VERSION@" "OCFS Manual Pages"
-.SH "NAME"
-fsck.ocfs \- Build an OCFS file system.
-.SH "SYNOPSIS"
-\fBfsck.ocfs\fR \-w  [\-V] [\-v] [\-q] device 
-.SH "DESCRIPTION"
-.PP 
-\fBfsck.ocfs\fR is used to check an OCFS file system on a device, usually a partition in a shared disk. \fBfsck.ocfs\fR will execute read-only if \-w is not specified. This is allows users to run fsck while a OCFS volume is mounted and active. The \fBfsck.ocfs\fR command will look for the first free raw device and bind the device specified to it. The command will fail if there is no free raw device available. One can also perform this raw binding manually and provide the /dev/raw/rawX as the device. Raw binding is used to ensure direct io behaviour across various flavors of linux.
-
-.SH "OPTIONS"
-.TP
-\fB\-w\fR 
-This option tell \fBfsck.ocfs\fR that it is going to run in read/write
-mode. This option should only be specified with the device properly unmounted
-on all nodes.
-
-.TP
-\fB\-V\fR 
-Display \fBfsck.ocfs\fR version.
-
-.TP
-\fB\-v\fR 
-Run \fBfsck.ocfs\fR in verbose mode.
-
-.TP
-\fB\-q\fR 
-Run \fBfsck.ocfs\fR in quiet mode.
-   
-.SH "BUGS"
-Stuff.
-
-.SH "SEE ALSO"
-.BR ocfs(5)
-
-.SH "AUTHORS"
-Oracle Corporation
-
-.SH "COPYRIGHT"
-Copyright \(co 2002, 2004 Oracle Corporation

Copied: trunk/fsck/fsck.ocfs.8.in (from rev 205, trunk/ocfs/fsck/fsck.ocfs.8.in)

Deleted: trunk/fsck/fsck_io.c
===================================================================
--- trunk/ocfs/fsck/fsck_io.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/fsck_io.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,214 +0,0 @@
-/*
- * fsck_io.c
- *
- * provides the actual file I/O support in ocfs file system
- * check utility
- *
- * Copyright (C) 2003, 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Author: Kurt Hackel, Sunil Mushran
- */
-
-#include "fsck.h"
-
-void *mem_alloc(int len)
-{
-	void *buf;
-
-	if ((buf = malloc_aligned(len)) == NULL)
-		LOG_ERROR("unable to allocate %d bytes of memory", len);
-
-	return buf;
-}				/* mem_alloc */
-
-
-loff_t myseek64(int fd, loff_t off, int whence)
-{
-	loff_t ret;
-
-	if ((ret = lseek64(fd, off, whence) == -1))
-		LOG_ERROR("lseek() %s", strerror(errno));
-
-	return ret;
-}				/* myseek64 */
-
-/*
- * myread()
- *
- */
-int myread(int file, char *buf, __u32 len)
-{
-	int ret;
-
-	if ((ret = read(file, buf, len)) == -1)
-		LOG_ERROR("read() %s", strerror(errno));
-
-	return ret;
-}				/* myread */
-
-
-/*
- * mywrite()
- *
- */
-int mywrite(int file, char *buf, __u32 len)
-{
-	int ret;
-
-	if ((ret = write(file, buf, len)) == -1)
-		LOG_ERROR("write() %s", strerror(errno));
-
-	return ret;
-}				/* mywrite */
-
-/*
- * myopen()
- *
- */
-int myopen(char *path, int flags)
-{
-    int file;
-    mode_t oldmode;
-
-    oldmode = umask(0000);
-    file = open(path, flags, 0777);
-    umask(oldmode);
-
-    return file;
-}				/* myopen */
-
-
-/*
- * myclose()
- *
- */
-void myclose(int file)
-{
-    if (file)
-	close(file);
-}				/* myclose */
-
-
-void read_system_file(int fd, ocfs_vol_disk_hdr * v, int fileid,
-		      ocfs_file_entry * fe)
-{
-    __u64 diskOffset = (fileid * OCFS_SECTOR_SIZE) + v->internal_off;
-
-    myseek64(fd, diskOffset, SEEK_SET);
-    read(fd, fe, OCFS_SECTOR_SIZE);
-}				/* read_system_file */
-
-
-int write_system_file(int fd, ocfs_vol_disk_hdr * v, int fileid,
-		      ocfs_file_entry * fe)
-{
-    int ret;
-    void *sector;
-    __u64 diskOffset = (fileid * OCFS_SECTOR_SIZE) + v->internal_off;
-
-    sector = malloc_aligned(OCFS_SECTOR_SIZE);
-    memset(sector, 0, OCFS_SECTOR_SIZE);
-    memcpy(sector, fe, sizeof(ocfs_file_entry));
-    myseek64(fd, diskOffset, SEEK_SET);
-    ret = write(fd, sector, OCFS_SECTOR_SIZE);
-    free(sector);
-    return ret;
-}				/* write_system_file */
-
-
-void read_cdsl_data(int fd, void *data, __u64 offset)
-{
-	int len = sizeof(__u64) * MAX_NODES;
-	int rdlen;
-
-	myseek64(fd, offset, SEEK_SET);
-	if ((rdlen = read(fd, data, len)) != len)
-		LOG_ERROR("short read for cdsl data... %d instead of %d bytes",
-			  rdlen, len);
-}				/* read_cdsl_data */
-
-
-int read_one_sector(int fd, char *buf, __u64 offset, int idx)
-{
-	int ret;
-
-	myseek64(fd, offset, SEEK_SET);
-	if ((ret = read(fd, buf, OCFS_SECTOR_SIZE)) == -1)
-		LOG_ERROR("read() %s", strerror(errno));
-	return ret;
-}				/* read_one_sector */
-
-
-int write_one_sector(int fd, char *buf, __u64 offset, int idx)
-{
-	int ret;
-
-	myseek64(fd, offset, SEEK_SET);
-	if ((ret = write(fd, buf, OCFS_SECTOR_SIZE)) == -1)
-		LOG_ERROR("write() %s", strerror(errno));
-	return ret;
-}				/* write_one_sector */
-
-
-int read_dir_node(int fd, char *buf, __u64 offset, int idx)
-{
-	int rdlen;
-
-	myseek64(fd, offset, SEEK_SET);
-
-	if ((rdlen = read(fd, buf, DIR_NODE_SIZE)) != DIR_NODE_SIZE) {
-		if (rdlen == -1)
-			LOG_ERROR("read() %s\n", strerror(errno));
-		else
-			LOG_ERROR("short read for dirnode... %d instead "
-				  "of %d bytes", rdlen, DIR_NODE_SIZE);
-	}
-    	return 0;
-}				/* read_dir_node */
-
-
-int write_dir_node (int fd, char *buf, __u64 offset, int idx)
-{
-	int ret;
-	myseek64(fd, offset, SEEK_SET);
-	if ((ret = write(fd, buf, DIR_NODE_SIZE)) == -1)
-		LOG_ERROR("write() %s", strerror(errno));
-	return ret;
-}				/* write_dir_node */
-
-
-int read_volume_bitmap (int fd, char *buf, __u64 offset, int idx)
-{
-	int rdlen;
-	
-	myseek64(fd, offset, SEEK_SET);
-	if ((rdlen = read(fd, buf, VOL_BITMAP_BYTES)) != VOL_BITMAP_BYTES)
-		LOG_ERROR("short read for volume bitmap... %d instead of %d bytes",
-			  rdlen, VOL_BITMAP_BYTES);
-	return 0;
-}				/* read_volume_bitmap */
-
-
-int write_volume_bitmap (int fd, char *buf, __u64 offset, int idx)
-{
-	int ret;
-	myseek64(fd, offset, SEEK_SET);
-	if ((ret = write(fd, buf, VOL_BITMAP_BYTES)) == -1)
-		LOG_ERROR("write() %s", strerror(errno));
-	return ret;
-}				/* write_volume_bitmap */

Copied: trunk/fsck/fsck_io.c (from rev 205, trunk/ocfs/fsck/fsck_io.c)

Deleted: trunk/fsck/fsck_print.c
===================================================================
--- trunk/ocfs/fsck/fsck_print.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/fsck_print.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,126 +0,0 @@
-/*
- * fsck_print.c
- *
- * print function for each structure type in ocfs
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#include "fsck.h"
-
-
-int print_dir_node (char *buf, int idx, GHashTable *bad, FILE *f)
-{
-	return print_class(buf, &ocfs_dir_node_class, f, bad);
-}
-int print_file_entry(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_file_entry_class, f, bad);
-}
-
-int print_extent_header(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_extent_group_class, f, bad);
-}
-
-int print_extent_data(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_extent_group_class, f, bad);
-}
-
-int print_vol_disk_header(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_vol_disk_hdr_class, f, bad);
-}
-
-int print_vol_label(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_vol_label_class, f, bad);
-}
-
-int print_disk_lock(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_disk_lock_class, f, bad);
-}
-
-int print_nodecfghdr(char *buf, int idx, GHashTable *bad, FILE *f) 
-{
-	return print_class(buf, &ocfs_node_config_hdr_class, f, bad);
-}
-
-int print_nodecfginfo(char *buf, int idx, GHashTable *bad, FILE *f) 
-{
-	return print_class(buf, &ocfs_disk_node_config_info_class, f, bad);
-}
-
-int print_publish_sector(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_publish_class, f, bad);
-}
-
-int print_vote_sector(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_vote_class, f, bad);
-}
-
-int print_volume_bitmap(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return 0; //print_class(buf, &ocfs_volume_bitmap_class, f, bad);
-}
-
-int print_vol_metadata(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_file_entry_class, f, bad);
-}
-
-int print_vol_metadata_log(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_file_entry_class, f, bad);
-}
-
-int print_dir_alloc(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_file_entry_class, f, bad);
-}
-
-int print_dir_alloc_bitmap(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_file_entry_class, f, bad);
-}
-
-int print_file_alloc(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_file_entry_class, f, bad);
-}
-
-int print_file_alloc_bitmap(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_file_entry_class, f, bad);
-}
-
-int print_recover_log(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_file_entry_class, f, bad);
-}
-
-int print_cleanup_log(char *buf, int idx, GHashTable *bad, FILE *f) 
-{ 
-	return print_class(buf, &ocfs_file_entry_class, f, bad);
-}

Copied: trunk/fsck/fsck_print.c (from rev 205, trunk/ocfs/fsck/fsck_print.c)

Deleted: trunk/fsck/fsck_print.h
===================================================================
--- trunk/ocfs/fsck/fsck_print.h	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/fsck_print.h	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,54 +0,0 @@
-/*
- * fsck_print.h
- *
- * Function prototypes, macros, etc. for related 'C' files
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#ifndef FSCK_PRINT_H
-#define FSCK_PRINT_H
-
-
-// for ALL print functions...
-// TODO: deal with bad array
-int print_dir_node (char *buf, int idx, GHashTable *bad, FILE *f);
-int print_file_entry(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_extent_header(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_extent_data(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_vol_disk_header(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_vol_label(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_disk_lock(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_disk_lock(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_nodecfghdr(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_nodecfginfo(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_publish_sector(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_vote_sector(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_volume_bitmap(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_vol_metadata(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_vol_metadata_log(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_dir_alloc(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_dir_alloc_bitmap(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_file_alloc(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_file_alloc_bitmap(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_recover_log(char *buf, int idx, GHashTable *bad, FILE *f);
-int print_cleanup_log(char *buf, int idx, GHashTable *bad, FILE *f);
-
-#endif /* FSCK_PRINT_H */

Copied: trunk/fsck/fsck_print.h (from rev 205, trunk/ocfs/fsck/fsck_print.h)

Deleted: trunk/fsck/layout.c
===================================================================
--- trunk/ocfs/fsck/layout.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/layout.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,433 +0,0 @@
-/*
- * layout.c
- *
- * ocfs file system block structure layouts
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#include "layout.h"
-
-#define LAYOUT_LOCAL_DEFS
-ocfs_disk_structure dirnode_t = {
-	dir_node,
-       	&ocfs_dir_node_class,
-       	dir_node_sig_match,
-       	read_dir_node,
-//	write_dir_node,
-	write_one_sector,
-       	verify_dir_node,
-       	print_dir_node,
-       	get_dir_node_defaults
-};
-ocfs_disk_structure fileent_t = {
-	file_entry,
-       	&ocfs_file_entry_class,
-       	file_entry_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_file_entry,
-       	print_file_entry,
-       	get_file_entry_defaults
-};
-ocfs_disk_structure exthdr_t = {
-	extent_header,
-       	&ocfs_extent_group_class,
-       	extent_header_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_extent_header,
-       	print_extent_header,
-       	get_extent_header_defaults
-};
-ocfs_disk_structure extdat_t = {
-	extent_data,
-	&ocfs_extent_group_class,
-       	extent_data_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_extent_data,
-       	print_extent_data,
-       	get_extent_data_defaults
-};
-ocfs_disk_structure diskhdr_t = { 
-	vol_disk_header,
-       	&ocfs_vol_disk_hdr_class,
-       	NULL,
-       	read_one_sector,
-	write_one_sector,
-       	verify_vol_disk_header,
-       	print_vol_disk_header,
-       	get_vol_disk_header_defaults 
-};
-ocfs_disk_structure vollabel_t = { 
-	vol_label_lock,
-       	&ocfs_vol_label_class,
-       	NULL,
-       	read_one_sector,
-	write_one_sector,
-       	verify_vol_label,
-       	print_vol_label,
-       	get_vol_label_defaults 
-};
-ocfs_disk_structure bmlock_t = {
-	bitmap_lock,
-       	&ocfs_disk_lock_class,
-       	NULL,
-       	read_one_sector,
-	write_one_sector,
-       	verify_disk_lock,
-       	print_disk_lock,
-       	get_disk_lock_defaults
-};
-ocfs_disk_structure nmlock_t = {
-	nm_lock,
-       	&ocfs_disk_lock_class,
-       	NULL,
-       	read_one_sector,
-	write_one_sector,
-       	verify_disk_lock,
-       	print_disk_lock,
-       	get_disk_lock_defaults
-};
-ocfs_disk_structure unused_t = {
-	unused,
-       	NULL,
-       	NULL,
-       	NULL,
-	NULL,
-       	NULL,
-       	NULL,
-       	NULL,
-};
-ocfs_disk_structure free_t = {
-	free_sector,
-       	NULL,
-       	NULL,
-       	NULL,
-	NULL,
-       	NULL,
-       	NULL,
-       	NULL,
-};
-ocfs_disk_structure nodecfghdr_t = {
-	node_cfg_hdr,
-       	&ocfs_node_config_hdr_class,
-       	nodecfghdr_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_nodecfghdr,
-       	print_nodecfghdr,
-       	get_nodecfghdr_defaults
-};
-ocfs_disk_structure nodecfginfo_t = {
-	node_cfg_info,
-       	&ocfs_disk_node_config_info_class,
-       	NULL,
-       	read_one_sector,
-	write_one_sector,
-       	verify_nodecfginfo,
-       	print_nodecfginfo,
-       	get_nodecfginfo_defaults
-};
-ocfs_disk_structure publish_t = {
-	publish_sector,
-       	&ocfs_publish_class,
-       	NULL,
-       	read_one_sector,
-	write_one_sector,
-       	verify_publish_sector,
-       	print_publish_sector,
-       	get_publish_sector_defaults
-};
-ocfs_disk_structure vote_t = {
-	vote_sector,
-       	&ocfs_vote_class,
-       	vote_sector_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_vote_sector,
-       	print_vote_sector,
-       	get_vote_sector_defaults
-};
-ocfs_disk_structure volbm_t = {
-	volume_bitmap,
-       	NULL,
-       	NULL,
-       	read_volume_bitmap,
-	write_volume_bitmap,
-       	verify_volume_bitmap,
-       	print_volume_bitmap,
-       	NULL
-};
-ocfs_disk_structure volmd_t = {
-	vol_metadata,
-       	&ocfs_file_entry_class,
-       	file_entry_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_vol_metadata,
-       	print_vol_metadata,
-       	get_vol_metadata_defaults
-};
-ocfs_disk_structure volmdlog_t = {
-	vol_metadata_log,
-       	&ocfs_file_entry_class,
-       	file_entry_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_vol_metadata_log,
-       	print_vol_metadata_log,
-       	get_vol_metadata_log_defaults
-};
-ocfs_disk_structure diralloc_t = {
-	dir_alloc,
-       	&ocfs_file_entry_class,
-       	file_entry_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_dir_alloc,
-       	print_dir_alloc,
-       	get_dir_alloc_defaults
-};
-ocfs_disk_structure dirallocbm_t = {
-	dir_alloc_bitmap,
-       	&ocfs_file_entry_class,
-       	file_entry_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_dir_alloc_bitmap,
-       	print_dir_alloc_bitmap,
-       	get_dir_alloc_bitmap_defaults
-};
-ocfs_disk_structure filealloc_t = {
-	file_alloc,
-       	&ocfs_file_entry_class,
-       	file_entry_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_file_alloc,
-       	print_file_alloc,
-       	get_file_alloc_defaults
-};
-ocfs_disk_structure fileallocbm_t = {
-	file_alloc_bitmap,
-       	&ocfs_file_entry_class,
-       	file_entry_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_file_alloc_bitmap,
-       	print_file_alloc_bitmap,
-       	get_file_alloc_bitmap_defaults
-};
-ocfs_disk_structure recover_t = {
-	recover_log,
-       	&ocfs_file_entry_class,
-       	file_entry_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_recover_log,
-       	print_recover_log,
-       	get_recover_log_defaults
-};
-ocfs_disk_structure cleanup_t = {
-	cleanup_log,
-       	&ocfs_file_entry_class,
-       	file_entry_sig_match,
-       	read_one_sector,
-	write_one_sector,
-       	verify_cleanup_log,
-       	print_cleanup_log,
-       	get_cleanup_log_defaults
-};
-
-ocfs_layout_t ocfs_header_layout[] = 
-{
-	{ 0, 1, &diskhdr_t, "Volume Header" },
-	{ 1, 1, &vollabel_t, "Volume Label" },
-	{ 2, 1, &bmlock_t, "Bitmap Lock" },
-	{ 3, 1, &nmlock_t, "NM Lock" },
-	{ 4, 4, &unused_t, "" },
-	{ 8, 1, &nodecfghdr_t, "Node Config Header" },
-	{ 9, 1, &unused_t, "" },
-	{ 10, 32, &nodecfginfo_t, "Node Config Info" },
-	{ 42, 1, &unused_t, "" },
-	{ 43, 1, &nodecfghdr_t, "Node Config Trailer" },
-	{ 44, 2, &unused_t, "" },
-	{ 46, 32, &publish_t, "Publish" },
-	{ 78, 32, &vote_t, "Vote" },
-	{ 110, 2048, &volbm_t, "Volume Bitmap File" },
-	{ 2158, 514, &free_t, "Free Bitmap File" },
-	{ 2672, 32, &volmd_t, "Volume Metadata File" },
-	{ 2704, 32, &volmdlog_t, "Volume Metadata Logfile" },
-	{ 2736, 32, &diralloc_t, "Directory Alloc File" },
-	{ 2768, 32, &dirallocbm_t, "Directory Alloc Bitmap File" },
-	{ 2800, 32, &filealloc_t, "Extent Alloc File" },
-	{ 2832, 32, &fileallocbm_t, "Extent Alloc Bitmap File" },
-	{ 2864, 32, &recover_t, "Recover File" },
-	{ 2896, 32, &cleanup_t, "Cleanup File" }
-};
-int ocfs_header_layout_sz = sizeof(ocfs_header_layout)/sizeof(ocfs_layout_t);
-
-ocfs_layout_t ocfs_data_layout[] = 
-{
-	{ ANY_BLOCK, 256, &dirnode_t, "directory node" },
-	{ ANY_BLOCK, 1, &fileent_t, "file entry" },
-	{ ANY_BLOCK, 1, &exthdr_t, "extent header" },
-	{ ANY_BLOCK, 1, &extdat_t, "extent data" }
-};
-int ocfs_data_layout_sz = sizeof(ocfs_data_layout)/sizeof(ocfs_layout_t);
-
-ocfs_layout_t ocfs_dir_layout[] = 
-{
-	{ 0, 1, &dirnode_t },
-	{ 1, 255, &fileent_t }
-};
-int ocfs_dir_layout_sz = sizeof(ocfs_dir_layout)/sizeof(ocfs_layout_t);
-
-ocfs_disk_structure *ocfs_all_structures[] = 
-{
-	&dirnode_t,
-	&fileent_t,
-	&exthdr_t,
-	&extdat_t,
-	&diskhdr_t,
-	&publish_t,
-	&vote_t,
-	&volmd_t,
-	&volmdlog_t,
-	&diralloc_t,
-	&dirallocbm_t,
-	&filealloc_t,
-	&fileallocbm_t,
-	&recover_t,
-	&cleanup_t,
-	&vollabel_t,
-	&bmlock_t,
-	&nmlock_t,
-	&nodecfghdr_t,
-	&nodecfginfo_t,
-	&volbm_t,
-	&unused_t,
-	&free_t
-};
-int ocfs_all_structures_sz = sizeof(ocfs_all_structures)/sizeof(ocfs_disk_structure);
-
-/* 
-     autoconfig subtypes
-
-int get_autoconfig_header_copy_defaults (char *buf, char **out, int idx);
-int get_autoconfig_header_defaults (char *buf, char **out, int idx);
-int get_autoconfig_node_info_defaults (char *buf, char **out, int idx);
-int autoconfig_header_copy_sig_match (char *buf, int idx);
-int autoconfig_header_sig_match (char *buf, int idx);
-int autoconfig_node_info_sig_match (char *buf, int idx);
-int print_autoconfig_header (char *buf, int idx);
-int print_autoconfig_header_copy (char *buf, int idx);
-int print_autoconfig_node_info (char *buf, int idx);
-int verify_autoconfig_header (int fd, char *buf, int idx);
-int verify_autoconfig_header_copy (int fd, char *buf, int idx);
-int verify_autoconfig_node_info (int fd, char *buf, int idx);
-
-
-ocfs_disk_structure autoconfig_hdr_t = {
-	autoconfig_header,
-	autoconfig_header_sig_match,
-	read_one_sector,
-	write_one_sector,
-	verify_autoconfig_header,
-	print_autoconfig_header,
-	get_autoconfig_header_defaults
-};
-ocfs_disk_structure autoconfig_node_info_t = {
-	autoconfig_node_info,
-	autoconfig_node_info_sig_match,
-	read_one_sector,
-	write_one_sector,
-	verify_autoconfig_node_info,
-	print_autoconfig_node_info,
-	get_autoconfig_node_info_defaults
-};
-ocfs_disk_structure autoconfig_hdr_copy_t = {
-	autoconfig_header_copy,
-	autoconfig_header_copy_sig_match,
-	read_one_sector,
-	write_one_sector,
-	verify_autoconfig_header_copy,
-	print_autoconfig_header_copy,
-	get_autoconfig_header_copy_defaults
-};
-
-ocfs_layout_t ocfs_autoconfig_layout[] = 
-{
-	{ 0, 1, autoconfig_hdr_t },
-	{ 1, 1, unused_t },
-	{ 2, 32, autoconfig_node_info_t },
-	{ 34, 1, unused_t },
-	{ 35, 1, autoconfig_hdr_copy_t }
-};
-int ocfs_autoconfig_layout_sz = sizeof(ocfs_autoconfig_layout)/sizeof(ocfs_layout_t);
-
-*/       
-
-
-
-
-ocfs_layout_t * find_nxt_hdr_struct(int type, int start)
-{
-	int i;
-	ocfs_disk_structure *s;
-	ocfs_layout_t *ret = NULL;
-
-	for (i=start; i<ocfs_header_layout_sz; i++)
-	{
-		ret = &(ocfs_header_layout[i]);
-		s = ret->kind;
-		if (s->type != type)
-			ret = NULL;
-		else
-			break;
-	}
-	return ret;
-}
-								
-
-ocfs_disk_structure * find_matching_struct(char *buf, int idx)
-{
-	int i;
-	ocfs_disk_structure *s;
-
-	for (i=0; i<ocfs_all_structures_sz; i++)
-	{
-		s = ocfs_all_structures[i];
-		if (s->sig_match == NULL)
-			continue;
-		if (s->sig_match(buf, idx) == 0)
-		{
-			return s;
-		}
-	}
-	return NULL;
-}
-
-
-
-#undef LAYOUT_LOCAL_DEFS
-

Copied: trunk/fsck/layout.c (from rev 205, trunk/ocfs/fsck/layout.c)

Deleted: trunk/fsck/layout.h
===================================================================
--- trunk/ocfs/fsck/layout.h	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/layout.h	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,224 +0,0 @@
-/*
- * layout.h
- *
- * Function prototypes, macros, etc. for related 'C' files
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#ifndef LAYOUT_H
-#define LAYOUT_H
-
-#define BLOCKS2BYTES(x)   ((x) << 9)
-#define BYTES2BLOCKS(x)   ((x) >> 9)
-
-/* 100% totally hardcoded to the ocfs version!!! */
-/*
-
-  block#    datatype                       description
-  --------- ------------------------------ --------------------------------------------
-  0         ocfs_vol_disk_header           *the* header                     - disk header
-  1         ocfs_vol_label                 volume label, volume lock        - locks
-  2         ocfs_file_entry (lock only)    bitmap lock                      - locks
-  3         ocfs_file_entry (lock only)    nm lock????                      - locks
-  4-7       none                           unused                           - 
-  8         ocfs_node_config_hdr           autoconfig header                - autoconfig
-  9         none                           unused                           - autoconfig
-  10-41     ocfs_disk_node_config_info     autoconfig nodes            0-31 - autoconfig 
-  42        none                           autoconfig lock (zeroed)         - autoconfig
-  43        ocfs_node_config_hdr           exact copy of block#8            - autoconfig
-  44-45     none                           unused                           - autoconfig
-  46-77     ocfs_publish                   publish nodes               0-31 - publish
-  78-109    ocfs_vote                      vote nodes                  0-31 - vote
-  110-2157  bitmap                         1MB (8 million bits max)         - volume bitmap
-  2158-2671 none                           514 free sectors                 - free sectors
-  2672-2703 ocfs_file_entry                OCFS_VOL_MD_SYSFILE         0-31 - data_start_off
-  2704-2735 ocfs_file_entry                OCFS_VOL_MD_LOG_SYSFILE     0-31 - 
-  2736-2767 ocfs_file_entry                OCFS_DIR_SYSFILE            0-31 - 
-  2768-2799 ocfs_file_entry                OCFS_DIR_BM_SYSFILE         0-31 - 
-  2800-2831 ocfs_file_entry                OCFS_FILE_EXTENT_SYSFILE    0-31 - 
-  2832-2863 ocfs_file_entry                OCFS_FILE_EXTENT_BM_SYSFILE 0-31 -
-  2864-2895 ocfs_file_entry                OCFS_RECOVER_LOG_SYSFILE    0-31 - 
-  2896-2927 ocfs_file_entry                OCFS_CLEANUP_LOG_SYSFILE    0-31 - 
-  ####      ocfs_dir_node                  the root directory               - root_off (offset can vary)
-  ####      none                           1022 free sectors                - end sectors
-
-*/
-
-typedef struct _ocfs_disk_structure ocfs_disk_structure;
-
-#include "fsck.h"
-
-enum
-{
-	unused = 0,
-	vol_disk_header,
-	vol_label_lock,
-	bitmap_lock,
-	nm_lock,
-	node_cfg_hdr,
-	node_cfg_info,
-	publish_sector,
-	vote_sector,
-	volume_bitmap,
-	free_sector,
-	vol_metadata,
-	vol_metadata_log,
-	dir_alloc,
-	dir_alloc_bitmap,
-	file_alloc,
-	file_alloc_bitmap,
-	recover_log,
-	cleanup_log,
-	dir_node,
-	file_entry,
-	extent_header,
-	extent_data,
-};
-
-
-struct _ocfs_disk_structure
-{
-	int type;
-	ocfs_class *cls;
-	int (*sig_match) (char *buf, int idx);
-	int (*read) (int fd, char *buf, __u64 offset, int idx);
-	int (*write) (int fd, char *buf, __u64 offset, int idx);
-	int (*verify) (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-	int (*output) (char *buf, int idx, GHashTable *bad, FILE *f);
-	int (*defaults) (char *buf, GString **out, int idx, int fld);
-};
-
-#define ANY_BLOCK  (0xffffffffUL)
-typedef struct _ocfs_layout_t
-{
-	__u32    block;
-	__u32    num_blocks;
-	ocfs_disk_structure *kind; 
-	char     name[50];
-} ocfs_layout_t;
-	
-/* 
- * these are all version 1.0.0 constants 
- * I could have derived them, but what's the point?  
- * they're konstant ;-)
- * I may later include the headers for mkfs/module
- * but I'm feeling lazy now...
- */
-#define OCFSCK_BITMAP_OFF           56320LLU    /* block# 110 */
-#define OCFSCK_PUBLISH_OFF          23552LLU    /* block# 46  */
-#define OCFSCK_VOTE_OFF             39936LLU    /* block# 78  */
-#define OCFSCK_AUTOCONF_OFF         4096LLU     /* block# 8 */
-#define OCFSCK_AUTOCONF_SIZE        17408LLU    /* 34 blocks */
-#define OCFSCK_NEW_CFG_OFF          21504LLU    /* block# 42 */
-#define OCFSCK_DATA_START_OFF       1368064LLU  /* block# 2672 */
-#define OCFSCK_INTERNAL_OFF         OCFSCK_DATA_START_OFF
-#define OCFSCK_ROOT_OFF 	    2416640LLU  /* block# 4720 */
-#define OCFSCK_MIN_MOUNT_POINT_LEN  (strlen("/a"))
-#define OCFSCK_END_SECTOR_BYTES     (1022*512)
-#define OCFSCK_NON_DATA_AREA        (OCFSCK_DATA_START_OFF+OCFSCK_END_SECTOR_BYTES)
-#define OCFSCK_MAX_CLUSTERS         (1024*1024*8)  /* maximum 1mb (8megabits) */
-
-
-#define BM_DATA_BIT_SET         0x01	
-#define BM_ALLOCATED            0x02
-#define BM_SIG_BIT_1            0x04
-#define BM_SIG_BIT_2            0x08
-#define BM_SIG_BIT_3            0x10
-#define BM_MULTIPLY_ALLOCATED   0x20
-#define BM_RESERVED_1           0x40
-#define BM_RESERVED_2           0x80
-				
-#define BM_SIG_NONE             (0)
-#define BM_SIG_FILE             (BM_SIG_BIT_1)
-#define BM_SIG_DIR              (BM_SIG_BIT_2)
-#define BM_SIG_EXTHDR           (BM_SIG_BIT_3)
-#define BM_SIG_EXTDAT           (BM_SIG_BIT_1|BM_SIG_BIT_2)
-#define BM_SIG_VOL              (BM_SIG_BIT_1|BM_SIG_BIT_3)
-#define BM_SIG_NODECFG          (BM_SIG_BIT_2|BM_SIG_BIT_3)
-#define BM_SIG_OTHER            (BM_SIG_BIT_1|BM_SIG_BIT_2|BM_SIG_BIT_3)
-
-
-#define ONE_KB                     (1024)
-#define ONE_MB                     (ONE_KB*ONE_KB)
-
-#define OCFSCK_LO_CLUSTER_SIZE     (4 * ONE_KB)
-#define OCFSCK_HI_CLUSTER_SIZE     (ONE_MB)
-#define OCFSCK_DIR_NODE_SIZE       (128 * ONE_KB)
-#define OCFSCK_BITMAP_DATA_SIZE    (8 * ONE_MB)
-
-
-
-
-
-
-#if 0
-
-1. traverse each directory, checking each dir header and file entry signature
-2. check the allocation for each file and dir, matching it back to a bit in the global bitmap
-3. link any set bits with no matching file entry to lost+found data chunks
-4. do interactive repairs of the header block with appropriate defaults
-5. make a lock-state mode which can allow the user to change the lock state of any file entry
-7. mark non set bits as set in bitmap according to space usage
-8. verify if this is mounted filesystem or not
-
-** 6. allow some (as yet undefined) editing of autoconfig sectors
-** 9. clearing of bloated system files
-
-#endif
-
-ocfs_layout_t * find_nxt_hdr_struct(int type, int start);
-ocfs_disk_structure * find_matching_struct(char *buf, int idx);
-
-#ifndef LAYOUT_LOCAL_DEFS
-extern ocfs_disk_structure dirnode_t;
-extern ocfs_disk_structure fileent_t;
-extern ocfs_disk_structure exthdr_t;
-extern ocfs_disk_structure extdat_t;
-extern ocfs_disk_structure diskhdr_t;
-extern ocfs_disk_structure vollabel_t;
-extern ocfs_disk_structure bmlock_t;
-extern ocfs_disk_structure nmlock_t;
-extern ocfs_disk_structure unused_t;
-extern ocfs_disk_structure free_t;
-extern ocfs_disk_structure nodecfghdr_t;
-extern ocfs_disk_structure nodecfginfo_t;
-extern ocfs_disk_structure publish_t;
-extern ocfs_disk_structure vote_t;
-extern ocfs_disk_structure volbm_t;
-extern ocfs_disk_structure volmd_t;
-extern ocfs_disk_structure volmdlog_t;
-extern ocfs_disk_structure diralloc_t;
-extern ocfs_disk_structure dirallocbm_t;
-extern ocfs_disk_structure filealloc_t;
-extern ocfs_disk_structure fileallocbm_t;
-extern ocfs_disk_structure recover_t;
-extern ocfs_disk_structure cleanup_t;
-extern ocfs_layout_t ocfs_header_layout[];
-extern int ocfs_header_layout_sz;
-extern ocfs_layout_t ocfs_data_layout[];
-extern int ocfs_data_layout_sz;
-extern ocfs_layout_t ocfs_dir_layout[];
-extern int ocfs_dir_layout_sz;
-extern ocfs_disk_structure *ocfs_all_structures[];
-extern int ocfs_all_structures_sz;
-#endif /* LAYOUT_LOCAL_DEFS */
-
-#endif /* LAYOUT_H */

Copied: trunk/fsck/layout.h (from rev 205, trunk/ocfs/fsck/layout.h)

Deleted: trunk/fsck/mkgetconst
===================================================================
--- trunk/ocfs/fsck/mkgetconst	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/mkgetconst	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,45 +0,0 @@
-#!/bin/bash
-# this is used by parse.c to turn a #define'd
-# constant name into a usable array bound
-# eg.  ocfs_alloc_ext extents[OCFS_MAX_DATA_EXTENTS]
-# input:   OCFS_MAX_DATA_EXTENTS 
-# output:  18
-# don't know why i bothered with sign/size
-# arrays should be unsigned 32-bit int bounded here
-# and hell, if it's that big, we're screwed
-
-
-if [ "$bigint" = "" ]; then
-	typ="long";
-	fmt="l";
-else
-	typ="long long";
-	fmt="ll";
-fi
-
-if [ "$signed" = "" ]; then
-	sgn="unsigned";
-	fmt=$fmt"u";
-else
-	sgn="signed";
-	fmt=$fmt"d";
-fi
-
-cat > getconst.c << DONE
-/* just to make it shut up */
-#define O_DIRECT        040000
-
-#include <stdio.h>
-#include "ocfsconst.h"
-
-int main(int argc, char **argv)
-{
-	${sgn} ${typ} c = $1;
-	printf("%${fmt}\n", c);
-	exit(0);
-}
-DONE
-
-gcc -I. -I${COMMON_HEADERS} -o getconst getconst.c
-./getconst
-rm getconst.c getconst > /dev/null 2>&1

Copied: trunk/fsck/mkgetconst (from rev 205, trunk/ocfs/fsck/mkgetconst)

Deleted: trunk/fsck/parse.c
===================================================================
--- trunk/ocfs/fsck/parse.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/parse.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,523 +0,0 @@
-/*
- * parse.c
- *
- * Utility to parse headers for ocfs file system check utility
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-/*  gcc -D_GNU_SOURCE parse.c -o parse . ./parseenv */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <ocfsbool.h>
-
-typedef struct _member
-{
-	char *name;
-	char *type;
-	char *flavor;
-	char *array_size;
-	char *hi;
-	char *lo;
-	int size;
-	bool is_signed;
-	int off;
-} member;
-
-typedef struct _oclass
-{
-	char *name;
-	int num_members;
-	int max_members;
-	member *members;
-} oclass;
-
-typedef struct _base_type
-{
-	char *name;
-	bool is_signed;
-	int size;
-} base_type;
-
-base_type known_types[] = 
-{ 
-	{"u64", false, 8}, 
-	{"u32", false, 4},
-	{"u16", false, 2},
-	{"u8",  false, 1},
-	{"s64", true,  8},
-	{"s32", true,  4},
-	{"s16", true,  2},
-	{"s8",  true,  1},
-	{"bool",false, 4}
-};
-int num_known = sizeof(known_types)/sizeof(base_type);
-
-void get_type_and_name(char *str, member *m);
-int print_one_member(oclass *cl, member *m, char *prefix);
-int print_one_class(oclass *cl);
-
-
-int num_classes = 0;
-int max_classes = 0;
-oclass *classes = NULL;
-
-oclass * add_class(oclass *cl)
-{
-	oclass *ret;
-
-	if (++num_classes > max_classes)
-	{
-		max_classes += 5;
-		classes = realloc(classes, max_classes*sizeof(oclass));
-	}
-	ret = (oclass *) (((char *)classes) + ((num_classes-1)*sizeof(oclass)));
-	memcpy(ret, cl, sizeof(oclass));
-	return ret;
-}
-
-member * add_member(oclass *cl, member *m)
-{
-	member *ret;
-	if (++(cl->num_members) > cl->max_members)
-	{
-		cl->max_members += 5;
-		cl->members = realloc(cl->members, cl->max_members*sizeof(member));
-	}
-	ret = (member *) (((char *)cl->members) + ((cl->num_members-1)*sizeof(member)));
-	memcpy(ret, m, sizeof(member));
-	return ret;
-}
-
-int main(int argc, char **argv)
-{
-	FILE *f;
-	char *buf;
-	bool in_class;
-	int i, j;
-	oclass curclass, *cc;
-
-	buf = malloc(4097);
-	if (buf==NULL)
-		exit(1);
-
-	if (argc < 2)
-	{
-		f = stdin;
-	}
-	else
-	{
-		f = fopen(argv[1], "r");
-		if (f == NULL)
-			exit(1);
-	}
-
-	printf("#include \"fsck.h\"\n\n");
-
-	in_class = false;
-	while (1)
-	{
-		member curmember, *cm = &curmember;
-		
-		memset(cm, 0, sizeof(member));
-		if (fgets(buf, 4097, f) == NULL)
-			break;
-		if (strstr(buf, "// CLASS"))
-		{
-			char *tmp, *tmp2, *tmp3;
-			in_class = true;
-			tmp = strstr(buf, "typedef");
-			if ((tmp3 = strstr(tmp, "struct")) == NULL)
-				tmp = strstr(tmp, "union");
-			else
-				tmp = tmp3;
-			tmp = strstr(tmp, "_");
-			tmp2 = ++tmp;
-			while (isalnum(*tmp2) || *tmp2=='_')
-				tmp2++;
-			*tmp2 = '\0';
-			curclass.name = strdup(tmp);
-			curclass.num_members = 0;
-			curclass.max_members = 0;
-			curclass.members = NULL;
-			cc = add_class(&curclass);
-		}
-		else if (strstr(buf, "// END CLASS"))
-		{
-			in_class = false;
-			cc = NULL;
-		}
-		else if (strstr(buf, "// DISKLOCK"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("disklock");
-		}
-		else if (strstr(buf, "// IPCONFIG"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("ipconfig");
-		}
-		else if (strstr(buf, "// GUID"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("guid");
-		}
-		else if (strstr(buf, "// ATTRIBS"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("attribs");
-		}
-		else if (strstr(buf, "// BOOL"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("bool");
-		}
-		else if (strstr(buf, "// CLUSTERSIZE"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("clustersize");
-		}
-		else if (strstr(buf, "// DATE"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("date");
-		}
-		else if (strstr(buf, "// DIRFLAG"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("dirflag");
-		}
-		else if (strstr(buf, "// DIRINDEX"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("dirindex");
-		}
-		else if (strstr(buf, "// DIRNODEINDEX"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("dirnodeindex");
-		}
-		else if (strstr(buf, "// DISKPTR"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("diskptr");
-		}
-		else if (strstr(buf, "// EXTENTTYPE"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("extenttype");
-		}
-		else if (strstr(buf, "// FILEFLAG"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("fileflag");
-		}
-		else if (strstr(buf, "// GID"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("gid");
-		}
-		else if (strstr(buf, "// LOCKLEVEL"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("locklevel");
-		}
-		else if (strstr(buf, "// NODEBITMAP"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("nodebitmap");
-		}
-		else if (strstr(buf, "// NODENUM"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("nodenum");
-		}
-		else if (strstr(buf, "// PERMS"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("perms");
-		}
-		else if (strstr(buf, "// SYNCFLAG"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("syncflag");
-		}
-		else if (strstr(buf, "// UID"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("uid");
-		}
-		else if (strstr(buf, "// UNUSED"))
-		{
-			// do nothing
-		}
-		else if (strstr(buf, "// EXTENT["))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("extent_array");
-		}
-		else if (strstr(buf, "// CHAR"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("char_array");
-		}
-		else if (strstr(buf, "// HEX"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("hex_array");
-		}
-		else if (strstr(buf, "// VOTEFLAG"))
-		{
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("voteflag_array");
-		}
-		else if (strstr(buf, "// NUMBER RANGE"))
-		{
-			char *tmp1,*tmp2;
-			tmp1 = strstr(buf, "RANGE");
-			tmp1 = strstr(tmp1, "(");
-			tmp2 = ++tmp1;
-			while (*tmp2!=',')
-				tmp2++;
-			cm->lo = strndup(tmp1, tmp2-tmp1);
-			tmp1 = ++tmp2;
-			while (*tmp2!=')')
-				tmp2++;
-			cm->hi = strndup(tmp1, tmp2-tmp1);
-			get_type_and_name(buf, cm);
-			cm = add_member(cc, cm);
-			cm->flavor = strdup("number_range");
-		}
-	}
-
-	for (i=0; i<num_classes; i++)
-		print_one_class(&(classes[i]));
-	
-	printf("ocfs_class *ocfs_all_classes[] = {\n");
-	
-	for (i=0; i<num_classes; i++)
-		printf("\t&(%s_class),\n", classes[i].name);
-
-	printf("};\n");
-	printf("int ocfs_num_classes = %d;\n", num_classes);
-
-	exit(0);	
-}
-int print_one_class(oclass *cl)
-{
-	int i;
-
-	printf("static ocfs_class_member %s_members[] = {\n", cl->name);
-	for (i=0; i<cl->num_members; i++)
-	{
-		member *m = &(cl->members[i]);
-		print_one_member(cl, m, NULL);
-	}
-	printf("};\n");
-
-	printf("ocfs_class %s_class = {\n", cl->name);
-	printf("\t\"%s\", \n", cl->name);
-	printf("\tsizeof(%s_members) / sizeof(ocfs_class_member), \n", cl->name);
-	printf("\t%s_members\n", cl->name);
-	printf("};\n");
-}
-
-int get_const_array_size(char *name)
-{
-	int ret;
-	char buf[200];
-	FILE *pipe;
-	
-	memset(buf, 0, 200);
-	sprintf(buf, "./mkgetconst \"%s\"", name);
-
-	pipe = popen(buf, "r");
-	if (pipe==NULL)
-		return 0;
-	ret = fread(buf, 200, 1, pipe);
-	buf[199] = '\0';
-	pclose(pipe);
-	ret = atoi(buf);
-
-	return ret;
-}
-
-int print_one_member(oclass *cl, member *m, char *prefix)
-{
-	int l, k, j, i;
-	base_type *this_type = NULL;
-
-	for (k=0; k<num_known; k++)
-	{
-		if (strcmp(known_types[k].name, m->type)==0 || 
-		    (strlen(m->type)>2 && strcmp(known_types[k].name, &(m->type[2]))==0 &&
-			  m->type[0]=='_' && m->type[1]=='_' ))
-		{
-			this_type = &(known_types[k]);
-			break;
-		}
-	}
-	
-	if (this_type == NULL)
-	{
-		if (prefix == NULL)
-		{
-			// TODO: get each of the subtype fields and print them here	
-			for (i=0; i<num_classes; i++)
-			{
-				oclass *subcl;
-				subcl = &(classes[i]);
-				if (strcmp(subcl->name, m->type)==0)
-				{
-					if (m->array_size)
-					{
-						char arrname[50];
-						int asz;
-					        asz = atoi(m->array_size);
-						if (asz==0)
-						{
-							asz = get_const_array_size(m->array_size);
-							// char *env_sz = getenv(m->array_size);
-							if (asz == 0)
-								exit(1);
-						}
-
-						for (l=0; l<asz; l++)
-						{
-							sprintf(arrname, "%s[%d]", m->name, l);
-							for (j=0; j<subcl->num_members; j++)
-								print_one_member(cl, &(subcl->members[j]), arrname);
-						}
-					}
-					else
-					{
-						for (j=0; j<subcl->num_members; j++)
-							print_one_member(cl, &(subcl->members[j]), m->name);
-					}
-					return 0;
-				}
-			}
-		}
-		// either 2 levels deep or failed to find class
-		exit(1);
-	}
-	
-	// open member
-	printf("\t{\n");
-	
-	// name
-	if (prefix)
-		printf("\t\t\"%s.%s\", ", prefix, m->name);
-	else
-		printf("\t\t\"%s\", ", m->name);
-		
-	// flavor
-	printf("\"%s\",\n", m->flavor);
-	
-	// typeinfo: { off, array_size, type_size, is_signed, lo, hi }
-	if (prefix)
-		printf("\t\t{ G_STRUCT_OFFSET(%s, %s.%s), ", cl->name, prefix, m->name);
-	else
-		printf("\t\t{ G_STRUCT_OFFSET(%s, %s), ", cl->name, m->name);
-	printf("%s, ", m->array_size ? m->array_size : "0");
-	printf("%d, ", this_type->size);
-	printf("%s, ", this_type->is_signed ? "true" : "false");
-	if (m->lo && m->hi)
-		printf("%s, %s },\n", m->lo, m->hi);
-	else
-		printf("0, 0 },\n");
-
-	// valid
-	printf("\t\t_%s_valid, ", m->flavor);
-
-	// to_string
-	printf("_%s_to_string_%s, ",  m->flavor, this_type->name);
-
-	// from_string
-	printf("_string_to_%s_%s, ",  m->flavor, this_type->name);
-
-	// helptext
-	printf("_get_%s_helptext", m->flavor);
-
-	// close member	
-	printf("\n\t},\n");
-	return 0;
-}
-
-void get_type_and_name(char *str, member *m)
-{
-	char *tmp, *tmp2, *tmp3;
-
-	tmp = str;
-	while (*tmp != ';')
-		tmp++;
-	*tmp = '\0';
-	tmp--;
-	while (isalnum(*tmp) || *tmp=='[' || *tmp==']' || *tmp=='_' || *tmp=='+')
-		tmp--;
-	tmp++;
-	if ((tmp2=strchr(tmp, '[')) != NULL)
-	{
-		tmp3 = ++tmp2;
-		while (*tmp3 != ']')
-			tmp3++;
-		*tmp3 = '\0';
-		m->array_size = strdup(tmp2);
-		*(--tmp2) = '\0';
-	}
-	m->name = strdup(tmp);
-	tmp--;
-	tmp2 = str;
-	while (isspace(*tmp2))
-		tmp2++;
-	while (isspace(*tmp))
-		tmp--;
-	*(++tmp) = '\0';
-	m->type = strdup(tmp2);
-}

Copied: trunk/fsck/parse.c (from rev 205, trunk/ocfs/fsck/parse.c)

Deleted: trunk/fsck/sig.c
===================================================================
--- trunk/ocfs/fsck/sig.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/sig.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,131 +0,0 @@
-/*
- * sig.c
- *
- * class signature checking for ocfs file system check utility
- *
- * Copyright (C) 2002, 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Author: Kurt Hackel, Sunil Mushran
- */
-
-#include "fsck.h"
-
-
-int nodecfghdr_sig_match (char *buf, int idx)
-{
-	ocfs_node_config_hdr *hdr = (ocfs_node_config_hdr *)buf;
-	if (!strncmp (hdr->signature, NODE_CONFIG_HDR_SIGN, NODE_CONFIG_SIGN_LEN))
-		return 0;
-	return -EINVAL;
-}
-
-int cleanup_log_sig_match (char *buf, int idx)
-{
-	return 0;
-}
-
-int dir_alloc_bitmap_sig_match (char *buf, int idx)
-{
-	return 0;
-}
-
-int dir_alloc_sig_match (char *buf, int idx)
-{
-	return 0;
-}
-
-int vol_disk_header_sig_match  (char *buf, int idx)
-{
-	ocfs_vol_disk_hdr *hdr = (ocfs_vol_disk_hdr *)buf;
-	if (memcmp (hdr->signature, OCFS_VOLUME_SIGNATURE,
-		    strlen (OCFS_VOLUME_SIGNATURE)) == 0)
-		return 0;
-	return -EINVAL;
-}
-
-int disk_lock_sig_match (char *buf, int idx)
-{
-	return 0;
-}
-
-int file_alloc_bitmap_sig_match (char *buf, int idx)
-{
-	return 0;
-}
-
-int file_alloc_sig_match (char *buf, int idx)
-{
-	return 0;
-}
-
-int publish_sector_sig_match (char *buf, int idx)
-{
-	return 0;
-}
-
-int recover_log_sig_match (char *buf, int idx)
-{
-	return 0;
-}
-
-int vol_metadata_log_sig_match (char *buf, int idx)
-{
-	return 0;
-}
-
-int vol_metadata_sig_match (char *buf, int idx)
-{
-	return 0;
-}
-
-int vote_sector_sig_match (char *buf, int idx)
-{
-	return 0;
-}
-
-int dir_node_sig_match (char *buf, int idx)
-{
-	ocfs_dir_node *dir = (ocfs_dir_node *)buf;
-	if (IS_VALID_DIR_NODE(dir))
-		return 0;
-	return -EINVAL;
-}
-
-int file_entry_sig_match (char *buf, int idx)
-{
-	ocfs_file_entry *fe = (ocfs_file_entry *)buf;
-	if (IS_VALID_FILE_ENTRY(fe))
-		return 0;
-	return -EINVAL;
-}
-
-int extent_header_sig_match (char *buf, int idx)
-{
-	ocfs_extent_group *ext = (ocfs_extent_group *)buf;
-	if (IS_VALID_EXTENT_HEADER(ext))
-		return 0;
-	return -EINVAL;
-}
-
-int extent_data_sig_match (char *buf, int idx)
-{
-	ocfs_extent_group *ext = (ocfs_extent_group *)buf;
-	if (IS_VALID_EXTENT_DATA(ext))
-		return 0;
-	return -EINVAL;
-}

Copied: trunk/fsck/sig.c (from rev 205, trunk/ocfs/fsck/sig.c)

Deleted: trunk/fsck/sig.h
===================================================================
--- trunk/ocfs/fsck/sig.h	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/sig.h	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,47 +0,0 @@
-/*
- * sig.h
- *
- * Function prototypes, macros, etc. for related 'C' files
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#ifndef SIG_H
-#define SIG_H
-
-int nodecfghdr_sig_match (char *buf, int idx);
-int cleanup_log_sig_match (char *buf, int idx);
-int dir_alloc_bitmap_sig_match (char *buf, int idx);
-int dir_alloc_sig_match (char *buf, int idx);
-int vol_disk_header_sig_match  (char *buf, int idx);
-int disk_lock_sig_match (char *buf, int idx);
-int file_alloc_bitmap_sig_match (char *buf, int idx);
-int file_alloc_sig_match (char *buf, int idx);
-int publish_sector_sig_match (char *buf, int idx);
-int recover_log_sig_match (char *buf, int idx);
-int vol_metadata_log_sig_match (char *buf, int idx);
-int vol_metadata_sig_match (char *buf, int idx);
-int vote_sector_sig_match (char *buf, int idx);
-int dir_node_sig_match (char *buf, int idx);
-int file_entry_sig_match (char *buf, int idx);
-int extent_header_sig_match (char *buf, int idx);
-int extent_data_sig_match (char *buf, int idx);
-
-#endif /* SIG_H */

Copied: trunk/fsck/sig.h (from rev 205, trunk/ocfs/fsck/sig.h)

Deleted: trunk/fsck/utils.c
===================================================================
--- trunk/ocfs/fsck/utils.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/utils.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,1700 +0,0 @@
-/*
- * utils.c
- *
- * ocfs file system check utility
- *
- * Copyright (C) 2003, 2004 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#include "fsck.h"
-
-extern ocfsck_context ctxt;
-extern char *usage_str; 
-
-extern int prn_len;
-extern int cnt_err;
-extern int cnt_wrn;
-extern int cnt_obj;
-extern bool int_err;
-extern bool prn_err;
-
-extern __u32 fs_num;
-
-/*
- * usage()
- *
- */
-void usage(void)
-{
-	printf("%s\n", usage_str);
-}				/* usage */
-
-void init_global_context(void)
-{
-	char *tmp;
-
-	memset(&OcfsGlobalCtxt, 0, sizeof(ocfs_global_ctxt));
-	OcfsGlobalCtxt.obj_id.type = OCFS_TYPE_GLOBAL_DATA;
-	OcfsGlobalCtxt.obj_id.size = sizeof (ocfs_global_ctxt);
-	OcfsGlobalCtxt.pref_node_num = 31;
-	OcfsGlobalCtxt.node_name = "user-tool";
-	OcfsGlobalCtxt.comm_info.type = OCFS_UDP;
-	OcfsGlobalCtxt.comm_info.ip_addr = "0.0.0.0";
-	OcfsGlobalCtxt.comm_info.ip_port = OCFS_IPC_DEFAULT_PORT;
-	OcfsGlobalCtxt.comm_info.ip_mask = NULL;
-	OcfsGlobalCtxt.comm_info_read = true;
-	memset(&OcfsGlobalCtxt.guid.id.host_id, 'f', HOSTID_LEN);
-	memset(&OcfsGlobalCtxt.guid.id.mac_id,  '0', MACID_LEN);
-
-	tmp = getenv("debug_level");
-	if (tmp)
-		debug_level = atoi(tmp);
-	tmp = getenv("debug_context");
-	if (tmp)
-		debug_context = atoi(tmp);
-	tmp = getenv("debug_exclude");
-	if (tmp)
-		debug_exclude = atoi(tmp);
-}
-
-
-/*
- * confirm_changes()
- *
- */
-int confirm_changes(__u64 off, ocfs_disk_structure *s, char *buf, int idx, GHashTable *bad)
-{
-	int ret = -1;
-	char *yesno, *loc;
-	int fd = ctxt.fd;
-
-	yesno = malloc(USER_INPUT_MAX);
-	if (!yesno) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	if (s->output(buf, idx, bad, stdout)==-1) {
-		//fprintf(stderr, "at least one bad field found\n");
-	}
-
-	printf("\n\nDo you really want to write your changes out? : ");
-
-	if (fgets(yesno, USER_INPUT_MAX, stdin) == NULL) {
-		ret = -1;
-		goto bail;
-	}
-
-	if ((loc = rindex(yesno, '\n')) != NULL)
-		*loc = '\0';
-
-       	if (strcasecmp(yesno, "yes")==0 || strcasecmp(yesno, "y")==0) {
-		if ((ret = s->write(fd, buf, off, idx)) == -1) {
-			LOG_INTERNAL();
-			goto bail;
-		}
-		else {
-			GHashTable *tmp = NULL;
-			ret = s->verify(fd, buf, off, idx, &tmp);
-			if (tmp != NULL)
-				g_hash_table_destroy(tmp);
-		}
-	}
-
-bail:
-	safefree(yesno);
-	return ret;
-}				/* confirm_changes */
-
-static char *saved_block = NULL;
-/*
- * read_print_struct()
- *
- */
-int read_print_struct(ocfs_disk_structure *s, char *buf, __u64 off, int idx, GHashTable **bad)
-{
-	int ret = 0;
-	int fd = ctxt.fd;
-	
-	if (saved_block == NULL)
-		saved_block = malloc(512);
-
-	if (saved_block == NULL)
-		return -1;
-
-	if (s->read(fd, buf, off, idx)==-1) {
-		LOG_ERROR("failed to read data");
-		return -2;
-	}
-
-	memcpy(saved_block, buf, 512);
-
-	if (s->sig_match) {
-		if (s->sig_match(buf, idx)==-EINVAL) {
-			LOG_ERROR("Bad signature found");
-			ret = -1;
-		}
-	}
-
-	if (s->verify(fd, buf, off, idx, bad)==-1) {
-		LOG_ERROR("structure failed verification");
-		ret = -1;
-	}
-
-	if (ret == -1 || (ret == 0 && ctxt.verbose)) {
-		if (s->output(buf, idx, *bad, stdout)==-1) {
-			//fprintf(stderr, "at least one bad field found\n");
-			//ret = -1;
-		}
-	}
-
-	return ret;
-}				/* read_print_struct */
-
-
-/*
- * get_device_size()
- *
- */
-int get_device_size(int fd)
-{
-	int ret = -1;
-	__u32 numblks;
-	struct stat buf;
-
-	if (fstat(fd, &buf) == -1) {
-		printf("%s: %s\n", ctxt.device, strerror(errno));
-		goto bail;
-	}
-
-	if (ctxt.dev_is_file) {		/* used during testing */
-		ctxt.device_size = buf.st_size;
-		goto finito;
-	} else if (S_ISCHR(buf.st_mode)) {
-		char *junk = NULL;
-		__u64 hi, lo, new, delta, last;
-		int ret;
-
-		junk = malloc_aligned(512);
-		if (!junk) {
-			LOG_INTERNAL();
-			goto bail;
-		}
-		hi = 0xfffffffffffffd00;
-		lo = 0ULL;
-		new = hi >> 1;
-
-		ctxt.device_size = 0;
-		do {
-			last = new;
-			myseek64(fd, new, SEEK_SET);
-			ret = read(fd, junk, 512);
-			if (ret == 512) {
-				/* go higher */
-				ctxt.device_size = (new + 512);
-				lo = new;
-				delta = (hi - lo) >> 1;
-				new = hi - delta;
-				new &= 0xfffffffffffffd00;
-			} else {
-				/* go lower */
-				hi = new;
-				delta = (hi - lo) >> 1;
-				new = lo + delta;
-				new &= 0xfffffffffffffd00;
-			}
-			
-			if (last == new || hi <= lo)
-				break;
-		} while (1);
-		while (ret == 512)
-		{
-			ctxt.device_size = (new + 512);
-			myseek64(fd, new, SEEK_SET);
-			ret = read(fd, junk, 512);
-			new += 512;
-		}
-		free_aligned(junk);
-		goto finito;
-	} else {
-		if (ioctl(fd, BLKGETSIZE, &numblks) == -1) {
-			printf("%s: %s\n", ctxt.device, strerror(errno));
-			goto bail;
-		} 
-		ctxt.device_size = numblks;
-		ctxt.device_size *= OCFS_SECTOR_SIZE;
-		goto finito;
-	}
-
-finito:
-	ret = 0;
-bail:
-	return ret;
-}				/* get_device_size */
-
-
-void handle_signal(int sig)
-{
-    switch (sig) {
-    case SIGTERM:
-    case SIGINT:
-	myclose(ctxt.fd);
-	unbind_raw(ctxt.raw_minor);
-	exit(1);
-    }
-}
-
-
-/*
- * check_heart_beat()
- *
- */
-int check_heart_beat(int *file, __u64 publ_off, __u32 sect_size)
-{
-	char *publish = NULL;
-	ocfs_super osb;
-	int ret = 0;
-	int i;
-	int waittime;
-	char *node_names[OCFS_MAXIMUM_NODES];
-	__u32 nodemap;
-
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
-		node_names[i] = NULL;
-
-	memset (&osb, 0, sizeof(ocfs_super));
-
-	if (!read_publish(*file, publ_off, sect_size, (void **)&publish)) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	/* alloc osb and pop sect_size */
-	osb.sect_size = sect_size;
-
-        /* call ocfs_update_publish_map(first_time = true) */
-	ocfs_update_publish_map (&osb, (void *)publish, true);
-
-	/* sleep(OCFS_NM_HEARTBEAT_TIME * 10) */
-	printf("Checking heart beat on volume ");
-	waittime = (OCFS_NM_HEARTBEAT_TIME/1000);
-	waittime = (waittime ? waittime : 1);
-	for (i = 0; i < OCFS_HBT_WAIT; ++i) {
-		printf(".");
-		fflush(stdout);
-		sleep(waittime);
-	}
-   
-	/* Close and re-open device to force disk read */
-	myclose(*file);
-
-	if ((*file = myopen(ctxt.raw_device, ctxt.flags)) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	memset (publish, 0, sect_size);
-	if (!read_publish(*file, publ_off, sect_size, (void **)&publish)) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	/* call ocfs_update_publish_map(first_time = false) */
-	ocfs_update_publish_map (&osb, (void *)publish, false);
-
-	printf("\r                                                \r");
-	fflush(stdout);
-
-	/* OCFS currently supports upto 32 nodes */
-	nodemap = LO(osb.publ_map);
-	if (!nodemap)
-		goto success;
-
-	/* Get names of all the nodes */
-	get_node_names(*file, ctxt.hdr, node_names, sect_size);
-
-	/* Prints the ones which are mounted */
-	printf("%s is mounted on nodes:", ctxt.device);
-	print_node_names(node_names, nodemap);
-
-	if (ctxt.write_changes) {
-		ctxt.write_changes = false;
-		printf("umount volume on node(s) before running fsck -w\n");
-		printf("Continuing in read-only mode\n");
-	}
-
-	printf("As %s is mounted on one or more nodes, fsck.ocfs may "
-	       "display false-positive errors\n", ctxt.device);
-
-success:
-	ret = 1;
-bail:
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
-		free(node_names[i]);
-
-	free_aligned(publish);
-	return ret;
-}				/* check_heart_beat */
-
-/*
- * read_publish()
- *
- */
-int read_publish(int file, __u64 publ_off, __u32 sect_size, void **buf)
-{
-	int ret = 0;
-	__u32 pub_len;
-
-	pub_len = OCFS_MAXIMUM_NODES * sect_size;
-
-	if (!*buf) {
-		if (!(*buf = malloc_aligned(pub_len))) {
-			LOG_INTERNAL();
-			goto bail;
-		}
-	}
-
-	if (myseek64(file, publ_off, SEEK_SET) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	if (myread(file, *buf, pub_len) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-			
-	ret = 1;
-
-bail:
-	return ret;
-}				/* read_publish */
-
-/*
- * get_node_names()
- *
- */
-int get_node_names(int file, ocfs_vol_disk_hdr *volhdr, char **node_names,
-		   __u32 sect_size)
-{
-	char *buf = NULL;
-	char *p;
-	int len;
-	int ret = 0;
-	int i;
-	ocfs_disk_node_config_info *conf;
-
-	len = volhdr->node_cfg_size;
-	if (!(buf = (char *) malloc_aligned(len))) {
-		LOG_INTERNAL();
-		goto bail;
-	} else
-		memset(buf, 0, len);
-
-	if (myseek64(file, volhdr->node_cfg_off, SEEK_SET) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	if (myread(file, buf, len) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	p = buf + (sect_size * 2);
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i, p += sect_size) {
-		conf = (ocfs_disk_node_config_info *)p;
-		if (conf->node_name[0])
-			node_names[i] = strdup(conf->node_name);
-	}
-
-	ret = 1;
-bail:
-	free_aligned(buf);
-	return ret;
-}				/* get_node_names */
-
-
-/*
- * print_node_names()
- *
- */
-void print_node_names(char **node_names, __u32 nodemap)
-{
-	int i, j;
-	char comma = '\0';
-
-	for (j = 1, i = 0; i < OCFS_MAXIMUM_NODES; ++i, j <<= 1) {
-		if (nodemap & j) {
-			if (node_names[i])
-				printf("%c %s", comma, node_names[i]);
-			else
-				printf("%c %d", comma, i);
-			comma = ',';
-		}
-	}
-	printf("\n");
-}				/* print_node_names */
-
-/*
- * print_gbl_alloc_errs()
- *
- */
-void print_gbl_alloc_errs(void)
-{
-	bitmap_data *bm1;
-	bitmap_data *bm2;
-	str_data *s1;
-	str_data *s2;
-	GArray *cbl = NULL;
-	__u32 i, j, k;
-	GArray *files = NULL;
-	GString *gs = NULL;
-	char *newstr = NULL;
-
-	files = g_array_new(false, true, sizeof(__u32));
-	cbl = g_array_new(false, true, sizeof(str_data));
-	gs = g_string_new (NULL);
-
-	/* walk the list and check for any duplicates */
-	for (i = 0; i < ctxt.vol_bm_data->len;) {
-		bm1 = &(g_array_index(ctxt.vol_bm_data, bitmap_data, i));
-		for (k = 0, j = i + 1; j < ctxt.vol_bm_data->len; ++j, ++k) {
-			bm2 = &(g_array_index(ctxt.vol_bm_data, bitmap_data, j));
-			if (bm2->bitnum == bm1->bitnum) {
-				if (!ctxt.verbose)
-					g_array_append_val(files, bm2->fnum);
-				else {
-					newstr = g_strdup_printf(", %u.%u",
-								 HILO(bm2->parent_off));
-					g_string_append (gs, newstr);
-					safefree(newstr);
-				}
-				continue;
-			} else
-				break;
-		}
-		if (k) {
-			if (!ctxt.verbose)
-				g_array_append_val(files, bm1->fnum);
-			else {
-				newstr = g_strdup_printf("%u.%u", HILO(bm1->parent_off));
-				g_string_prepend(gs, newstr);
-				add_str_data(cbl, bm1->bitnum, gs->str);
-				safefree(newstr);
-				if (gs) {
-					g_string_free(gs, true);
-					gs = g_string_new (NULL);
-				}
-			}
-		}
-		i += k + 1;
-	}
-
-	if (files->len || cbl->len)
-		LOG_ERROR("Global bitmap corruption detected");
-	else
-		goto bail;
-
-	if (ctxt.verbose) {
-		for (i = 0; i < cbl->len;) {
-			s1 = &(g_array_index(cbl, str_data, i));
-			for (k = 0, j = i + 1; j < cbl->len; ++k, ++j) {
-				s2 = &(g_array_index(cbl, str_data, j));
-				if (s1->num + k + 1 != s2->num)
-					break;
-				if (strncmp(s1->str, s2->str, sizeof(s1->str)))
-					break;
-			}
-			if (k)
-				LOG_PRINT("Bits# %u-%u allocated to objects %s", s1->num, s1->num+k, s1->str);
-			else
-				LOG_PRINT("Bit# %u allocated to objects %s", s1->num, s1->str);
-			i += k + 1;
-		}
-		goto bail;
-	}
-
-	/* concise output */
-	LOG_PRINT("Global bitmap corruption involves the following objects:");
-	print_filenames(files);
-
-bail:
-	if (files)
-		g_array_free(files, true);
-	if (gs)
-		g_string_free(gs, true);
-	if (cbl) {
-		for (i = 0; i < cbl->len; ++i) {
-			s1 = &(g_array_index(cbl, str_data, i));
-			safefree(s1->str);
-		}
-		g_array_free(cbl, true);
-	}
-
-	return ;
-}				/* print_gbl_alloc_errs */
-
-/*
- * print_filenames()
- *
- */
-void print_filenames(GArray *files)
-{
-	str_data *fs;
-	__u32 num, oldnum;
-	__u32 i;
-
-	qsort(files->data, files->len, sizeof(__u32), &comp_nums);
-
-	num = oldnum = ULONG_MAX;
-	for (i = 0; i < files->len; ++i) {
-		num = g_array_index(files, __u32, i);
-		if (num != oldnum) {
-			fs = &(g_array_index(ctxt.filenames, str_data, num));
-			LOG_PRINT("%s", fs->str);
-			oldnum = num;
-		}
-	}
-}				/* print_filenames */
-
-/*
- * print_bit_ranges()
- *
- */
-void print_bit_ranges(GArray *bits, char *str1, char *str2)
-{
-	__u32 i, j, k;
-	__u32 bit1, bit2;
-	GString *gs = NULL;
-	char comma[3];
-	gchar newstr[50];
-
-	if (!bits)
-		goto bail;
-
-	gs = g_string_new (NULL);
-
-	*comma = '\0';
-	for (i = 0; i < bits->len;) {
-		bit1 = g_array_index(bits, __u32, i);
-		for (k = 0, j = i + 1; j < bits->len; ++k, ++j) {
-			bit2 = g_array_index(bits, __u32, j);
-			if (bit1 + k + 1 != bit2)
-				break;
-		}
-		if (k)
-			sprintf(newstr, "%s%u-%u", comma, bit1, bit1 + k);
-		else
-			sprintf(newstr, "%s%u", comma, bit1);
-		g_string_append (gs, newstr);
-		if (!i)
-			strcpy(comma, ", ");
-		i += k + 1;
-	}
-
-	LOG_PRINT("List of %s bits in the %s bitmap: %s", str1, str2, gs->str);
-
-bail:
-	if (gs)
-		g_string_free(gs, true);
-	return ;
-}				/* print_bit_ranges */
-
-/*
- * find_unset_bits()
- *
- */
-void find_unset_bits(__u8 *vol_bm, char *bitmap)
-{
-	__u32 i, j;
-	bitmap_data *bm;
-	GArray *bits = NULL;
-	GArray *files = NULL;
-	__u32 bitnum;
-	bitmap_data kbm;
-
-	bits = g_array_new(false, true, sizeof(__u32));
-	files = g_array_new(false, true, sizeof(__u32));
-
-	/* clearing all the allocated bits in the global bitmap */
-	for (i = 0; i < ctxt.vol_bm_data->len; ++i) {
-		bm = &(g_array_index(ctxt.vol_bm_data, bitmap_data, i));
-		j = __test_and_clear_bit(bm->bitnum, (unsigned long *)vol_bm);
-		if (!j) {
-			if (!test_bit(bm->bitnum, (unsigned long *)ctxt.vol_bm))
-				g_array_append_val(bits, bm->bitnum);
-		}
-	}
-
-	if (!bits->len)
-		goto bail;
-
-	LOG_WARNING("Global bitmap has unset bits");
-	print_bit_ranges(bits, "unset", bitmap);
-
-	for (i = 0; i < bits->len; ++i) {
-		bitnum = g_array_index(bits, __u32, i);
-
-		memset (&kbm, 0, sizeof(bitmap_data));
-		kbm.bitnum = bitnum;
-		kbm.alloc_node = OCFS_INVALID_NODE_NUM;
-		bm = bsearch(&kbm, ctxt.vol_bm_data->data, ctxt.vol_bm_data->len,
-			     sizeof(bitmap_data), &comp_bits);
-		g_array_append_val(files, bm->fnum);
-	}
-
-	LOG_PRINT("List of files affected by the unset bits:");
-	print_filenames(files);
-
-bail:
-	if (bits)
-		g_array_free(bits, true);
-	if (files)
-		g_array_free(files, true);
-	return ;
-}				/* find_unset_bits */
-
-/*
- * find_set_bits()
- *
- */
-void find_set_bits(__u8 *vol_bm, char *bitmap)
-{
-	__u32 i, j;
-	GArray *bits = NULL;
-
-	bits = g_array_new(false, true, sizeof(__u32));
-
-	/* The first 1MB in the bitmap is for the system fe's */
-	j = VOL_BITMAP_BYTES / ctxt.hdr->cluster_size;
-
-	for (i = j; i < ctxt.hdr->num_clusters; ++i) {
-		if (test_bit(i, (unsigned long *)vol_bm))
-			g_array_append_val(bits, i);
-	}
-
-	if (bits) {
-		LOG_WARNING("Unused bits (wasted space) detected in the global bitmap.");
-		print_bit_ranges(bits, "unused", bitmap);
-	}
-
-	if (bits)
-		g_array_free(bits, true);
-	return ;
-}				/* find_set_bits */
-
-/*
- * check_global_bitmap()
- *
- */
-int check_global_bitmap(int fd)
-{
-	int ret = -1;
-	__u8 *vol_bm = NULL;
-	
-	/* sorting the global bitmap data on alloc_node and bit_num */
-	qsort(ctxt.vol_bm_data->data, ctxt.vol_bm_data->len,
-	      sizeof(bitmap_data), &comp_bits);
-
-	print_gbl_alloc_errs();
-
-	/* make a temp copy of the volume bitmap */
-	if ((vol_bm = malloc_aligned(VOL_BITMAP_BYTES)) == NULL) {
-		LOG_INTERNAL();
-		goto bail;
-	} else
-		memcpy(vol_bm, ctxt.vol_bm, VOL_BITMAP_BYTES);
-
-	find_unset_bits(vol_bm, "global");
-
-//#ifdef STILL_DEBUGGING
-	/* cross check... ensure no bit in the global bitmap is set */
-	find_set_bits(vol_bm, "global");
-//#endif
-
-	ret = 0;
-bail:
-	free_aligned(vol_bm);
-	return ret;
-}				/* check_global_bitmap */
-
-
-/*
- * check_node_bitmaps()
- *
- * Checks extent and directory bitmaps for all nodes
- *
- */
-int check_node_bitmaps(int fd, GArray *bm_data, __u8 **node_bm,
-		       __u32 *node_bm_sz, char *str)
-{
-	int ret = -1;
-	bitmap_data *bm1;
-	bitmap_data *bm2;
-	__u8 *temp_bm[OCFS_MAXIMUM_NODES];
-	__u32 i;
-	__u32 j;
-
-	/* sorting the node bitmap data on alloc_node and bit_num */
-	qsort(bm_data->data, bm_data->len, sizeof(bitmap_data), &comp_bits);
-#ifdef STILL_DEBUGGING
-	for (i = 0; i < bm_data->len; ++i) {
-		bm1 = &(g_array_index(bm_data, bitmap_data, i));
-	}
-#endif
-	for (i = 0; i < bm_data->len; ++i) {
-		bm1 = &(g_array_index(bm_data, bitmap_data, i));
-		for (j = i + 1; j < bm_data->len; ++j) {
-			bm2 = &(g_array_index(bm_data, bitmap_data, j));
-			if (bm2->alloc_node != bm1->alloc_node)
-				break;
-			if (bm2->bitnum == bm1->bitnum) {
-				LOG_ERROR("Block %u.%u (bit# %u) allocated "
-					  "to %s %u.%u and %u.%u on node %u",
-					  HILO(bm1->fss_off), bm1->bitnum,
-					  str, HILO(bm1->parent_off),
-					  HILO(bm2->parent_off), bm1->alloc_node);
-				continue;
-			} else
-				break;
-		}
-	}
-
-	/* make a temp copy of the node bitmaps */
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i) {
-		if (!node_bm_sz[i]) {
-			temp_bm[i] = NULL;
-			continue;
-		}
-		if ((temp_bm[i] = malloc_aligned(node_bm_sz[i])) == NULL) {
-			LOG_INTERNAL();
-			goto bail;
-		} else
-			memcpy(temp_bm[i], node_bm[i], node_bm_sz[i]);
-	}
-
-	/* clearing all the allocated bits in the extent bitmap */
-	for (i = 0; i < bm_data->len; ++i) {
-		bm1 = &(g_array_index(bm_data, bitmap_data, i));
-		if (!temp_bm[bm1->alloc_node]) {
-			LOG_ERROR("%s bitmap for node %d not allocated but "
-				  "structure at offset %u.%u suggests otherwise",
-				  str, bm1->alloc_node, HILO(bm1->fss_off));
-			continue;
-		}
-		j = __test_and_clear_bit(bm1->bitnum, (unsigned long *)temp_bm[bm1->alloc_node]);
-		if (!j) {
-			if (!test_bit(bm1->bitnum, (unsigned long *)node_bm[bm1->alloc_node]))
-				LOG_ERROR("Bit %u is unset in the %s bitmap "
-					  "of node %d", bm1->bitnum, str,
-					  bm1->alloc_node);
-		}
-	}
-
-#ifdef STILL_DEBUGGING
-	/* cross check... ensure no bit in the extent/directory bitmap is set */
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i) {
-		if (!temp_bm[i])
-			continue;
-		len = node_bm_sz[i] * 8;
-		for (j = 0; j < len; ++j) {
-			if (test_bit(j, temp_bm[i]))
-				LOG_ERROR("Bit %u in the %s bitmap of node "
-					  "%d is unaccounted", j, str, i);
-		}
-	}
-#endif
-
-	ret = 0;
-bail:
-	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
-		free_aligned(temp_bm[i]);
-	return ret;
-}				/* check_node_bitmaps */
-
-/*
- * comp_nums()
- *
- */
-int comp_nums(const void *q1, const void *q2)
-{
-	__u32 *num1 = (__u32 *)q1;
-	__u32 *num2 = (__u32 *)q2;
-
-	return *num1 - *num2;
-}				/* comp_nums */
-
-
-
-/*
- * comp_bits()
- *
- */
-int comp_bits(const void *q1, const void *q2)
-{
-	bitmap_data *bm1 = (bitmap_data *)q1;
-	bitmap_data *bm2 = (bitmap_data *)q2;
-	__s32 ret;
-
-	ret = bm1->alloc_node - bm2->alloc_node;
-	if (!ret)
-		ret = bm1->bitnum - bm2->bitnum;
-
-	return ret;
-}				/* comp_bits */
-
-static int fe_compare_func(const void *m1, const void *m2);
-
-/* if we ever rewrite this as a shared library or 
- * parallelized fsck we will have to change this */
-ocfs_dir_node *globaldir = NULL;
-
-static int fe_compare_func(const void *m1, const void *m2)
-{
-	ocfs_file_entry *fe1, *fe2;
-	__u8 idx1, idx2;
-	int ret;
-
-	if (globaldir == NULL) {
-		LOG_INTERNAL();
-		exit(0);
-	}
-
-	idx1 = *(__u8 *)m1;
-	idx2 = *(__u8 *)m2;
-
-	fe1 = (ocfs_file_entry *) ((char *)FIRST_FILE_ENTRY(globaldir) + (idx1 * OCFS_SECTOR_SIZE));
-	fe2 = (ocfs_file_entry *) ((char *)FIRST_FILE_ENTRY(globaldir) + (idx2 * OCFS_SECTOR_SIZE));
-
-	if (IS_FE_DELETED(fe1->sync_flags) ||
-	    (!(fe1->sync_flags & OCFS_SYNC_FLAG_VALID)) ||
-	    IS_FE_DELETED(fe2->sync_flags) ||
-	    (!(fe2->sync_flags & OCFS_SYNC_FLAG_VALID)))
-		return 0;
-
-	ret = strncmp(fe1->filename, fe2->filename, 255);
-	
-	return -ret;
-}
-
-
-/*
- * traverse_dir_nodes()
- *
- */
-void traverse_dir_nodes(int fd, __u64 offset, char *dirpath)
-{
-	int i;
-	int ret;
-	char *dirbuf = NULL;
-	ocfs_file_entry *febuf = NULL;
-	__u64 dir_offset;
-	__u64 off;
-	ocfs_disk_structure *dirst;
-	ocfs_disk_structure *fest;
-	GHashTable *bad;
-	ocfs_dir_node *dir;
-   
-	dirst = &dirnode_t;
-	fest = &fileent_t;
-	bad = NULL;
-
-	if ((dirbuf = malloc_aligned(DIR_NODE_SIZE)) == NULL) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	if ((febuf = (ocfs_file_entry *) malloc_aligned(OCFS_SECTOR_SIZE)) == NULL) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	dir_offset = offset;
-	dir = (ocfs_dir_node *)dirbuf;
-
-	CLEAR_AND_PRINT(dirpath);
-
-	while (1) {
-		ret = read_print_struct(dirst, dirbuf, dir_offset, 0, &bad);
-
-		if (bad)
-			g_hash_table_destroy(bad);
-
-		if (ret == -1) {
-			LOG_ERROR("failed to read directory at offset %u.%u",
-				  HILO(dir_offset));
-			goto bail;
-		}
-
-		/* Add bitmap entry for the dirnode itself */
-		add_bm_data(dir->alloc_file_off, 1, dir->alloc_node, 
-			    dir_offset,
-			    (dir->alloc_node == OCFS_INVALID_NODE_NUM ? bm_global : bm_dir));
-
-		for (i = 0; i < dir->num_ent_used; i++) {
-			off = dir_offset;
-			off += OCFS_SECTOR_SIZE;	/* move past the dirnode header */
-			off += (OCFS_SECTOR_SIZE * dir->index[i]);
-
-			ret = read_print_struct(fest, (char *)febuf, off, 0, &bad);
-			if (bad)
-				g_hash_table_destroy(bad);
-			if (ret == -1) {
-				LOG_ERROR("failed to read file entry at offset %u.%u",
-					  HILO(off));
-				continue;
-			}
-
-			if (!IS_FE_DELETED(febuf->sync_flags))
-				check_file_entry(fd, febuf, off, dir->index[i], false, dirpath);
-		}
-
-		/* is there another directory chained off of this one? */
-		if (dir->next_node_ptr == -1)
-			break;		/* nope, we're done */
-		else
-			dir_offset = dir->next_node_ptr;	/* keep going */
-	}
-
-bail:
-	free_aligned(dirbuf);
-	free_aligned(febuf);
-}				/* traverse_dir_nodes */
-
-/*
- * handle_one_cdsl_entry()
- *
- */
-void handle_one_cdsl_entry(int fd, ocfs_file_entry *fe, __u64 offset)
-{
-}				/* handle_one_cdsl_entry */
-
-
-/*
- * check_file_entry()
- *
- */
-void check_file_entry(int fd, ocfs_file_entry *fe, __u64 offset, int slot,
-		      bool systemfile, char *dirpath)
-{
-	void *buf = NULL;
-	int indx = 0;
-	int val = 0;
-	char *path = NULL;
-
-	if (systemfile)
-		val = 3;
-	else {
-		if (fe->attribs & OCFS_ATTRIB_FILE_CDSL)
-			val = 1;
-		else if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
-			val = 2;
-		else if (fe->attribs & (OCFS_ATTRIB_REG | OCFS_ATTRIB_SYMLINK))
-			val = 3;
-		else {
-			LOG_ERROR ("unknown attribs %x at offset %u.%u",
-				   fe->attribs, HILO(offset));
-			goto bail;
-		}
-	}
-
-	++cnt_obj;
-	if (val == 2)
-		path = g_strdup_printf("%s%s/", dirpath, fe->filename);
-	else
-		path = g_strdup_printf("%s%s", dirpath, fe->filename);
-
-	switch (val) {
-	case 1:
-		CLEAR_AND_PRINT(path);
-		handle_one_cdsl_entry(fd, fe, offset);
-		break;
-
-	case 2:
-		if (fe->extents[0].disk_off) {
-			handle_leaf_extents(fd, fe->extents, 1,
-				 	OCFS_INVALID_NODE_NUM, fe->this_sector);
-			traverse_dir_nodes(fd, fe->extents[0].disk_off, path);
-		} else
-			LOG_ERROR("Invalid dir entry at %u.%u", HILO(offset));
-		break;
-
-	case 3:
-		add_str_data(ctxt.filenames, fs_num, path);
-		fs_num++;
-
-		if (ctxt.verbose) {
-			safefree(path);
-			path = g_strdup_printf("%s%s\t(%d)", dirpath, fe->filename, slot);
-		}
-		CLEAR_AND_PRINT(path);
-
-		if (fe->local_ext)
-			handle_leaf_extents(fd, fe->extents,
-					    OCFS_MAX_FILE_ENTRY_EXTENTS,
-					    OCFS_INVALID_NODE_NUM, fe->this_sector);
-		else {
-			if ((buf = malloc_aligned(MAX_EXTENTS * OCFS_SECTOR_SIZE)) == NULL) {
-				LOG_INTERNAL();
-				goto bail;
-			}
-
-			traverse_fe_extents(fd, fe, buf, &indx);
-
-			/* check ext->next_data_ext */
-			check_next_data_ext(fe, buf, indx);
-
-			/* check fe->last_ext_ptr */
-			check_fe_last_data_ext(fe, buf, indx);
-		}
-		break;
-
-	default:
-		break;
-	}
-
-bail:
-	safefree(path);
-	free_aligned(buf);
-	return ;
-}				/* check_file_entry */
-
-/*
- * add_bm_data()
- *
- */
-bitmap_data * add_bm_data(__u64 start, __u64 len, __s32 alloc_node,
-			  __u64 parent_offset, int type)
-{
-	bitmap_data *bm = NULL;
-	__u32 bitnum = 0;
-	__u32 num = 0;
-	void *buf = NULL;
-	void *p;
-	int i;
-	__u32 fnum = 0;
-
-	switch (type) {
-	case bm_extent:
-		bitnum = start >> OCFS_LOG_SECTOR_SIZE;
-		num = len;
-		fnum = fs_num - 1;
-		break;
-
-	case bm_dir:
-		bitnum = start / OCFS_DEFAULT_DIR_NODE_SIZE;
-		num = len;
-		break;
-
-	case bm_symlink:
-		break;
-
-	case bm_global:
-	case bm_filedata:
-		bitnum = (start - ctxt.hdr->data_start_off) >>
-				ctxt.cluster_size_bits;
-		num = len >> ctxt.cluster_size_bits;
-		fnum = fs_num - 1;
-		break;
-
-	default:
-		break;
-	}
-
-	if (num == 0)
-		goto bail;
-
-	if (type == bm_global)
-		fnum = ULONG_MAX;
-
-	if ((buf = malloc(sizeof(bitmap_data) * num)) == NULL) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	for (i = 0, p = buf; i < num; ++i) {
-		bm = (bitmap_data *)p;
-		bm->bitnum = bitnum + i;
-		bm->fss_off = start;
-		bm->alloc_node = alloc_node;
-		bm->parent_off = parent_offset;
-		bm->fnum = fnum;
-		p += sizeof(bitmap_data);
-	}
-
-	bm = (bitmap_data *)buf;
-
-	switch (type) {
-	case bm_dir:
-		g_array_append_vals(ctxt.dir_bm_data, bm, num);
-		break;
-
-	case bm_extent:
-		g_array_append_vals(ctxt.ext_bm_data, bm, num);
-		break;
-
-	case bm_global:
-	case bm_filedata:
-		g_array_append_vals(ctxt.vol_bm_data, bm, num);
-		break;
-
-	default:
-		break;
-	}
-
-bail:
-	return bm;
-}				/* add_bm_data */
-
-/*
- * add_str_data()
- *
- */
-int add_str_data(GArray *sd, __u32 num, char *str)
-{
-	str_data *f;
-	
-	f = malloc(sizeof(str_data));
-	if (!f) {
-		LOG_INTERNAL();
-		return -1;
-	}
-
-	f->num = num;
-	f->str = strdup(str);
-	g_array_append_vals(sd, f, 1);
-
-	return 0;
-}				/* add_str_data */
-
-/*
- * handle_leaf_extents()
- *
- */
-int handle_leaf_extents (int fd, ocfs_alloc_ext *arr, int num, __u32 node,
-			 __u64 parent_offset)
-{
-	int i;
-	int ret = 0;
-
-	for (i = 0; i < num; i++) {
-		if (arr[i].disk_off)
-			if (!add_bm_data(arr[i].disk_off, arr[i].num_bytes,
-					 node, parent_offset, bm_filedata))
-				ret = -1;
-	}
-
-	return ret;
-}				/* handle_leaf_extents */
-
-
-/*
- * traverse_extent()
- *
- */
-void traverse_extent(int fd, ocfs_extent_group * exthdr, int flag, void *buf,
-		     int *indx)
-{
-	ocfs_extent_group *ext = NULL;
-	int i;
-	int j;
-	__u64 len;
-	int ret;
-	int type;
-	ocfs_disk_structure *disk_struct;
-	GHashTable *bad;
-
-	if (*indx >= MAX_EXTENTS) {
-		LOG_ERROR("Too many extents after ext=%u.%u",
-			  HILO(exthdr->this_ext));
-		goto bail;
-	}
-
-	for (i = 0; i < exthdr->next_free_ext; ++i) {
-		if (!exthdr->extents[i].disk_off)
-			continue;
-
-		ext = (ocfs_extent_group *) (buf + (*indx * OCFS_SECTOR_SIZE));
-		++*indx;
-
-		if (flag == OCFS_EXTENT_HEADER)
-			disk_struct = &exthdr_t;
-		else
-			disk_struct = &extdat_t;
-
-		ret = read_print_struct(disk_struct, (char *)ext,
-					exthdr->extents[i].disk_off, 0, &bad);
-
-		if (bad)
-			g_hash_table_destroy(bad);
-
-		if (ret == -1) {
-			LOG_ERROR("failed to read extent at offset %u.%u",
-				  HILO(exthdr->extents[i].disk_off));
-			goto bail;
-		}
-
-		/* check up_hdr_node_ptr */
-		if (exthdr->this_ext != ext->up_hdr_node_ptr) {
-			LOG_ERROR("up_hdr_node_ptr %u.%u in extent %u.%u "
-				  "should be %u.%u", HILO(ext->up_hdr_node_ptr),
-				  HILO(ext->this_ext), HILO(exthdr->this_ext));
-		}
-
-		/* check first file offset */
-		if (exthdr->extents[i].file_off != ext->extents[0].file_off) {
-			LOG_ERROR("extents[0].file_off=%u.%u in extent %u.%u "
-				  "should be %u.%u", HILO(ext->extents[0].file_off),
-				  HILO(ext->this_ext), HILO(exthdr->extents[i].file_off));
-		}
-
-		/* check total bytes */
-		for (j = 0, len = 0; j < OCFS_MAX_DATA_EXTENTS; j++)
-			len += ext->extents[j].num_bytes;
-
-		if (exthdr->extents[i].num_bytes != len) {
-			LOG_ERROR("total num_bytes in extent %u.%u is %u.%u "
-				  "but should be %u.%u", HILO(ext->this_ext),
-				  HILO(len), HILO(exthdr->extents[i].num_bytes));
-		}
-
-		/* Add bitmap entry for the extent itself */
-		add_bm_data(ext->alloc_file_off, 1, ext->alloc_node, ext->this_ext,
-			    bm_extent);
-
-		if (flag == OCFS_EXTENT_HEADER) {
-			type = ext->granularity ? OCFS_EXTENT_HEADER : OCFS_EXTENT_DATA;
-			traverse_extent(fd, ext, type, buf, indx);
-		} else {
-			handle_leaf_extents(fd, ext->extents, ext->next_free_ext,
-					    OCFS_INVALID_NODE_NUM, ext->this_ext);
-		}
-	}
-
-bail:
-	return ;
-}				/* traverse_extent */
-
-
-/*
- * traverse_fe_extents()
- *
- */
-void traverse_fe_extents(int fd, ocfs_file_entry *fe, void *buf, int *indx)
-{
-	int i;
-	int j;
-	int ret;
-	__u64 len;
-	ocfs_extent_group *ext = NULL;
-	int type;
-	ocfs_disk_structure *disk_struct;
-	GHashTable *bad;
-
-	if (*indx >= MAX_EXTENTS) {
-		LOG_ERROR("error too many extents in fe at offset %u.%u",
-			  HILO(fe->this_sector));
-		goto bail;
-	}
-
-	for (i = 0; i < fe->next_free_ext; i++) {
-		if (!fe->extents[i].disk_off)
-			continue;
-
-		ext = (ocfs_extent_group *) (buf + (*indx * OCFS_SECTOR_SIZE));
-		++*indx;
-
-		if (fe->granularity)
-			disk_struct = &exthdr_t;
-		else
-			disk_struct = &extdat_t;
-
-		ret = read_print_struct(disk_struct, (char *)ext, 
-					fe->extents[i].disk_off, 0, &bad);
-		if (bad)
-			g_hash_table_destroy(bad);
-
-		if (ret == -1) {
-			LOG_ERROR("failed to read extent at offset %u.%u",
-				  HILO(fe->extents[i].disk_off));
-			goto bail;
-		}
-
-		if (fe->this_sector != ext->up_hdr_node_ptr) {
-			LOG_ERROR("up_hdr_node_ptr %u.%u in extent %u.%u "
-				  "should be %u.%u", HILO(ext->up_hdr_node_ptr),
-				  HILO(ext->this_ext), HILO(fe->this_sector));
-		}
-
-		/* check first file offset */
-		if (fe->extents[i].file_off != ext->extents[0].file_off) {
-			LOG_ERROR("extents[0].file_off=%u.%u in extent %u.%u "
-				  "should be %u.%u", HILO(ext->extents[0].file_off),
-				  HILO(ext->this_ext), HILO(fe->extents[i].file_off));
-		}
-
-		/* check total bytes */
-		for (j = 0, len = 0; j < OCFS_MAX_DATA_EXTENTS; j++)
-			len += ext->extents[j].num_bytes;
-
-		if (fe->extents[i].num_bytes != len) {
-			LOG_ERROR("total num_bytes in extent %u.%u is %u.%u "
-				  "but should be %u.%u", HILO(ext->this_ext),
-				  HILO(len), HILO(fe->extents[i].num_bytes));
-		}
-
-		/* Add bitmap entry for the extent itself */
-		add_bm_data(ext->alloc_file_off, 1, ext->alloc_node, ext->this_ext,
-			    bm_extent);
-
-		if (fe->granularity) {
-			type = ext->granularity ? OCFS_EXTENT_HEADER : OCFS_EXTENT_DATA;
-			traverse_extent(fd, ext, type, buf, indx);
-		} else {
-			handle_leaf_extents(fd, ext->extents, ext->next_free_ext,
-					    OCFS_INVALID_NODE_NUM, ext->this_ext);
-		}
-	}
-
-bail:
-	return ;
-}				/* traverse_fe_extents */
-
-
-/*
- * check_next_data_ext()
- *
- */
-int check_next_data_ext(ocfs_file_entry *fe, void *buf, int indx)
-{
-	void *ptr;
-	int i;
-	__u64 next_data_ext;
-	ocfs_extent_group *ext;
-	int ret = 0;
-
-	ptr = buf + ((indx - 1) * OCFS_SECTOR_SIZE);
-
-	for (i = indx - 1, next_data_ext = 0; i >= 0; --i,
-	     ptr -= OCFS_SECTOR_SIZE) {
-		ext = (ocfs_extent_group *)ptr;
-
-		if (ext->type != OCFS_EXTENT_DATA)
-			continue;
-
-		if (ext->next_data_ext != next_data_ext) {
-			LOG_ERROR("ext->next_data_ext=%u.%u in extent "
-				  "%u.%u instead of %u.%u",
-				  HILO(ext->next_data_ext),
-				  HILO(ext->this_ext),
-				  HILO(next_data_ext));
-			ret = -1;
-		}
-		next_data_ext = ext->this_ext;
-	}
-
-	return ret;
-}				/* check_next_data_ext */
-
-/*
- * check_fe_last_data_ext()
- *
- */
-int check_fe_last_data_ext(ocfs_file_entry *fe, void *buf, int indx)
-{
-	ocfs_extent_group *ext;
-	int ret = 0;
-
-	ext = (ocfs_extent_group *) (buf + ((indx - 1) * OCFS_SECTOR_SIZE));
-
-	if (fe->last_ext_ptr != ext->this_ext) {
-		LOG_ERROR("fe->last_ext_ptr=%u.%u in fe %u.%u "
-			  "instead of %u.%u", HILO(fe->last_ext_ptr),
-			  HILO(fe->this_sector), HILO(ext->this_ext));
-		ret = -1;
-	}
-
-	return ret;
-}				/* check_fe_last_data_ext */
-
-/*
- * check_dir_index()
- *
- */
-int check_dir_index (char *dirbuf, __u64 dir_offset)
-{
-	ocfs_file_entry *fe = NULL;
-	ocfs_dir_node *dirnode = (ocfs_dir_node *)dirbuf;
-	int ret = 0;
-	__u8 i;
-	__u8 j;
-	__u8 offset;
-	__u8 ind1[256];
-	__u8 ind2[256];
-	ocfs_disk_structure *dirst = &dirnode_t;
-
-	memset(ind1, 0, 256);
-	memset(ind2, 0, 256);
-
-	/* Any erroneous/duplicates/deleted files in the index */
-	for (i = 0, j = 0; i < dirnode->num_ent_used; ++i) {
-		offset = dirnode->index[i];
-
-		/* erroneous */
-		if (offset > 253)
-			continue;
-
-		/* duplicates */
-		if (ind1[offset] == 0)
-			ind1[offset] = 1;
-		else
-			continue;
-
-		/* deleted */
-		fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirbuf) +
-					  (offset * OCFS_SECTOR_SIZE));
-		if (IS_FE_DELETED(fe->sync_flags))
-			continue;
-
-		/* good ones in ind2 */
-		ind2[j++] = offset;
-	}
-
-	/* Use new num_ents_used */
-	if (j != dirnode->num_ent_used) {
-		LOG_ERROR("Incorrect number of entries found in dirnode");
-		if (ctxt.write_changes) {
-			globaldir = dirnode;
-			qsort(ind2, j, sizeof(__u8), fe_compare_func);
-			memcpy(dirnode->index, ind2, 256);
-			dirnode->num_ent_used = j;
-
-			if (dirst->write(ctxt.fd, dirbuf, dir_offset, 0) == -1) {
-				LOG_INTERNAL();
-				exit(1);
-			} else
-				LOG_PRINT("Fixed");
-		} else
-			LOG_PRINT("To fix, rerun with -w");
-		goto bail;
-	}
-
-	/* Is the index in sorted order */
-	globaldir = dirnode;
-	memset(ind1, 0, 256);
-	memcpy(ind1, dirnode->index, dirnode->num_ent_used);
-	qsort(ind1, dirnode->num_ent_used, sizeof(__u8), fe_compare_func);
-
-	if (memcmp(ind1, dirnode->index, dirnode->num_ent_used) != 0) {
-		LOG_ERROR("Bad dir index found");
-		if (ctxt.write_changes) {
-			memcpy(dirnode->index, ind1, dirnode->num_ent_used);
-
-			if (dirst->write(ctxt.fd, dirbuf, dir_offset, 0) == -1) {
-				LOG_INTERNAL();
-				exit(1);
-			} else
-				LOG_PRINT("Fixed");
-		} else
-			LOG_PRINT("To fix, rerun with -w");
-	}
-bail:
-	return ret;
-}				/* check_dir_index */
-
-
-/*
- * check_num_del()
- *
- */
-int check_num_del (char *dirbuf, __u64 dir_offset)
-{
-	ocfs_file_entry *fe = NULL;
-	ocfs_dir_node *dirnode = (ocfs_dir_node *)dirbuf;
-	int i;
-	int j;
-	int ret = 0;
-	__u8 offset;
-	__u8 ind[256];
-
-	if (dirnode->num_del == 0 && dirnode->num_ent_used == 0)
-		goto bail;
-
-	if (dirnode->num_del == 0 && dirnode->num_ent_used > 0) {
-		memset(ind, 0, 256);
-		for (i = 0; i < dirnode->num_ent_used; ++i) {
-			if (dirnode->index[i] >= dirnode->num_ent_used) {
-				ret = -1;
-				break;
-			}
-		}
-		goto bail;
-	}
-
-	/* num_del > 0 && dirnode->num_ents_used > 0 */
-	memset(ind, 0, 256);
-
-	offset = dirnode->first_del;
-	for (i = 0; i < dirnode->num_del; ++i) {
-		if (offset > 253) {
-			ret = -1;
-			break;
-		}
-
-		/* check if offset is in index and hence invalid */
-		for (j = 0; j < dirnode->num_ent_used; ++j) {
-			if (dirnode->index[j] == offset) {
-				ret = -1;
-				break;
-			}
-		}
-
-		/* check for circular list */
-		if (ind[offset]) {
-			ret = -1;
-			break;
-		} else
-			ind[offset] = 1;
-
-		fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode) +
-					  (offset * OCFS_SECTOR_SIZE));
-
-		/* file has to be deleted to be in the list */
-		if (fe->sync_flags) {
-			ret = -1;
-			break;
-		}
-
-		offset = (__u8)fe->next_del;
-	}
-
-bail:
-	return ret;
-}				/* check_num_del */
-
-
-/*
- * fix_num_del()
- *	Should be called after check_num_del()
- */
-int fix_num_del (char *dirbuf, __u64 dir_offset)
-{
-	ocfs_dir_node *dirnode = (ocfs_dir_node *)dirbuf;
-	ocfs_file_entry *fe = NULL;
-	int i;
-	int j;
-	int num_del;
-	__u8 largest_off = 0;
-	__u8 ind[256];
-	__u8 offset;
-	__u64 feoff;
-	ocfs_disk_structure *dirst = &dirnode_t;
-	ocfs_disk_structure *fest = &fileent_t;
-
-	memset (ind, 0xFF, 256);
-	
-	/* largest offset in index */
-	for (i = 0; i < dirnode->num_ent_used; ++i)
-		largest_off = max(largest_off, dirnode->index[i]);
-
-	num_del = largest_off - dirnode->num_ent_used + 1;
-
-	if (!num_del)
-		goto bail;
-
-	fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode));
-
-	for (i = 0, j = 0; i < largest_off; ++i) {
-		if (IS_FE_DELETED(fe->sync_flags))
-			ind[j++] = i;
-		fe = (ocfs_file_entry *)((char *)fe + OCFS_SECTOR_SIZE);
-	}
-
-	if (j != num_del) {
-		LOG_ERROR("while fixing num_del");
-		exit(1);
-	}
-
-	/* write dirnode */
-	dirnode->num_del = num_del;
-	dirnode->first_del = ind[0];
-	if (dirst->write(ctxt.fd, dirbuf, dir_offset, 0) == -1) {
-		LOG_INTERNAL();
-		exit(1);
-	}
-
-	for (i = 0; i < j; ++i) {
-		offset = ind[i];
-		fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode) +
-					  (offset * OCFS_SECTOR_SIZE));
-		feoff = dir_offset + ((1 + offset) * OCFS_SECTOR_SIZE);
-		fe->next_del = ind[i+1];
-		/* write fe */
-		if (fest->write(ctxt.fd, (char *)fe, feoff, 0) == -1) {
-			LOG_INTERNAL();
-			exit(1);
-		}
-	}
-
-bail:
-	return 0;
-}				/* fix_num_del */
-
-/*
- * fix_fe_offsets()
- *
- */
-int fix_fe_offsets(char *dirbuf, __u64 dir_offset)
-{
-	ocfs_dir_node *dirnode = (ocfs_dir_node *)dirbuf;
-	ocfs_disk_structure *fest = &fileent_t;
-	ocfs_file_entry *fe;
-	__u64 feoff;
-	__u8 off;
-	int i;
-
-	for (i = 0; i < dirnode->num_ent_used; ++i) {
-		off = dirnode->index[i];
-		fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode) +
-					  (off * OCFS_SECTOR_SIZE));
-		feoff = dir_offset + ((1 + off) * OCFS_SECTOR_SIZE);
-
-		if (IS_FE_DELETED(fe->sync_flags)) {
-			LOG_INTERNAL();
-			exit(1);
-		}
-
-		if (fe->this_sector != feoff ||
-		    fe->dir_node_ptr != dir_offset) {
-			if (ctxt.write_changes) {
-				fe->this_sector = feoff;
-				fe->dir_node_ptr = dir_offset;
-				/* write fe */
-				if (fest->write(ctxt.fd, (char *)fe, feoff, 0) == -1) {
-					LOG_INTERNAL();
-					exit(1);
-				}
-			}
-		}
-	}
-
-	return 0;
-}				/* fix_fe_offsets */

Copied: trunk/fsck/utils.c (from rev 205, trunk/ocfs/fsck/utils.c)
===================================================================
--- trunk/ocfs/fsck/utils.c	2004-08-30 22:26:51 UTC (rev 205)
+++ trunk/fsck/utils.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -0,0 +1,1700 @@
+/*
+ * utils.c
+ *
+ * ocfs file system check utility
+ *
+ * Copyright (C) 2003, 2004 Oracle.  All rights reserved.
+ *
+ * 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 021110-1307, USA.
+ *
+ * Authors: Kurt Hackel, Sunil Mushran
+ */
+
+#include "fsck.h"
+
+extern ocfsck_context ctxt;
+extern char *usage_str; 
+
+extern int prn_len;
+extern int cnt_err;
+extern int cnt_wrn;
+extern int cnt_obj;
+extern bool int_err;
+extern bool prn_err;
+
+extern __u32 fs_num;
+
+/*
+ * usage()
+ *
+ */
+void usage(void)
+{
+	printf("%s\n", usage_str);
+}				/* usage */
+
+void init_global_context(void)
+{
+	char *tmp;
+
+	memset(&OcfsGlobalCtxt, 0, sizeof(ocfs_global_ctxt));
+	OcfsGlobalCtxt.obj_id.type = OCFS_TYPE_GLOBAL_DATA;
+	OcfsGlobalCtxt.obj_id.size = sizeof (ocfs_global_ctxt);
+	OcfsGlobalCtxt.pref_node_num = 31;
+	OcfsGlobalCtxt.node_name = "user-tool";
+	OcfsGlobalCtxt.comm_info.type = OCFS_UDP;
+	OcfsGlobalCtxt.comm_info.ip_addr = "0.0.0.0";
+	OcfsGlobalCtxt.comm_info.ip_port = OCFS_IPC_DEFAULT_PORT;
+	OcfsGlobalCtxt.comm_info.ip_mask = NULL;
+	OcfsGlobalCtxt.comm_info_read = true;
+	memset(&OcfsGlobalCtxt.guid.id.host_id, 'f', HOSTID_LEN);
+	memset(&OcfsGlobalCtxt.guid.id.mac_id,  '0', MACID_LEN);
+
+	tmp = getenv("debug_level");
+	if (tmp)
+		debug_level = atoi(tmp);
+	tmp = getenv("debug_context");
+	if (tmp)
+		debug_context = atoi(tmp);
+	tmp = getenv("debug_exclude");
+	if (tmp)
+		debug_exclude = atoi(tmp);
+}
+
+
+/*
+ * confirm_changes()
+ *
+ */
+int confirm_changes(__u64 off, ocfs_disk_structure *s, char *buf, int idx, GHashTable *bad)
+{
+	int ret = -1;
+	char *yesno, *loc;
+	int fd = ctxt.fd;
+
+	yesno = malloc(USER_INPUT_MAX);
+	if (!yesno) {
+		LOG_INTERNAL();
+		goto bail;
+	}
+
+	if (s->output(buf, idx, bad, stdout)==-1) {
+		//fprintf(stderr, "at least one bad field found\n");
+	}
+
+	printf("\n\nDo you really want to write your changes out? : ");
+
+	if (fgets(yesno, USER_INPUT_MAX, stdin) == NULL) {
+		ret = -1;
+		goto bail;
+	}
+
+	if ((loc = rindex(yesno, '\n')) != NULL)
+		*loc = '\0';
+
+       	if (strcasecmp(yesno, "yes")==0 || strcasecmp(yesno, "y")==0) {
+		if ((ret = s->write(fd, buf, off, idx)) == -1) {
+			LOG_INTERNAL();
+			goto bail;
+		}
+		else {
+			GHashTable *tmp = NULL;
+			ret = s->verify(fd, buf, off, idx, &tmp);
+			if (tmp != NULL)
+				g_hash_table_destroy(tmp);
+		}
+	}
+
+bail:
+	safefree(yesno);
+	return ret;
+}				/* confirm_changes */
+
+static char *saved_block = NULL;
+/*
+ * read_print_struct()
+ *
+ */
+int read_print_struct(ocfs_disk_structure *s, char *buf, __u64 off, int idx, GHashTable **bad)
+{
+	int ret = 0;
+	int fd = ctxt.fd;
+	
+	if (saved_block == NULL)
+		saved_block = malloc(512);
+
+	if (saved_block == NULL)
+		return -1;
+
+	if (s->read(fd, buf, off, idx)==-1) {
+		LOG_ERROR("failed to read data");
+		return -2;
+	}
+
+	memcpy(saved_block, buf, 512);
+
+	if (s->sig_match) {
+		if (s->sig_match(buf, idx)==-EINVAL) {
+			LOG_ERROR("Bad signature found");
+			ret = -1;
+		}
+	}
+
+	if (s->verify(fd, buf, off, idx, bad)==-1) {
+		LOG_ERROR("structure failed verification");
+		ret = -1;
+	}
+
+	if (ret == -1 || (ret == 0 && ctxt.verbose)) {
+		if (s->output(buf, idx, *bad, stdout)==-1) {
+			//fprintf(stderr, "at least one bad field found\n");
+			//ret = -1;
+		}
+	}
+
+	return ret;
+}				/* read_print_struct */
+
+
+/*
+ * get_device_size()
+ *
+ */
+int get_device_size(int fd)
+{
+	int ret = -1;
+	__u32 numblks;
+	struct stat buf;
+
+	if (fstat(fd, &buf) == -1) {
+		printf("%s: %s\n", ctxt.device, strerror(errno));
+		goto bail;
+	}
+
+	if (ctxt.dev_is_file) {		/* used during testing */
+		ctxt.device_size = buf.st_size;
+		goto finito;
+	} else if (S_ISCHR(buf.st_mode)) {
+		char *junk = NULL;
+		__u64 hi, lo, new, delta, last;
+		int ret;
+
+		junk = malloc_aligned(512);
+		if (!junk) {
+			LOG_INTERNAL();
+			goto bail;
+		}
+		hi = 0xfffffffffffffd00ULL;
+		lo = 0ULL;
+		new = hi >> 1;
+
+		ctxt.device_size = 0;
+		do {
+			last = new;
+			myseek64(fd, new, SEEK_SET);
+			ret = read(fd, junk, 512);
+			if (ret == 512) {
+				/* go higher */
+				ctxt.device_size = (new + 512);
+				lo = new;
+				delta = (hi - lo) >> 1;
+				new = hi - delta;
+				new &= 0xfffffffffffffd00ULL;
+			} else {
+				/* go lower */
+				hi = new;
+				delta = (hi - lo) >> 1;
+				new = lo + delta;
+				new &= 0xfffffffffffffd00ULL;
+			}
+			
+			if (last == new || hi <= lo)
+				break;
+		} while (1);
+		while (ret == 512)
+		{
+			ctxt.device_size = (new + 512);
+			myseek64(fd, new, SEEK_SET);
+			ret = read(fd, junk, 512);
+			new += 512;
+		}
+		free_aligned(junk);
+		goto finito;
+	} else {
+		if (ioctl(fd, BLKGETSIZE, &numblks) == -1) {
+			printf("%s: %s\n", ctxt.device, strerror(errno));
+			goto bail;
+		} 
+		ctxt.device_size = numblks;
+		ctxt.device_size *= OCFS_SECTOR_SIZE;
+		goto finito;
+	}
+
+finito:
+	ret = 0;
+bail:
+	return ret;
+}				/* get_device_size */
+
+
+void handle_signal(int sig)
+{
+    switch (sig) {
+    case SIGTERM:
+    case SIGINT:
+	myclose(ctxt.fd);
+	unbind_raw(ctxt.raw_minor);
+	exit(1);
+    }
+}
+
+
+/*
+ * check_heart_beat()
+ *
+ */
+int check_heart_beat(int *file, __u64 publ_off, __u32 sect_size)
+{
+	char *publish = NULL;
+	ocfs_super osb;
+	int ret = 0;
+	int i;
+	int waittime;
+	char *node_names[OCFS_MAXIMUM_NODES];
+	__u32 nodemap;
+
+	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
+		node_names[i] = NULL;
+
+	memset (&osb, 0, sizeof(ocfs_super));
+
+	if (!read_publish(*file, publ_off, sect_size, (void **)&publish)) {
+		LOG_INTERNAL();
+		goto bail;
+	}
+
+	/* alloc osb and pop sect_size */
+	osb.sect_size = sect_size;
+
+        /* call ocfs_update_publish_map(first_time = true) */
+	ocfs_update_publish_map (&osb, (void *)publish, true);
+
+	/* sleep(OCFS_NM_HEARTBEAT_TIME * 10) */
+	printf("Checking heart beat on volume ");
+	waittime = (OCFS_NM_HEARTBEAT_TIME/1000);
+	waittime = (waittime ? waittime : 1);
+	for (i = 0; i < OCFS_HBT_WAIT; ++i) {
+		printf(".");
+		fflush(stdout);
+		sleep(waittime);
+	}
+   
+	/* Close and re-open device to force disk read */
+	myclose(*file);
+
+	if ((*file = myopen(ctxt.raw_device, ctxt.flags)) == -1) {
+		LOG_INTERNAL();
+		goto bail;
+	}
+
+	memset (publish, 0, sect_size);
+	if (!read_publish(*file, publ_off, sect_size, (void **)&publish)) {
+		LOG_INTERNAL();
+		goto bail;
+	}
+
+	/* call ocfs_update_publish_map(first_time = false) */
+	ocfs_update_publish_map (&osb, (void *)publish, false);
+
+	printf("\r                                                \r");
+	fflush(stdout);
+
+	/* OCFS currently supports upto 32 nodes */
+	nodemap = LO(osb.publ_map);
+	if (!nodemap)
+		goto success;
+
+	/* Get names of all the nodes */
+	get_node_names(*file, ctxt.hdr, node_names, sect_size);
+
+	/* Prints the ones which are mounted */
+	printf("%s is mounted on nodes:", ctxt.device);
+	print_node_names(node_names, nodemap);
+
+	if (ctxt.write_changes) {
+		ctxt.write_changes = false;
+		printf("umount volume on node(s) before running fsck -w\n");
+		printf("Continuing in read-only mode\n");
+	}
+
+	printf("As %s is mounted on one or more nodes, fsck.ocfs may "
+	       "display false-positive errors\n", ctxt.device);
+
+success:
+	ret = 1;
+bail:
+	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
+		free(node_names[i]);
+
+	free_aligned(publish);
+	return ret;
+}				/* check_heart_beat */
+
+/*
+ * read_publish()
+ *
+ */
+int read_publish(int file, __u64 publ_off, __u32 sect_size, void **buf)
+{
+	int ret = 0;
+	__u32 pub_len;
+
+	pub_len = OCFS_MAXIMUM_NODES * sect_size;
+
+	if (!*buf) {
+		if (!(*buf = malloc_aligned(pub_len))) {
+			LOG_INTERNAL();
+			goto bail;
+		}
+	}
+
+	if (myseek64(file, publ_off, SEEK_SET) == -1) {
+		LOG_INTERNAL();
+		goto bail;
+	}
+
+	if (myread(file, *buf, pub_len) == -1) {
+		LOG_INTERNAL();
+		goto bail;
+	}
+			
+	ret = 1;
+
+bail:
+	return ret;
+}				/* read_publish */
+
+/*
+ * get_node_names()
+ *
+ */
+int get_node_names(int file, ocfs_vol_disk_hdr *volhdr, char **node_names,
+		   __u32 sect_size)
+{
+	char *buf = NULL;
+	char *p;
+	int len;
+	int ret = 0;
+	int i;
+	ocfs_disk_node_config_info *conf;
+
+	len = volhdr->node_cfg_size;
+	if (!(buf = (char *) malloc_aligned(len))) {
+		LOG_INTERNAL();
+		goto bail;
+	} else
+		memset(buf, 0, len);
+
+	if (myseek64(file, volhdr->node_cfg_off, SEEK_SET) == -1) {
+		LOG_INTERNAL();
+		goto bail;
+	}
+
+	if (myread(file, buf, len) == -1) {
+		LOG_INTERNAL();
+		goto bail;
+	}
+
+	p = buf + (sect_size * 2);
+	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i, p += sect_size) {
+		conf = (ocfs_disk_node_config_info *)p;
+		if (conf->node_name[0])
+			node_names[i] = strdup(conf->node_name);
+	}
+
+	ret = 1;
+bail:
+	free_aligned(buf);
+	return ret;
+}				/* get_node_names */
+
+
+/*
+ * print_node_names()
+ *
+ */
+void print_node_names(char **node_names, __u32 nodemap)
+{
+	int i, j;
+	char comma = '\0';
+
+	for (j = 1, i = 0; i < OCFS_MAXIMUM_NODES; ++i, j <<= 1) {
+		if (nodemap & j) {
+			if (node_names[i])
+				printf("%c %s", comma, node_names[i]);
+			else
+				printf("%c %d", comma, i);
+			comma = ',';
+		}
+	}
+	printf("\n");
+}				/* print_node_names */
+
+/*
+ * print_gbl_alloc_errs()
+ *
+ */
+void print_gbl_alloc_errs(void)
+{
+	bitmap_data *bm1;
+	bitmap_data *bm2;
+	str_data *s1;
+	str_data *s2;
+	GArray *cbl = NULL;
+	__u32 i, j, k;
+	GArray *files = NULL;
+	GString *gs = NULL;
+	char *newstr = NULL;
+
+	files = g_array_new(false, true, sizeof(__u32));
+	cbl = g_array_new(false, true, sizeof(str_data));
+	gs = g_string_new (NULL);
+
+	/* walk the list and check for any duplicates */
+	for (i = 0; i < ctxt.vol_bm_data->len;) {
+		bm1 = &(g_array_index(ctxt.vol_bm_data, bitmap_data, i));
+		for (k = 0, j = i + 1; j < ctxt.vol_bm_data->len; ++j, ++k) {
+			bm2 = &(g_array_index(ctxt.vol_bm_data, bitmap_data, j));
+			if (bm2->bitnum == bm1->bitnum) {
+				if (!ctxt.verbose)
+					g_array_append_val(files, bm2->fnum);
+				else {
+					newstr = g_strdup_printf(", %u.%u",
+								 HILO(bm2->parent_off));
+					g_string_append (gs, newstr);
+					safefree(newstr);
+				}
+				continue;
+			} else
+				break;
+		}
+		if (k) {
+			if (!ctxt.verbose)
+				g_array_append_val(files, bm1->fnum);
+			else {
+				newstr = g_strdup_printf("%u.%u", HILO(bm1->parent_off));
+				g_string_prepend(gs, newstr);
+				add_str_data(cbl, bm1->bitnum, gs->str);
+				safefree(newstr);
+				if (gs) {
+					g_string_free(gs, true);
+					gs = g_string_new (NULL);
+				}
+			}
+		}
+		i += k + 1;
+	}
+
+	if (files->len || cbl->len)
+		LOG_ERROR("Global bitmap corruption detected");
+	else
+		goto bail;
+
+	if (ctxt.verbose) {
+		for (i = 0; i < cbl->len;) {
+			s1 = &(g_array_index(cbl, str_data, i));
+			for (k = 0, j = i + 1; j < cbl->len; ++k, ++j) {
+				s2 = &(g_array_index(cbl, str_data, j));
+				if (s1->num + k + 1 != s2->num)
+					break;
+				if (strncmp(s1->str, s2->str, sizeof(s1->str)))
+					break;
+			}
+			if (k)
+				LOG_PRINT("Bits# %u-%u allocated to objects %s", s1->num, s1->num+k, s1->str);
+			else
+				LOG_PRINT("Bit# %u allocated to objects %s", s1->num, s1->str);
+			i += k + 1;
+		}
+		goto bail;
+	}
+
+	/* concise output */
+	LOG_PRINT("Global bitmap corruption involves the following objects:");
+	print_filenames(files);
+
+bail:
+	if (files)
+		g_array_free(files, true);
+	if (gs)
+		g_string_free(gs, true);
+	if (cbl) {
+		for (i = 0; i < cbl->len; ++i) {
+			s1 = &(g_array_index(cbl, str_data, i));
+			safefree(s1->str);
+		}
+		g_array_free(cbl, true);
+	}
+
+	return ;
+}				/* print_gbl_alloc_errs */
+
+/*
+ * print_filenames()
+ *
+ */
+void print_filenames(GArray *files)
+{
+	str_data *fs;
+	__u32 num, oldnum;
+	__u32 i;
+
+	qsort(files->data, files->len, sizeof(__u32), &comp_nums);
+
+	num = oldnum = ULONG_MAX;
+	for (i = 0; i < files->len; ++i) {
+		num = g_array_index(files, __u32, i);
+		if (num != oldnum) {
+			fs = &(g_array_index(ctxt.filenames, str_data, num));
+			LOG_PRINT("%s", fs->str);
+			oldnum = num;
+		}
+	}
+}				/* print_filenames */
+
+/*
+ * print_bit_ranges()
+ *
+ */
+void print_bit_ranges(GArray *bits, char *str1, char *str2)
+{
+	__u32 i, j, k;
+	__u32 bit1, bit2;
+	GString *gs = NULL;
+	char comma[3];
+	gchar newstr[50];
+
+	if (!bits)
+		goto bail;
+
+	gs = g_string_new (NULL);
+
+	*comma = '\0';
+	for (i = 0; i < bits->len;) {
+		bit1 = g_array_index(bits, __u32, i);
+		for (k = 0, j = i + 1; j < bits->len; ++k, ++j) {
+			bit2 = g_array_index(bits, __u32, j);
+			if (bit1 + k + 1 != bit2)
+				break;
+		}
+		if (k)
+			sprintf(newstr, "%s%u-%u", comma, bit1, bit1 + k);
+		else
+			sprintf(newstr, "%s%u", comma, bit1);
+		g_string_append (gs, newstr);
+		if (!i)
+			strcpy(comma, ", ");
+		i += k + 1;
+	}
+
+	LOG_PRINT("List of %s bits in the %s bitmap: %s", str1, str2, gs->str);
+
+bail:
+	if (gs)
+		g_string_free(gs, true);
+	return ;
+}				/* print_bit_ranges */
+
+/*
+ * find_unset_bits()
+ *
+ */
+void find_unset_bits(__u8 *vol_bm, char *bitmap)
+{
+	__u32 i, j;
+	bitmap_data *bm;
+	GArray *bits = NULL;
+	GArray *files = NULL;
+	__u32 bitnum;
+	bitmap_data kbm;
+
+	bits = g_array_new(false, true, sizeof(__u32));
+	files = g_array_new(false, true, sizeof(__u32));
+
+	/* clearing all the allocated bits in the global bitmap */
+	for (i = 0; i < ctxt.vol_bm_data->len; ++i) {
+		bm = &(g_array_index(ctxt.vol_bm_data, bitmap_data, i));
+		j = __test_and_clear_bit(bm->bitnum, (unsigned long *)vol_bm);
+		if (!j) {
+			if (!test_bit(bm->bitnum, (unsigned long *)ctxt.vol_bm))
+				g_array_append_val(bits, bm->bitnum);
+		}
+	}
+
+	if (!bits->len)
+		goto bail;
+
+	LOG_WARNING("Global bitmap has unset bits");
+	print_bit_ranges(bits, "unset", bitmap);
+
+	for (i = 0; i < bits->len; ++i) {
+		bitnum = g_array_index(bits, __u32, i);
+
+		memset (&kbm, 0, sizeof(bitmap_data));
+		kbm.bitnum = bitnum;
+		kbm.alloc_node = OCFS_INVALID_NODE_NUM;
+		bm = bsearch(&kbm, ctxt.vol_bm_data->data, ctxt.vol_bm_data->len,
+			     sizeof(bitmap_data), &comp_bits);
+		g_array_append_val(files, bm->fnum);
+	}
+
+	LOG_PRINT("List of files affected by the unset bits:");
+	print_filenames(files);
+
+bail:
+	if (bits)
+		g_array_free(bits, true);
+	if (files)
+		g_array_free(files, true);
+	return ;
+}				/* find_unset_bits */
+
+/*
+ * find_set_bits()
+ *
+ */
+void find_set_bits(__u8 *vol_bm, char *bitmap)
+{
+	__u32 i, j;
+	GArray *bits = NULL;
+
+	bits = g_array_new(false, true, sizeof(__u32));
+
+	/* The first 1MB in the bitmap is for the system fe's */
+	j = VOL_BITMAP_BYTES / ctxt.hdr->cluster_size;
+
+	for (i = j; i < ctxt.hdr->num_clusters; ++i) {
+		if (test_bit(i, (unsigned long *)vol_bm))
+			g_array_append_val(bits, i);
+	}
+
+	if (bits) {
+		LOG_WARNING("Unused bits (wasted space) detected in the global bitmap.");
+		print_bit_ranges(bits, "unused", bitmap);
+	}
+
+	if (bits)
+		g_array_free(bits, true);
+	return ;
+}				/* find_set_bits */
+
+/*
+ * check_global_bitmap()
+ *
+ */
+int check_global_bitmap(int fd)
+{
+	int ret = -1;
+	__u8 *vol_bm = NULL;
+	
+	/* sorting the global bitmap data on alloc_node and bit_num */
+	qsort(ctxt.vol_bm_data->data, ctxt.vol_bm_data->len,
+	      sizeof(bitmap_data), &comp_bits);
+
+	print_gbl_alloc_errs();
+
+	/* make a temp copy of the volume bitmap */
+	if ((vol_bm = malloc_aligned(VOL_BITMAP_BYTES)) == NULL) {
+		LOG_INTERNAL();
+		goto bail;
+	} else
+		memcpy(vol_bm, ctxt.vol_bm, VOL_BITMAP_BYTES);
+
+	find_unset_bits(vol_bm, "global");
+
+//#ifdef STILL_DEBUGGING
+	/* cross check... ensure no bit in the global bitmap is set */
+	find_set_bits(vol_bm, "global");
+//#endif
+
+	ret = 0;
+bail:
+	free_aligned(vol_bm);
+	return ret;
+}				/* check_global_bitmap */
+
+
+/*
+ * check_node_bitmaps()
+ *
+ * Checks extent and directory bitmaps for all nodes
+ *
+ */
+int check_node_bitmaps(int fd, GArray *bm_data, __u8 **node_bm,
+		       __u32 *node_bm_sz, char *str)
+{
+	int ret = -1;
+	bitmap_data *bm1;
+	bitmap_data *bm2;
+	__u8 *temp_bm[OCFS_MAXIMUM_NODES];
+	__u32 i;
+	__u32 j;
+
+	/* sorting the node bitmap data on alloc_node and bit_num */
+	qsort(bm_data->data, bm_data->len, sizeof(bitmap_data), &comp_bits);
+#ifdef STILL_DEBUGGING
+	for (i = 0; i < bm_data->len; ++i) {
+		bm1 = &(g_array_index(bm_data, bitmap_data, i));
+	}
+#endif
+	for (i = 0; i < bm_data->len; ++i) {
+		bm1 = &(g_array_index(bm_data, bitmap_data, i));
+		for (j = i + 1; j < bm_data->len; ++j) {
+			bm2 = &(g_array_index(bm_data, bitmap_data, j));
+			if (bm2->alloc_node != bm1->alloc_node)
+				break;
+			if (bm2->bitnum == bm1->bitnum) {
+				LOG_ERROR("Block %u.%u (bit# %u) allocated "
+					  "to %s %u.%u and %u.%u on node %u",
+					  HILO(bm1->fss_off), bm1->bitnum,
+					  str, HILO(bm1->parent_off),
+					  HILO(bm2->parent_off), bm1->alloc_node);
+				continue;
+			} else
+				break;
+		}
+	}
+
+	/* make a temp copy of the node bitmaps */
+	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i) {
+		if (!node_bm_sz[i]) {
+			temp_bm[i] = NULL;
+			continue;
+		}
+		if ((temp_bm[i] = malloc_aligned(node_bm_sz[i])) == NULL) {
+			LOG_INTERNAL();
+			goto bail;
+		} else
+			memcpy(temp_bm[i], node_bm[i], node_bm_sz[i]);
+	}
+
+	/* clearing all the allocated bits in the extent bitmap */
+	for (i = 0; i < bm_data->len; ++i) {
+		bm1 = &(g_array_index(bm_data, bitmap_data, i));
+		if (!temp_bm[bm1->alloc_node]) {
+			LOG_ERROR("%s bitmap for node %d not allocated but "
+				  "structure at offset %u.%u suggests otherwise",
+				  str, bm1->alloc_node, HILO(bm1->fss_off));
+			continue;
+		}
+		j = __test_and_clear_bit(bm1->bitnum, (unsigned long *)temp_bm[bm1->alloc_node]);
+		if (!j) {
+			if (!test_bit(bm1->bitnum, (unsigned long *)node_bm[bm1->alloc_node]))
+				LOG_ERROR("Bit %u is unset in the %s bitmap "
+					  "of node %d", bm1->bitnum, str,
+					  bm1->alloc_node);
+		}
+	}
+
+#ifdef STILL_DEBUGGING
+	/* cross check... ensure no bit in the extent/directory bitmap is set */
+	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i) {
+		if (!temp_bm[i])
+			continue;
+		len = node_bm_sz[i] * 8;
+		for (j = 0; j < len; ++j) {
+			if (test_bit(j, temp_bm[i]))
+				LOG_ERROR("Bit %u in the %s bitmap of node "
+					  "%d is unaccounted", j, str, i);
+		}
+	}
+#endif
+
+	ret = 0;
+bail:
+	for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
+		free_aligned(temp_bm[i]);
+	return ret;
+}				/* check_node_bitmaps */
+
+/*
+ * comp_nums()
+ *
+ */
+int comp_nums(const void *q1, const void *q2)
+{
+	__u32 *num1 = (__u32 *)q1;
+	__u32 *num2 = (__u32 *)q2;
+
+	return *num1 - *num2;
+}				/* comp_nums */
+
+
+
+/*
+ * comp_bits()
+ *
+ */
+int comp_bits(const void *q1, const void *q2)
+{
+	bitmap_data *bm1 = (bitmap_data *)q1;
+	bitmap_data *bm2 = (bitmap_data *)q2;
+	__s32 ret;
+
+	ret = bm1->alloc_node - bm2->alloc_node;
+	if (!ret)
+		ret = bm1->bitnum - bm2->bitnum;
+
+	return ret;
+}				/* comp_bits */
+
+static int fe_compare_func(const void *m1, const void *m2);
+
+/* if we ever rewrite this as a shared library or 
+ * parallelized fsck we will have to change this */
+ocfs_dir_node *globaldir = NULL;
+
+static int fe_compare_func(const void *m1, const void *m2)
+{
+	ocfs_file_entry *fe1, *fe2;
+	__u8 idx1, idx2;
+	int ret;
+
+	if (globaldir == NULL) {
+		LOG_INTERNAL();
+		exit(0);
+	}
+
+	idx1 = *(__u8 *)m1;
+	idx2 = *(__u8 *)m2;
+
+	fe1 = (ocfs_file_entry *) ((char *)FIRST_FILE_ENTRY(globaldir) + (idx1 * OCFS_SECTOR_SIZE));
+	fe2 = (ocfs_file_entry *) ((char *)FIRST_FILE_ENTRY(globaldir) + (idx2 * OCFS_SECTOR_SIZE));
+
+	if (IS_FE_DELETED(fe1->sync_flags) ||
+	    (!(fe1->sync_flags & OCFS_SYNC_FLAG_VALID)) ||
+	    IS_FE_DELETED(fe2->sync_flags) ||
+	    (!(fe2->sync_flags & OCFS_SYNC_FLAG_VALID)))
+		return 0;
+
+	ret = strncmp(fe1->filename, fe2->filename, 255);
+	
+	return -ret;
+}
+
+
+/*
+ * traverse_dir_nodes()
+ *
+ */
+void traverse_dir_nodes(int fd, __u64 offset, char *dirpath)
+{
+	int i;
+	int ret;
+	char *dirbuf = NULL;
+	ocfs_file_entry *febuf = NULL;
+	__u64 dir_offset;
+	__u64 off;
+	ocfs_disk_structure *dirst;
+	ocfs_disk_structure *fest;
+	GHashTable *bad;
+	ocfs_dir_node *dir;
+   
+	dirst = &dirnode_t;
+	fest = &fileent_t;
+	bad = NULL;
+
+	if ((dirbuf = malloc_aligned(DIR_NODE_SIZE)) == NULL) {
+		LOG_INTERNAL();
+		goto bail;
+	}
+
+	if ((febuf = (ocfs_file_entry *) malloc_aligned(OCFS_SECTOR_SIZE)) == NULL) {
+		LOG_INTERNAL();
+		goto bail;
+	}
+
+	dir_offset = offset;
+	dir = (ocfs_dir_node *)dirbuf;
+
+	CLEAR_AND_PRINT(dirpath);
+
+	while (1) {
+		ret = read_print_struct(dirst, dirbuf, dir_offset, 0, &bad);
+
+		if (bad)
+			g_hash_table_destroy(bad);
+
+		if (ret == -1) {
+			LOG_ERROR("failed to read directory at offset %u.%u",
+				  HILO(dir_offset));
+			goto bail;
+		}
+
+		/* Add bitmap entry for the dirnode itself */
+		add_bm_data(dir->alloc_file_off, 1, dir->alloc_node, 
+			    dir_offset,
+			    (dir->alloc_node == OCFS_INVALID_NODE_NUM ? bm_global : bm_dir));
+
+		for (i = 0; i < dir->num_ent_used; i++) {
+			off = dir_offset;
+			off += OCFS_SECTOR_SIZE;	/* move past the dirnode header */
+			off += (OCFS_SECTOR_SIZE * dir->index[i]);
+
+			ret = read_print_struct(fest, (char *)febuf, off, 0, &bad);
+			if (bad)
+				g_hash_table_destroy(bad);
+			if (ret == -1) {
+				LOG_ERROR("failed to read file entry at offset %u.%u",
+					  HILO(off));
+				continue;
+			}
+
+			if (!IS_FE_DELETED(febuf->sync_flags))
+				check_file_entry(fd, febuf, off, dir->index[i], false, dirpath);
+		}
+
+		/* is there another directory chained off of this one? */
+		if (dir->next_node_ptr == -1)
+			break;		/* nope, we're done */
+		else
+			dir_offset = dir->next_node_ptr;	/* keep going */
+	}
+
+bail:
+	free_aligned(dirbuf);
+	free_aligned(febuf);
+}				/* traverse_dir_nodes */
+
+/*
+ * handle_one_cdsl_entry()
+ *
+ */
+void handle_one_cdsl_entry(int fd, ocfs_file_entry *fe, __u64 offset)
+{
+}				/* handle_one_cdsl_entry */
+
+
+/*
+ * check_file_entry()
+ *
+ */
+void check_file_entry(int fd, ocfs_file_entry *fe, __u64 offset, int slot,
+		      bool systemfile, char *dirpath)
+{
+	void *buf = NULL;
+	int indx = 0;
+	int val = 0;
+	char *path = NULL;
+
+	if (systemfile)
+		val = 3;
+	else {
+		if (fe->attribs & OCFS_ATTRIB_FILE_CDSL)
+			val = 1;
+		else if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
+			val = 2;
+		else if (fe->attribs & (OCFS_ATTRIB_REG | OCFS_ATTRIB_SYMLINK))
+			val = 3;
+		else {
+			LOG_ERROR ("unknown attribs %x at offset %u.%u",
+				   fe->attribs, HILO(offset));
+			goto bail;
+		}
+	}
+
+	++cnt_obj;
+	if (val == 2)
+		path = g_strdup_printf("%s%s/", dirpath, fe->filename);
+	else
+		path = g_strdup_printf("%s%s", dirpath, fe->filename);
+
+	switch (val) {
+	case 1:
+		CLEAR_AND_PRINT(path);
+		handle_one_cdsl_entry(fd, fe, offset);
+		break;
+
+	case 2:
+		if (fe->extents[0].disk_off) {
+			handle_leaf_extents(fd, fe->extents, 1,
+				 	OCFS_INVALID_NODE_NUM, fe->this_sector);
+			traverse_dir_nodes(fd, fe->extents[0].disk_off, path);
+		} else
+			LOG_ERROR("Invalid dir entry at %u.%u", HILO(offset));
+		break;
+
+	case 3:
+		add_str_data(ctxt.filenames, fs_num, path);
+		fs_num++;
+
+		if (ctxt.verbose) {
+			safefree(path);
+			path = g_strdup_printf("%s%s\t(%d)", dirpath, fe->filename, slot);
+		}
+		CLEAR_AND_PRINT(path);
+
+		if (fe->local_ext)
+			handle_leaf_extents(fd, fe->extents,
+					    OCFS_MAX_FILE_ENTRY_EXTENTS,
+					    OCFS_INVALID_NODE_NUM, fe->this_sector);
+		else {
+			if ((buf = malloc_aligned(MAX_EXTENTS * OCFS_SECTOR_SIZE)) == NULL) {
+				LOG_INTERNAL();
+				goto bail;
+			}
+
+			traverse_fe_extents(fd, fe, buf, &indx);
+
+			/* check ext->next_data_ext */
+			check_next_data_ext(fe, buf, indx);
+
+			/* check fe->last_ext_ptr */
+			check_fe_last_data_ext(fe, buf, indx);
+		}
+		break;
+
+	default:
+		break;
+	}
+
+bail:
+	safefree(path);
+	free_aligned(buf);
+	return ;
+}				/* check_file_entry */
+
+/*
+ * add_bm_data()
+ *
+ */
+bitmap_data * add_bm_data(__u64 start, __u64 len, __s32 alloc_node,
+			  __u64 parent_offset, int type)
+{
+	bitmap_data *bm = NULL;
+	__u32 bitnum = 0;
+	__u32 num = 0;
+	void *buf = NULL;
+	void *p;
+	int i;
+	__u32 fnum = 0;
+
+	switch (type) {
+	case bm_extent:
+		bitnum = start >> OCFS_LOG_SECTOR_SIZE;
+		num = len;
+		fnum = fs_num - 1;
+		break;
+
+	case bm_dir:
+		bitnum = start / OCFS_DEFAULT_DIR_NODE_SIZE;
+		num = len;
+		break;
+
+	case bm_symlink:
+		break;
+
+	case bm_global:
+	case bm_filedata:
+		bitnum = (start - ctxt.hdr->data_start_off) >>
+				ctxt.cluster_size_bits;
+		num = len >> ctxt.cluster_size_bits;
+		fnum = fs_num - 1;
+		break;
+
+	default:
+		break;
+	}
+
+	if (num == 0)
+		goto bail;
+
+	if (type == bm_global)
+		fnum = ULONG_MAX;
+
+	if ((buf = malloc(sizeof(bitmap_data) * num)) == NULL) {
+		LOG_INTERNAL();
+		goto bail;
+	}
+
+	for (i = 0, p = buf; i < num; ++i) {
+		bm = (bitmap_data *)p;
+		bm->bitnum = bitnum + i;
+		bm->fss_off = start;
+		bm->alloc_node = alloc_node;
+		bm->parent_off = parent_offset;
+		bm->fnum = fnum;
+		p += sizeof(bitmap_data);
+	}
+
+	bm = (bitmap_data *)buf;
+
+	switch (type) {
+	case bm_dir:
+		g_array_append_vals(ctxt.dir_bm_data, bm, num);
+		break;
+
+	case bm_extent:
+		g_array_append_vals(ctxt.ext_bm_data, bm, num);
+		break;
+
+	case bm_global:
+	case bm_filedata:
+		g_array_append_vals(ctxt.vol_bm_data, bm, num);
+		break;
+
+	default:
+		break;
+	}
+
+bail:
+	return bm;
+}				/* add_bm_data */
+
+/*
+ * add_str_data()
+ *
+ */
+int add_str_data(GArray *sd, __u32 num, char *str)
+{
+	str_data *f;
+	
+	f = malloc(sizeof(str_data));
+	if (!f) {
+		LOG_INTERNAL();
+		return -1;
+	}
+
+	f->num = num;
+	f->str = strdup(str);
+	g_array_append_vals(sd, f, 1);
+
+	return 0;
+}				/* add_str_data */
+
+/*
+ * handle_leaf_extents()
+ *
+ */
+int handle_leaf_extents (int fd, ocfs_alloc_ext *arr, int num, __u32 node,
+			 __u64 parent_offset)
+{
+	int i;
+	int ret = 0;
+
+	for (i = 0; i < num; i++) {
+		if (arr[i].disk_off)
+			if (!add_bm_data(arr[i].disk_off, arr[i].num_bytes,
+					 node, parent_offset, bm_filedata))
+				ret = -1;
+	}
+
+	return ret;
+}				/* handle_leaf_extents */
+
+
+/*
+ * traverse_extent()
+ *
+ */
+void traverse_extent(int fd, ocfs_extent_group * exthdr, int flag, void *buf,
+		     int *indx)
+{
+	ocfs_extent_group *ext = NULL;
+	int i;
+	int j;
+	__u64 len;
+	int ret;
+	int type;
+	ocfs_disk_structure *disk_struct;
+	GHashTable *bad;
+
+	if (*indx >= MAX_EXTENTS) {
+		LOG_ERROR("Too many extents after ext=%u.%u",
+			  HILO(exthdr->this_ext));
+		goto bail;
+	}
+
+	for (i = 0; i < exthdr->next_free_ext; ++i) {
+		if (!exthdr->extents[i].disk_off)
+			continue;
+
+		ext = (ocfs_extent_group *) (buf + (*indx * OCFS_SECTOR_SIZE));
+		++*indx;
+
+		if (flag == OCFS_EXTENT_HEADER)
+			disk_struct = &exthdr_t;
+		else
+			disk_struct = &extdat_t;
+
+		ret = read_print_struct(disk_struct, (char *)ext,
+					exthdr->extents[i].disk_off, 0, &bad);
+
+		if (bad)
+			g_hash_table_destroy(bad);
+
+		if (ret == -1) {
+			LOG_ERROR("failed to read extent at offset %u.%u",
+				  HILO(exthdr->extents[i].disk_off));
+			goto bail;
+		}
+
+		/* check up_hdr_node_ptr */
+		if (exthdr->this_ext != ext->up_hdr_node_ptr) {
+			LOG_ERROR("up_hdr_node_ptr %u.%u in extent %u.%u "
+				  "should be %u.%u", HILO(ext->up_hdr_node_ptr),
+				  HILO(ext->this_ext), HILO(exthdr->this_ext));
+		}
+
+		/* check first file offset */
+		if (exthdr->extents[i].file_off != ext->extents[0].file_off) {
+			LOG_ERROR("extents[0].file_off=%u.%u in extent %u.%u "
+				  "should be %u.%u", HILO(ext->extents[0].file_off),
+				  HILO(ext->this_ext), HILO(exthdr->extents[i].file_off));
+		}
+
+		/* check total bytes */
+		for (j = 0, len = 0; j < OCFS_MAX_DATA_EXTENTS; j++)
+			len += ext->extents[j].num_bytes;
+
+		if (exthdr->extents[i].num_bytes != len) {
+			LOG_ERROR("total num_bytes in extent %u.%u is %u.%u "
+				  "but should be %u.%u", HILO(ext->this_ext),
+				  HILO(len), HILO(exthdr->extents[i].num_bytes));
+		}
+
+		/* Add bitmap entry for the extent itself */
+		add_bm_data(ext->alloc_file_off, 1, ext->alloc_node, ext->this_ext,
+			    bm_extent);
+
+		if (flag == OCFS_EXTENT_HEADER) {
+			type = ext->granularity ? OCFS_EXTENT_HEADER : OCFS_EXTENT_DATA;
+			traverse_extent(fd, ext, type, buf, indx);
+		} else {
+			handle_leaf_extents(fd, ext->extents, ext->next_free_ext,
+					    OCFS_INVALID_NODE_NUM, ext->this_ext);
+		}
+	}
+
+bail:
+	return ;
+}				/* traverse_extent */
+
+
+/*
+ * traverse_fe_extents()
+ *
+ */
+void traverse_fe_extents(int fd, ocfs_file_entry *fe, void *buf, int *indx)
+{
+	int i;
+	int j;
+	int ret;
+	__u64 len;
+	ocfs_extent_group *ext = NULL;
+	int type;
+	ocfs_disk_structure *disk_struct;
+	GHashTable *bad;
+
+	if (*indx >= MAX_EXTENTS) {
+		LOG_ERROR("error too many extents in fe at offset %u.%u",
+			  HILO(fe->this_sector));
+		goto bail;
+	}
+
+	for (i = 0; i < fe->next_free_ext; i++) {
+		if (!fe->extents[i].disk_off)
+			continue;
+
+		ext = (ocfs_extent_group *) (buf + (*indx * OCFS_SECTOR_SIZE));
+		++*indx;
+
+		if (fe->granularity)
+			disk_struct = &exthdr_t;
+		else
+			disk_struct = &extdat_t;
+
+		ret = read_print_struct(disk_struct, (char *)ext, 
+					fe->extents[i].disk_off, 0, &bad);
+		if (bad)
+			g_hash_table_destroy(bad);
+
+		if (ret == -1) {
+			LOG_ERROR("failed to read extent at offset %u.%u",
+				  HILO(fe->extents[i].disk_off));
+			goto bail;
+		}
+
+		if (fe->this_sector != ext->up_hdr_node_ptr) {
+			LOG_ERROR("up_hdr_node_ptr %u.%u in extent %u.%u "
+				  "should be %u.%u", HILO(ext->up_hdr_node_ptr),
+				  HILO(ext->this_ext), HILO(fe->this_sector));
+		}
+
+		/* check first file offset */
+		if (fe->extents[i].file_off != ext->extents[0].file_off) {
+			LOG_ERROR("extents[0].file_off=%u.%u in extent %u.%u "
+				  "should be %u.%u", HILO(ext->extents[0].file_off),
+				  HILO(ext->this_ext), HILO(fe->extents[i].file_off));
+		}
+
+		/* check total bytes */
+		for (j = 0, len = 0; j < OCFS_MAX_DATA_EXTENTS; j++)
+			len += ext->extents[j].num_bytes;
+
+		if (fe->extents[i].num_bytes != len) {
+			LOG_ERROR("total num_bytes in extent %u.%u is %u.%u "
+				  "but should be %u.%u", HILO(ext->this_ext),
+				  HILO(len), HILO(fe->extents[i].num_bytes));
+		}
+
+		/* Add bitmap entry for the extent itself */
+		add_bm_data(ext->alloc_file_off, 1, ext->alloc_node, ext->this_ext,
+			    bm_extent);
+
+		if (fe->granularity) {
+			type = ext->granularity ? OCFS_EXTENT_HEADER : OCFS_EXTENT_DATA;
+			traverse_extent(fd, ext, type, buf, indx);
+		} else {
+			handle_leaf_extents(fd, ext->extents, ext->next_free_ext,
+					    OCFS_INVALID_NODE_NUM, ext->this_ext);
+		}
+	}
+
+bail:
+	return ;
+}				/* traverse_fe_extents */
+
+
+/*
+ * check_next_data_ext()
+ *
+ */
+int check_next_data_ext(ocfs_file_entry *fe, void *buf, int indx)
+{
+	void *ptr;
+	int i;
+	__u64 next_data_ext;
+	ocfs_extent_group *ext;
+	int ret = 0;
+
+	ptr = buf + ((indx - 1) * OCFS_SECTOR_SIZE);
+
+	for (i = indx - 1, next_data_ext = 0; i >= 0; --i,
+	     ptr -= OCFS_SECTOR_SIZE) {
+		ext = (ocfs_extent_group *)ptr;
+
+		if (ext->type != OCFS_EXTENT_DATA)
+			continue;
+
+		if (ext->next_data_ext != next_data_ext) {
+			LOG_ERROR("ext->next_data_ext=%u.%u in extent "
+				  "%u.%u instead of %u.%u",
+				  HILO(ext->next_data_ext),
+				  HILO(ext->this_ext),
+				  HILO(next_data_ext));
+			ret = -1;
+		}
+		next_data_ext = ext->this_ext;
+	}
+
+	return ret;
+}				/* check_next_data_ext */
+
+/*
+ * check_fe_last_data_ext()
+ *
+ */
+int check_fe_last_data_ext(ocfs_file_entry *fe, void *buf, int indx)
+{
+	ocfs_extent_group *ext;
+	int ret = 0;
+
+	ext = (ocfs_extent_group *) (buf + ((indx - 1) * OCFS_SECTOR_SIZE));
+
+	if (fe->last_ext_ptr != ext->this_ext) {
+		LOG_ERROR("fe->last_ext_ptr=%u.%u in fe %u.%u "
+			  "instead of %u.%u", HILO(fe->last_ext_ptr),
+			  HILO(fe->this_sector), HILO(ext->this_ext));
+		ret = -1;
+	}
+
+	return ret;
+}				/* check_fe_last_data_ext */
+
+/*
+ * check_dir_index()
+ *
+ */
+int check_dir_index (char *dirbuf, __u64 dir_offset)
+{
+	ocfs_file_entry *fe = NULL;
+	ocfs_dir_node *dirnode = (ocfs_dir_node *)dirbuf;
+	int ret = 0;
+	__u8 i;
+	__u8 j;
+	__u8 offset;
+	__u8 ind1[256];
+	__u8 ind2[256];
+	ocfs_disk_structure *dirst = &dirnode_t;
+
+	memset(ind1, 0, 256);
+	memset(ind2, 0, 256);
+
+	/* Any erroneous/duplicates/deleted files in the index */
+	for (i = 0, j = 0; i < dirnode->num_ent_used; ++i) {
+		offset = dirnode->index[i];
+
+		/* erroneous */
+		if (offset > 253)
+			continue;
+
+		/* duplicates */
+		if (ind1[offset] == 0)
+			ind1[offset] = 1;
+		else
+			continue;
+
+		/* deleted */
+		fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirbuf) +
+					  (offset * OCFS_SECTOR_SIZE));
+		if (IS_FE_DELETED(fe->sync_flags))
+			continue;
+
+		/* good ones in ind2 */
+		ind2[j++] = offset;
+	}
+
+	/* Use new num_ents_used */
+	if (j != dirnode->num_ent_used) {
+		LOG_ERROR("Incorrect number of entries found in dirnode");
+		if (ctxt.write_changes) {
+			globaldir = dirnode;
+			qsort(ind2, j, sizeof(__u8), fe_compare_func);
+			memcpy(dirnode->index, ind2, 256);
+			dirnode->num_ent_used = j;
+
+			if (dirst->write(ctxt.fd, dirbuf, dir_offset, 0) == -1) {
+				LOG_INTERNAL();
+				exit(1);
+			} else
+				LOG_PRINT("Fixed");
+		} else
+			LOG_PRINT("To fix, rerun with -w");
+		goto bail;
+	}
+
+	/* Is the index in sorted order */
+	globaldir = dirnode;
+	memset(ind1, 0, 256);
+	memcpy(ind1, dirnode->index, dirnode->num_ent_used);
+	qsort(ind1, dirnode->num_ent_used, sizeof(__u8), fe_compare_func);
+
+	if (memcmp(ind1, dirnode->index, dirnode->num_ent_used) != 0) {
+		LOG_ERROR("Bad dir index found");
+		if (ctxt.write_changes) {
+			memcpy(dirnode->index, ind1, dirnode->num_ent_used);
+
+			if (dirst->write(ctxt.fd, dirbuf, dir_offset, 0) == -1) {
+				LOG_INTERNAL();
+				exit(1);
+			} else
+				LOG_PRINT("Fixed");
+		} else
+			LOG_PRINT("To fix, rerun with -w");
+	}
+bail:
+	return ret;
+}				/* check_dir_index */
+
+
+/*
+ * check_num_del()
+ *
+ */
+int check_num_del (char *dirbuf, __u64 dir_offset)
+{
+	ocfs_file_entry *fe = NULL;
+	ocfs_dir_node *dirnode = (ocfs_dir_node *)dirbuf;
+	int i;
+	int j;
+	int ret = 0;
+	__u8 offset;
+	__u8 ind[256];
+
+	if (dirnode->num_del == 0 && dirnode->num_ent_used == 0)
+		goto bail;
+
+	if (dirnode->num_del == 0 && dirnode->num_ent_used > 0) {
+		memset(ind, 0, 256);
+		for (i = 0; i < dirnode->num_ent_used; ++i) {
+			if (dirnode->index[i] >= dirnode->num_ent_used) {
+				ret = -1;
+				break;
+			}
+		}
+		goto bail;
+	}
+
+	/* num_del > 0 && dirnode->num_ents_used > 0 */
+	memset(ind, 0, 256);
+
+	offset = dirnode->first_del;
+	for (i = 0; i < dirnode->num_del; ++i) {
+		if (offset > 253) {
+			ret = -1;
+			break;
+		}
+
+		/* check if offset is in index and hence invalid */
+		for (j = 0; j < dirnode->num_ent_used; ++j) {
+			if (dirnode->index[j] == offset) {
+				ret = -1;
+				break;
+			}
+		}
+
+		/* check for circular list */
+		if (ind[offset]) {
+			ret = -1;
+			break;
+		} else
+			ind[offset] = 1;
+
+		fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode) +
+					  (offset * OCFS_SECTOR_SIZE));
+
+		/* file has to be deleted to be in the list */
+		if (fe->sync_flags) {
+			ret = -1;
+			break;
+		}
+
+		offset = (__u8)fe->next_del;
+	}
+
+bail:
+	return ret;
+}				/* check_num_del */
+
+
+/*
+ * fix_num_del()
+ *	Should be called after check_num_del()
+ */
+int fix_num_del (char *dirbuf, __u64 dir_offset)
+{
+	ocfs_dir_node *dirnode = (ocfs_dir_node *)dirbuf;
+	ocfs_file_entry *fe = NULL;
+	int i;
+	int j;
+	int num_del;
+	__u8 largest_off = 0;
+	__u8 ind[256];
+	__u8 offset;
+	__u64 feoff;
+	ocfs_disk_structure *dirst = &dirnode_t;
+	ocfs_disk_structure *fest = &fileent_t;
+
+	memset (ind, 0xFF, 256);
+	
+	/* largest offset in index */
+	for (i = 0; i < dirnode->num_ent_used; ++i)
+		largest_off = max(largest_off, dirnode->index[i]);
+
+	num_del = largest_off - dirnode->num_ent_used + 1;
+
+	if (!num_del)
+		goto bail;
+
+	fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode));
+
+	for (i = 0, j = 0; i < largest_off; ++i) {
+		if (IS_FE_DELETED(fe->sync_flags))
+			ind[j++] = i;
+		fe = (ocfs_file_entry *)((char *)fe + OCFS_SECTOR_SIZE);
+	}
+
+	if (j != num_del) {
+		LOG_ERROR("while fixing num_del");
+		exit(1);
+	}
+
+	/* write dirnode */
+	dirnode->num_del = num_del;
+	dirnode->first_del = ind[0];
+	if (dirst->write(ctxt.fd, dirbuf, dir_offset, 0) == -1) {
+		LOG_INTERNAL();
+		exit(1);
+	}
+
+	for (i = 0; i < j; ++i) {
+		offset = ind[i];
+		fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode) +
+					  (offset * OCFS_SECTOR_SIZE));
+		feoff = dir_offset + ((1 + offset) * OCFS_SECTOR_SIZE);
+		fe->next_del = ind[i+1];
+		/* write fe */
+		if (fest->write(ctxt.fd, (char *)fe, feoff, 0) == -1) {
+			LOG_INTERNAL();
+			exit(1);
+		}
+	}
+
+bail:
+	return 0;
+}				/* fix_num_del */
+
+/*
+ * fix_fe_offsets()
+ *
+ */
+int fix_fe_offsets(char *dirbuf, __u64 dir_offset)
+{
+	ocfs_dir_node *dirnode = (ocfs_dir_node *)dirbuf;
+	ocfs_disk_structure *fest = &fileent_t;
+	ocfs_file_entry *fe;
+	__u64 feoff;
+	__u8 off;
+	int i;
+
+	for (i = 0; i < dirnode->num_ent_used; ++i) {
+		off = dirnode->index[i];
+		fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode) +
+					  (off * OCFS_SECTOR_SIZE));
+		feoff = dir_offset + ((1 + off) * OCFS_SECTOR_SIZE);
+
+		if (IS_FE_DELETED(fe->sync_flags)) {
+			LOG_INTERNAL();
+			exit(1);
+		}
+
+		if (fe->this_sector != feoff ||
+		    fe->dir_node_ptr != dir_offset) {
+			if (ctxt.write_changes) {
+				fe->this_sector = feoff;
+				fe->dir_node_ptr = dir_offset;
+				/* write fe */
+				if (fest->write(ctxt.fd, (char *)fe, feoff, 0) == -1) {
+					LOG_INTERNAL();
+					exit(1);
+				}
+			}
+		}
+	}
+
+	return 0;
+}				/* fix_fe_offsets */

Deleted: trunk/fsck/ver.c
===================================================================
--- trunk/ocfs/fsck/ver.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/ver.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,41 +0,0 @@
-/*
- * ver.c
- *
- * prints version
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#include <stdio.h>
-
-void version(char *progname);
-
-/*
- * version()
- *
- */
-void version(char *progname)
-{
-	printf("%s %s %s (build %s)\n", progname,
-					FSCK_BUILD_VERSION,
-					FSCK_BUILD_DATE,
-					FSCK_BUILD_MD5);
-	return ;
-}				/* version */

Copied: trunk/fsck/ver.c (from rev 205, trunk/ocfs/fsck/ver.c)

Deleted: trunk/fsck/verify.c
===================================================================
--- trunk/ocfs/fsck/verify.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/verify.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,980 +0,0 @@
-/*
- * verify.c
- *
- * verification checks for ocfs file system check utility
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#include "fsck.h"
-
-
-extern ocfsck_context ctxt;
-extern bool never_mounted;
-extern __u32 fs_version;
-
-/*
- * test_member_range()
- *
- */
-int test_member_range(ocfs_class *cl, const char *name, char *buf)
-{
-	ocfs_class_member *mbr;
-	int i, ret = -1;
-
-	mbr = find_class_member(cl, name, &i);
-	if (mbr->valid(buf, &(mbr->type)) != 0)
-		ret = i;
-	return ret;
-}				/* test_member_range */
-
-/*
- * check_outside_bounds()
- *
- */
-int check_outside_bounds(char *buf, int structsize)
-{
-	int i;
-	/* check for oddities */
-	for (i=structsize; i<512; i++)
-		if (buf[i] != 0)
-			return -1;
-	return 0;
-}				/* check_outside_bounds */
-
-/*
- * verify_nodecfghdr()
- *	 ocfs_disk_lock disk_lock;
- *	 char signature[NODE_CONFIG_SIGN_LEN];
- *	 __u32 version;
- *	 __u32 num_nodes;
- *	 __u32 last_node;
- *	 __u64 cfg_seq_num;
- */
-int verify_nodecfghdr (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	int ret = 0;
-	ocfs_node_config_hdr *hdr;
-	ocfs_layout_t *lay;
-	ocfs_class *cl;
-	ocfs_class_member *mbr;
-	int i;
-
-	hdr = (ocfs_node_config_hdr *)buf;
-	lay = find_nxt_hdr_struct(node_cfg_hdr, 0);
-	cl = lay->kind->cls;
-	*bad = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-	if (check_outside_bounds(buf, sizeof(ocfs_node_config_hdr)) == -1)
-		LOG_WARNING("nonzero bytes after the disk structure");
-
-	ret = verify_disk_lock (fd, buf, offset, idx, bad);
-
-	if (hdr->version != NODE_CONFIG_VER) {
-		mbr = find_class_member(cl, "version", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-
-	if (hdr->num_nodes > OCFS_MAXIMUM_NODES) {
-		mbr = find_class_member(cl, "num_nodes", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-
-	if (g_hash_table_size(*bad) == 0)
-		ret = 0;
-
-	return ret;
-}				/* verify_nodecfghdr */
-
-/*
- * verify_nodecfginfo()
- *	ocfs_disk_lock disk_lock;
- *	char node_name[MAX_NODE_NAME_LENGTH + 1];
- *	ocfs_guid guid;
- *	ocfs_ipc_config_info ipc_config;
- */
-int verify_nodecfginfo (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	int ret = 0;
-	ocfs_disk_node_config_info *node;
-	ocfs_layout_t *lay;
-	ocfs_class *cl;
-
-	node = (ocfs_disk_node_config_info *)buf;
-	lay = find_nxt_hdr_struct(node_cfg_info, 0);
-	cl = lay->kind->cls;
-	*bad = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-	if (check_outside_bounds(buf, sizeof(ocfs_disk_node_config_info)) == -1)
-		LOG_WARNING("nonzero bytes after the disk structure");
-
-	ret = verify_disk_lock (fd, buf, offset, idx, bad);
-
-	if (g_hash_table_size(*bad) == 0)
-		ret = 0;
-
-	return ret;
-}				/* verify_nodecfginfo */
-
-/*
- * verify_system_file_entry()
- *
- */
-int verify_system_file_entry (int fd, char *buf, __u64 offset, int idx, GHashTable **bad, char *fname, int type)
-{
-	int ret, i;
-	ocfs_file_entry *fe;
-	ocfs_class_member *mbr;
-	ocfs_class *cl;
-	int slot;
-
-	cl = &ocfs_file_entry_class;
-	fe = (ocfs_file_entry *)buf;
-
-	ret = verify_file_entry (fd, buf, offset, idx, bad);
-
-	if (strncmp(fe->filename, fname, strlen(fname)) != 0)
-	{
-		mbr = find_class_member(cl, "filename", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-		ret = -1;
-	}
-
-	slot = (((fe->this_sector - ctxt.hdr->data_start_off) / 512) % 32);
-	check_file_entry(fd, fe, fe->this_sector, slot, true, "$");
-
-	if (fe->disk_lock.curr_master != ((type+idx) % OCFS_MAXIMUM_NODES) &&
-	    fe->disk_lock.curr_master != OCFS_INVALID_NODE_NUM &&
-	    fe->disk_lock.file_lock != OCFS_DLM_NO_LOCK) {
-		LOG_ERROR("bug 3038188 found! system file locked "
-			  "by another node: file=%s type=%d idx=%d node=%d",
-			  fname, type, idx, fe->disk_lock.curr_master);
-		LOG_ERROR("solution: unmount on all nodes except %d, then "
-			  "touch a file in any directory on node %d",
-			  ((type+idx) % OCFS_MAXIMUM_NODES), ((type+idx) % OCFS_MAXIMUM_NODES));
-	}
-
- 	return ret;
-}				/* verify_system_file_entry */
-
-#include <unistd.h>
-#include <linux/unistd.h>
-
-
-/*
- * load_sysfile_bitmap()
- *
- */
-static int load_sysfile_bitmap (int fd, char *buf, int idx, bool dirbm)
-{
-	int ret = -1;
-	ocfs_file_entry *fe;
-	loff_t prev;
-	char *ptr;
-	int fileid;
-
-	fe = (ocfs_file_entry *)buf;
-
-	if (fe->file_size <= 0) {
-		ret = 0;
-		goto bail;
-	}
-	
-	if (dirbm) {
-		if ((ctxt.dir_bm[idx] = malloc_aligned(fe->alloc_size)) == NULL) {
-			LOG_INTERNAL();
-			goto bail;
-		}
-		memset(ctxt.dir_bm[idx], 0, fe->alloc_size);
-		ctxt.dir_bm_sz[idx] = fe->file_size;
-		ptr = ctxt.dir_bm[idx];
-		fileid = idx + OCFS_FILE_DIR_ALLOC_BITMAP;
-	} else {
-		if ((ctxt.ext_bm[idx] = malloc_aligned(fe->alloc_size)) == NULL) {
-			LOG_INTERNAL();
-			goto bail;
-		}
-		memset(ctxt.ext_bm[idx], 0, fe->alloc_size);
-		ctxt.ext_bm_sz[idx] = fe->file_size;
-		ptr = ctxt.ext_bm[idx];
-		fileid = idx + OCFS_FILE_FILE_ALLOC_BITMAP;
-	}
-
-	if ((prev=myseek64(fd, 0ULL, SEEK_CUR)) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	ret = ocfs_read_system_file(ctxt.vcb, fileid, ptr, fe->alloc_size,
-				    (__u64)0);
-#if 0
-	if (ret >= 0) {
-		ocfs_alloc_bm bm;
-		int freebits, firstclear;
-
-		LOG_VERBOSE("succeeded\n");
-		ocfs_initialize_bitmap(&bm, ptr, (__u32) (fe->file_size * 8));
-		freebits = ocfs_count_bits(&bm);
-		firstclear = ocfs_find_clear_bits(&bm, 1, 0, 0);
-		LOG_VERBOSE("freebits=%d firstclear=%d numbits=%llu\n",
-			    freebits, firstclear, fe->file_size * 8);
-	} else {
-		LOG_VERBOSE("failed\n");
-	}
-#endif
-
-	if ((prev=myseek64(fd, prev, SEEK_SET)) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-      bail:
-	return ret;
-}				/* load_sysfile_bitmap */
-
-/*
- * verify_dir_alloc_bitmap()
- *
- */
-int verify_dir_alloc_bitmap (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	char fname[30];
-	sprintf(fname, "%s%d", "DirBitMapFile", idx+OCFS_FILE_DIR_ALLOC_BITMAP);
-	load_sysfile_bitmap(fd, buf, idx, true);
-	return verify_system_file_entry (fd, buf, offset, idx, bad, fname, OCFS_FILE_DIR_ALLOC_BITMAP);
-}				/* verify_dir_alloc_bitmap */
-
-/*
- * verify_file_alloc_bitmap()
- *
- */
-int verify_file_alloc_bitmap (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	char fname[30];
-	sprintf(fname, "%s%d", "ExtentBitMapFile", idx+OCFS_FILE_FILE_ALLOC_BITMAP);
-	load_sysfile_bitmap(fd, buf, idx, false);
-	return verify_system_file_entry (fd, buf, offset, idx, bad, fname, OCFS_FILE_FILE_ALLOC_BITMAP);
-}				/* verify_file_alloc_bitmap */
-
-/*
- * verify_dir_alloc()
- *
- */
-int verify_dir_alloc (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	char fname[30];
-	sprintf(fname, "%s%d", "DirFile", idx+OCFS_FILE_DIR_ALLOC);
-	return verify_system_file_entry (fd, buf, offset, idx, bad, fname, OCFS_FILE_DIR_ALLOC);
-}				/* verify_dir_alloc */
-
-/*
- * verify_file_alloc()
- *
- */
-int verify_file_alloc (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	char fname[30];
-	sprintf(fname, "%s%d", "ExtentFile", idx+OCFS_FILE_FILE_ALLOC);
-	return verify_system_file_entry (fd, buf, offset, idx, bad, fname, OCFS_FILE_FILE_ALLOC);
-}				/* verify_file_alloc */
-
-/*
- * verify_vol_metadata()
- *
- */
-int verify_vol_metadata (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	char fname[30];
-	sprintf(fname, "%s", "VolMetaDataFile");  // no file #
-	return verify_system_file_entry (fd, buf, offset, idx, bad, fname, OCFS_FILE_VOL_META_DATA);
-}				/* verify_vol_metadata */
-
-/*
- * verify_vol_metadata_log()
- *
- */
-int verify_vol_metadata_log (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	char fname[30];
-	sprintf(fname, "%s", "VolMetaDataLogFile");  // no file #
-	return verify_system_file_entry (fd, buf, offset, idx, bad, fname, OCFS_FILE_VOL_LOG_FILE);
-}				/* verify_vol_metadata_log */
-
-/*
- * verify_cleanup_log()
- *
- */
-int verify_cleanup_log (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	char fname[30];
-	sprintf(fname, "%s%d", "CleanUpLogFile", idx+CLEANUP_FILE_BASE_ID);
-	return verify_system_file_entry (fd, buf, offset, idx, bad, fname, CLEANUP_FILE_BASE_ID);
-}				/* verify_cleanup_log */
-
-/*
- * verify_recover_log()
- *
- */
-int verify_recover_log (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	char fname[30];
-	sprintf(fname, "%s%d", "RecoverLogFile", idx+LOG_FILE_BASE_ID);
-	return verify_system_file_entry (fd, buf, offset, idx, bad, fname, LOG_FILE_BASE_ID);
-}				/* verify_recover_log */
-
-/*
- * verify_volume_bitmap()
- *
- */
-int verify_volume_bitmap (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	return 0;
-}				/* verify_volume_bitmap */
-
-/*
- * verify_publish_sector()
- *
- */
-int verify_publish_sector (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	int i;
-	ocfs_publish *pub;
-	ocfs_class *cl;
-
-	pub = (ocfs_publish *)buf;
-	cl = &ocfs_publish_class;
-	*bad = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-	if ((i = test_member_range(cl, "time", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "vote", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "dirty", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "vote_type", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "vote_map", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "publ_seq_num", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "dir_ent", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "comm_seq_num", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	if (g_hash_table_size(*bad) == 0)
-		return 0;
-	return -1;
-}				/* verify_publish_sector */
-
-/*
- * verify_vote_sector()
- *
- */
-int verify_vote_sector (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	int i;
-	ocfs_vote *vote;
-	ocfs_class *cl;
-
-	vote = (ocfs_vote *)buf;
-	cl = &ocfs_vote_class;
-	*bad = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-	if ((i = test_member_range(cl, "vote", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "vote_seq_num", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "dir_ent", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "open_handle", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	if (g_hash_table_size(*bad) == 0)
-		return 0;
-	return -1;
-}				/* verify_vote_sector */
-
-/*
- * verify_dir_node()
- *
- */
-int verify_dir_node (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	int ret = 0;
-	ocfs_class *cl;
-
-	cl = &ocfs_dir_node_class;
-	*bad = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-	if (check_outside_bounds(buf, sizeof(ocfs_dir_node)) == -1)
-		LOG_WARNING("nonzero bytes after the disk structure");
-
-	/* ocfs_disk_lock disk_lock; */ 
-	ret = verify_disk_lock (fd, buf, offset, idx, bad);
-
-	/* __u64 alloc_file_off;     */ 
-	/* __u32 alloc_node;         */ 
-	/* __u64 free_node_ptr;      */ 
-	/* __u64 node_disk_off;      */ 
-	/* __s64 next_node_ptr;      */ 
-	/* __s64 indx_node_ptr;      */ 
-	/* __s64 next_del_ent_node;  */ 
-	/* __s64 head_del_ent_node;  */ 
-
-	/* __u8 index[256];          */
-	check_dir_index(buf, offset);
-
-	/* __u8 first_del;           */
-	/* __u8 num_del;             */
-	ret = check_num_del(buf, offset);
-	if (ret) {
-		LOG_ERROR("Bad list of deleted entries found");
-		if (ctxt.write_changes) {
-			fix_num_del(buf, offset);
-			LOG_PRINT("Fixed");
-		} else
-			LOG_PRINT("To fix, rerun with -w");
-		ret = 0;
-	}
-
-	/* __u8 num_ents;	     */
-	/* __u8 depth;		     */
-	/* __u8 num_ent_used;	     */
-	/* __u8 dir_node_flags;	     */
-	/* __u8 sync_flags;          */
-	/* __u8 index_dirty;         */
-	/* __u8 bad_off;             */
-	/* __u64 num_tot_files;      */
-	/* __u8 reserved[119];       */
-	/* __u8 file_ent[1];         */
-
-	fix_fe_offsets(buf, offset);
-
-	if (g_hash_table_size(*bad) == 0)
-		ret = 0;
-
-	return 0;
-}				/* verify_dir_node */
-
-/*
- * verify_file_entry()
- *
- */
-int verify_file_entry (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	int ret = 0;
-	ocfs_file_entry *fe;
-	ocfs_class *cl;
-	ocfs_class_member *mbr;
-	int i;
-	int j;
-	__u64 size = 0;
-	__u64 off = 0;
-	char tmpstr[255];
-
-	fe = (ocfs_file_entry *)buf;
-	cl = &ocfs_file_entry_class;
-	*bad = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-	if (check_outside_bounds(buf, sizeof(ocfs_file_entry)) == -1)
-		LOG_WARNING("nonzero bytes after the disk structure");
-
-	/* ocfs_disk_lock disk_lock; */
-	ret = verify_disk_lock (fd, buf, offset, idx, bad);
-
-	/* bool local_ext;     */
-	/* __s32 granularity;  */
-	if ((fe->local_ext && fe->granularity != -1) ||
-	    (!fe->local_ext && fe->granularity < 0)) {
-		mbr = find_class_member(cl, "local_ext", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-		mbr = find_class_member(cl, "granularity", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-
-	/* __u8 next_free_ext; */
-	if (fe->next_free_ext > OCFS_MAX_FILE_ENTRY_EXTENTS) {
-		mbr = find_class_member(cl, "next_free_ext", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-
-	/* __s8 next_del; fix_fe_offset */
-
-	/* __u8 filename[OCFS_MAX_FILENAME_LENGTH]; */
-	/* __u16 filename_len; */
-	
-	for (j = 0; j < OCFS_MAX_FILE_ENTRY_EXTENTS; j++)
-		size += fe->extents[j].num_bytes;
-
-	/* __u64 file_size;    */
-	if (!(fe->attribs & OCFS_ATTRIB_DIRECTORY) && fe->file_size > size) {
-		mbr = find_class_member(cl, "file_size", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	
-	/* __u64 alloc_size;   */
-	if (!(fe->attribs & OCFS_ATTRIB_DIRECTORY) && fe->alloc_size != size) {
-		mbr = find_class_member(cl, "alloc_size", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-
-	/* __u64 create_time;  */
-	/* __u64 modify_time;  */
-
-	/* ocfs_alloc_ext extents[OCFS_MAX_FILE_ENTRY_EXTENTS]; */
-	for (j = 0, off = 0; j < OCFS_MAX_FILE_ENTRY_EXTENTS; ++j) {
-		if (!fe->extents[j].num_bytes)
-			continue;
-
-		if (fe->extents[j].file_off != off) {
-			sprintf(tmpstr, "extents[%d].file_off", j);
-			mbr = find_class_member(cl, tmpstr, &i);
-			g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-		}
-
-		off += fe->extents[j].num_bytes;
-
-		if (fe->extents[j].num_bytes && !fe->extents[j].disk_off) {
-			sprintf(tmpstr, "extents[%d].num_bytes", j);
-			mbr = find_class_member(cl, tmpstr, &i);
-			g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-		}
-	}
-
-	/* __u64 dir_node_ptr; fix_fe_offset */
-
-	/* __u64 this_sector;  fix_fe_offset */
-	if (!fe->this_sector) {
-		mbr = find_class_member(cl, "this_sector", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-
-	/* __u64 last_ext_ptr; */
-	if (!fe->local_ext && !fe->last_ext_ptr) {
-		mbr = find_class_member(cl, "last_ext_ptr", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-
-	/* __u32 sync_flags;  */
-	/* __u32 link_cnt;  */
-	/* __u32 attribs;   */
-	/* __u32 prot_bits; */
-	/* __u32 uid;       */
-	/* __u32 gid;       */
-	/* __u16 dev_major; */
-	/* __u16 dev_minor; */
-
-	if (g_hash_table_size(*bad) == 0)
-		ret = 0;
-
-	return 0;
-}				/* verify_file_entry */
-
-/*
- * verify_extent_group()
- *
- */
-int verify_extent_group (int fd, char *buf, __u64 offset, int idx, GHashTable **bad, int type, __u64 up_ptr)
-{
-	ocfs_extent_group *ext;
-	ocfs_class *cl;
-	ocfs_class_member *mbr;
-	int i, j;
-	char mname[255];
-	__u64 len;
-
-	ext = (ocfs_extent_group *)buf;
-	cl = &ocfs_extent_group_class;
-	*bad = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-	if (ext->type != type) {
-		mbr = find_class_member(cl, "type", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-
-	if ((i = test_member_range(cl, "next_free_ext", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	if ((i = test_member_range(cl, "curr_sect", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	if ((i = test_member_range(cl, "max_sects", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	if ((i = test_member_range(cl, "alloc_node", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	if ((i = test_member_range(cl, "this_ext", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	if ((i = test_member_range(cl, "next_data_ext", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	if ((i = test_member_range(cl, "alloc_file_off", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	if ((i = test_member_range(cl, "last_ext_ptr", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	if ((i = test_member_range(cl, "granularity", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	// make sure the up_ptr isn't b0rk3n
-	if (up_ptr != 0ULL && ext->up_hdr_node_ptr != up_ptr) {
-		i = test_member_range(cl, "up_hdr_node_ptr", buf);
-		if (i != -1)
-			g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-
-	len = ext->extents[0].file_off;
-	for (j = 0; j < OCFS_MAX_DATA_EXTENTS; j++) {
-		if (!ext->extents[j].num_bytes)
-			continue;
-
-		if (ext->extents[j].file_off != len) {
-			sprintf(mname, "extents[%d].file_off", j);
-			mbr = find_class_member(cl, mname, &i);
-			g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-		}
-
-		len += ext->extents[j].num_bytes;
-
-		if (ext->extents[j].num_bytes && !ext->extents[j].disk_off) {
-			sprintf(mname, "extents[%d].num_bytes", i);
-			mbr = find_class_member(cl, mname, &i);
-			g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-		}
-	}
-
-	if (g_hash_table_size(*bad) == 0)
-		return 0;
-
-	return -1;
-}				/* verify_extent_group */
-
-/*
- * verify_extent_header()
- *
- */
-int verify_extent_header (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	return verify_extent_group(fd, buf, offset, idx, bad, OCFS_EXTENT_HEADER, 0ULL);
-}				/* verify_extent_header */
-
-/*
- * verify_extent_data()
- *
- */
-int verify_extent_data (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	return verify_extent_group(fd, buf, offset, idx, bad, OCFS_EXTENT_DATA, 0ULL);
-}				/* verify_extent_data */
-
-
-
-// TODO: FIXME error handling
-/*
- * load_volume_bitmap()
- *
- */
-int load_volume_bitmap(void)
-{
-	loff_t old;
-	int ret = -1;
-
-	/* assumes the hdr has already been verified */
-	if (ctxt.hdr->bitmap_off == 0) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	if ((old = myseek64(ctxt.fd, 0, SEEK_CUR)) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	if (myseek64(ctxt.fd, ctxt.hdr->bitmap_off, SEEK_SET) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	if (myread(ctxt.fd, ctxt.vol_bm, VOL_BITMAP_BYTES) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	if (myseek64(ctxt.fd, old, SEEK_SET) == -1) {
-		LOG_INTERNAL();
-		goto bail;
-	}
-
-	ret = 0;
-
-      bail:
-	return ret;
-}				/* load_volume_bitmap */
-
-/*
- * verify_vol_disk_header()
- *
- */
-int verify_vol_disk_header(int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	int len, ret = -1;
-	__u64 j;
-	ocfs_dir_node *dir = NULL;
-	ocfs_vol_disk_hdr *hdr;
-	ocfs_layout_t *lay;
-	ocfs_class *cl;
-	ocfs_class_member *mbr;
-	int i;
-
-	dir = (ocfs_dir_node *) malloc_aligned(512);
-	hdr = (ocfs_vol_disk_hdr *)buf;
-	lay = find_nxt_hdr_struct(vol_disk_header, 0);
-	cl = lay->kind->cls;
-	*bad = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-	if (check_outside_bounds(buf, sizeof(ocfs_vol_disk_hdr)) == -1) {
-		LOG_WARNING("nonzero bytes after the disk header structure");
-	}
-
-#if 0
-	if (hdr->minor_version != OCFS_MINOR_VERSION)
-	{
-		mbr = find_class_member(cl, "minor_version", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->major_version != OCFS_MAJOR_VERSION)
-	{
-		mbr = find_class_member(cl, "major_version", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-#endif
-
-	if (hdr->major_version == 1)
-		fs_version = 1;
-	else if (hdr->major_version == 2)
-		fs_version = 2;
-	else {
-		mbr = find_class_member(cl, "major_version", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-
-	if (strncmp(hdr->signature, OCFS_VOLUME_SIGNATURE, MAX_VOL_SIGNATURE_LEN) != 0)
-	{
-		mbr = find_class_member(cl, "signature", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	len = strnlen(hdr->mount_point, MAX_MOUNT_POINT_LEN);
-	if (len == MAX_MOUNT_POINT_LEN || len < OCFSCK_MIN_MOUNT_POINT_LEN)
-	{
-		mbr = find_class_member(cl, "mount_point", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->bitmap_off != OCFSCK_BITMAP_OFF)
-	{
-		mbr = find_class_member(cl, "bitmap_off", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->publ_off != OCFSCK_PUBLISH_OFF)
-	{
-		mbr = find_class_member(cl, "publ_off", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->vote_off != OCFSCK_VOTE_OFF)
-	{
-		mbr = find_class_member(cl, "vote_off", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->node_cfg_off != OCFSCK_AUTOCONF_OFF)
-	{
-		mbr = find_class_member(cl, "node_cfg_off", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->node_cfg_size !=  OCFSCK_AUTOCONF_SIZE)
-	{
-		mbr = find_class_member(cl, "node_cfg_size", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->new_cfg_off != OCFSCK_NEW_CFG_OFF)
-	{
-		mbr = find_class_member(cl, "new_cfg_off", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->data_start_off != OCFSCK_DATA_START_OFF)
-	{
-		mbr = find_class_member(cl, "data_start_off", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->internal_off == 0)
-		never_mounted = true;
-	else if (hdr->internal_off != OCFSCK_INTERNAL_OFF)
-	{
-		mbr = find_class_member(cl, "internal_off", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->num_nodes != (__u64)OCFS_MAXIMUM_NODES)
-	{
-		mbr = find_class_member(cl, "num_nodes", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->serial_num != 0ULL)
-	{
-		mbr = find_class_member(cl, "serial_num", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->start_off != 0ULL)
-	{
-		mbr = find_class_member(cl, "start_off", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->root_bitmap_off != 0ULL)
-	{
-		mbr = find_class_member(cl, "root_bitmap_off", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->root_bitmap_size != 0ULL)
-	{
-		mbr = find_class_member(cl, "root_bitmap_size", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->root_size != 0ULL)
-	{
-		mbr = find_class_member(cl, "root_size", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->dir_node_size != 0ULL)
-	{
-		mbr = find_class_member(cl, "dir_node_size", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if (hdr->file_node_size != 0ULL)
-	{
-		mbr = find_class_member(cl, "file_node_size", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	if ((i = test_member_range(cl, "excl_mount", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "uid", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "gid", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "prot_bits", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	if (hdr->device_size > ctxt.device_size)
-	{
-		mbr = find_class_member(cl, "device_size", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-	
-	ctxt.cluster_size_bits = 11; // 2048
-	for (j = OCFSCK_LO_CLUSTER_SIZE; j <= OCFSCK_HI_CLUSTER_SIZE; j *= 2)
-	{
-		ctxt.cluster_size_bits++;
-		if (hdr->cluster_size == j)
-		{
-			if (j * hdr->num_clusters > ctxt.device_size - OCFSCK_NON_DATA_AREA ||
-			    hdr->num_clusters < 1 || hdr->num_clusters > OCFSCK_MAX_CLUSTERS)
-			{
-				mbr = find_class_member(cl, "num_clusters", &i);
-				g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-			}
-			break;
-		}
-	}
-	if (j > OCFSCK_HI_CLUSTER_SIZE)
-	{
-		mbr = find_class_member(cl, "cluster_size", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-
-	/* the root off is *always* at OCFSCK_ROOT_OFF */
-	/* and we can no longer do the signature check because */
-	/* it may be bad and we want to be able to change it later */
-	if (hdr->root_off == 0)
-		never_mounted = true;
-	else if (hdr->root_off != OCFSCK_ROOT_OFF)
-	{
-		mbr = find_class_member(cl, "root_off", &i);
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	}
-
-
-	if (g_hash_table_size(*bad) == 0)
-	{
-		memcpy(ctxt.hdr, buf, OCFS_SECTOR_SIZE);
-		ctxt.vcb = get_fake_vcb(ctxt.fd, ctxt.hdr, /* node# */ 0);
-		if ((ret = load_volume_bitmap()) != 0)
-			LOG_ERROR("failed to read volume bitmap");
-	}
-	if (dir)
-		free_aligned(dir);
-	return ret;
-}				/* verify_vol_disk_header */
-
-/*
- * verify_vol_label()
- *
- */
-int verify_vol_label (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	ocfs_vol_label *lbl;
-
-	lbl = (ocfs_vol_label *)buf;
-
-	if (check_outside_bounds(buf, sizeof(ocfs_vol_label)) == -1) {
-		LOG_WARNING("nonzero bytes after the volume label structure");
-	}
-
-	return verify_disk_lock (fd, buf, offset, idx, bad);
-}				/* verify_vol_label */
-
-/*
- * verify_disk_lock()
- *
- */
-int verify_disk_lock (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
-{
-	ocfs_disk_lock *lock;
-	ocfs_class *cl;
-	int i;
-
-	lock = (ocfs_disk_lock *)buf;
-	cl = &ocfs_disk_lock_class;
-	*bad = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-	if ((i = test_member_range(cl, "curr_master", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "writer_node_num", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "reader_node_num", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "oin_node_map", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-	if ((i = test_member_range(cl, "file_lock", buf)) != -1)
-		g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
-
-	if (g_hash_table_size(*bad) == 0)
-		return 0;
-	return -1;
-}				/* verify_disk_lock */

Copied: trunk/fsck/verify.c (from rev 205, trunk/ocfs/fsck/verify.c)

Deleted: trunk/fsck/verify.h
===================================================================
--- trunk/ocfs/fsck/verify.h	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/fsck/verify.h	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,57 +0,0 @@
-/*
- * verify.h
- *
- * Function prototypes, macros, etc. for related 'C' files
- *
- * Copyright (C) 2003 Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Sunil Mushran
- */
-
-#ifndef VERIFY_H
-#define VERIFY_H
-
-int test_member_range(ocfs_class *cl, const char *name, char *buf);
-int check_outside_bounds(char *buf, int structsize);
-int verify_vol_disk_header  (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_disk_lock (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_vol_label  (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_nodecfghdr (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_nodecfginfo (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_cleanup_log (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_dir_alloc (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_dir_alloc_bitmap (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_file_alloc (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_file_alloc_bitmap (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_publish_sector (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_recover_log (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_vol_metadata (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_vol_metadata_log (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_volume_bitmap (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_vote_sector (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_dir_node (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_file_entry (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_extent_group (int fd, char *buf, __u64 offset, int idx, GHashTable **bad,
-			 int type, __u64 up_ptr);
-int verify_extent_header (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_extent_data (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
-int verify_system_file_entry (int fd, char *buf, __u64 offset, int idx, GHashTable **bad, 
-			      char *fname, int type);
-int load_volume_bitmap(void);
-
-#endif /* VERIFY_H */

Copied: trunk/fsck/verify.h (from rev 205, trunk/ocfs/fsck/verify.h)

Copied: trunk/libocfs (from rev 204, trunk/ocfs/libocfs)

Copied: trunk/libocfs/Common (from rev 205, trunk/ocfs/libocfs/Common)

Copied: trunk/libocfs/Linux (from rev 205, trunk/ocfs/libocfs/Linux)

Deleted: trunk/libocfs/Makefile
===================================================================
--- trunk/ocfs/libocfs/Makefile	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/libocfs/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,126 +0,0 @@
-TOPDIR = ../..
-
-include $(TOPDIR)/Preamble.make
-
-WARNINGS = -Wall -Wstrict-prototypes -Wno-format
-
-ifneq ($(OCFS_PROCESSOR),x86_64)
-WARNINGS += -Wmissing-prototypes -Wmissing-declarations
-endif
-
-ifdef OCFS_DEBUG
-OPTS += -g
-endif
-
-DEFINES = -DLINUX -DUSERSPACE_TOOL
-
-INCLUDES = -I. -ICommon/inc -ILinux/inc
-
-LIBRARIES = libocfs.a
-
-CFLAGS = $(OPTS) -fno-strict-aliasing -pthread $(WARNINGS)
-
-OPTIMIZE = -O2
-
-ifeq ($(OCFS_PROCESSOR),ppc64)
-endif
-ifeq ($(OCFS_PROCESSOR),x86_64)
-  CFLAGS += -m64
-endif
-ifeq ($(OCFS_PROCESSOR),ia64)
-endif
-ifeq ($(OCFS_PROCESSOR),i686)
-  DEFINES += -D__ILP32__
-endif
-ifeq ($(OCFS_PROCESSOR),s390x)
-  DEFINES += -D__LP64__
-endif
-
-CFLAGS += $(OPTIMIZE)
-
-ifdef OCFS_DEBUG
-DEFINES += -DDEBUG
-endif
-
-ifdef OCFS_TRACE
-DEFINES += -DTRACE
-endif
-
-CPARTNER = \
-	Common/ocfsgenalloc.c	\
-	Common/ocfsgensysfile.c	\
-	Common/ocfsgencreate.c	\
-	Common/ocfsgenutil.c	\
-	Common/ocfsgenmisc.c	\
-	Common/ocfsgentrans.c	\
-	Common/ocfsgendirnode.c	\
-	Common/ocfsgenvolcfg.c	\
-	Linux/ocfsmount.c	\
-	Linux/ocfsfile.c	\
-	Linux/ocfsport.c	\
-	Linux/ocfsbitmap.c	\
-	Linux/ocfshash.c	\
-	Common/ocfsgennm.c	\
-	Common/ocfsheartbeat.c	\
-	Common/ocfsgendlm.c 	\
-	libocfs.c		\
-	bindraw.c
-
-CALONE = \
-	Linux/ocfsdlm.c
-
-CFILES = $(CPARTNER) $(CALONE)
-
-HTEMP1 = $(subst .c,.h,$(CPARTNER))
-HTEMP2 = $(subst Common,Common/inc,$(HTEMP1))
-HPARTNER = $(subst Linux,Linux/inc,$(HTEMP2))
-
-HALONE = \
-	Common/inc/ocfs.h		\
-	Common/inc/ocfsbool.h		\
-	Common/inc/ocfsdef.h		\
-	Common/inc/ocfserr.h		\
-	Common/inc/ocfstrace.h		\
-	Common/inc/ocfsvol.h		\
-	Common/inc/ocfscom.h		\
-	Common/inc/ocfsdisk.h		\
-	Common/inc/ocfstrans.h		\
-	Common/inc/ocfsconst.h		\
-	Common/inc/ocfsdlm.h		\
-	Common/inc/ocfsver.h		\
-	Common/inc/ocfsgenvote.h	\
-	Linux/inc/ocfsdlmp.h		\
-	Linux/inc/ocfsioctl.h		\
-	Linux/inc/ocfsiosup.h		\
-	Linux/inc/ocfsmain.h		\
-	Linux/inc/ocfsproc.h
-
-HFILES = $(HPARTNER) $(HALONE)
-
-$(CFILES): $(HFILES)
-
-OBJS = $(subst .c,.o,$(CFILES))
-
-ifeq ($(OCFS_PROCESSOR),s390x)
-  OBJS += bitmap.o
-endif
-
-libocfs.a: $(OBJS)
-	rm -f $@
-	$(AR) r $@ $^
-	$(RANLIB) $@
-
-CLEAN_RULES = clean-libocfs
-
-clean-libocfs:
-	rm -f Common/*.o Linux/*.o Common/*.p Linux/*.p Common/*.s Linux/*.s *.o *.p *.s
-
-DIST_FILES = $(CFILES) $(HFILES) bitmap.S
-
-DIST_RULES = dist-subdircreate
-
-dist-subdircreate:
-	$(TOPDIR)/mkinstalldirs $(DIST_DIR)/Common/inc
-	$(TOPDIR)/mkinstalldirs $(DIST_DIR)/Linux/inc
-
-include $(TOPDIR)/Postamble.make

Copied: trunk/libocfs/Makefile (from rev 205, trunk/ocfs/libocfs/Makefile)
===================================================================
--- trunk/ocfs/libocfs/Makefile	2004-08-30 22:26:51 UTC (rev 205)
+++ trunk/libocfs/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -0,0 +1,126 @@
+TOPDIR = ..
+
+include $(TOPDIR)/Preamble.make
+
+WARNINGS = -Wall -Wstrict-prototypes -Wno-format
+
+ifneq ($(OCFS_PROCESSOR),x86_64)
+WARNINGS += -Wmissing-prototypes -Wmissing-declarations
+endif
+
+ifdef OCFS_DEBUG
+OPTS += -g
+endif
+
+DEFINES = -DLINUX -DUSERSPACE_TOOL
+
+INCLUDES = -I. -ICommon/inc -ILinux/inc
+
+LIBRARIES = libocfs.a
+
+CFLAGS = $(OPTS) -fno-strict-aliasing -pthread $(WARNINGS)
+
+OPTIMIZE = -O2
+
+ifeq ($(OCFS_PROCESSOR),ppc64)
+endif
+ifeq ($(OCFS_PROCESSOR),x86_64)
+  CFLAGS += -m64
+endif
+ifeq ($(OCFS_PROCESSOR),ia64)
+endif
+ifeq ($(OCFS_PROCESSOR),i686)
+  DEFINES += -D__ILP32__
+endif
+ifeq ($(OCFS_PROCESSOR),s390x)
+  DEFINES += -D__LP64__
+endif
+
+CFLAGS += $(OPTIMIZE)
+
+ifdef OCFS_DEBUG
+DEFINES += -DDEBUG
+endif
+
+ifdef OCFS_TRACE
+DEFINES += -DTRACE
+endif
+
+CPARTNER = \
+	Common/ocfsgenalloc.c	\
+	Common/ocfsgensysfile.c	\
+	Common/ocfsgencreate.c	\
+	Common/ocfsgenutil.c	\
+	Common/ocfsgenmisc.c	\
+	Common/ocfsgentrans.c	\
+	Common/ocfsgendirnode.c	\
+	Common/ocfsgenvolcfg.c	\
+	Linux/ocfsmount.c	\
+	Linux/ocfsfile.c	\
+	Linux/ocfsport.c	\
+	Linux/ocfsbitmap.c	\
+	Linux/ocfshash.c	\
+	Common/ocfsgennm.c	\
+	Common/ocfsheartbeat.c	\
+	Common/ocfsgendlm.c 	\
+	libocfs.c		\
+	bindraw.c
+
+CALONE = \
+	Linux/ocfsdlm.c
+
+CFILES = $(CPARTNER) $(CALONE)
+
+HTEMP1 = $(subst .c,.h,$(CPARTNER))
+HTEMP2 = $(subst Common,Common/inc,$(HTEMP1))
+HPARTNER = $(subst Linux,Linux/inc,$(HTEMP2))
+
+HALONE = \
+	Common/inc/ocfs.h		\
+	Common/inc/ocfsbool.h		\
+	Common/inc/ocfsdef.h		\
+	Common/inc/ocfserr.h		\
+	Common/inc/ocfstrace.h		\
+	Common/inc/ocfsvol.h		\
+	Common/inc/ocfscom.h		\
+	Common/inc/ocfsdisk.h		\
+	Common/inc/ocfstrans.h		\
+	Common/inc/ocfsconst.h		\
+	Common/inc/ocfsdlm.h		\
+	Common/inc/ocfsver.h		\
+	Common/inc/ocfsgenvote.h	\
+	Linux/inc/ocfsdlmp.h		\
+	Linux/inc/ocfsioctl.h		\
+	Linux/inc/ocfsiosup.h		\
+	Linux/inc/ocfsmain.h		\
+	Linux/inc/ocfsproc.h
+
+HFILES = $(HPARTNER) $(HALONE)
+
+$(CFILES): $(HFILES)
+
+OBJS = $(subst .c,.o,$(CFILES))
+
+ifeq ($(OCFS_PROCESSOR),s390x)
+  OBJS += bitmap.o
+endif
+
+libocfs.a: $(OBJS)
+	rm -f $@
+	$(AR) r $@ $^
+	$(RANLIB) $@
+
+CLEAN_RULES = clean-libocfs
+
+clean-libocfs:
+	rm -f Common/*.o Linux/*.o Common/*.p Linux/*.p Common/*.s Linux/*.s *.o *.p *.s
+
+DIST_FILES = $(CFILES) $(HFILES) bitmap.S
+
+DIST_RULES = dist-subdircreate
+
+dist-subdircreate:
+	$(TOPDIR)/mkinstalldirs $(DIST_DIR)/Common/inc
+	$(TOPDIR)/mkinstalldirs $(DIST_DIR)/Linux/inc
+
+include $(TOPDIR)/Postamble.make

Deleted: trunk/libocfs/bindraw.c
===================================================================
--- trunk/ocfs/libocfs/bindraw.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/libocfs/bindraw.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,160 +0,0 @@
-
-/*
- * bindraw.c
- *
- * Binds device to first available raw device
- *
- * Copyright (C) 2004, Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Sunil Mushran
- */
-
-#include <sys/raw.h>
-
-#include "libocfs.h"
-#include "bindraw.h"
-
-/*
- * bind_raw()
- *
- */
-int bind_raw(char *blk_dev, int *raw_minor, char *raw_dev, int rdlen)
-{
-	int fd = 0;
-	int i;
-	struct raw_config_request rcs;
-	struct stat statbuf;
-	int ret = -1;
-
-	memset(&statbuf, 0, sizeof(struct stat));
-	if (stat(blk_dev, &statbuf) == -1) {
-		LOG_ERROR("%s", strerror(errno));
-		goto bail;
-	}
-
-	if (MAJOR(statbuf.st_rdev) == 0) {
-		LOG_ERROR("Invalid device %s", blk_dev);
-		goto bail;
-	}
-
-	if (strstr(blk_dev, "/dev/raw")) {
-		strncpy(raw_dev, blk_dev, rdlen-1);
-		raw_dev[rdlen-1] = '\0';
-	}
-	else {
-		fd = open("/dev/rawctl", O_RDWR);
-		if (fd == -1) {
-			LOG_ERROR("Error opening /dev/rawctl.\n%s",
-				  strerror(errno));
-			goto bail;
-		}
-
-		for (i = 1; i < 255; ++i) {
-			memset(&rcs, 0, sizeof(struct raw_config_request));
-			rcs.raw_minor = i;
-			if (ioctl(fd, RAW_GETBIND, &rcs) == -1)
-				continue;
-			if (rcs.block_major == 0)
-				break;
-		}
-
-		if (i >= 255) {
-			LOG_ERROR("unable to find a free raw device /dev/raw/rawXX");
-			goto bail;
-		}
-
-		*raw_minor = i;
-		snprintf(raw_dev, rdlen, "/dev/raw/raw%d", i);
-
-		rcs.raw_minor = i;
-		rcs.block_major = (__u64)MAJOR(statbuf.st_rdev);
-		rcs.block_minor = (__u64)MINOR(statbuf.st_rdev);
-		if (ioctl(fd, RAW_SETBIND, &rcs) == -1) {
-			LOG_ERROR("%s", strerror(errno));
-			*raw_minor = 0;
-			raw_dev[0] = '\0';
-			goto bail;
-		}
-	}
-
-	ret = 0;
-bail:
-	if (fd)
-		close(fd);
-
-	return ret;
-}				/* bind_raw */
-
-/*
- * unbind_raw()
- *
- */
-void unbind_raw(int raw_minor)
-{
-	int fd = 0;
-	struct raw_config_request rcs;
-	
-	if (raw_minor == 0)
-		goto bail;
-
-	/* printf("Unbinding %d\n", raw_minor); */
-
-	fd = open("/dev/rawctl", O_RDWR);
-	if (fd == -1) {
-		LOG_ERROR("Error opening /dev/rawctl.\n%s",
-			  strerror(errno));
-		goto bail;
-	}
-
-	rcs.raw_minor = raw_minor;
-	rcs.block_major = 0;
-	rcs.block_minor = 0;
-	if (ioctl(fd, RAW_SETBIND, &rcs) == -1) {
-		LOG_ERROR("%s", strerror(errno));
-		goto bail;
-	}
-
-bail:
-	if (fd)
-		close(fd);
-	return ;
-}				/* unbind_raw */
-
-static void signal_message (int sig)
-{
-#define LINE1 "Abnormal termination!\n"
-#define LINE2 "There may be bound raw devices left lying around, please clean them up\n"
-#define LINE3 "using the raw(8) command.\n"
-
-  write(2, LINE1, sizeof(LINE1) - 1);
-  write(2, LINE2, sizeof(LINE2) - 1);
-  write(2, LINE3, sizeof(LINE3) - 1);
-
-  signal(sig, SIG_DFL);
-
-  raise(sig);
-}
-
-void init_raw_cleanup_message(void)
-{
-    signal (SIGHUP, signal_message);
-    signal (SIGQUIT, signal_message);
-    signal (SIGABRT, signal_message);
-    signal (SIGBUS, signal_message);
-    signal (SIGSEGV, signal_message);
-}

Copied: trunk/libocfs/bindraw.c (from rev 205, trunk/ocfs/libocfs/bindraw.c)

Deleted: trunk/libocfs/bindraw.h
===================================================================
--- trunk/ocfs/libocfs/bindraw.h	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/libocfs/bindraw.h	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,35 +0,0 @@
-
-/*
- * bindraw.h
- *
- * Declarations, prototypes, etc.
- *
- * Copyright (C) 2004, Oracle.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Authors: Sunil Mushran
- */
-
-#ifndef _BINDRAW_H_
-#define _BINDRAW_H_
-
-int bind_raw(char *blk_dev, int *raw_minor, char *raw_dev, int rdlen);
-void unbind_raw(int raw_minor);
-
-void init_raw_cleanup_message(void);
-
-#endif

Copied: trunk/libocfs/bindraw.h (from rev 205, trunk/ocfs/libocfs/bindraw.h)

Deleted: trunk/libocfs/bitmap.S
===================================================================
--- trunk/ocfs/libocfs/bitmap.S	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/libocfs/bitmap.S	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,55 +0,0 @@
-/*
- *  arch/s390/kernel/bitmap.S
- *    Bitmaps for set_bit, clear_bit, test_and_set_bit, ...
- *    See include/asm-s390/{bitops.h|posix_types.h} for details
- *
- *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky (schwidefsky at de.ibm.com),
- */
-
-         .globl _oi_bitmap
-_oi_bitmap:
-         .byte  0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80
-
-         .globl _ni_bitmap
-_ni_bitmap:
-         .byte  0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F
-
-         .globl _zb_findmap
-_zb_findmap:
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4 
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4
-         .byte  0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,8
-
-         .globl _sb_findmap
-_sb_findmap:
-         .byte  8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-         .byte  4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0

Copied: trunk/libocfs/bitmap.S (from rev 205, trunk/ocfs/libocfs/bitmap.S)

Deleted: trunk/libocfs/libocfs.c
===================================================================
--- trunk/ocfs/libocfs/libocfs.c	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/libocfs/libocfs.c	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,256 +0,0 @@
-/*
- * libocfs.c
- *
- * provides dummy functions for userspace tools
- * to allow ocfs kernel module source to work in userspace
- *
- * Copyright (C) 2002, 2003 Oracle Corporation.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Author: Kurt Hackel
- */
-
-#define DUMMY_C_LOCAL_DECLS
-#include <libocfs.h>
-#undef DUMMY_C_LOCAL_DECLS
-#include <string.h>
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-long TIME_ZERO = 0;
-__u32 osb_id;
-__u32 mount_cnt;
-ocfs_ipc_ctxt OcfsIpcCtxt;
-
-#if 0
-ocfs_global_ctxt OcfsGlobalCtxt = {
-	.pref_node_num = -1,
-	.node_name = "userspacetool",
-	.comm_info = {OCFS_UDP, "0.0.0.0", OCFS_IPC_DEFAULT_PORT, NULL}
-};
-#endif
-extern ocfs_global_ctxt OcfsGlobalCtxt;
-
-bool ocfs_linux_get_inode_offset (struct inode * inode, __u64 * off, ocfs_inode ** oin)
-{
-    return false;
-}
-
-bool ocfs_linux_get_dir_entry_offset (ocfs_super * osb, __u64 * off, __u64 parentOff,
-				struct qstr * fileName, ocfs_file_entry ** fileEntry)
-{
-    return false;
-}
-
-void complete(struct completion *c)
-{
-}
-
-void ocfs_release_cached_oin (ocfs_super * osb, ocfs_inode * oin)
-{
-}
-
-void init_waitqueue_head(wait_queue_head_t *q)
-{
-}
-
-void init_MUTEX (struct semaphore *sem)
-{
-}
-
-
-void truncate_inode_pages(struct address_space *as, loff_t off)
-{
-}
-
-unsigned int kdev_t_to_nr(kdev_t dev)
-{
-	return 0;
-}
-
-void init_special_inode(struct inode *inode, umode_t mode, int x)
-{
-}
-
-int fsync_inode_buffers(struct inode *inode)
-{
-	return 0;
-}
-
-void d_prune_aliases(struct inode *inode)
-{
-
-}
-
-void get_random_bytes(void *buf, int nbytes)
-{
-	FILE *f;
-
-	f = fopen("/dev/random", "r");
-	if (!f) {
-		fprintf(stderr, "get_random_bytes: cannot open /dev/random\n");
-		exit(1);
-	}
-	if (fread(buf, 1, nbytes, f) != nbytes) {
-		fprintf(stderr, "get_random_bytes: cannot read /dev/random\n");
-		fclose(f);
-		exit(1);
-	}
-	fclose(f);
-}
-
-char *ocfs_strerror(int errnum) 
-{
-	return strerror(errnum);
-}
-
-void *ocfs_linux_dbg_alloc(int Size, char *file, int line)
-{
-    return malloc_aligned(Size);
-}
-void ocfs_linux_dbg_free (const void *Buffer)
-{
-    free_aligned((void *)Buffer);
-}
-
-int ocfs_write_disk(ocfs_super * vcb, void *buf, __u32 len, __u64 off)
-{
-    return ocfs_write_force_disk(vcb, buf, len, off);
-}
-
-int LinuxWriteForceDisk(ocfs_super * vcb, void *buf, __u32 len, __u64 off,
-			bool cached)
-{
-    int fd;
-    
-    fd = (int) vcb->sb->s_dev;
-
-    lseek64(fd, off, SEEK_SET);
-
-    if (write(fd, buf, len) == -1) {
-	    fprintf(stderr, "fd is %d\n", fd);
-	    fprintf(stderr, "LinuxWriteForceDisk: Could not write: %s\n", strerror(errno));
-	    return(-EFAIL);
-    }
-    
-    return 0;
-}
-
-int ocfs_write_force_disk(ocfs_super * vcb, void *buf, __u32 len, __u64 off)
-{
-    return LinuxWriteForceDisk(vcb, buf, len, off, false);
-}
-#if 0
-int ocfs_write_metadata(ocfs_super * vcb, void *buf, __u32 len, __u64 off)
-{
-    return ocfs_write_force_disk(vcb, buf, len, off);
-}
-#endif
-
-int ocfs_read_force_disk_ex (ocfs_super * osb, void **Buffer, __u32 AllocLen,
-			     __u32 ReadLen, __u64 Offset)
-{
-	return ocfs_read_disk_ex(osb, Buffer, AllocLen, ReadLen, Offset);
-}
-int ocfs_read_disk_ex (ocfs_super * osb, void **Buffer, __u32 AllocLen,
-		       __u32 ReadLen, __u64 Offset) 
-{
-	if (!Buffer)
-		return -EINVAL;
-	if (!*Buffer) {
-		*Buffer = malloc_aligned(AllocLen);
-		if (!*Buffer)
-			return -ENOMEM;
-	}
-	return ocfs_read_disk(osb, *Buffer, ReadLen, Offset);
-}
-
-
-int ocfs_read_disk(ocfs_super * vcb, void *buf, __u32 len, __u64 off)
-{
-    int fd;
-
-    fd = (int) vcb->sb->s_dev;
-
-    lseek64(fd, off, SEEK_SET);
-
-    if (read(fd, buf, len) == -1) {
-	    fprintf(stderr, "ocfs_read_disk: Could not read: %s\n", strerror(errno));
-	    return(-EFAIL);
-    }
-
-    return (0);
-}
-
-int LinuxReadForceDisk(ocfs_super * VCB, void *Buffer, __u32 Length,
-		       __u64 Offset, bool Cached)
-{
-    return ocfs_read_disk(VCB, Buffer, Length, Offset);
-}
-int ocfs_read_force_disk(ocfs_super * VCB, void *Buffer, __u32 Length, __u64 Offset)
-{
-    return ocfs_read_disk(VCB, Buffer, Length, Offset);
-}
-#if 0
-int ocfs_read_metadata(ocfs_super * VCB, void *Buffer, __u32 Length, __u64 Offset)
-{
-    return ocfs_read_disk(VCB, Buffer, Length, Offset);
-}
-#endif
-
-
-ocfs_super *get_fake_vcb(int fd, ocfs_vol_disk_hdr * hdr, int nodenum)
-{
-    ocfs_super *vcb;
-
-    /* fake a few VCB values */
-    vcb = (ocfs_super *) malloc_aligned(sizeof(ocfs_super));
-    if (!vcb)
-	    return NULL;
-    vcb->sb = malloc_aligned(sizeof(struct super_block));
-    if (!vcb->sb) {
-	    free_aligned(vcb);
-	    return NULL;
-    }
-
-    vcb->vol_layout.root_start_off = hdr->root_off;
-    vcb->vol_layout.root_int_off = hdr->internal_off;
-    vcb->vol_layout.cluster_size = hdr->cluster_size;
-    vcb->vol_layout.data_start_off = hdr->data_start_off;
-    vcb->vol_layout.node_cfg_off = hdr->node_cfg_off;
-    vcb->vol_layout.node_cfg_size = hdr->node_cfg_size;
-
-    vcb->sect_size = 512;
-    vcb->curr_trans_id = 0;
-    vcb->sb->s_dev = fd;
-    vcb->node_num = nodenum;
-
-    return vcb;
-}
-
-
-void * malloc_aligned(int size)
-{
-	return memalign(512, size);
-}
-
-void free_aligned(void *ptr)
-{
-	if (ptr)
-		free(ptr);
-}

Copied: trunk/libocfs/libocfs.c (from rev 205, trunk/ocfs/libocfs/libocfs.c)

Deleted: trunk/libocfs/libocfs.h
===================================================================
--- trunk/ocfs/libocfs/libocfs.h	2004-08-27 00:43:26 UTC (rev 204)
+++ trunk/libocfs/libocfs.h	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,492 +0,0 @@
-/*
- * libocfs.h
- *
- * kernel dummy types, macros, etc. used by userspace tools
- *
- * Copyright (C) 2002, 2003 Oracle Corporation.  All rights reserved.
- *
- * 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 021110-1307, USA.
- *
- * Author: Kurt Hackel, Sunil Mushran
- */
-
-#ifndef _LIBOCFS_H_
-#define _LIBOCFS_H_
-
-#ifndef DUMMY_C_LOCAL_DECLS
-extern long TIME_ZERO;
-#endif
-
-/* Horrific, for SuSE */
-#ifdef __ia64__
-#define ia64_cmpxchg(sem,ptr,old,new,size)						\
-({											\
-	__typeof__(ptr) _p_ = (ptr);							\
-	__typeof__(new) _n_ = (new);							\
-	__u64 _o_, _r_;									\
-											\
-	switch (size) {									\
-	      case 1: _o_ = (__u8 ) (long) (old); break;				\
-	      case 2: _o_ = (__u16) (long) (old); break;				\
-	      case 4: _o_ = (__u32) (long) (old); break;				\
-	      case 8: _o_ = (__u64) (long) (old); break;				\
-	      default: break;								\
-	}										\
-	 __asm__ __volatile__ ("mov ar.ccv=%0;;" :: "rO"(_o_));				\
-	switch (size) {									\
-	      case 1:									\
-		__asm__ __volatile__ ("cmpxchg1."sem" %0=[%1],%2,ar.ccv"		\
-				      : "=r"(_r_) : "r"(_p_), "r"(_n_) : "memory");	\
-		break;									\
-											\
-	      case 2:									\
-		__asm__ __volatile__ ("cmpxchg2."sem" %0=[%1],%2,ar.ccv"		\
-				      : "=r"(_r_) : "r"(_p_), "r"(_n_) : "memory");	\
-		break;									\
-											\
-	      case 4:									\
-		__asm__ __volatile__ ("cmpxchg4."sem" %0=[%1],%2,ar.ccv"		\
-				      : "=r"(_r_) : "r"(_p_), "r"(_n_) : "memory");	\
-		break;									\
-											\
-	      case 8:									\
-		__asm__ __volatile__ ("cmpxchg8."sem" %0=[%1],%2,ar.ccv"		\
-				      : "=r"(_r_) : "r"(_p_), "r"(_n_) : "memory");	\
-		break;									\
-											\
-	      default:									\
-		_r_ = 0;								\
-		break;									\
-	}										\
-	(__typeof__(old)) _r_;								\
-})
-
-#define cmpxchg_acq(ptr,o,n)	ia64_cmpxchg("acq", (ptr), (o), (n), sizeof(*(ptr)))
-#endif
-
-/* Get large file support */
-#define _GNU_SOURCE
-
-/* plain old user stuff */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-#include <time.h>
-#include <sys/time.h>
-#include <sys/mman.h>
-
-/* Special case, cause of twisty nested includes */
-#ifndef _LINUX_LIST_H
-#define INIT_LIST_HEAD(a)	do { } while(0)
-#define list_add_tail(a,b)	do { } while(0)
-#define list_del(a)		do { } while(0)
-struct list_head
-{
-    struct list_head *next, *prev;
-};
-#endif
-
-/* reqd by ocfsformat */
-#undef WNOHANG
-#undef WUNTRACED
-#include <linux/fs.h>
-
-#include <pthread.h>
-#include <sched.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-
-#include <asm/bitops.h>
-
-
-/* it sucks, but i have to fake a few types to get by */
-#define spin_lock_init(lock)    do { } while(0)
-#define spin_lock(lock)         (void)(lock) /* Not "unused variable". */
-#define spin_is_locked(lock)    (0)
-#define spin_trylock(lock)      ({1; })
-#define spin_unlock_wait(lock)  do { } while(0)
-#define spin_unlock(lock)       do { } while(0)
-#define down(x)			do { } while(0)
-#define up(x)			do { } while(0)
-#define init_timer(x)		do { } while(0)
-#define wake_up(x)		do { } while(0)
-#define max(a,b)		((a) < (b) ? (b) : (a))
-#define min(a,b)		((a) < (b) ? (a) : (b))
-#define CURRENT_TIME		(time(NULL))
-#define init_completion(x)	do { } while(0)
-#define HZ			(100)
-#define jiffies                 ({ struct timeval tv; \
-				   long j; \
-				   gettimeofday(&tv, NULL); \
-				   if (TIME_ZERO==0) \
-				     TIME_ZERO = tv.tv_sec; \
-				   j = (tv.tv_sec - TIME_ZERO) * HZ; \
-				   if (j < 0) \
-				     j = 0; \
-				   j += ((tv.tv_usec) / (1000000 / HZ)); \
-				   (j); })
-#define time_after(a,b)		((long)(b) - (long)(a) < 0)
-#define kmalloc(a, b) malloc_aligned(a)
-#define vmalloc(a)    malloc_aligned(a)
-#define kfree(a)      free_aligned(a)
-#define vfree(a)      free_aligned(a)
-#define fsync_no_super(fd)     fsync(fd)
-#define printk(a, x...)    fprintf(stderr, a, ##x)
-#define BUG()              fprintf(stderr, "BUG!\n")
-
-#define OCFS_PAGE_SIZE  4096
-#define IN
-#define OUT
-#define KERN_ERR   
-#define FILE_BUFFER_SIZE  (1048576 * 2)
-#define ATTR_MODE       1
-#define ATTR_UID        2
-#define ATTR_GID        4
-#define ATTR_SIZE       8
-#define ATTR_ATIME      16
-#define ATTR_MTIME      32
-#define ATTR_CTIME      64
-#define ATTR_ATIME_SET  128
-#define ATTR_MTIME_SET  256
-#define ATTR_FORCE      512     /* Not a change, but a change it */
-#define ATTR_ATTR_FLAG  1024
-#define NODEV 0
-
-#ifndef UINT_MAX
-#define UINT_MAX	(~0U)
-#endif
-#ifndef ULONG_MAX
-#define ULONG_MAX	(~0U)
-#endif
-
-
-
-#define DELETED_FLAGS  (OCFS_SYNC_FLAG_DELETED | \
-			OCFS_SYNC_FLAG_MARK_FOR_DELETION | \
-			OCFS_SYNC_FLAG_NAME_DELETED)
-
-
-
-typedef unsigned short kdev_t;
-
-struct buffer_head {
-	int a;
-};
-
-struct address_space {
-	int a;
-};
-
-struct iattr { 
-    unsigned long long ia_size;
-    int ia_uid;
-    int ia_gid;
-    int ia_mode;
-    int ia_ctime;
-    int ia_mtime;
-    int ia_valid;
-};
-
-typedef int spinlock_t;
-typedef int wait_queue_head_t;
-
-struct completion {
-	unsigned int done;
-	wait_queue_head_t wait;
-};
-
-struct timer_list {
-	unsigned long expires;
-	unsigned long data;
-	void (*function)(unsigned long);
-};
-
-struct super_block
-{
-    int s_dev;
-    union {
-	    void *generic_sbp;
-    } u;
-};
-
-struct semaphore
-{
-    int semid;
-};
-struct inode
-{
-    void * i_mapping;
-    struct list_head i_dentry;
-    int i_nlink;
-    struct super_block *i_sb;
-    unsigned int i_flags;
-    unsigned long i_ino;
-    int i_mode;
-    unsigned long long i_size;
-    int i_uid;
-    int i_gid;
-    unsigned long i_blocks;
-    unsigned long i_blksize;
-    int i_ctime;
-    int i_atime;
-    int i_mtime;
-    kdev_t i_rdev;
-    union {
-        void *generic_ip;
-    } u;
-};
-struct qstr {
-	const unsigned char * name; 
-	unsigned int len;
-	unsigned int hash;
-};
-struct dentry 
-{
-	struct qstr d_name;
-	struct inode *d_inode;
-};
-typedef int kmem_cache_t;
-struct tq_struct
-{
-    int a;
-};
-
-
-struct task_struct
-{
-    pthread_t thread;
-};
-
-union semun {
-	int val;                    /* value for SETVAL */
-	struct semid_ds *buf;       /* buffer for IPC_STAT, IPC_SET */
-	unsigned short int *array;  /* array for GETALL, SETALL */
-	struct seminfo *__buf;      /* buffer for IPC_INFO */
-};
-
-/* aligned alloc prototypes */
-void *memalign(size_t boundary, size_t size);
-void * malloc_aligned(int size);
-void free_aligned(void *ptr);
-
-#ifndef ATOMIC_INIT
-
-/* atomic_t stuff */
-
-#if !defined(_ASM_IA64_ATOMIC_H) && !defined(__ARCH_X86_64_ATOMIC__) && !defined(__ARCH_I386_ATOMIC__) && !defined(_PPC_BITOPS_H) /* yes bitops is right. RH sucks and uses stub headers which still define _ASM_PPC_ATOMIC_H_ */
-typedef struct { volatile int counter; } atomic_t;
-#endif
-
-#define ATOMIC_INIT(i)  { (i) }
-
-#define atomic_read(v)          ((v)->counter)
-#define atomic_set(v,i)         (((v)->counter) = (i))
-
-static inline void atomic_inc(atomic_t *v)
-{
-    v->counter++;
-}
-
-static inline int atomic_dec_and_test(atomic_t *v)
-{
-    v->counter--;
-    return v->counter != 0;
-}
-#endif
-
-
-#if !defined(test_bit)
-
-#if defined(__powerpc__) && !defined(__powerpc64__)
-
-static __inline__ void set_bit(int nr, volatile void * addr)
-{
-	unsigned long old;
-	unsigned long mask = 1 << (nr & 0x1f);
-	unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
-
-	__asm__ __volatile__("\n\
-1:	lwarx   %0,0,%3 \n\
-        or      %0,%0,%2 \n\
-	stwcx.  %0,0,%3 \n\
-	bne-    1b"
-	: "=&r" (old), "=m" (*p)
-	: "r" (mask), "r" (p), "m" (*p)
-	: "cc" );
-}
-
-static __inline__ void clear_bit(int nr, volatile void *addr)
-{
-	unsigned long old;
-	unsigned long mask = 1 << (nr & 0x1f);
-	unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
-
-	__asm__ __volatile__("\n\
-1:	lwarx   %0,0,%3 \n\
-	andc    %0,%0,%2 \n\
-	stwcx.  %0,0,%3 \n\
-	bne-    1b"
-	: "=&r" (old), "=m" (*p)
-	: "r" (mask), "r" (p), "m" (*p)
-	: "cc");
-}
-
-static __inline__ int __test_and_clear_bit(int nr, volatile void *addr)
-{
-	unsigned long mask = 1 << (nr & 0x1f);
-	unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
-	unsigned long old = *p;
-
-	*p = old & ~mask;
-	return (old & mask) != 0;
-}
-
-static __inline__ int test_bit(int nr, __const__ volatile void *addr)
-{
-	__const__ unsigned int *p = (__const__ unsigned int *) addr;
-
-	return ((p[nr >> 5] >> (nr & 0x1f)) & 1) != 0;
-}
-
-static __inline__ int __ilog2(unsigned int x)
-{
-	int lz;
-
-	asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x));
-	return 31 - lz;
-}
-
-static __inline__ int ffz(unsigned int x)
-{
-	if ((x = ~x) == 0)
-		return 32;
-	return __ilog2(x & -x);
-}
-
-static __inline__ unsigned long find_next_zero_bit(void * addr,
-	unsigned long size, unsigned long offset)
-{
-	unsigned int * p = ((unsigned int *) addr) + (offset >> 5);
-	unsigned int result = offset & ~31UL;
-	unsigned int tmp;
-
-	if (offset >= size)
-		return size;
-	size -= result;
-	offset &= 31UL;
-	if (offset) {
-		tmp = *p++;
-		tmp |= ~0UL >> (32-offset);
-		if (size < 32)
-			goto found_first;
-		if (tmp != ~0U)
-			goto found_middle;
-		size -= 32;
-		result += 32;
-	}
-	while (size >= 32) {
-		if ((tmp = *p++) != ~0U)
-			goto found_middle;
-		result += 32;
-		size -= 32;
-	}
-	if (!size)
-		return result;
-	tmp = *p;
-found_first:
-	tmp |= ~0UL << size;
-	if (tmp == ~0UL)        /* Are any bits zero? */
-		return result + size; /* Nope. */
-found_middle:
-	return result + ffz(tmp);
-}
-
-#elif !defined(__ia64__)
-#error "Your platform doesn't provide the functions required in <asm/bitops.h>"
-#endif
-
-#endif /* !smp_mb__before_clear_bit */
-
-
-/* include all the rest from ocfs.h */
-#include <ocfsbool.h>
-#include <ocfscom.h>
-#include <ocfsconst.h>
-#include <ocfshash.h>
-#include <ocfstrace.h>
-#include <ocfsvol.h>
-#include <ocfsdisk.h>
-#include <ocfsdef.h>
-#include <ocfstrans.h>
-#include <ocfsdlm.h>
-#include <ocfsver.h>
-#include <ocfsiosup.h>
-#include <ocfsport.h>
-#include <ocfsgenmisc.h>
-#include <ocfsgenalloc.h>
-#include <ocfsgencreate.h>
-#include <ocfsgendirnode.h>
-#include <ocfsgendlm.h>
-#include <ocfsheartbeat.h>
-#include <ocfsgennm.h>
-#include <ocfsgensysfile.h>
-#include <ocfsgentrans.h>
-#include <ocfsgenutil.h>
-#include <ocfsgenvolcfg.h>
-#include <ocfsgenvote.h>
-#include <ocfsbitmap.h>
-#include <ocfsdlmp.h>
-#include <ocfsfile.h>
-#include <ocfsioctl.h>
-//#include <ocfsipc.h>
-#include <ocfsmain.h>
-#include <ocfsmount.h>
-#include <ocfsproc.h>
-
-
-/* Error reporting convenience function */
-#define LOG_ERROR(fmt, arg...)						\
-	do {								\
-		fprintf(stderr, "ERROR: ");				\
-		fprintf(stderr, fmt, ## arg);				\
-		fprintf(stderr, ", %s, %d\n", __FILE__, __LINE__);	\
-		fflush(stderr);						\
-	} while (0)
-
-
-/* prototypes for fake functions in libocfs.c */
-void complete(struct completion *c);
-void init_waitqueue_head(wait_queue_head_t *q);
-void init_MUTEX (struct semaphore *sem);
-void truncate_inode_pages(struct address_space *as, loff_t off);
-unsigned int kdev_t_to_nr(kdev_t dev);
-void init_special_inode(struct inode *inode, umode_t mode, int x);
-int fsync_inode_buffers(struct inode *inode);
-void d_prune_aliases(struct inode *inode);
-void get_random_bytes(void *buf, int nbytes);
-char *ocfs_strerror(int errnum) ;
-ocfs_super *get_fake_vcb(int fd, ocfs_vol_disk_hdr * hdr, int nodenum);
-
-
-#endif

Copied: trunk/libocfs/libocfs.h (from rev 205, trunk/ocfs/libocfs/libocfs.h)

Deleted: trunk/ocfs/Makefile
===================================================================
--- trunk/ocfs/Makefile	2004-08-30 22:26:51 UTC (rev 205)
+++ trunk/ocfs/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -1,7 +0,0 @@
-TOPDIR = ..
-
-include $(TOPDIR)/Preamble.make
-
-SUBDIRS = libocfs debugocfs format fsck bugfix
-
-include $(TOPDIR)/Postamble.make

Modified: trunk/ocfstool/Makefile
===================================================================
--- trunk/ocfstool/Makefile	2004-08-30 22:26:51 UTC (rev 205)
+++ trunk/ocfstool/Makefile	2004-08-30 22:37:59 UTC (rev 206)
@@ -15,7 +15,7 @@
 MANS = ocfstool.8
 
 DEFINES = -DOCFSTOOL_VERSION=\"$(VERSION)\"
-INCLUDES = $(GTK_CFLAGS) -I$(TOPDIR)/ocfs/libocfs -I$(TOPDIR)/ocfs/debugocfs
+INCLUDES = $(GTK_CFLAGS) -I$(TOPDIR)/libocfs -I$(TOPDIR)/debugocfs
 
 OPTIMIZE = -O2
 
@@ -58,6 +58,6 @@
 DIST_FILES = $(CFILES) $(HFILES) ocfstool.8.in
 
 ocfstool: $(OBJS)
-	$(LINK) $(GTK_LIBS) -L$(TOPDIR)/ocfs/debugocfs -ldebugocfs -L$(TOPDIR)/ocfs/libocfs -locfs
+	$(LINK) $(GTK_LIBS) -L$(TOPDIR)/debugocfs -ldebugocfs -L$(TOPDIR)/libocfs -locfs
 
 include $(TOPDIR)/Postamble.make



More information about the Ocfs-tools-commits mailing list