[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/gfs/gfs_mkfs Makefile device_geometry. ...



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rpeterso sourceware org	2006-07-10 23:39:35

Modified files:
	gfs/gfs_mkfs   : Makefile device_geometry.c fs_geometry.c main.c 
	                 mkfs_gfs.h structures.c 

Log message:
	Changes necessary due to removal of iddev parts (replaced by libvolume_id)
	Also incorporated libgfs for common functions.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_mkfs/Makefile.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_mkfs/device_geometry.c.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_mkfs/fs_geometry.c.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_mkfs/main.c.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_mkfs/mkfs_gfs.h.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_mkfs/structures.c.diff?cvsroot=cluster&r1=1.2&r2=1.3

--- cluster/gfs/gfs_mkfs/Makefile	2005/05/19 19:51:08	1.4
+++ cluster/gfs/gfs_mkfs/Makefile	2006/07/10 23:39:35	1.5
@@ -28,7 +28,7 @@
 	-DGFS_RELEASE_NAME=\"${RELEASE}\"
 
 INCLUDE= -I${top_srcdir}/include -I${top_srcdir}/config \
-	-I${gfskincdir} -I${iddevincdir} -I${incdir}
+	-I${gfskincdir} -I${incdir} -I${top_srcdir}/libgfs
 
 ifneq (${KERNEL_SRC}, )
 # Use the kernel tree if patched, otherwise, look where cluster headers
@@ -40,13 +40,12 @@
 INCLUDE += -I${incdir}
 endif
 
-LDFLAGS+= -L${iddevlibdir} -L${libdir}
-LOADLIBES+= -liddev
+LDFLAGS+=-L${top_srcdir}/libgfs -L${libdir}
 
 all: ${TARGET}
 
 gfs_mkfs: ${SOURCE}
-	${CC} ${CFLAGS} ${INCLUDE} ${LDFLAGS} ${SOURCE} ${LOADLIBES} ${LDLIBS} -o $@
+	${CC} ${CFLAGS} ${INCLUDE} ${LDFLAGS} ${SOURCE} ${LOADLIBES} ${LDLIBS} -o $@ -lgfs -lvolume_id
 
 copytobin: ${TARGET}
 	cp ${TARGET} ${top_srcdir}/bin
--- cluster/gfs/gfs_mkfs/device_geometry.c	2004/09/01 18:31:50	1.2
+++ cluster/gfs/gfs_mkfs/device_geometry.c	2006/07/10 23:39:35	1.3
@@ -27,13 +27,8 @@
 #include "global.h"
 #include <linux/gfs_ondisk.h>
 #include "osi_list.h"
-#include "iddev.h"
-
 #include "mkfs_gfs.h"
-
-
-
-
+#include "libgfs.h"
 
 /**
  * device_geometry - Get the size of a device
@@ -44,35 +39,31 @@
 
 void device_geometry(commandline_t *comline, mkfs_device_t *device)
 {
-  int fd;
-  uint64 bytes;
-  int error;
-
-
-  fd = open(comline->device, O_RDONLY);
-  if (fd < 0)
-    die("can't open %s: %s\n", comline->device, strerror(errno));
-
-  error = device_size(fd, &bytes);
-  if (error)
-    die("can't determine size of %s: %s\n", comline->device, strerror(errno));
+	int fd;
+	uint64 bytes;
+	int error;
 
-  close(fd);
+	fd = open(comline->device, O_RDONLY);
+	if (fd < 0)
+		die("can't open %s: %s\n", comline->device, strerror(errno));
 
+	error = device_size(fd, &bytes);
+	if (error)
+		die("can't determine size of %s: %s\n", comline->device, strerror(errno));
 
-  if (comline->debug)
-    printf("\nPartition size = %"PRIu64"\n", bytes >> 9);
+	close(fd);
 
+	if (comline->debug)
+		printf("\nPartition size = %"PRIu64"\n", bytes >> 9);
 
-  device->nsubdev = 1;
+	device->nsubdev = 1;
 
-  type_zalloc(device->subdev, mkfs_subdevice_t, 1);
+	type_zalloc(device->subdev, mkfs_subdevice_t, 1);
 
-  device->subdev->start = 0;
-  device->subdev->length = bytes >> 9;
+	device->subdev->start = 0;
+	device->subdev->length = bytes >> 9;
 }
 
-
 /**
  * add_journals_to_device - carve space out of a mkfs_device_t to add journals
  * @comline: the command line arguments
@@ -82,51 +73,44 @@
 
 void add_journals_to_device(commandline_t *comline, mkfs_device_t *device)
 {
-  mkfs_subdevice_t *old;
-  uint64 jsize;
-  unsigned int x;
-
-
-  MKFS_ASSERT(device->nsubdev == 1 &&
-	      !device->subdev->is_journal, );
-
+	mkfs_subdevice_t *old;
+	uint64 jsize;
+	unsigned int x;
 
-  if (!comline->journals)
-    die("No journals specified (use -j)\n");
+	MKFS_ASSERT(device->nsubdev == 1 &&
+				!device->subdev->is_journal, );
 
-  if (!comline->jsize)
-    die("journal size is zero (use -J)\n");
+	if (!comline->journals)
+		die("No journals specified (use -j)\n");
 
-  jsize = comline->jsize * (1 << 20) / GFS_BASIC_BLOCK;
+	if (!comline->jsize)
+		die("journal size is zero (use -J)\n");
 
-  if (comline->journals * jsize > device->subdev->length)
-    die("Partition too small for number/size of journals\n");
+	jsize = comline->jsize * (1 << 20) / GFS_BASIC_BLOCK;
 
+	if (comline->journals * jsize > device->subdev->length)
+		die("Partition too small for number/size of journals\n");
 
-  old = device->subdev;
+	old = device->subdev;
 
+	device->nsubdev = comline->journals + 2;
+	type_zalloc(device->subdev, mkfs_subdevice_t, device->nsubdev);
+	
+	device->subdev[0].start = old->start;
+	device->subdev[0].length = (old->length - comline->journals * jsize) / 2;
 
-  device->nsubdev = comline->journals + 2;
-  type_zalloc(device->subdev, mkfs_subdevice_t, device->nsubdev);
+	for (x = 1; x <= comline->journals; x++) {
+		device->subdev[x].start = device->subdev[x - 1].start + device->subdev[x - 1].length;
+		device->subdev[x].length = jsize;
+		device->subdev[x].is_journal = TRUE;
+	}
 
-  device->subdev[0].start = old->start;
-  device->subdev[0].length = (old->length - comline->journals * jsize) / 2;
+	device->subdev[x].start = device->subdev[x - 1].start + device->subdev[x - 1].length;
+	device->subdev[x].length = device->subdev[0].length;
 
-  for (x = 1; x <= comline->journals; x++)
-  {
-    device->subdev[x].start = device->subdev[x - 1].start + device->subdev[x - 1].length;
-    device->subdev[x].length = jsize;
-    device->subdev[x].is_journal = TRUE;
-  }
-
-  device->subdev[x].start = device->subdev[x - 1].start + device->subdev[x - 1].length;
-  device->subdev[x].length = device->subdev[0].length;
-
-
-  free(old);
+	free(old);
 }
 
-
 /**
  * fix_device_geometry - round off address and lengths and convert to FS blocks
  * @comline: the command line
@@ -136,60 +120,47 @@
 
 void fix_device_geometry(commandline_t *comline, mkfs_device_t *device)
 {
-  unsigned int x;
-  uint64 offset, len;
-  uint32 bbsize = comline->bsize >> 9;
+	unsigned int x;
+	uint64 offset, len;
+	uint32 bbsize = comline->bsize >> 9;
+	
+	if (comline->debug) {
+		printf("\nDevice Geometry:  (in basic blocks)\n");
+		for (x = 0; x < device->nsubdev; x++)
+			printf("  SubDevice #%d:  %s:  start = %"PRIu64", len = %"PRIu64"\n",
+				   x,
+				   (device->subdev[x].is_journal) ? "journal" : "data",
+				   device->subdev[x].start,
+				   device->subdev[x].length);
+	}
+
+	/*  Make sure all the subdevices are aligned  */
+
+	for (x = 0; x < device->nsubdev; x++) {
+		offset = device->subdev[x].start;
+		len = device->subdev[x].length;
+
+		if (len < 100 * bbsize)
+			die("subdevice %d is way too small (%"PRIu64" bytes)\n", x, len * GFS_BASIC_BLOCK); 
+
+		if (offset % bbsize) {
+			len -= bbsize - (offset % bbsize);
+			offset += bbsize - (offset % bbsize);
+		}
+
+		device->subdev[x].start = offset / bbsize;
+		device->subdev[x].length = len / bbsize;
+	}
+
+	if (comline->debug) {
+		printf("\nDevice Geometry:  (in FS blocks)\n");
+		for (x = 0; x < device->nsubdev; x++)
+			printf("  SubDevice #%d:  %s:  start = %"PRIu64", len = %"PRIu64"\n",
+				   x,
+				   (device->subdev[x].is_journal) ? "journal" : "data",
+				   device->subdev[x].start,
+				   device->subdev[x].length);
 
-
-  if (comline->debug)
-  {
-    printf("\nDevice Geometry:  (in basic blocks)\n");
-    for (x = 0; x < device->nsubdev; x++)
-      printf("  SubDevice #%d:  %s:  start = %"PRIu64", len = %"PRIu64"\n",
-	     x,
-	     (device->subdev[x].is_journal) ? "journal" : "data",
-	     device->subdev[x].start,
-	     device->subdev[x].length);
-  }
-
-
-  /*  Make sure all the subdevices are aligned  */
-
-  for (x = 0; x < device->nsubdev; x++)
-  {
-    offset = device->subdev[x].start;
-    len = device->subdev[x].length;
-
-
-    if (len < 100 * bbsize)
-      die("subdevice %d is way too small (%"PRIu64" bytes)\n", x, len * GFS_BASIC_BLOCK); 
-
-
-    if (offset % bbsize)
-    {
-      len -= bbsize - (offset % bbsize);
-      offset += bbsize - (offset % bbsize);
-    }
-
-
-    device->subdev[x].start = offset / bbsize;
-    device->subdev[x].length = len / bbsize;
-  }
-
-
-  if (comline->debug)
-  {
-    printf("\nDevice Geometry:  (in FS blocks)\n");
-    for (x = 0; x < device->nsubdev; x++)
-      printf("  SubDevice #%d:  %s:  start = %"PRIu64", len = %"PRIu64"\n",
-	     x,
-	     (device->subdev[x].is_journal) ? "journal" : "data",
-	     device->subdev[x].start,
-	     device->subdev[x].length);
-
-    printf("\njournals = %u\n", comline->journals);
-  }
+		printf("\njournals = %u\n", comline->journals);
+	}
 }
