[Ocfs2-tools-commits] smushran commits r388 - in trunk: . libocfs2 libocfs2/include mkfs.ocfs2 tunefs.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Nov 11 14:02:24 CST 2004


Author: smushran
Date: 2004-11-11 14:02:22 -0600 (Thu, 11 Nov 2004)
New Revision: 388

Added:
   trunk/libocfs2/expanddir.c
   trunk/libocfs2/newdir.c
Modified:
   trunk/CREDITS
   trunk/libocfs2/Makefile
   trunk/libocfs2/include/ocfs2.h
   trunk/libocfs2/ocfs2_err.et.in
   trunk/libocfs2/openfs.c
   trunk/mkfs.ocfs2/mkfs.c
   trunk/tunefs.ocfs2/Cscope.make
   trunk/tunefs.ocfs2/Makefile
   trunk/tunefs.ocfs2/tunefs.c
Log:
expanddir.c and newdir.c added to libocfs
more code added to tunefs

Modified: trunk/CREDITS
===================================================================
--- trunk/CREDITS	2004-11-11 03:04:23 UTC (rev 387)
+++ trunk/CREDITS	2004-11-11 20:02:22 UTC (rev 388)
@@ -20,6 +20,9 @@
 mounted.ocfs2:
 	Written by Sunil Mushran.
 
+tunefs.ocfs2
+	Written by Sunil Mushran.
+
 ocfs2cdsl:
 	Written by Manish Singh.
 

Modified: trunk/libocfs2/Makefile
===================================================================
--- trunk/libocfs2/Makefile	2004-11-11 03:04:23 UTC (rev 387)
+++ trunk/libocfs2/Makefile	2004-11-11 20:02:22 UTC (rev 388)
@@ -63,7 +63,9 @@
 	alloc.c		\
 	checkhb.c	\
 	kernel-rbtree.c	\
-	bitops.c
+	bitops.c	\
+	expanddir.c	\
+	newdir.c
 
 HFILES =				\
 	include/jfs_user.h		\

