[Ocfs2-tools-commits] smushran commits r360 - in trunk: .
debugfs.ocfs2 tunefs.ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Nov 3 17:56:49 CST 2004
Author: smushran
Date: 2004-11-03 17:56:47 -0600 (Wed, 03 Nov 2004)
New Revision: 360
Added:
trunk/tunefs.ocfs2/
trunk/tunefs.ocfs2/Cscope.make
trunk/tunefs.ocfs2/Makefile
trunk/tunefs.ocfs2/tunefs.c
Modified:
trunk/Makefile
trunk/debugfs.ocfs2/Makefile
trunk/debugfs.ocfs2/main.c
Log:
tunefs.ocfs2 added
version in debugfs fixed
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2004-11-03 22:14:37 UTC (rev 359)
+++ trunk/Makefile 2004-11-03 23:56:47 UTC (rev 360)
@@ -22,7 +22,7 @@
$(error could not detect architecture for tools)
endif
-SUBDIRS = libocfs2 fsck.ocfs2 mkfs.ocfs2 mounted.ocfs2 extras load_ocfs ocfs_uid_gen patches
+SUBDIRS = libocfs2 fsck.ocfs2 mkfs.ocfs2 mounted.ocfs2 tunefs.ocfs2 extras load_ocfs ocfs_uid_gen patches
ifdef BUILD_OCFS2CDSL
SUBDIRS += ocfs2cdsl
Modified: trunk/debugfs.ocfs2/Makefile
===================================================================
--- trunk/debugfs.ocfs2/Makefile 2004-11-03 22:14:37 UTC (rev 359)
+++ trunk/debugfs.ocfs2/Makefile 2004-11-03 23:56:47 UTC (rev 360)
@@ -4,7 +4,8 @@
SBIN_PROGRAMS = debugfs.ocfs2
-DEFINES = -DG_DISABLE_DEPRECATED -DLINUX -DDEBUGOCFS -DDEBUG -DDEBUGOCFS_VERSION=\"0.0.1\"
+DEFINES = -DG_DISABLE_DEPRECATED -DLINUX -DDEBUGOCFS -DDEBUG
+DEFINES += -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\"
INCLUDES = -Iinclude -I$(TOPDIR)/libocfs2/include
INCLUDES += $(GLIB_CFLAGS)
Modified: trunk/debugfs.ocfs2/main.c
===================================================================
--- trunk/debugfs.ocfs2/main.c 2004-11-03 22:14:37 UTC (rev 359)
+++ trunk/debugfs.ocfs2/main.c 2004-11-03 23:56:47 UTC (rev 360)
@@ -28,7 +28,7 @@
#define PROMPT "debugfs: "
static void usage (char *progname);
-static void print_version (void);
+static void print_version (char *progname);
static char *get_line (void);
gboolean allow_write = FALSE;
@@ -51,9 +51,9 @@
* print_version()
*
*/
-static void print_version (void)
+static void print_version (char *progname)
{
- g_print ("debugocfs version " DEBUGOCFS_VERSION "\n");
+ fprintf(stderr, "%s %s\n", progname, VERSION);
} /* print_version */
/*
@@ -83,6 +83,7 @@
char *device = NULL;
char *arg;
gboolean seen_device = FALSE;
+ char *progname;
#define INSTALL_SIGNAL(sig) \
do { \
@@ -95,6 +96,8 @@
INSTALL_SIGNAL(SIGTERM);
INSTALL_SIGNAL(SIGINT);
+ progname = basename(argv[0]);
+
for (i = 1; i < argc; i++) {
arg = argv[i];
if ((strcmp (arg, "--write") == 0) ||
@@ -102,7 +105,7 @@
allow_write = TRUE;
} else if ((strcmp (arg, "--version") == 0) ||
(strcmp (arg, "-V") == 0)) {
- print_version ();
+ print_version (progname);
exit (0);
} else if ((strcmp (arg, "--help") == 0) ||
(strcmp (arg, "-?") == 0)) {
@@ -117,7 +120,7 @@
}
}
- print_version ();
+ print_version (progname);
if (device) {
line = g_strdup_printf ("open %s", device);
Added: trunk/tunefs.ocfs2/Cscope.make
===================================================================
--- trunk/tunefs.ocfs2/Cscope.make 2004-11-03 22:14:37 UTC (rev 359)
+++ trunk/tunefs.ocfs2/Cscope.make 2004-11-03 23:56:47 UTC (rev 360)
@@ -0,0 +1,10 @@
+.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 ../libocfs2/ -maxdepth 2 -name '*.c' -print >>cscope.files
+ find ../libocfs2/ -maxdepth 2 -name '*.h' -print >>cscope.files
+ cscope -b
Added: trunk/tunefs.ocfs2/Makefile
===================================================================
--- trunk/tunefs.ocfs2/Makefile 2004-11-03 22:14:37 UTC (rev 359)
+++ trunk/tunefs.ocfs2/Makefile 2004-11-03 23:56:47 UTC (rev 360)
@@ -0,0 +1,46 @@
+TOPDIR = ..
+
+include $(TOPDIR)/Preamble.make
+
+WARNINGS = -Wall -Wstrict-prototypes -Wno-format -Wmissing-prototypes \
+ -Wmissing-declarations
+
+OPTS = -g
+ifdef OCFS_DEBUG
+OPTS = -g
+endif
+
+CFLAGS = $(OPTS) -fno-strict-aliasing $(WARNINGS)
+
+LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
+
+SBIN_PROGRAMS = tunefs.ocfs2
+
+INCLUDES = -I$(TOPDIR)/libocfs2/include
+DEFINES = -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\"
+
+OPTIMIZE = -O2
+
+ifeq ($(OCFS_PROCESSOR),x86_64)
+ CFLAGS += -m64
+endif
+ifeq ($(OCFS_PROCESSOR),ia64)
+endif
+ifeq ($(OCFS_PROCESSOR),i686)
+ DEFINES += -D__ILP32__
+endif
+
+CFLAGS += $(OPTIMIZE)
+
+VERSION_FILES = tunefs.c
+VERSION_SRC = tunefs.c
+VERSION_PREFIX = OCFS2
+
+#MANS = fsck.ocfs2.8
+
+DIST_FILES = $(VERSION_FILES) $(VERSION_SRC)
+
+tunefs.ocfs2: tunefs.o
+ $(LINK) $(LIBOCFS2_LIBS) $(COM_ERR_LIBS) $(VERMAGIC)
+
+include $(TOPDIR)/Postamble.make
Added: trunk/tunefs.ocfs2/tunefs.c
===================================================================
--- trunk/tunefs.ocfs2/tunefs.c 2004-11-03 22:14:37 UTC (rev 359)
+++ trunk/tunefs.ocfs2/tunefs.c 2004-11-03 23:56:47 UTC (rev 360)
@@ -0,0 +1,323 @@
+/*
+ * tune.c
+ *
+ * ocfs2 tune utility
+ *
+ * Copyright (C) 2004 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.
+ *
+ * Authors: Sunil Mushran
+ */
+
+#define _LARGEFILE64_SOURCE
+#define _GNU_SOURCE /* Because libc really doesn't want us using O_DIRECT? */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/fd.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+#include <malloc.h>
+#include <time.h>
+#include <libgen.h>
+#include <netinet/in.h>
+#include <inttypes.h>
+
+#include <ocfs2.h>
+#include <ocfs2_fs.h>
+#include <ocfs2_disk_dlm.h>
+#include <ocfs1_fs_compat.h>
+#include <kernel-list.h>
+
+typedef struct _ocfs2_tune_opts {
+ uint16_t num_nodes;
+ uint64_t vol_size;
+ uint64_t jrnl_size;
+ char *vol_label;
+ char *progname;
+ char *device;
+ int verbose;
+ int quiet;
+ time_t tune_time;
+ int fd;
+} ocfs2_tune_opts;
+
+ocfs2_tune_opts opts;
+
+/*
+ * usage()
+ *
+ */
+static void usage(const char *progname)
+{
+ fprintf(stderr, "Usage: %s [-L volume-label] [-n number-of-nodes]\n"
+ "\t\t[-j journal-size] [-S volume-size] [-qvV] device\n",
+ progname);
+ exit(0);
+}
+
+/*
+ * version()
+ *
+ */
+static void version(const char *progname)
+{
+ fprintf(stderr, "%s %s\n", progname, VERSION);
+}
+
+/*
+ * get_number()
+ *
+ */
+static int get_number(char *arg, uint64_t *res)
+{
+ char *ptr = NULL;
+ uint64_t num;
+
+ num = strtoull(arg, &ptr, 0);
+
+ if ((ptr == arg) || (num == UINT64_MAX))
+ return(-EINVAL);
+
+ switch (*ptr) {
+ case '\0':
+ break;
+
+ case 'g':
+ case 'G':
+ num *= 1024;
+ /* FALL THROUGH */
+
+ case 'm':
+ case 'M':
+ num *= 1024;
+ /* FALL THROUGH */
+
+ case 'k':
+ case 'K':
+ num *= 1024;
+ /* FALL THROUGH */
+
+ case 'b':
+ case 'B':
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ *res = num;
+
+ return 0;
+}
+
+/*
+ * get_options()
+ *
+ */
+static void get_options(int argc, char **argv)
+{
+ int c;
+ int show_version = 0;
+ int ret;
+ char *dummy;
+ uint64_t val;
+ uint64_t max_journal_size = 500 * ONE_MEGA_BYTE;
+
+ static struct option long_options[] = {
+ { "label", 1, 0, 'L' },
+ { "nodes", 1, 0, 'n' },
+ { "verbose", 0, 0, 'v' },
+ { "quiet", 0, 0, 'q' },
+ { "version", 0, 0, 'V' },
+ { "journalsize", 0, 0, 'j'},
+ { "volumesize", 0, 0, 'S'},
+ { 0, 0, 0, 0}
+ };
+
+ if (argc && *argv)
+ opts.progname = basename(argv[0]);
+ else
+ opts.progname = strdup("tunefs.ocfs2");
+
+ while (1) {
+ c = getopt_long(argc, argv, "L:n:j:S:vqV", long_options,
+ NULL);
+
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case 'L':
+ opts.vol_label = strdup(optarg);
+
+ if (strlen(opts.vol_label) >= MAX_VOL_LABEL_LEN) {
+ com_err(opts.progname, 0,
+ "Volume label too long: must be less "
+ "than %d characters",
+ MAX_VOL_LABEL_LEN);
+ exit(1);
+ }
+ break;
+
+ case 'n':
+ opts.num_nodes = strtoul(optarg, &dummy, 0);
+
+ if (opts.num_nodes > OCFS2_MAX_NODES ||
+ *dummy != '\0') {
+ com_err(opts.progname, 0,
+ "Number of nodes must be no more than %d",
+ OCFS2_MAX_NODES);
+ exit(1);
+ } else if (opts.num_nodes < 2) {
+ com_err(opts.progname, 0,
+ "Initial nodes must be at least 2");
+ exit(1);
+ }
+ break;
+
+ case 'j':
+ ret = get_number(optarg, &val);
+
+ if (ret ||
+ val < OCFS2_MIN_JOURNAL_SIZE ||
+ val > max_journal_size) {
+ com_err(opts.progname, 0,
+ "Invalid journal size %s: must be "
+ "between %d and %"PRIu64" bytes",
+ optarg,
+ OCFS2_MIN_JOURNAL_SIZE,
+ max_journal_size);
+ exit(1);
+ }
+
+ opts.jrnl_size = val;
+ break;
+
+ case 'S':
+ ret = get_number(optarg, &val);
+ if (ret)
+ exit(1);
+
+// if (ret || val > MAX_VOL_SIZE) {
+// com_err(opts.progname, 0,
+// "Invalid device size %s: must be "
+// "between %d and %"PRIu64" bytes",
+// optarg,
+// BOO, MAX_VOL_SIZE);
+// exit(1);
+// }
+
+ opts.vol_size = val;
+ break;
+
+ case 'v':
+ opts.verbose = 1;
+ break;
+
+ case 'q':
+ opts.quiet = 1;
+ break;
+
+ case 'V':
+ show_version = 1;
+ break;
+
+ default:
+ usage(opts.progname);
+ break;
+ }
+ }
+
+ if (!opts.quiet || show_version)
+ version(opts.progname);
+
+ if (show_version)
+ exit(0);
+
+ if (optind == argc)
+ usage(opts.progname);
+
+ opts.device = strdup(argv[optind]);
+
+ opts.tune_time = time(NULL);
+
+ return ;
+}
+
+/*
+ * main()
+ *
+ */
+int main(int argc, char **argv)
+{
+ errcode_t ret = 0;
+ ocfs2_filesys *fs = NULL;
+
+ initialize_ocfs_error_table();
+
+ setbuf(stdout, NULL);
+ setbuf(stderr, NULL);
+
+ memset (&opts, 0, sizeof(opts));
+
+ get_options(argc, argv);
+
+ ret = ocfs2_open(opts.device, OCFS2_FLAG_RO, 0, 0, &fs);
+ if (ret)
+ goto bail;
+
+// check_32bit_blocks (s);
+
+ // validate_changes();
+
+ if (opts.vol_label) {
+ printf("Changing volume label from %s to %s\n",
+ OCFS2_RAW_SB(fs->fs_super)->s_label, opts.vol_label);
+ }
+
+ 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);
+ }
+
+ if (opts.jrnl_size) {
+// printf("Changing journal size %"PRIu64" to %"PRIu64"\n",
+// s->journal_size_in_bytes, opts.jrnl_size);
+ }
+
+ if (opts.vol_size) {
+ uint64_t vol_size = fs->fs_clusters <<
+ OCFS2_RAW_SB(fs->fs_super)->s_clustersize_bits;
+ printf("Changing volume size %"PRIu64" to %"PRIu64"\n",
+ vol_size, opts.vol_size);
+ }
+
+ // write_superblock();
+
+bail:
+ if (fs)
+ ocfs2_close(fs);
+
+ return ret;
+}
More information about the Ocfs2-tools-commits
mailing list