-
-
-
--- cluster/gfs/gfs_mkfs/fs_geometry.c	2004/06/24 08:53:23	1.1
+++ cluster/gfs/gfs_mkfs/fs_geometry.c	2006/07/10 23:39:35	1.2
@@ -29,10 +29,6 @@
 
 #include "mkfs_gfs.h"
 
-
-
-
-
 /**
  * how_many_rgrps - figure out how many RG to put in a subdevice
  * @comline: the command line
@@ -43,21 +39,20 @@
 
 static uint64 how_many_rgrps(commandline_t *comline, mkfs_subdevice_t *sdev)
 {
-  uint64 nrgrp;
-  unsigned int min = (comline->expert) ? 1 : 4;
+	uint64 nrgrp;
+	unsigned int min = (comline->expert) ? 1 : 4;
 
-  nrgrp = DIV_RU(sdev->length, (comline->rgsize << 20) / comline->bsize);
+	nrgrp = DIV_RU(sdev->length, (comline->rgsize << 20) / comline->bsize);
 
-  if (nrgrp < min)
-    nrgrp = min;
+	if (nrgrp < min)
+		nrgrp = min;
 
-  if (comline->debug)
-    printf("  nrgrp = %"PRIu64"\n", nrgrp);
+	if (comline->debug)
+		printf("  nrgrp = %"PRIu64"\n", nrgrp);
 
-  return nrgrp;
+	return nrgrp;
 }
 
-
 /**
  * compute_rgrp_layout - figure out where the RG in a FS are
  * @comline: the command line
@@ -69,79 +64,67 @@
 
 void compute_rgrp_layout(commandline_t *comline, mkfs_device_t *device, osi_list_t *rlist)
 {
-  mkfs_subdevice_t *sdev;
-  rgrp_list_t *rl, *rlast = NULL;
-  osi_list_t *tmp;
-  uint64 rgrp, nrgrp;
-  unsigned int x;
-  int first_sdev = TRUE;
+	mkfs_subdevice_t *sdev;
+	rgrp_list_t *rl, *rlast = NULL;
+	osi_list_t *tmp;
+	uint64 rgrp, nrgrp;
+	unsigned int x;
+	int first_sdev = TRUE;
 
+	for (x = 0; x < device->nsubdev; x++) {
+		sdev = &device->subdev[x];
 
-  for (x = 0; x < device->nsubdev; x++)
-  {
-    sdev = &device->subdev[x];
+		if (!sdev->is_journal) {
+			/* If this is the 1st subdevice reserve space for the superblock */
 
-    if (!sdev->is_journal)
-    {
-      /*  If this is the first subdevice reserve space for the superblock  */
+			if (first_sdev)
+				sdev->length -= comline->sb_addr + 1;
 
-      if (first_sdev)
-	sdev->length -= comline->sb_addr + 1;
+			if (comline->debug)
+				printf("\nData Subdevice %u\n", x);
 
+			nrgrp = how_many_rgrps(comline, sdev);
 
-      if (comline->debug)
-	printf("\nData Subdevice %u\n", x);
+			for (rgrp = 0; rgrp < nrgrp; rgrp++) {
+				type_zalloc(rl, rgrp_list_t, 1);
 
-      nrgrp = how_many_rgrps(comline, sdev);
+				rl->subdevice = x;
 
+				if (rgrp) {
+					rl->rg_offset = rlast->rg_offset + rlast->rg_length;
+					rl->rg_length = sdev->length / nrgrp;
+				}
+				else {
+					rl->rg_offset = sdev->start;
+					rl->rg_length = sdev->length - (nrgrp - 1) * (sdev->length / nrgrp);
 
-      for (rgrp = 0; rgrp < nrgrp; rgrp++)
-      {
-	type_zalloc(rl, rgrp_list_t, 1);
+					if (first_sdev)
+						rl->rg_offset += comline->sb_addr + 1;
+				}
 
-	rl->subdevice = x;
+				osi_list_add_prev(&rl->list, rlist);
 
-	if (rgrp)
-	{
-	  rl->rg_offset = rlast->rg_offset + rlast->rg_length;
-	  rl->rg_length = sdev->length / nrgrp;
-	}
-	else
-	{
-	  rl->rg_offset = sdev->start;
-	  rl->rg_length = sdev->length - (nrgrp - 1) * (sdev->length / nrgrp);
+				rlast = rl;
+			}
 
-	  if (first_sdev)
-	    rl->rg_offset += comline->sb_addr + 1;
-	}
+			first_sdev = FALSE;
 
-	osi_list_add_prev(&rl->list, rlist);
-
-	rlast = rl;
-      }
+			comline->rgrps += nrgrp;
+		}
+	}
 
-      first_sdev = FALSE;
+	if (comline->debug) {
+		printf("\n");
 
-      comline->rgrps += nrgrp;
-    }
-  }
-
-
-  if (comline->debug)
-  {
-    printf("\n");
-
-    for (tmp = rlist->next; tmp != rlist; tmp = tmp->next)
-    {
-      rl = osi_list_entry(tmp, rgrp_list_t, list);
-      printf("subdevice %u:  rg_o = %"PRIu64", rg_l = %"PRIu64"\n",
-	     rl->subdevice,
-	     rl->rg_offset, rl->rg_length);
-    }
-  }
+		for (tmp = rlist->next; tmp != rlist; tmp = tmp->next) {
+			rl = osi_list_entry(tmp, rgrp_list_t, list);
+			printf("subdevice %u:  rg_o = %"PRIu64", rg_l = %"PRIu64"\n",
+				   rl->subdevice,
+				   rl->rg_offset, rl->rg_length);
+		}
+	}
 }
 
-
 /**
  * compute_journal_layout - figure out where the journals in a FS are
  * @comline: the command line
@@ -153,56 +136,48 @@
 
 void compute_journal_layout(commandline_t *comline, mkfs_device_t *device, osi_list_t *jlist)
 {
-  mkfs_subdevice_t *sdev;
-  journal_list_t *jl;
-  osi_list_t *tmp;
-  unsigned int x, j = 0;
-  uint64 boffset, bcount;
-  unsigned int min_jsize = (comline->expert) ? 1 : 32;
-
-
-  for (x = 0; x < device->nsubdev; x++)
-  {
-    sdev = &device->subdev[x];
+	mkfs_subdevice_t *sdev;
+	journal_list_t *jl;
+	osi_list_t *tmp;
+	unsigned int x, j = 0;
+	uint64 boffset, bcount;
+	unsigned int min_jsize = (comline->expert) ? 1 : 32;
+
+	for (x = 0; x < device->nsubdev; x++) {
+		sdev = &device->subdev[x];
+
+		if (sdev->is_journal) {
+			type_zalloc(jl, journal_list_t, 1);
+
+			/*  Align the journals on seg_size boundries  */
+
+			boffset = sdev->start;
+			bcount = sdev->length;
+
+			if ((bcount + comline->seg_size) * comline->bsize < min_jsize << 20)
+				die("journal %d is too small (minimum size is %u MB)\n", j, min_jsize);
+
+			if (boffset % comline->seg_size) {
+				bcount -= comline->seg_size - (boffset % comline->seg_size);
+				boffset += comline->seg_size - (boffset % comline->seg_size);
+			}
+
+			jl->start = boffset;
+			jl->segments = bcount / comline->seg_size;
+			
+			osi_list_add_prev(&jl->list, jlist);
 
-    if (sdev->is_journal)
-    {
-      type_zalloc(jl, journal_list_t, 1);
-
-      /*  Align the journals on seg_size boundries  */
-
-      boffset = sdev->start;
-      bcount = sdev->length;
-
-      if ((bcount + comline->seg_size) * comline->bsize < min_jsize << 20)
-	die("journal %d is too small (minimum size is %u MB)\n", j, min_jsize);
-
-      if (boffset % comline->seg_size)
-      {
-	bcount -= comline->seg_size - (boffset % comline->seg_size);
-	boffset += comline->seg_size - (boffset % comline->seg_size);
-      }
-
-      jl->start = boffset;
-      jl->segments = bcount / comline->seg_size;
-
-      osi_list_add_prev(&jl->list, jlist);
-
-      j++;
-    }
-  }
-
-
-  if (comline->debug)
-  {
-    printf("\n");
+			j++;
+		}
+	}
 
-    for (tmp = jlist->next, j = 0; tmp != jlist; tmp = tmp->next, j++)
-    {
-      jl = osi_list_entry(tmp, journal_list_t, list);
-      printf("journal %u:  start = %"PRIu64", segments = %u\n",
-	     j, jl->start, jl->segments);
-    }
-  }
+	if (comline->debug) {
+		printf("\n");
+		
+		for (tmp = jlist->next, j = 0; tmp != jlist; tmp = tmp->next, j++) {
+			jl = osi_list_entry(tmp, journal_list_t, list);
+			printf("journal %u:  start = %"PRIu64", segments = %u\n",
+				   j, jl->start, jl->segments);
+		}
+	}
 }
-
--- cluster/gfs/gfs_mkfs/main.c	2005/01/05 01:49:05	1.3
+++ cluster/gfs/gfs_mkfs/main.c	2006/07/10 23:39:35	1.4
@@ -26,8 +26,8 @@
 #include "global.h"
 #include <linux/gfs_ondisk.h>
 #include "osi_list.h"
-#include "iddev.h"
-
+#include "libvolume_id.h"
+#include "libgfs.h"
 #include "copyright.cf"
 
 #define EXTERN
@@ -218,25 +218,27 @@
 
 void are_you_sure(commandline_t *comline)
 {
-  char buf[1024];
-  char input[32];
-  int unknown;
-
-  unknown = identify_device(comline->fd, buf, 1024);
-  if (unknown < 0)
-    die("error identifying the contents of %s: %s\n", comline->device, strerror(errno));
-
-  printf("This will destroy any data on %s.\n", comline->device);
-  if (!unknown)
-    printf("  It appears to contain a %s.\n", buf);
-
-  printf("\nAre you sure you want to proceed? [y/n] ");
-  fgets(input, 32, stdin);
+	char input[32];
+	struct volume_id *vid = NULL;
 
-  if (input[0] != 'y')
-    die("aborted\n");
-  else
-    printf("\n");
+	vid = volume_id_open_node(comline->device);
+	if (vid == NULL)
+		die("error identifying the contents of %s: %s\n",
+		    comline->device, strerror(errno));
+
+	printf("This will destroy any data on %s.\n",
+	       comline->device);
+	if (volume_id_probe_all(vid, 0, MKFS_DEFAULT_BSIZE) == 0)
+		printf("  It appears to contain a %s %s.\n", vid->type,
+			   vid->usage_id == VOLUME_ID_OTHER? "partition" : vid->usage);
+	volume_id_close(vid);
+	printf("\nAre you sure you want to proceed? [y/n] ");
+	fgets(input, 32, stdin);
+
+	if (input[0] != 'y')
+		die("aborted\n");
+	else
+		printf("\n");
 }
 
 