Added: trunk/libocfs2/expanddir.c
===================================================================
--- trunk/libocfs2/expanddir.c	2004-11-11 03:04:23 UTC (rev 387)
+++ trunk/libocfs2/expanddir.c	2004-11-11 20:02:22 UTC (rev 388)
@@ -0,0 +1,202 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
+ * expanddir.c
+ *
+ * Expands an OCFS2 directory.  For the OCFS2 userspace library.
+ *
+ * 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, version 2,  as published by the Free Software Foundation.
+ * 
+ * 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
+ *
+ *  This code is a port of e2fsprogs/lib/ext2fs/expanddir.c
+ *  Copyright (C) 1993, 1999 Theodore Ts'o.
+ */
+
+#define _XOPEN_SOURCE 600 /* Triggers magic in features.h */
+#define _LARGEFILE64_SOURCE
+
+#include <stdio.h>
+#include <string.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "ocfs2.h"
+
+
+struct expand_dir_struct {
+	ocfs2_dinode   *inode;
+	int		done;
+	int		newblocks;
+	errcode_t	err;
+};
+
+/*
+ * expand_dir_proc()
+ *
+ *  TODO expand_dir_proc needs to extend the allocation when needed
+ */
+static int expand_dir_proc(ocfs2_filesys *fs, uint64_t blocknr,
+			   uint64_t blockcnt, void *priv_data)
+{
+	struct expand_dir_struct *es = (struct expand_dir_struct *) priv_data;
+	ocfs2_dinode *inode;
+	uint64_t i_size_in_blks;
+	char *new_blk = NULL;
+	errcode_t ret;
+
+	inode = es->inode;
+
+	i_size_in_blks = inode->i_size >>
+	       			OCFS2_RAW_SB(fs->fs_super)->s_blocksize_bits;
+
+	if (i_size_in_blks == 0) {
+		es->err = OCFS2_ET_DIR_CORRUPTED;
+		return OCFS2_BLOCK_ABORT;
+	}
+
+	if (i_size_in_blks == blockcnt) {
+		/* init new dir block */
+		ret = ocfs2_new_dir_block(fs, 0, 0, &new_blk);
+		if (ret) {
+			es->err = ret;
+			return OCFS2_BLOCK_ABORT;
+		}
+
+		/* write new dir block */
+		ret = ocfs2_write_dir_block(fs, blocknr, new_blk);
+		if (ret) {
+			es->err = ret;
+			return OCFS2_BLOCK_ABORT;
+		}
+		es->done = 1;
+	}
+
+	if (es->done)
+		return OCFS2_BLOCK_CHANGED | OCFS2_BLOCK_ABORT;
+	else
+		return 0;
+
+/***********************************************************************
+	struct expand_dir_struct *es = (struct expand_dir_struct *) priv_data;
+	blk_t	new_blk;
+	static blk_t	last_blk = 0;
+	char		*block;
+	errcode_t	ret;
+
+	if (*blocknr) {
+		last_blk = *blocknr;
+		return 0;
+	}
+	ret = ocfs2_new_block(fs, last_blk, 0, &new_blk);
+	if (ret) {
+		es->err = ret;
+		return OCFS2_BLOCK_ABORT;
+	}
+	if (blockcnt > 0) {
+		ret = ocfs2_new_dir_block(fs, 0, 0, &block);
+		if (ret) {
+			es->err = ret;
+			return OCFS2_BLOCK_ABORT;
+		}
+		es->done = 1;
+		ret = ocfs2_write_dir_block(fs, new_blk, block);
+	} else {
+		ret = ocfs2_malloc_block(fs->fs_io, (void **)&block);
+		if (ret) {
+			es->err = ret;
+			return OCFS2_BLOCK_ABORT;
+		}
+		memset(block, 0, fs->blocksize);
+		ret = io_channel_write_blk(fs->io, new_blk, 1, block);
+	}	
+	if (ret) {
+		es->err = ret;
+		return OCFS2_BLOCK_ABORT;
+	}
+	ext2fs_free_mem((void **) &block);
+	*blocknr = new_blk;
+	ext2fs_block_alloc_stats(fs, new_blk, +1);
+	es->newblocks++;
+
+	if (es->done)
+		return (OCFS2_BLOCK_CHANGED | OCFS2_BLOCK_ABORT);
+	else
+		return OCFS2_BLOCK_CHANGED;
+****************************************************************/
+}
+
+errcode_t ocfs2_expand_dir(ocfs2_filesys *fs, uint64_t dir)
+{
+	errcode_t ret = 0;
+	struct expand_dir_struct es;
+	ocfs2_dinode *inode;
+	char *buf = NULL;
+
+	if (!(fs->fs_flags & OCFS2_FLAG_RW))
+		return OCFS2_ET_RO_FILESYS;
+
+	/* ensure it is a dir */
+	ret = ocfs2_check_directory(fs, dir);
+	if (ret)
+		return ret;
+
+	/* malloc block to read inode */
+	ret = ocfs2_malloc_block(fs->fs_io, &buf);
+	if (ret)
+		return ret;
+	else
+		inode = (ocfs2_dinode *)buf;
+
+	/* read inode */
+	ret = ocfs2_read_inode(fs, dir, (char *)inode);
+	if (ret)
+		goto bail;
+
+	es.inode = inode;
+	es.done = 0;
+	es.err = 0;
+	es.newblocks = 0;
+
+	ret = ocfs2_block_iterate(fs, dir, OCFS2_BLOCK_FLAG_APPEND,
+				  expand_dir_proc, &es);
+	if (es.err)
+		return es.err;
+	if (!es.done)
+		return OCFS2_ET_EXPAND_DIR_ERR;
+
+	/*
+	 * Update the size and block count fields in the inode.
+	 */
+	ret = ocfs2_read_inode(fs, dir, (char *)inode);
+	if (ret)
+		goto bail;
+
+	inode->i_size += fs->fs_blocksize;
+//	inode->i_blocks += (fs->fs_blocksize / 512) * es.newblocks;
+
+	ret = ocfs2_write_inode(fs, dir, (char *)inode);
+	if (ret)
+		goto bail;
+
+bail:
+	if (buf)
+		ocfs2_free(&buf);
+
+	return ret;
+}

Modified: trunk/libocfs2/include/ocfs2.h
===================================================================
--- trunk/libocfs2/include/ocfs2.h	2004-11-11 03:04:23 UTC (rev 387)
+++ trunk/libocfs2/include/ocfs2.h	2004-11-11 20:02:22 UTC (rev 388)
@@ -234,6 +234,7 @@
 errcode_t io_write_block(io_channel *channel, int64_t blkno, int count,
 			 const char *data);
 
+errcode_t ocfs2_write_super(ocfs2_filesys *fs);
 errcode_t ocfs2_open(const char *name, int flags,
 		     unsigned int superblock, unsigned int blksize,
 		     ocfs2_filesys **ret_fs);
@@ -430,9 +431,14 @@
 			   uint64_t blkno,
 			   int *oldval);
 
+errcode_t ocfs2_expand_dir(ocfs2_filesys *fs, uint64_t dir);
+
 errcode_t ocfs2_test_inode_allocated(ocfs2_filesys *fs, uint64_t blkno,
 				     int *is_allocated);
 
+errcode_t ocfs2_new_dir_block(ocfs2_filesys *fs, uint64_t dir_ino,
+			      uint64_t parent_ino, char **block);
+
 /* 
  * ${foo}_to_${bar} is a floor function.  blocks_to_clusters will
  * returns the cluster that contains a block, not the number of clusters

Added: trunk/libocfs2/newdir.c
===================================================================
--- trunk/libocfs2/newdir.c	2004-11-11 03:04:23 UTC (rev 387)
+++ trunk/libocfs2/newdir.c	2004-11-11 20:02:22 UTC (rev 388)
@@ -0,0 +1,84 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
+ * newdir.c
+ *
+ * Create a new directory block
+ *
+ * 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, version 2,  as published by the Free Software Foundation.
+ * 
+ * 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
+ *
+ *  This code is a port of e2fsprogs/lib/ext2fs/newdir.c
+ *  Copyright (C) 1994, 1995 Theodore Ts'o.
+ */
+
+#define _XOPEN_SOURCE 600 /* Triggers magic in features.h */
+#define _LARGEFILE64_SOURCE
+
+#include <stdio.h>
+#include <string.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "ocfs2.h"
+
+/*
+ * Create new directory block
+ */
+errcode_t ocfs2_new_dir_block(ocfs2_filesys *fs, uint64_t dir_ino,
+			      uint64_t parent_ino, char **block)
+{
+	struct ocfs2_dir_entry 	*dir = NULL;
+	errcode_t		ret;
+	char			*buf;
+	int			rec_len;
+
+	ret = ocfs2_malloc_block(fs->fs_io, &buf);
+	if (ret)
+		return ret;
+
+	memset(buf, 0, fs->fs_blocksize);
+
+	dir = (struct ocfs2_dir_entry *) buf;
+	dir->rec_len = fs->fs_blocksize;
+
+	if (dir_ino) {
+		/*
+		 * Set up entry for '.'
+		 */
+		dir->inode = dir_ino;
+		dir->name_len = 1;
+		dir->name[0] = '.';
+		rec_len = dir->rec_len - OCFS2_DIR_REC_LEN(1);
+		dir->rec_len = OCFS2_DIR_REC_LEN(1);
+
+		/*
+		 * Set up entry for '..'
+		 */
+		dir = (struct ocfs2_dir_entry *) (buf + dir->rec_len);
+		dir->rec_len = rec_len;
+		dir->inode = parent_ino;
+		dir->name_len = 2;
+		dir->name[0] = '.';
+		dir->name[1] = '.';
+	}
+
+	*block = buf;
+	return 0;
+}

Modified: trunk/libocfs2/ocfs2_err.et.in
===================================================================
--- trunk/libocfs2/ocfs2_err.et.in	2004-11-11 03:04:23 UTC (rev 387)
+++ trunk/libocfs2/ocfs2_err.et.in	2004-11-11 20:02:22 UTC (rev 388)
@@ -135,4 +135,7 @@
 ec	OCFS2_ET_FREEING_UNALLOCATED_REGION,
 	"Attempting to free unallocated region"
 
+ec	OCFS2_ET_EXPAND_DIR_ERR,
+	"Unable to expand directory"
+
 	end