@@ -283,125 +285,105 @@
 
 int main(int argc, char *argv[])
 {
-  commandline_t comline;
-  mkfs_device_t device;
-  osi_list_t rlist;
-  osi_list_t jlist;
-  unsigned int x;
-
+	commandline_t comline;
+	mkfs_device_t device;
+	osi_list_t rlist;
+	osi_list_t jlist;
+	unsigned int x;
 
-  prog_name = argv[0];
+	prog_name = argv[0];
 
-  osi_list_init(&rlist);
-  osi_list_init(&jlist);
+	osi_list_init(&rlist);
+	osi_list_init(&jlist);
 
+	/*  Process the command line arguments  */
 
-  /*  Process the command line arguments  */
+	memset(&comline, 0, sizeof(commandline_t));
+	comline.bsize = MKFS_DEFAULT_BSIZE;
+	comline.seg_size = MKFS_DEFAULT_SEG_SIZE;
+	comline.jsize = MKFS_DEFAULT_JSIZE;
+	comline.rgsize = MKFS_DEFAULT_RGSIZE;
 
-  memset(&comline, 0, sizeof(commandline_t));
-  comline.bsize = MKFS_DEFAULT_BSIZE;
-  comline.seg_size = MKFS_DEFAULT_SEG_SIZE;
-  comline.jsize = MKFS_DEFAULT_JSIZE;
-  comline.rgsize = MKFS_DEFAULT_RGSIZE;
+	decode_arguments(argc, argv, &comline);
 
-  decode_arguments(argc, argv, &comline);
+	if (!comline.expert) {
+		char buf[256];
+		if (test_locking(comline.lockproto, comline.locktable, buf, 256))
+			die("%s\n", buf);
+	}
 
-  if (!comline.expert)
-  {
-    char buf[256];
-    if (test_locking(comline.lockproto, comline.locktable, buf, 256))
-      die("%s\n", buf);
-  }
+	/*  Block sizes must be a power of two from 512 to 65536  */
 
+	for (x = 512; x; x <<= 1)
+		if (x == comline.bsize)
+			break;
 
+	if (!x || comline.bsize > 65536)
+		die("block size must be a power of two between 512 and 65536\n");
 
-  /*  Block sizes must be a power of two from 512 to 65536  */
-
-  for (x = 512; x; x <<= 1)
-    if (x == comline.bsize)
-      break;
+	comline.sb_addr = GFS_SB_ADDR * GFS_BASIC_BLOCK / comline.bsize;
 
-  if (!x || comline.bsize > 65536)
-    die("block size must be a power of two between 512 and 65536\n");
+	if (comline.seg_size < 2)
+		die("segment size too small\n");
 
-  comline.sb_addr = GFS_SB_ADDR * GFS_BASIC_BLOCK / comline.bsize;
+	if (!comline.expert && (uint64)comline.seg_size * comline.bsize > 4194304)
+		die("segment size too large\n");
 
-  if (comline.seg_size < 2)
-    die("segment size too small\n");
-
-  if (!comline.expert && (uint64)comline.seg_size * comline.bsize > 4194304)
-    die("segment size too large\n");
-
-  if (comline.expert)
-  {
-    if (1 > comline.rgsize || comline.rgsize > 2048)
-      die("bad resource group size\n");
-  }
-  else
-  {
-    if (32 > comline.rgsize || comline.rgsize > 2048)
-      die("bad resource group size\n");
-  }
+	if (comline.expert) {
+		if (1 > comline.rgsize || comline.rgsize > 2048)
+			die("bad resource group size\n");
+	}
+	else {
+		if (32 > comline.rgsize || comline.rgsize > 2048)
+			die("bad resource group size\n");
+	}
 
+	/*  Get the device geometry  */
 
+	memset(&device, 0, sizeof(mkfs_device_t));
 
-  /*  Get the device geometry  */
+	device_geometry(&comline, &device);
+	add_journals_to_device(&comline, &device);
 
-  memset(&device, 0, sizeof(mkfs_device_t));
+	fix_device_geometry(&comline, &device);
 
-  device_geometry(&comline, &device);
-  add_journals_to_device(&comline, &device);
+	/*  Compute the resource group layouts  */
 
-  fix_device_geometry(&comline, &device);
+	compute_rgrp_layout(&comline, &device, &rlist);
 
+	compute_journal_layout(&comline, &device, &jlist);
 
+	/*  Start writing stuff out  */
 
-  /*  Compute the resource group layouts  */
+	comline.fd = open(comline.device, O_RDWR);
+	if (comline.fd < 0)
+		die("can't open device %s\n", comline.device);
 
-  compute_rgrp_layout(&comline, &device, &rlist);
+	if (!comline.override)
+		are_you_sure(&comline);
 
-  compute_journal_layout(&comline, &device, &jlist);
+	write_mkfs_sb(&comline, &rlist);
 
+	/*  Figure out where we start allocating in rgrp 0  */
+	comline.rgrp0_next = comline.sbd->sd_sb.sb_root_di.no_addr + 1;
 
-  /*  Start writing stuff out  */
+	write_jindex(&comline, &jlist);
 
-  comline.fd = open(comline.device, O_RDWR);
-  if (comline.fd < 0)
-    die("can't open device %s\n", comline.device);
+	write_rindex(&comline, &rlist);
 
+	write_root(&comline);
 
-  if (!comline.override)
-    are_you_sure(&comline);
+	write_quota(&comline);
 
+	write_license(&comline);
 
-  write_sb(&comline, &rlist);
+	write_rgrps(&comline, &rlist);
 
-  /*  Figure out where we start allocting in rgrp 0  */
-  comline.rgrp0_next = comline.sb->sb_root_di.no_addr + 1;
+	write_journals(&comline, &jlist);
 
-  write_jindex(&comline, &jlist);
+	close(comline.fd);
+	free(comline.sbd);
+	print_results(&comline);
 
-  write_rindex(&comline, &rlist);
-
-  write_root(&comline);
-
-  write_quota(&comline);
-
-  write_license(&comline);
-
-  write_rgrps(&comline, &rlist);
-
-  write_journals(&comline, &jlist);
-
-
-  close(comline.fd);
-
-
-  print_results(&comline);
-
-
-  exit(EXIT_SUCCESS);
+	exit(EXIT_SUCCESS);
 }
-
-
-
--- cluster/gfs/gfs_mkfs/mkfs_gfs.h	2005/01/05 01:49:05	1.3
+++ cluster/gfs/gfs_mkfs/mkfs_gfs.h	2006/07/10 23:39:35	1.4
@@ -115,7 +115,7 @@
 
   uint64 rgrps;             /*  Number of rgrps  */
   int fd;                   /*  fd of the device  */
-  struct gfs_sb *sb;             /*  A copy of the superblock  */
+  struct gfs_sbd *sbd;      /*  A copy of the superblock */
   uint64 fssize;            /*  size of the filesystem  */
 
   uint64 sb_addr;
@@ -178,7 +178,7 @@
 
 /*  structures.c  */
 
-void write_sb(commandline_t *comline, osi_list_t *rlist);
+void write_mkfs_sb(commandline_t *comline, osi_list_t *rlist);
 void write_jindex(commandline_t *comline, osi_list_t *jlist);
 void write_rindex(commandline_t *comline, osi_list_t *rlist);
 void write_root(commandline_t *comline);
--- cluster/gfs/gfs_mkfs/structures.c	2005/04/14 19:27:34	1.2
+++ cluster/gfs/gfs_mkfs/structures.c	2006/07/10 23:39:35	1.3
@@ -27,39 +27,13 @@
 #include <linux/gfs_ondisk.h>
 #include "osi_list.h"
 #include "linux_endian.h"
-
+#include "libgfs.h"
 #include "mkfs_gfs.h"
 
 
 #define MKFS_ROOT_MODE              (0755)
 #define MKFS_HIDDEN_MODE            (0600)
 
-
-#define do_lseek(fd, off) \
-{ \
-  if (lseek((fd), (off), SEEK_SET) != (off)) \
-    die("bad seek: %s on line %d of file %s\n", \
-	strerror(errno),__LINE__, __FILE__); \
-}
-
-#define do_read(fd, buff, len) \
-{ \
-  if (read((fd), (buff), (len)) != (len)) \
-    die("bad read: %s on line %d of file %s\n", \
-	strerror(errno), __LINE__, __FILE__); \
-}
-
-#define do_write(fd, buff, len) \
-{ \
-  if (write((fd), (buff), (len)) != (len)) \
-    die("bad write: %s on line %d of file %s\n", \
-	strerror(errno), __LINE__, __FILE__); \
-}
-
-
-
-
-
 /**
  * rgblocks2bitblocks - blerg
  * @bsize: the FS block size
@@ -102,132 +76,76 @@
 
 
 /**
- * write_sb - write the superblock
+ * write_mkfs_sb - write the superblock
  * @comline: the command line
  * @rlist: the list of RGs
  *
  */
 
-void write_sb(commandline_t *comline, osi_list_t *rlist)
+void write_mkfs_sb(commandline_t *comline, osi_list_t *rlist)
 {
-  struct gfs_sb *sb;
-  uint64 jindex_dinode;
-  char buf[comline->bsize];
-  int x;
-
-
-  memset(buf, 0, comline->bsize);
-
-  for (x = 0; x < comline->sb_addr; x++)
-  {
-    do_lseek(comline->fd, x * comline->bsize);
-    do_write(comline->fd, buf, comline->bsize);
-  }
-
-
-  /*  Figure out the location of the journal index inode  */
-
-  {
-	  rgrp_list_t *rl = osi_list_entry(rlist->next, rgrp_list_t, list);
-	  uint32_t rgblocks, bitblocks;
-
-	  rgblocks = rl->rg_length;
-	  rgblocks2bitblocks(comline->bsize, &rgblocks, &bitblocks);
-
-	  jindex_dinode = rl->rg_offset + bitblocks;
-  }
-
-
-  /*  Now, fill in the superblock  */
-
-  type_zalloc(sb, struct gfs_sb, 1);
-  comline->sb = sb;
-
-
-  sb->sb_header.mh_magic = GFS_MAGIC;
-  sb->sb_header.mh_type = GFS_METATYPE_SB;
-  sb->sb_header.mh_format = GFS_FORMAT_SB;
-
-  sb->sb_fs_format = GFS_FORMAT_FS;
-  sb->sb_multihost_format = GFS_FORMAT_MULTI;
-
-  sb->sb_bsize = comline->bsize;
-  sb->sb_bsize_shift = ffs(comline->bsize) - 1;
-  sb->sb_seg_size = comline->seg_size;
-
-  sb->sb_jindex_di.no_formal_ino = jindex_dinode;
-  sb->sb_jindex_di.no_addr = jindex_dinode;
-  sb->sb_rindex_di.no_formal_ino = jindex_dinode + 1;
-  sb->sb_rindex_di.no_addr = jindex_dinode + 1;
-  sb->sb_root_di.no_formal_ino = jindex_dinode + 4;
-  sb->sb_root_di.no_addr = jindex_dinode + 4;
-
-  strcpy(sb->sb_lockproto, comline->lockproto);
-  strcpy(sb->sb_locktable, comline->locktable);
-
-  sb->sb_quota_di.no_formal_ino = jindex_dinode + 2;
-  sb->sb_quota_di.no_addr = jindex_dinode + 2;
-  sb->sb_license_di.no_formal_ino = jindex_dinode + 3;
-  sb->sb_license_di.no_addr = jindex_dinode + 3;
-
-
-  gfs_sb_out(sb, buf);
-
-
-  do_lseek(comline->fd, comline->sb_addr * comline->bsize);
-  do_write(comline->fd, buf, comline->bsize);
-
-
-  if (comline->debug)
-  {
-    printf("\nSuperblock:\n");
-    gfs_sb_print(sb);
-  }
-}
-
-
-/**
- * compute_height - give a file length and block size compute the file's height
- * @sz: the file size
- * @bsize: the blocksize
- *
- * Returns: the file height
- */
-
-static unsigned int compute_height(uint64 sz, unsigned int bsize)
-{
-  uint32 diptrs = (bsize - sizeof(struct gfs_dinode)) / sizeof(uint64);
-  uint32 inptrs = (bsize - sizeof(struct gfs_indirect)) / sizeof(uint64);
-  unsigned int height;
-  uint64 space, old_space;
-
-
-  bsize -= sizeof(struct gfs_meta_header);
-
-  height = 1;
-  space = diptrs * bsize;
-
-
-  for (;;)
-  {
-    if (sz <= space)
-      break;
-
-    old_space = space;
+	struct gfs_sbd *sbd;
+	uint64 jindex_dinode;
+	char buf[comline->bsize];
+	int x;
+
+	memset(buf, 0, comline->bsize);
+
+	for (x = 0; x < comline->sb_addr; x++) {
+		do_lseek(comline->fd, x * comline->bsize);
+		do_write(comline->fd, buf, comline->bsize);
+	}
 
-    height++;
-    space *= inptrs;
+	/*  Figure out the location of the journal index inode  */
+	{
+		rgrp_list_t *rl = osi_list_entry(rlist->next, rgrp_list_t, list);
+		uint32_t rgblocks, bitblocks;
+		
+		rgblocks = rl->rg_length;
+		rgblocks2bitblocks(comline->bsize, &rgblocks, &bitblocks);
+		
+		jindex_dinode = rl->rg_offset + bitblocks;
+	}
 
-    if (space / inptrs != old_space ||
-	space % inptrs != 0)
-      break;
-  }
+	/*  Now, fill in the superblock  */
 
+	type_zalloc(sbd, struct gfs_sbd, 1);
+	comline->sbd = sbd;
 
-  return height;
+	sbd->sd_sb.sb_header.mh_magic = GFS_MAGIC;
+	sbd->sd_sb.sb_header.mh_type = GFS_METATYPE_SB;
+	sbd->sd_sb.sb_header.mh_format = GFS_FORMAT_SB;
+
+	sbd->sd_sb.sb_fs_format = GFS_FORMAT_FS;
+	sbd->sd_sb.sb_multihost_format = GFS_FORMAT_MULTI;
+
+	sbd->sd_sb.sb_bsize = comline->bsize;
+	sbd->sd_sb.sb_bsize_shift = ffs(comline->bsize) - 1;
+	sbd->sd_sb.sb_seg_size = comline->seg_size;
+
+	sbd->sd_sb.sb_jindex_di.no_formal_ino = jindex_dinode;
+	sbd->sd_sb.sb_jindex_di.no_addr = jindex_dinode;
+	sbd->sd_sb.sb_rindex_di.no_formal_ino = jindex_dinode + 1;
+	sbd->sd_sb.sb_rindex_di.no_addr = jindex_dinode + 1;
+	sbd->sd_sb.sb_root_di.no_formal_ino = jindex_dinode + 4;
+	sbd->sd_sb.sb_root_di.no_addr = jindex_dinode + 4;
+
+	strcpy(sbd->sd_sb.sb_lockproto, comline->lockproto);
+	strcpy(sbd->sd_sb.sb_locktable, comline->locktable);
+
+	sbd->sd_sb.sb_quota_di.no_formal_ino = jindex_dinode + 2;
+	sbd->sd_sb.sb_quota_di.no_addr = jindex_dinode + 2;
+	sbd->sd_sb.sb_license_di.no_formal_ino = jindex_dinode + 3;
+	sbd->sd_sb.sb_license_di.no_addr = jindex_dinode + 3;
+	sbd->sd_fsb2bb_shift = sbd->sd_sb.sb_bsize_shift - GFS_BASIC_BLOCK_SHIFT;
+
+	write_sb(comline->fd, sbd);
+	if (comline->debug) {
+		printf("\nSuperblock:\n");
+		gfs_sb_print(&sbd->sd_sb);
+	}
 }
 