Modified: trunk/libocfs2/openfs.c
===================================================================
--- trunk/libocfs2/openfs.c	2004-11-11 03:04:23 UTC (rev 387)
+++ trunk/libocfs2/openfs.c	2004-11-11 20:02:22 UTC (rev 388)
@@ -106,6 +106,33 @@
 	return ret;
 }
 
+errcode_t ocfs2_write_super(ocfs2_filesys *fs)
+{
+	errcode_t ret;
+	char *blk;
+	ocfs2_dinode *di;
+
+	if (!(fs->fs_flags & OCFS2_FLAG_RW))
+		return OCFS2_ET_RO_FILESYS;
+
+	blk = (char *)fs->fs_super;
+	di = (ocfs2_dinode *)blk;
+
+	ret = OCFS2_ET_BAD_MAGIC;
+	if (memcmp(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE,
+		   strlen(OCFS2_SUPER_BLOCK_SIGNATURE)))
+		goto out_blk;
+
+	ret = io_write_block(fs->fs_io, OCFS2_SUPER_BLOCK_BLKNO, 1, blk);
+	if (ret)
+		goto out_blk;
+
+	return 0;
+
+out_blk:
+	return ret;
+}
+
 errcode_t ocfs2_open(const char *name, int flags,
 		     unsigned int superblock, unsigned int block_size,
 		     ocfs2_filesys **ret_fs)

Modified: trunk/mkfs.ocfs2/mkfs.c
===================================================================
--- trunk/mkfs.ocfs2/mkfs.c	2004-11-11 03:04:23 UTC (rev 387)
+++ trunk/mkfs.ocfs2/mkfs.c	2004-11-11 20:02:22 UTC (rev 388)
@@ -260,6 +260,7 @@
 static void add_entry_to_directory(State *s, DirData *dir, char *name,
 				   uint64_t byte_off, uint8_t type);
 static uint32_t blocks_needed(State *s);
+static uint32_t sys_blocks_needed(State *s);
 static uint32_t system_dir_blocks_needed(State *s);
 static void check_32bit_blocks(State *s);
 static void format_superblock(State *s, SystemFileDiskRecord *rec,
@@ -1381,14 +1382,31 @@
 }
 
 static uint32_t
+sys_blocks_needed(State *s)
+{
+	uint32_t num = 0;
+	uint32_t cnt = sizeof(system_files) / sizeof(SystemFileInfo);
+	int i;
+
+	for (i = 0; i < cnt; ++i) {
+		if (system_files[i].global)
+			++num;
+		else
+			num += s->initial_nodes;
+	}
+
+	return num;
+}
+
+static uint32_t
 system_dir_blocks_needed(State *s)
 {
 	int bytes_needed = 0;
 	int each = OCFS2_DIR_REC_LEN(SYSTEM_FILE_NAME_MAX);
 	int entries_per_block = s->blocksize / each;
 
-	bytes_needed = (blocks_needed(s) + entries_per_block -
-			1 / entries_per_block) << s->blocksize_bits;
+	bytes_needed = ((sys_blocks_needed(s) + entries_per_block -
+			1) / entries_per_block) << s->blocksize_bits;
 
 	return (bytes_needed + s->cluster_size - 1) >> s->cluster_size_bits;
 }

Modified: trunk/tunefs.ocfs2/Cscope.make
===================================================================
--- trunk/tunefs.ocfs2/Cscope.make	2004-11-11 03:04:23 UTC (rev 387)
+++ trunk/tunefs.ocfs2/Cscope.make	2004-11-11 20:02:22 UTC (rev 388)
@@ -7,4 +7,5 @@
 	find . -maxdepth 2 -name '*.h' -print >>cscope.files
 	find ../libocfs2/ -maxdepth 2 -name '*.c' -print >>cscope.files
 	find ../libocfs2/ -maxdepth 2 -name '*.h' -print >>cscope.files
+	find ../libocfs2/ -maxdepth 2 -name '*.et' -print >>cscope.files
 	cscope -b

Modified: trunk/tunefs.ocfs2/Makefile
===================================================================
--- trunk/tunefs.ocfs2/Makefile	2004-11-11 03:04:23 UTC (rev 387)
+++ trunk/tunefs.ocfs2/Makefile	2004-11-11 20:02:22 UTC (rev 388)
@@ -5,9 +5,10 @@
 WARNINGS = -Wall -Wstrict-prototypes -Wno-format -Wmissing-prototypes \
            -Wmissing-declarations
 