-
 /**
  * build_tree - build the pointers and indirect blocks for a file
  * @comline: the command line
@@ -239,92 +157,79 @@
 
 static void build_tree(commandline_t *comline, struct gfs_dinode *di, uint64 addr, unsigned int blocks)
 {
-  struct gfs_indirect ind;
-  char *buf;
-  unsigned int x, offset;
-  unsigned int height;
-  unsigned int indblocks;
-  uint64 tmp_addr;
-  unsigned int tmp_blocks;
-
+	struct gfs_indirect ind;
+	char *buf;
+	unsigned int x, offset;
+	unsigned int height;
+	unsigned int indblocks;
+	uint64 tmp_addr;
+	unsigned int tmp_blocks;
   
-  di->di_height = compute_height(di->di_size, comline->bsize);
-
-
-  if (di->di_height == 1)
-  {
-    type_zalloc(buf, char, comline->bsize);
-
-    for (x = 0; x < blocks; x++)
-      ((uint64 *)(buf + sizeof(struct gfs_dinode)))[x] = cpu_to_gfs64(addr + x);
-
-    gfs_dinode_out(di, buf);
-
-    do_lseek(comline->fd, di->di_num.no_addr * comline->bsize);
-    do_write(comline->fd, buf, comline->bsize);
-
-    free(buf);
-  }
-  else
-  {
-    tmp_addr = addr;
-    tmp_blocks = blocks;
+	di->di_height = compute_height(comline->sbd, di->di_size);
 
+	if (di->di_height == 1) {
+		type_zalloc(buf, char, comline->bsize);
 
-    for (height = di->di_height; height > 1; height--)
-    {
-      memset(&ind, 0, sizeof(struct gfs_indirect));
-      ind.in_header.mh_magic = GFS_MAGIC;
-      ind.in_header.mh_type = GFS_METATYPE_IN;
-      ind.in_header.mh_format = GFS_FORMAT_IN;
+		for (x = 0; x < blocks; x++)
+			((uint64 *)(buf + sizeof(struct gfs_dinode)))[x] = cpu_to_gfs64(addr + x);
 
+		gfs_dinode_out(di, buf);
 
-      indblocks = DIV_RU((tmp_blocks * sizeof(uint64)),
-			 (comline->bsize - sizeof(struct gfs_indirect)));
+		do_lseek(comline->fd, di->di_num.no_addr * comline->bsize);
+		do_write(comline->fd, buf, comline->bsize);
 
-      type_zalloc(buf, char, indblocks * comline->bsize);
-
-
-      offset = 0;
-      for (x = 0; x < tmp_blocks; x++)
-      {
-	if (!(offset % comline->bsize))
-	{
-	  gfs_indirect_out(&ind, buf + offset);
-	  offset += sizeof(struct gfs_indirect);
+		free(buf);
 	}
+	else {
+		tmp_addr = addr;
+		tmp_blocks = blocks;
+
+		for (height = di->di_height; height > 1; height--) {
+			memset(&ind, 0, sizeof(struct gfs_indirect));
+			ind.in_header.mh_magic = GFS_MAGIC;
+			ind.in_header.mh_type = GFS_METATYPE_IN;
+			ind.in_header.mh_format = GFS_FORMAT_IN;
+
+			indblocks = DIV_RU((tmp_blocks * sizeof(uint64)),
+							   (comline->bsize - sizeof(struct gfs_indirect)));
+
+			type_zalloc(buf, char, indblocks * comline->bsize);
+
+			offset = 0;
+			for (x = 0; x < tmp_blocks; x++) {
+				if (!(offset % comline->bsize)) {
+					gfs_indirect_out(&ind, buf + offset);
+					offset += sizeof(struct gfs_indirect);
+				}
+				
+				*((uint64 *)(buf + offset)) = cpu_to_gfs64(tmp_addr + x);
+				offset += sizeof(uint64);
+			}
+
+			do_lseek(comline->fd, comline->rgrp0_next * comline->bsize);
+			do_write(comline->fd, buf, indblocks * comline->bsize);
+
+			free(buf);
+
+			tmp_addr = comline->rgrp0_next;
+			tmp_blocks = indblocks;
+
+			di->di_blocks += indblocks;
+			
+			comline->rgrp0_next += indblocks;
+		}
+		type_zalloc(buf, char, comline->bsize);
 
-	*((uint64 *)(buf + offset)) = cpu_to_gfs64(tmp_addr + x);
-	offset += sizeof(uint64);
-      }
-
-
-      do_lseek(comline->fd, comline->rgrp0_next * comline->bsize);
-      do_write(comline->fd, buf, indblocks * comline->bsize);
-
-      free(buf);
-
-      tmp_addr = comline->rgrp0_next;
-      tmp_blocks = indblocks;
-
-      di->di_blocks += indblocks;
-
-      comline->rgrp0_next += indblocks;
-    }
-
-
-    type_zalloc(buf, char, comline->bsize);
-
-    for (x = 0; x < tmp_blocks; x++)
-      ((uint64 *)(buf + sizeof(struct gfs_dinode)))[x] = cpu_to_gfs64(tmp_addr + x);
+		for (x = 0; x < tmp_blocks; x++)
+			((uint64 *)(buf + sizeof(struct gfs_dinode)))[x] = cpu_to_gfs64(tmp_addr + x);
 
-    gfs_dinode_out(di, buf);
+		gfs_dinode_out(di, buf);
 
-    do_lseek(comline->fd, di->di_num.no_addr * comline->bsize);
-    do_write(comline->fd, buf, comline->bsize);    
+		do_lseek(comline->fd, di->di_num.no_addr * comline->bsize);
+		do_write(comline->fd, buf, comline->bsize);    
 
-    free(buf);
-  }
+		free(buf);
+	}
 }
 
 
@@ -338,49 +243,41 @@
 
 static char *fill_jindex(commandline_t *comline, osi_list_t *jlist)
 {
-  journal_list_t *jl;
-  struct gfs_jindex ji;
-  osi_list_t *tmp;
-  char *buf;
-  unsigned int j = 0;
-
-
-  type_alloc(buf, char, comline->journals * sizeof(struct gfs_jindex));
-
-
-  for (tmp = jlist->next; tmp != jlist; tmp = tmp->next)
-  {
-    jl = osi_list_entry(tmp, journal_list_t, list);
-
-    memset(&ji, 0, sizeof(struct gfs_jindex));
-
-    ji.ji_addr = jl->start;
-    ji.ji_nsegment = jl->segments;
+	journal_list_t *jl;
+	struct gfs_jindex ji;
+	osi_list_t *tmp;
+	char *buf;
+	unsigned int j = 0;
+	
+	type_alloc(buf, char, comline->journals * sizeof(struct gfs_jindex));
 
-    gfs_jindex_out(&ji, buf + j * sizeof(struct gfs_jindex));
+	for (tmp = jlist->next; tmp != jlist; tmp = tmp->next) {
+		jl = osi_list_entry(tmp, journal_list_t, list);
 
-    j++;
-  }
+		memset(&ji, 0, sizeof(struct gfs_jindex));
 
+		ji.ji_addr = jl->start;
+		ji.ji_nsegment = jl->segments;
 
-  if (comline->debug)
-  {
-    printf("\nJournal Index data:\n";);
+		gfs_jindex_out(&ji, buf + j * sizeof(struct gfs_jindex));
 
-    for (j = 0; j < comline->journals; j++)
-    {
-      gfs_jindex_in(&ji, buf + j * sizeof(struct gfs_jindex));
+		j++;
+	}
 
-      printf("\n  Journal %d\n", j);
-      gfs_jindex_print(&ji);
-    }
-  }
+	if (comline->debug) {
+		printf("\nJournal Index data:\n";);
 
+		for (j = 0; j < comline->journals; j++) {
+			gfs_jindex_in(&ji, buf + j * sizeof(struct gfs_jindex));
+			
+			printf("\n  Journal %d\n", j);
+			gfs_jindex_print(&ji);
+		}
+	}
 
-  return buf;
+	return buf;
 }
 
-
 /**
  * write_jindex - write out the journal index
  * @comline: the command line
@@ -390,96 +287,82 @@
 
 void write_jindex(commandline_t *comline, osi_list_t *jlist)
 {
-  struct gfs_dinode di;
-  struct gfs_meta_header jd;
-  char *buf, *data;
-  uint64 addr;
-  unsigned int blocks;
-  unsigned int x, left, jbsize = comline->bsize - sizeof(struct gfs_meta_header);
-
+	struct gfs_dinode di;
+	struct gfs_meta_header jd;
+	char *buf, *data;
+	uint64 addr;
+	unsigned int blocks;
+	unsigned int x, left, jbsize = comline->bsize - sizeof(struct gfs_meta_header);
 
-  memset(&di, 0, sizeof(struct gfs_dinode));
+	memset(&di, 0, sizeof(struct gfs_dinode));
  
-  di.di_header.mh_magic = GFS_MAGIC;
-  di.di_header.mh_type = GFS_METATYPE_DI;
-  di.di_header.mh_format = GFS_FORMAT_DI;
-
-  di.di_num = comline->sb->sb_jindex_di;
-
-  di.di_mode = MKFS_HIDDEN_MODE;
-  di.di_nlink = 1;
-  di.di_size = comline->journals * sizeof(struct gfs_jindex);
-  di.di_blocks = 1;
-  di.di_atime = di.di_mtime = di.di_ctime = time(NULL);
-
-  di.di_flags = GFS_DIF_JDATA;
-  di.di_payload_format = GFS_FORMAT_JI;
-  di.di_type = GFS_FILE_REG;
-
-
-  data = fill_jindex(comline, jlist);
-
+	di.di_header.mh_magic = GFS_MAGIC;
+	di.di_header.mh_type = GFS_METATYPE_DI;
+	di.di_header.mh_format = GFS_FORMAT_DI;
 
-  if (di.di_size < comline->bsize - sizeof(struct gfs_dinode))
-  {
-    type_zalloc(buf, char, comline->bsize);
+	di.di_num = comline->sbd->sd_sb.sb_jindex_di;
 
-    gfs_dinode_out(&di, buf);
+	di.di_mode = MKFS_HIDDEN_MODE;
+	di.di_nlink = 1;
+	di.di_size = comline->journals * sizeof(struct gfs_jindex);
+	di.di_blocks = 1;
+	di.di_atime = di.di_mtime = di.di_ctime = time(NULL);
 
-    memcpy(buf + sizeof(struct gfs_dinode), data, comline->journals * sizeof(struct gfs_jindex));
+	di.di_flags = GFS_DIF_JDATA;
+	di.di_payload_format = GFS_FORMAT_JI;
+	di.di_type = GFS_FILE_REG;
 
-    do_lseek(comline->fd, di.di_num.no_addr * comline->bsize);
-    do_write(comline->fd, buf, comline->bsize);
+	data = fill_jindex(comline, jlist);
 
-    free(buf);
-  }
-  else
-  {
-    blocks = DIV_RU(di.di_size, (comline->bsize - sizeof(struct gfs_meta_header)));
-    di.di_blocks += blocks;
+	if (di.di_size < comline->bsize - sizeof(struct gfs_dinode)) {
+		type_zalloc(buf, char, comline->bsize);
 
-    addr = comline->rgrp0_next;
+		gfs_dinode_out(&di, buf);
 
+		memcpy(buf + sizeof(struct gfs_dinode), data, comline->journals * sizeof(struct gfs_jindex));
 
-    memset(&jd, 0, sizeof(struct gfs_meta_header));
-    jd.mh_magic = GFS_MAGIC;
-    jd.mh_type = GFS_METATYPE_JD;
-    jd.mh_format = GFS_FORMAT_JD;
-
-
-    type_zalloc(buf, char, blocks * comline->bsize);
-
-    left = comline->journals * sizeof(struct gfs_jindex);
-    for (x = 0; x < blocks; x++)
-    {
-      gfs_meta_header_out(&jd, buf + x * comline->bsize);
-      memcpy(buf + x * comline->bsize + sizeof(struct gfs_meta_header),
-	     data + x * jbsize,
-	     (left > jbsize) ? jbsize : left);
-      left -= jbsize;
-    }
-
-
-    do_lseek(comline->fd, addr * comline->bsize);
-    do_write(comline->fd, buf, blocks * comline->bsize);
-
-    free(buf);
+		do_lseek(comline->fd, di.di_num.no_addr * comline->bsize);
+		do_write(comline->fd, buf, comline->bsize);
 
+		free(buf);
+	}
+	else {
+		blocks = DIV_RU(di.di_size, (comline->bsize - sizeof(struct gfs_meta_header)));
+		di.di_blocks += blocks;
+
+		addr = comline->rgrp0_next;
+		memset(&jd, 0, sizeof(struct gfs_meta_header));
+		jd.mh_magic = GFS_MAGIC;
+		jd.mh_type = GFS_METATYPE_JD;
+		jd.mh_format = GFS_FORMAT_JD;
+
+		type_zalloc(buf, char, blocks * comline->bsize);
+
+		left = comline->journals * sizeof(struct gfs_jindex);
+		for (x = 0; x < blocks; x++) {
+			gfs_meta_header_out(&jd, buf + x * comline->bsize);
+			memcpy(buf + x * comline->bsize + sizeof(struct gfs_meta_header),
+				   data + x * jbsize,
+				   (left > jbsize) ? jbsize : left);
+			left -= jbsize;
+		}
 
-    comline->rgrp0_next += blocks;
+		do_lseek(comline->fd, addr * comline->bsize);
+		do_write(comline->fd, buf, blocks * comline->bsize);
 
-    build_tree(comline, &di, addr, blocks);
-  }
+		free(buf);
 
+		comline->rgrp0_next += blocks;
 
-  free(data);
+		build_tree(comline, &di, addr, blocks);
+	}
 
+	free(data);
 
-  if (comline->debug)
-  {
-    printf("\nJournal index dinode:\n");
-    gfs_dinode_print(&di);
-  }
+	if (comline->debug) {
+		printf("\nJournal index dinode:\n");
+		gfs_dinode_print(&di);
+	}
 }
 
 
@@ -493,61 +376,52 @@
 
 static char *fill_rindex(commandline_t *comline, osi_list_t *rlist)
 {
-  struct gfs_rindex *ri, rindex;
-  rgrp_list_t *rl;
-  osi_list_t *tmp;
-  char *buf;
-  unsigned int r = 0;
-  uint32 rgblocks, bitblocks;
-
-
-  type_alloc(buf, char, comline->rgrps * sizeof(struct gfs_rindex));
+	struct gfs_rindex *ri, rindex;
+	rgrp_list_t *rl;
+	osi_list_t *tmp;
+	char *buf;
+	unsigned int r = 0;
+	uint32 rgblocks, bitblocks;
 
+	type_alloc(buf, char, comline->rgrps * sizeof(struct gfs_rindex));
 
-  for (tmp = rlist->next; tmp != rlist; tmp = tmp->next)
-  {
-    rl = osi_list_entry(tmp, rgrp_list_t, list);
-
-    rgblocks = rl->rg_length;
-    rgblocks2bitblocks(comline->bsize, &rgblocks, &bitblocks);
-
-    type_zalloc(ri, struct gfs_rindex, 1);
-    rl->ri = ri;
-
-    ri->ri_addr = rl->rg_offset;
-    ri->ri_length = bitblocks;
-
-    ri->ri_data1 = rl->rg_offset + bitblocks;
-    ri->ri_data = rgblocks;
-
-    ri->ri_bitbytes = rgblocks / GFS_NBBY;
-
-    gfs_rindex_out(ri, buf + r * sizeof(struct gfs_rindex));
+	for (tmp = rlist->next; tmp != rlist; tmp = tmp->next) {
+		rl = osi_list_entry(tmp, rgrp_list_t, list);
+	
+		rgblocks = rl->rg_length;
+		rgblocks2bitblocks(comline->bsize, &rgblocks, &bitblocks);
 
-    comline->fssize += rgblocks;
+		type_zalloc(ri, struct gfs_rindex, 1);
+		rl->ri = ri;
+		
+		ri->ri_addr = rl->rg_offset;
+		ri->ri_length = bitblocks;
 
-    r++;
-  }
+		ri->ri_data1 = rl->rg_offset + bitblocks;
+		ri->ri_data = rgblocks;
 
+		ri->ri_bitbytes = rgblocks / GFS_NBBY;
 
-  if (comline->debug)
-  {
-    printf("\nResource Index data:\n";);
+		gfs_rindex_out(ri, buf + r * sizeof(struct gfs_rindex));
+		
+		comline->fssize += rgblocks;
 
-    for (r = 0; r < comline->rgrps; r++)
-    {
-      gfs_rindex_in(&rindex, buf + r * sizeof(struct gfs_rindex));
+		r++;
+	}
 
-      printf("\n  Resource index %d\n", r);
-      gfs_rindex_print(&rindex);
-    }
-  }
+	if (comline->debug) {
+		printf("\nResource Index data:\n";);
 
+		for (r = 0; r < comline->rgrps; r++) {
+			gfs_rindex_in(&rindex, buf + r * sizeof(struct gfs_rindex));
 
-  return buf;
+			printf("\n  Resource index %d\n", r);
+			gfs_rindex_print(&rindex);
+		}
+	}
+	return buf;
 }
 
-
 /**
  * write_rindex - write out the resource group index
  * @comline: the command line
@@ -557,96 +431,83 @@
 
 void write_rindex(commandline_t *comline, osi_list_t *rlist)
 {
-  struct gfs_dinode di;
-  struct gfs_meta_header jd;
-  char *buf, *data;
-  uint64 addr;
-  unsigned int blocks;
-  unsigned int x, left, jbsize = comline->bsize - sizeof(struct gfs_meta_header);
-
-
-  memset(&di, 0, sizeof(struct gfs_dinode));
+	struct gfs_dinode di;
+	struct gfs_meta_header jd;
+	char *buf, *data;
+	uint64 addr;
+	unsigned int blocks;
+	unsigned int x, left, jbsize = comline->bsize - sizeof(struct gfs_meta_header);
 
-  di.di_header.mh_magic = GFS_MAGIC;
-  di.di_header.mh_type = GFS_METATYPE_DI;
-  di.di_header.mh_format = GFS_FORMAT_DI;
+	memset(&di, 0, sizeof(struct gfs_dinode));
 
-  di.di_num = comline->sb->sb_rindex_di;
+	di.di_header.mh_magic = GFS_MAGIC;
+	di.di_header.mh_type = GFS_METATYPE_DI;
+	di.di_header.mh_format = GFS_FORMAT_DI;
 
-  di.di_mode = MKFS_HIDDEN_MODE;
-  di.di_nlink = 1;
-  di.di_size = comline->rgrps * sizeof(struct gfs_rindex);
-  di.di_blocks = 1;
-  di.di_atime = di.di_mtime = di.di_ctime = time(NULL);
+	di.di_num = comline->sbd->sd_sb.sb_rindex_di;
 
-  di.di_flags = GFS_DIF_JDATA;
-  di.di_payload_format = GFS_FORMAT_RI;
-  di.di_type = GFS_FILE_REG;
+	di.di_mode = MKFS_HIDDEN_MODE;
+	di.di_nlink = 1;
+	di.di_size = comline->rgrps * sizeof(struct gfs_rindex);
+	di.di_blocks = 1;
+	di.di_atime = di.di_mtime = di.di_ctime = time(NULL);
 
+	di.di_flags = GFS_DIF_JDATA;
+	di.di_payload_format = GFS_FORMAT_RI;
+	di.di_type = GFS_FILE_REG;
 
-  data = fill_rindex(comline, rlist);
+	data = fill_rindex(comline, rlist);
 
+	if (di.di_size < comline->bsize - sizeof(struct gfs_dinode)) {
+		type_zalloc(buf, char, comline->bsize);
 
-  if (di.di_size < comline->bsize - sizeof(struct gfs_dinode))
-  {
-    type_zalloc(buf, char, comline->bsize);
-
-    gfs_dinode_out(&di, buf);
+		gfs_dinode_out(&di, buf);
     
-    memcpy(buf + sizeof(struct gfs_dinode), data, comline->rgrps * sizeof(struct gfs_rindex));
-
-    do_lseek(comline->fd, di.di_num.no_addr * comline->bsize);
-    do_write(comline->fd, buf, comline->bsize);
-
-    free(buf);
-  }
-  else
-  {
-    blocks = DIV_RU(di.di_size, (comline->bsize - sizeof(struct gfs_meta_header)));
-    di.di_blocks += blocks;
-
-    addr = comline->rgrp0_next;
-
-
-    memset(&jd, 0, sizeof(struct gfs_meta_header));
-    jd.mh_magic = GFS_MAGIC;
-    jd.mh_type = GFS_METATYPE_JD;
-    jd.mh_format = GFS_FORMAT_JD;
-
+		memcpy(buf + sizeof(struct gfs_dinode), data, comline->rgrps * sizeof(struct gfs_rindex));
 
-    type_zalloc(buf, char, blocks * comline->bsize);
-
-    left = comline->rgrps * sizeof(struct gfs_rindex);
-    for (x = 0; x < blocks; x++)
-    {
-      gfs_meta_header_out(&jd, buf + x * comline->bsize);
-      memcpy(buf + x * comline->bsize + sizeof(struct gfs_meta_header),
-	     data + x * jbsize,
-	     (left > jbsize) ? jbsize : left);
-      left -= jbsize;
-    }
-
-
-    do_lseek(comline->fd, addr * comline->bsize);
-    do_write(comline->fd, buf, blocks * comline->bsize);
-
-    free(buf);
+		do_lseek(comline->fd, di.di_num.no_addr * comline->bsize);
+		do_write(comline->fd, buf, comline->bsize);
 
+		free(buf);
+	}
+	else {
+		blocks = DIV_RU(di.di_size, (comline->bsize - sizeof(struct gfs_meta_header)));
+		di.di_blocks += blocks;
+
+		addr = comline->rgrp0_next;
+
+		memset(&jd, 0, sizeof(struct gfs_meta_header));
+		jd.mh_magic = GFS_MAGIC;
+		jd.mh_type = GFS_METATYPE_JD;
+		jd.mh_format = GFS_FORMAT_JD;
+
+		type_zalloc(buf, char, blocks * comline->bsize);
+
+		left = comline->rgrps * sizeof(struct gfs_rindex);
+		for (x = 0; x < blocks; x++) {
+			gfs_meta_header_out(&jd, buf + x * comline->bsize);
+			memcpy(buf + x * comline->bsize + sizeof(struct gfs_meta_header),
+				   data + x * jbsize,
+				   (left > jbsize) ? jbsize : left);
+			left -= jbsize;
+		}
 
-    comline->rgrp0_next += blocks;
+		do_lseek(comline->fd, addr * comline->bsize);
+		do_write(comline->fd, buf, blocks * comline->bsize);
 
-    build_tree(comline, &di, addr, blocks);
-  }
+		free(buf);
 
+		comline->rgrp0_next += blocks;
 
-  free(data);
+		build_tree(comline, &di, addr, blocks);
+	}
 
+	free(data);
 
-  if (comline->debug)
-  {
-    printf("\nResource index dinode:\n");
-    gfs_dinode_print(&di);
-  }
+	if (comline->debug) {
+		printf("\nResource index dinode:\n");
+		gfs_dinode_print(&di);
+	}
 }
 
 
@@ -658,89 +519,78 @@
 
 void write_root(commandline_t *comline)
 {
-  struct gfs_dinode di;
-  struct gfs_dirent de;
-
-  char buf[comline->bsize];
-
-
-  memset(&di, 0, sizeof(struct gfs_dinode));
-  memset(buf, 0, comline->bsize);
-
-
-  di.di_header.mh_magic = GFS_MAGIC;
-  di.di_header.mh_type = GFS_METATYPE_DI;
-  di.di_header.mh_format = GFS_FORMAT_DI;
+	struct gfs_dinode di;
+	struct gfs_dirent de;
+	char buf[comline->bsize];
 
-  di.di_num = comline->sb->sb_root_di;
+	memset(&di, 0, sizeof(struct gfs_dinode));
+	memset(buf, 0, comline->bsize);
 
-  di.di_mode = MKFS_ROOT_MODE;
-  di.di_nlink = 2;
-  di.di_size = comline->bsize - sizeof(struct gfs_dinode);
-  di.di_blocks = 1;
-  di.di_atime = di.di_mtime = di.di_ctime = time(NULL);
+	di.di_header.mh_magic = GFS_MAGIC;
+	di.di_header.mh_type = GFS_METATYPE_DI;
+	di.di_header.mh_format = GFS_FORMAT_DI;
 
-  di.di_flags = GFS_DIF_JDATA;
-  di.di_payload_format = GFS_FORMAT_DE;
-  di.di_type = GFS_FILE_DIR;
+	di.di_num = comline->sbd->sd_sb.sb_root_di;
 
-  di.di_entries = 2;
+	di.di_mode = MKFS_ROOT_MODE;
+	di.di_nlink = 2;
+	di.di_size = comline->bsize - sizeof(struct gfs_dinode);
+	di.di_blocks = 1;
+	di.di_atime = di.di_mtime = di.di_ctime = time(NULL);
 
-  gfs_dinode_out(&di, buf);
+	di.di_flags = GFS_DIF_JDATA;
+	di.di_payload_format = GFS_FORMAT_DE;
+	di.di_type = GFS_FILE_DIR;
 
+	di.di_entries = 2;
 
-  /*  Fill in .  */
+	gfs_dinode_out(&di, buf);
 
-  memset(&de, 0, sizeof(struct gfs_dirent));
+	/*  Fill in .  */
 
-  de.de_inum = comline->sb->sb_root_di;
-  de.de_hash = gfs_dir_hash(".", 1);
-  de.de_rec_len = GFS_DIRENT_SIZE(1);
-  de.de_name_len = 1;
-  de.de_type = GFS_FILE_DIR;
+	memset(&de, 0, sizeof(struct gfs_dirent));
 
-  gfs_dirent_out(&de, buf + sizeof(struct gfs_dinode));
-  memcpy(buf + sizeof(struct gfs_dinode) + sizeof(struct gfs_dirent), ".", 1);
+	de.de_inum = comline->sbd->sd_sb.sb_root_di;
+	de.de_hash = gfs_dir_hash(".", 1);
+	de.de_rec_len = GFS_DIRENT_SIZE(1);
+	de.de_name_len = 1;
+	de.de_type = GFS_FILE_DIR;
 
-  if (comline->debug)
-  {
-    printf("\nRoot Dinode dirent:\n");
-    gfs_dirent_print(&de, ".");
-  }
+	gfs_dirent_out(&de, buf + sizeof(struct gfs_dinode));
+	memcpy(buf + sizeof(struct gfs_dinode) + sizeof(struct gfs_dirent), ".", 1);
 