-OPTS = -g
 ifdef OCFS_DEBUG
-OPTS = -g
+OPTS = -O -ggdb
+else
+OPTS = -O2
 endif
 
 CFLAGS = $(OPTS) -fno-strict-aliasing $(WARNINGS) 
@@ -19,8 +20,6 @@
 INCLUDES = -I$(TOPDIR)/libocfs2/include
 DEFINES = -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\"
 
-OPTIMIZE = -O2
-
 ifeq ($(OCFS_PROCESSOR),x86_64)
   CFLAGS += -m64
 endif
@@ -30,8 +29,6 @@
   DEFINES += -D__ILP32__
 endif
 
-CFLAGS += $(OPTIMIZE)
-
 #MANS = fsck.ocfs2.8
 
 CFILES = tunefs.c

Modified: trunk/tunefs.ocfs2/tunefs.c
===================================================================
--- trunk/tunefs.ocfs2/tunefs.c	2004-11-11 03:04:23 UTC (rev 387)
+++ trunk/tunefs.ocfs2/tunefs.c	2004-11-11 20:02:22 UTC (rev 388)
@@ -42,6 +42,7 @@
 #include <libgen.h>
 #include <netinet/in.h>
 #include <inttypes.h>
+#include <ctype.h>
 
 #include <ocfs2.h>
 #include <ocfs2_fs.h>
@@ -49,6 +50,8 @@
 #include <ocfs1_fs_compat.h>
 #include <kernel-list.h>
 
+#define SYSTEM_FILE_NAME_MAX   40
+
 typedef struct _ocfs2_tune_opts {
 	uint16_t num_nodes;
 	uint64_t vol_size;
@@ -266,6 +269,95 @@
 }
 
 /*
+ * add_nodes()
+ *
+ */
+static errcode_t add_nodes(ocfs2_filesys *fs)
+{
+	errcode_t ret = 0;
+	uint16_t old_num = OCFS2_RAW_SB(fs->fs_super)->s_max_nodes;
+	char fname[SYSTEM_FILE_NAME_MAX];
+	uint64_t inode_num;
+	int i, j;
+
+	for (i = OCFS2_LAST_GLOBAL_SYSTEM_INODE + 1; i < NUM_SYSTEM_INODES; ++i) {
+		for (j = old_num; j < opts.num_nodes; ++j) {
+			sprintf(fname, ocfs2_system_inode_names[i], j);
+			printf("Adding %s...  ", fname);
+			inode_num = 0;
+			ret =  ocfs2_new_system_inode(fs, &inode_num);
+			if (ret)
+				return ret;
+			ret = ocfs2_link(fs, fs->fs_sysdir_blkno, fname,
+					 inode_num, S_IFREG);
+			if (ret) {
+				if (ret == OCFS2_ET_DIR_NO_SPACE) {
+					ret = ocfs2_expand_dir(fs, fs->fs_sysdir_blkno);
+					if (!ret)
+						ret = ocfs2_link(fs, fs->fs_sysdir_blkno,
+								 fname, inode_num, S_IFREG);
+				}
+				if (ret)
+					return ret;
+			}
+			printf("\r                                                     \r");
+		}
+	}
+
+	return 0;
+}
+
+/*
+ * update_volume_label()
+ *
+ */
+static void update_volume_label(ocfs2_filesys *fs, int *changed)
+{
+	strncpy (OCFS2_RAW_SB(fs->fs_super)->s_label, opts.vol_label,
+		 MAX_VOL_LABEL_LEN);
+
+	*changed = 1;
+
+	return ;
+}
+
+/*
+ * update_nodes()
+ *
+ */
+static errcode_t update_nodes(ocfs2_filesys *fs, int *changed)
+{
+	errcode_t ret = 0;
+
+	ret = add_nodes(fs);
+	if (ret)
+		return ret;
+
+	OCFS2_RAW_SB(fs->fs_super)->s_max_nodes = opts.num_nodes;
+	*changed = 1;
+
+	return ret;
+}
+
+/*
+ * update_journal_size()
+ *
+ */
+static errcode_t update_journal_size(ocfs2_filesys *fs, int *changed)
+{
+	return 0;
+}
+
+/*
+ * update_volume_size()
+ *
+ */
+static errcode_t update_volume_size(ocfs2_filesys *fs, int *changed)
+{
+	return 0;
+}
+
+/*
  * main()
  *
  */