+	if (comline->debug) {
+		printf("\nRoot Dinode dirent:\n");
+		gfs_dirent_print(&de, ".");
+	}
 
-  /*  Fill in ..  */
-
-  memset(&de, 0, sizeof(struct gfs_dirent));
-
-  de.de_inum = comline->sb->sb_root_di;
-  de.de_hash = gfs_dir_hash("..", 2);
-  de.de_rec_len = comline->bsize - GFS_DIRENT_SIZE(1) - sizeof(struct gfs_dinode);
-  de.de_name_len = 2;
-  de.de_type = GFS_FILE_DIR;
-
-  gfs_dirent_out(&de, buf + sizeof(struct gfs_dinode) + GFS_DIRENT_SIZE(1));
-  memcpy(buf + sizeof(struct gfs_dinode) + GFS_DIRENT_SIZE(1) + sizeof(struct gfs_dirent), "..", 2);
-
-  if (comline->debug)
-  {
-    printf("\nRoot Dinode dirent:\n");
-    gfs_dirent_print(&de, "..");
-  }
+	/*  Fill in ..  */
 
+	memset(&de, 0, sizeof(struct gfs_dirent));
 
-  do_lseek(comline->fd, di.di_num.no_addr * comline->bsize);
-  do_write(comline->fd, buf, comline->bsize);
+	de.de_inum = comline->sbd->sd_sb.sb_root_di;
+	de.de_hash = gfs_dir_hash("..", 2);
+	de.de_rec_len = comline->bsize - GFS_DIRENT_SIZE(1) - sizeof(struct gfs_dinode);
+	de.de_name_len = 2;
+	de.de_type = GFS_FILE_DIR;
+
+	gfs_dirent_out(&de, buf + sizeof(struct gfs_dinode) + GFS_DIRENT_SIZE(1));
+	memcpy(buf + sizeof(struct gfs_dinode) + GFS_DIRENT_SIZE(1) + sizeof(struct gfs_dirent), "..", 2);
+
+	if (comline->debug) {
+		printf("\nRoot Dinode dirent:\n");
+		gfs_dirent_print(&de, "..");
+	}
 
+	do_lseek(comline->fd, di.di_num.no_addr * comline->bsize);
+	do_write(comline->fd, buf, comline->bsize);
 
-  if (comline->debug)
-  {
-    printf("\nRoot dinode:\n");
-    gfs_dinode_print(&di);
-  }
+	if (comline->debug) {
+		printf("\nRoot dinode:\n");
+		gfs_dinode_print(&di);
+	}
 }
 
-
 /**
  * write_quota - write out the quota dinode
  * @comline: the command line
@@ -749,75 +599,65 @@
 
 void write_quota(commandline_t *comline)
 {
-  struct gfs_dinode di;
-  struct gfs_quota qu;
-
-  char buf[comline->bsize];
-
-
-  memset(&di, 0, sizeof(struct gfs_dinode));
-  memset(buf, 0, comline->bsize);
-
+	struct gfs_dinode di;
+	struct gfs_quota qu;
 
-  di.di_header.mh_magic = GFS_MAGIC;
-  di.di_header.mh_type = GFS_METATYPE_DI;
-  di.di_header.mh_format = GFS_FORMAT_DI;
+	char buf[comline->bsize];
 
-  di.di_num = comline->sb->sb_quota_di;
+	memset(&di, 0, sizeof(struct gfs_dinode));
+	memset(buf, 0, comline->bsize);
 
-  di.di_mode = MKFS_HIDDEN_MODE;
-  di.di_nlink = 1;
-  di.di_size = 2 * sizeof(struct gfs_quota);
-  di.di_blocks = 1;
-  di.di_atime = di.di_mtime = di.di_ctime = time(NULL);
+	di.di_header.mh_magic = GFS_MAGIC;
+	di.di_header.mh_type = GFS_METATYPE_DI;
+	di.di_header.mh_format = GFS_FORMAT_DI;
 
-  di.di_flags = GFS_DIF_JDATA;
-  di.di_payload_format = GFS_FORMAT_QU;
-  di.di_type = GFS_FILE_REG;
+	di.di_num = comline->sbd->sd_sb.sb_quota_di;
 
-  gfs_dinode_out(&di, buf);
+	di.di_mode = MKFS_HIDDEN_MODE;
+	di.di_nlink = 1;
+	di.di_size = 2 * sizeof(struct gfs_quota);
+	di.di_blocks = 1;
+	di.di_atime = di.di_mtime = di.di_ctime = time(NULL);
 
+	di.di_flags = GFS_DIF_JDATA;
+	di.di_payload_format = GFS_FORMAT_QU;
+	di.di_type = GFS_FILE_REG;
 
-  /*  Fill in the root user quota  */
+	gfs_dinode_out(&di, buf);
 
-  memset(&qu, 0, sizeof(struct gfs_quota));
-  qu.qu_value = comline->rgrp0_next - comline->sb->sb_jindex_di.no_addr;
+	/*  Fill in the root user quota  */
 
-  gfs_quota_out(&qu, buf + sizeof(struct gfs_dinode));
+	memset(&qu, 0, sizeof(struct gfs_quota));
+	qu.qu_value = comline->rgrp0_next - comline->sbd->sd_sb.sb_jindex_di.no_addr;
 
-  if (comline->debug)
-  {
-    printf("\nRoot user quota:\n");
-    gfs_quota_print(&qu);
-  }
+	gfs_quota_out(&qu, buf + sizeof(struct gfs_dinode));
 
+	if (comline->debug) {
+		printf("\nRoot user quota:\n");
+		gfs_quota_print(&qu);
+	}
 
-  /*  Fill in the root group quota  */
-
-  memset(&qu, 0, sizeof(struct gfs_quota));
-  qu.qu_value = comline->rgrp0_next - comline->sb->sb_jindex_di.no_addr;
-
-  gfs_quota_out(&qu, buf + sizeof(struct gfs_dinode) + sizeof(struct gfs_quota));
+	/*  Fill in the root group quota  */
 
-  if (comline->debug)
-  {
-    printf("\nRoot group quota:\n");
-    gfs_quota_print(&qu);
-  }
+	memset(&qu, 0, sizeof(struct gfs_quota));
+	qu.qu_value = comline->rgrp0_next - comline->sbd->sd_sb.sb_jindex_di.no_addr;
 
+	gfs_quota_out(&qu, buf + sizeof(struct gfs_dinode) + sizeof(struct gfs_quota));
 
-  do_lseek(comline->fd, di.di_num.no_addr * comline->bsize);
-  do_write(comline->fd, buf, comline->bsize);
+	if (comline->debug) {
+		printf("\nRoot group quota:\n");
+		gfs_quota_print(&qu);
+	}
 
+	do_lseek(comline->fd, di.di_num.no_addr * comline->bsize);
+	do_write(comline->fd, buf, comline->bsize);
 
-  if (comline->debug)
-  {
-    printf("\nQuota dinode:\n");
-    gfs_dinode_print(&di);
-  }
+	if (comline->debug) {
+		printf("\nQuota dinode:\n");
+		gfs_dinode_print(&di);
+	}
 }
 
-
 /**
  * write_license - write out the quota dinode
  * @comline: the command line
@@ -826,46 +666,41 @@
 
 void write_license(commandline_t *comline)
 {
-  struct gfs_dinode di;
+	struct gfs_dinode di;
 
-  char buf[comline->bsize];
+	char buf[comline->bsize];
 
+	memset(&di, 0, sizeof(struct gfs_dinode));
+	memset(buf, 0, comline->bsize);
 
-  memset(&di, 0, sizeof(struct gfs_dinode));
-  memset(buf, 0, comline->bsize);
+	di.di_header.mh_magic = GFS_MAGIC;
+	di.di_header.mh_type = GFS_METATYPE_DI;
+	di.di_header.mh_format = GFS_FORMAT_DI;
 
+	di.di_num = comline->sbd->sd_sb.sb_license_di;
 
-  di.di_header.mh_magic = GFS_MAGIC;
-  di.di_header.mh_type = GFS_METATYPE_DI;
-  di.di_header.mh_format = GFS_FORMAT_DI;
+	di.di_mode = MKFS_HIDDEN_MODE;
+	di.di_nlink = 1;
+	di.di_size = 0;
+	di.di_blocks = 1;
+	di.di_atime = di.di_mtime = di.di_ctime = time(NULL);
 
-  di.di_num = comline->sb->sb_license_di;
+	di.di_flags = GFS_DIF_JDATA;
+	di.di_payload_format = GFS_FORMAT_QU;
+	di.di_type = GFS_FILE_REG;
 
-  di.di_mode = MKFS_HIDDEN_MODE;
-  di.di_nlink = 1;
-  di.di_size = 0;
-  di.di_blocks = 1;
-  di.di_atime = di.di_mtime = di.di_ctime = time(NULL);
+	gfs_dinode_out(&di, buf);
 
-  di.di_flags = GFS_DIF_JDATA;
-  di.di_payload_format = GFS_FORMAT_QU;
-  di.di_type = GFS_FILE_REG;
+	do_lseek(comline->fd, di.di_num.no_addr * comline->bsize);
+	do_write(comline->fd, buf, comline->bsize);
 
-  gfs_dinode_out(&di, buf);
 
-
-  do_lseek(comline->fd, di.di_num.no_addr * comline->bsize);
-  do_write(comline->fd, buf, comline->bsize);
-
-
-  if (comline->debug)
-  {
-    printf("\nLicense dinode:\n");
-    gfs_dinode_print(&di);
-  }
+	if (comline->debug) {
+		printf("\nLicense dinode:\n");
+		gfs_dinode_print(&di);
+	}
 }
 
-
 /**
  * write_rgrps - write out the resource group headers
  * @comline: the command line
@@ -875,110 +710,96 @@
 
 void write_rgrps(commandline_t *comline, osi_list_t *rlist)
 {
-  struct gfs_rgrp rg;
-  struct gfs_meta_header rb;
-  rgrp_list_t *rl;
-  osi_list_t *tmp;
-  char *buf, *data;
-  unsigned int x, offset;
-  unsigned int byte, bit;
-  unsigned int blk_count;
-  unsigned int r = 0;
-
-
-  memset(&rb, 0, sizeof(struct gfs_meta_header));
-  rb.mh_magic = GFS_MAGIC;
-  rb.mh_type = GFS_METATYPE_RB;
-  rb.mh_format = GFS_FORMAT_RB;
-
-
-  for (tmp = rlist->next; tmp != rlist; tmp = tmp->next)
-  {
-    rl = osi_list_entry(tmp, rgrp_list_t, list);
-
-    memset(&rg, 0, sizeof(struct gfs_rgrp));
-    rg.rg_header.mh_magic = GFS_MAGIC;
-    rg.rg_header.mh_type = GFS_METATYPE_RG;
-    rg.rg_header.mh_format = GFS_FORMAT_RG;
-    rg.rg_free = rl->ri->ri_data;
-
-    type_zalloc(data, char, rl->ri->ri_bitbytes);
-    type_zalloc(buf, char, rl->ri->ri_length * comline->bsize);
-
-
-    /*  Deal with the special case of the first dinode  */
-
-    if (!r)
-    {
-      if (comline->rgrp0_next > rl->ri->ri_data1 + rl->ri->ri_data)
-	die("RG 0 is full.\n");
-
-      /*  Compensate for the hidden dinodes  */
-
-      *data = (GFS_BLKST_USEDMETA << 3 * GFS_BIT_SIZE) |
-	(GFS_BLKST_USEDMETA << 2 * GFS_BIT_SIZE) |
-	  (GFS_BLKST_USEDMETA << GFS_BIT_SIZE) |
-	    GFS_BLKST_USEDMETA;
-      *(data + 1) = GFS_BLKST_USEDMETA;
-      rg.rg_free -= 5;
-      rg.rg_useddi = 5;
-
-      /*  Compensate for the data the hidden dinodes point to  */
-
-      for (x = rl->ri->ri_data1 + 5; x < comline->rgrp0_next; x++)
-      {
-	byte = (x - rl->ri->ri_data1) / GFS_NBBY;
-	bit = (x - rl->ri->ri_data1) % GFS_NBBY;
-
-	data[byte] |= GFS_BLKST_USEDMETA << (bit * GFS_BIT_SIZE);
-
-	rg.rg_free--;
-	rg.rg_usedmeta++;
-      }
-    }
-
-
-    gfs_rgrp_out(&rg, buf);
-    offset = sizeof(struct gfs_rgrp);
-    blk_count = 1;
-
-    for (x = 0; x < rl->ri->ri_bitbytes; x++)
-    {
-      if (!(offset % comline->bsize))
-      {
-	gfs_meta_header_out(&rb, buf + offset);
-	offset += sizeof(struct gfs_meta_header);
-	blk_count++;
-      }
-
-      buf[offset] = data[x];
-      offset++;
-    }
-
-    if (blk_count != rl->ri->ri_length)
-      die("RG underflow (rg = %u, blk_count = %u, rl->ri->ri_length = %u)\n",
-	  r, blk_count, rl->ri->ri_length);
-
-
-    do_lseek(comline->fd, rl->ri->ri_addr * comline->bsize);
-    do_write(comline->fd, buf, rl->ri->ri_length * comline->bsize);
-
+	struct gfs_rgrp rg;
+	struct gfs_meta_header rb;
+	rgrp_list_t *rl;
+	osi_list_t *tmp;
+	char *buf, *data;
+	unsigned int x, offset;
+	unsigned int byte, bit;
+	unsigned int blk_count;
+	unsigned int r = 0;
+
+	memset(&rb, 0, sizeof(struct gfs_meta_header));
+	rb.mh_magic = GFS_MAGIC;
+	rb.mh_type = GFS_METATYPE_RB;
+	rb.mh_format = GFS_FORMAT_RB;
+
+	for (tmp = rlist->next; tmp != rlist; tmp = tmp->next) {
+		rl = osi_list_entry(tmp, rgrp_list_t, list);
+		
+		memset(&rg, 0, sizeof(struct gfs_rgrp));
+		rg.rg_header.mh_magic = GFS_MAGIC;
+		rg.rg_header.mh_type = GFS_METATYPE_RG;
+		rg.rg_header.mh_format = GFS_FORMAT_RG;
+		rg.rg_free = rl->ri->ri_data;
+
+		type_zalloc(data, char, rl->ri->ri_bitbytes);
+		type_zalloc(buf, char, rl->ri->ri_length * comline->bsize);
+
+		/*  Deal with the special case of the first dinode  */
+
+		if (!r) {
+			if (comline->rgrp0_next > rl->ri->ri_data1 + rl->ri->ri_data)
+				die("RG 0 is full.\n");
+			
+			/*  Compensate for the hidden dinodes  */
+
+			*data = (GFS_BLKST_USEDMETA << 3 * GFS_BIT_SIZE) |
+				(GFS_BLKST_USEDMETA << 2 * GFS_BIT_SIZE) |
+				(GFS_BLKST_USEDMETA << GFS_BIT_SIZE) |
+				GFS_BLKST_USEDMETA;
+			*(data + 1) = GFS_BLKST_USEDMETA;
+			rg.rg_free -= 5;
+			rg.rg_useddi = 5;
+
+			/*  Compensate for the data the hidden dinodes point to  */
+
+			for (x = rl->ri->ri_data1 + 5; x < comline->rgrp0_next; x++) {
+				byte = (x - rl->ri->ri_data1) / GFS_NBBY;
+				bit = (x - rl->ri->ri_data1) % GFS_NBBY;
+				
+				data[byte] |= GFS_BLKST_USEDMETA << (bit * GFS_BIT_SIZE);
+				
+				rg.rg_free--;
+				rg.rg_usedmeta++;
+			}
+		}
 
-    free(buf);
-    free(data);
+		gfs_rgrp_out(&rg, buf);
+		offset = sizeof(struct gfs_rgrp);
+		blk_count = 1;
+
+		for (x = 0; x < rl->ri->ri_bitbytes; x++) {
+			if (!(offset % comline->bsize)) {
+				gfs_meta_header_out(&rb, buf + offset);
+				offset += sizeof(struct gfs_meta_header);
+				blk_count++;
+			}
 
+			buf[offset] = data[x];
+			offset++;
+		}
 
-    if (comline->debug)
-    {
-      printf("\nResource group header %d\n", r);
-      gfs_rgrp_print(&rg);
-    }
+		if (blk_count != rl->ri->ri_length)
+			die("RG underflow (rg = %u, blk_count = %u, rl->ri->ri_length = %u)\n",
+				r, blk_count, rl->ri->ri_length);
+		
+		do_lseek(comline->fd, rl->ri->ri_addr * comline->bsize);
+		do_write(comline->fd, buf, rl->ri->ri_length * comline->bsize);
+
+		free(buf);
+		free(data);
+
+		if (comline->debug) {
+			printf("\nResource group header %d\n", r);
+			gfs_rgrp_print(&rg);
+		}
 
-    r++;
-  }
+		r++;
+	}
 }
 
-
 /**
  * write_journals - write out the journal log headers
  * @comline: the command line
@@ -988,55 +809,48 @@
 
 void write_journals(commandline_t *comline, osi_list_t *jlist)
 {
-  struct gfs_log_header lh;
-  journal_list_t *jl;
-  osi_list_t *tmp;
-  char buf[comline->bsize];
-  uint32 seg, sequence;
-  int x = 0;
-
-
-  srandom(time(NULL));
-
-
-  for (tmp = jlist->next; tmp != jlist; tmp = tmp->next)
-  {
-    jl = osi_list_entry(tmp, journal_list_t, list);
-
-    if (comline->debug)
-      printf("Starting journal %d\n", x++);
-
-    sequence = jl->segments / (RAND_MAX + 1.0) * random();
-
-    for (seg = 0; seg < jl->segments; seg++)
-    {
-      memset(buf, 0, comline->bsize);
-      memset(&lh, 0, sizeof(struct gfs_log_header));
-
-      lh.lh_header.mh_magic = GFS_MAGIC;
-      lh.lh_header.mh_type = GFS_METATYPE_LH;
-      lh.lh_header.mh_format = GFS_FORMAT_LH;
-      lh.lh_flags = GFS_LOG_HEAD_UNMOUNT;
-      lh.lh_first = jl->start + seg * comline->seg_size;
-      lh.lh_sequence = sequence;
-      /*  Don't care about tail  */
-      /*  Don't care about log dump  */
-
-      gfs_log_header_out(&lh, buf);
-      gfs_log_header_out(&lh, buf + GFS_BASIC_BLOCK - sizeof(struct gfs_log_header));
-
-      do_lseek(comline->fd, lh.lh_first * comline->bsize);
-      do_write(comline->fd, buf, comline->bsize);
-
-      if (++sequence == jl->segments)
-	sequence = 0;
-
-      if (!(seg % 100))
-	if (comline->debug)
-	  printf("seg #%u\n", seg);
-	
-    }
-  }
+	struct gfs_log_header lh;
+	journal_list_t *jl;
+	osi_list_t *tmp;
+	char buf[comline->bsize];
+	uint32 seg, sequence;
+	int x = 0;
+
+	srandom(time(NULL));
+
+	for (tmp = jlist->next; tmp != jlist; tmp = tmp->next) {
+		jl = osi_list_entry(tmp, journal_list_t, list);
+
+		if (comline->debug)
+			printf("Starting journal %d\n", x++);
+
+		sequence = jl->segments / (RAND_MAX + 1.0) * random();
+
+		for (seg = 0; seg < jl->segments; seg++) {
+			memset(buf, 0, comline->bsize);
+			memset(&lh, 0, sizeof(struct gfs_log_header));
+
+			lh.lh_header.mh_magic = GFS_MAGIC;
+			lh.lh_header.mh_type = GFS_METATYPE_LH;
+			lh.lh_header.mh_format = GFS_FORMAT_LH;
+			lh.lh_flags = GFS_LOG_HEAD_UNMOUNT;
+			lh.lh_first = jl->start + seg * comline->seg_size;
+			lh.lh_sequence = sequence;
+			/*  Don't care about tail  */
+			/*  Don't care about log dump  */
+
+			gfs_log_header_out(&lh, buf);
+			gfs_log_header_out(&lh, buf + GFS_BASIC_BLOCK - sizeof(struct gfs_log_header));
+
+			do_lseek(comline->fd, lh.lh_first * comline->bsize);
+			do_write(comline->fd, buf, comline->bsize);
+
+			if (++sequence == jl->segments)
+				sequence = 0;
+
+			if (!(seg % 100))
+				if (comline->debug)
+					printf("seg #%u\n", seg);
+		}
+	}
 }
-
-


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]