@@ -273,6 +365,8 @@
 {
 	errcode_t ret = 0;
 	ocfs2_filesys *fs = NULL;
+	int write_super = 0;
+	uint16_t tmp;
 
 	initialize_ocfs_error_table();
 
@@ -283,29 +377,44 @@
 
 	get_options(argc, argv);
 
-	ret = ocfs2_open(opts.device, OCFS2_FLAG_RO, 0, 0, &fs);
-	if (ret)
+	ret = ocfs2_open(opts.device, OCFS2_FLAG_RW, 0, 0, &fs);
+	if (ret) {
+		if (ret == OCFS2_ET_OCFS_REV)
+			printf("ERROR: %s is an ocfs (and not ocfs2) volume. ", opts.device);
+		else
+			printf("ERROR: %s is not an ocfs2 volume. ", opts.device);
+		printf("Aborting.\n");
 		goto bail;
+	}
 
 //	check_32bit_blocks (s);
 
-	// validate_changes();
-
+	/* validate volume label */
 	if (opts.vol_label) {
 		printf("Changing volume label from %s to %s\n",
 		       OCFS2_RAW_SB(fs->fs_super)->s_label, opts.vol_label);
 	}
 
+	/* validate num nodes */
 	if (opts.num_nodes) {
-		printf("Changing number of nodes from %d to %d\n",
-		       OCFS2_RAW_SB(fs->fs_super)->s_max_nodes, opts.num_nodes);
+		tmp = OCFS2_RAW_SB(fs->fs_super)->s_max_nodes;
+		if (opts.num_nodes > tmp) {
+			printf("Changing number of nodes from %d to %d\n",
+			       tmp, opts.num_nodes);
+		} else {
+			printf("ERROR: Nodes (%d) has to be larger than "
+			       "configured nodes (%d)\n", opts.num_nodes, tmp);
+			goto bail;
+		}
 	}
 
+	/* validate journal size */
 	if (opts.jrnl_size) {
 //		printf("Changing journal size %"PRIu64" to %"PRIu64"\n",
 //		       s->journal_size_in_bytes, opts.jrnl_size);
 	}
 
+	/* validate volume size */
 	if (opts.vol_size) {
 		uint64_t vol_size = fs->fs_clusters <<
 		       	OCFS2_RAW_SB(fs->fs_super)->s_clustersize_bits;
@@ -313,8 +422,55 @@
 		       vol_size, opts.vol_size);
 	}
 
-	// write_superblock();
+	/* Abort? */
+	printf("Proceed (y/N): ");
+	if (toupper(getchar()) != 'Y') {
+		printf("Aborting operation.\n");
+		goto bail;
+	}
 
+	/* update volume label */
+	if (opts.vol_label)
+		update_volume_label(fs, &write_super);
+
+	/* update number of nodes */
+	if (opts.num_nodes) {
+		ret = update_nodes(fs, &write_super);
+		if (ret) {
+			com_err(opts.progname, ret, "while updating nodes");
+			goto bail;
+		}
+	}
+
+	/* update journal size */
+	if (opts.jrnl_size) {
+		ret = update_journal_size(fs, &write_super);
+		if (ret) {
+			com_err(opts.progname, ret, "while updating journal size");
+			goto bail;
+		}
+	}
+
+	/* update volume size */
+	if (opts.vol_size) {
+		ret = update_volume_size(fs, &write_super);
+		if (ret) {
+			com_err(opts.progname, ret, "while updating volume size");
+			goto bail;
+		}
+	}
+
+
+	/* write superblock */
+	if (write_super) {
+		ret = ocfs2_write_super(fs);
+		if (ret) {
+			com_err(opts.progname, ret, "while writing superblock");
+			goto bail;
+		}
+		printf("Wrote Superblock\n");
+	}
+
 bail:
 	if (fs)
 		ocfs2_close(fs);



More information about the Ocfs2-tools-commits mailing list