gfs2-utils: master - tune: Clean up and make closer to tune2fs

Steven Whitehouse swhiteho at fedoraproject.org
Thu Dec 2 13:51:22 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitdiff;h=fab89dc7afd8672037f76a16b37f229a3d86950c
Commit:        fab89dc7afd8672037f76a16b37f229a3d86950c
Parent:        29685b697efe63402e55629812f7ae22391b2e38
Author:        Steven Whitehouse <swhiteho at redhat.com>
AuthorDate:    Thu Dec 2 13:25:35 2010 +0000
Committer:     Steven Whitehouse <swhiteho at redhat.com>
CommitterDate: Thu Dec 2 13:25:35 2010 +0000

tune: Clean up and make closer to tune2fs

The -l messages have been reordered so that they now print
in the same order as tune2fs where the messages are common
and the messages have also been reformatted so that the
printed text is the same in the common cases.

The test for gfs2 has been corrected - the magic number is the
same for gfs and gfs2, we have to look at the format number to
tell the two versions apart.

The tool now prints the root and master inode numbers (for gfs2).

The strings have also been updated.

Signed-off-by: Steven Whitehouse <swhiteho at redhat.com>
---
 gfs2/tune/main.c     |   11 ++---
 gfs2/tune/super.c    |   65 ++++++++++++++++---------------
 gfs2/tune/tunegfs2.h |   18 ++++-----
 po/gfs2-utils.pot    |  103 ++++++++++++++++++++++++++------------------------
 4 files changed, 101 insertions(+), 96 deletions(-)

diff --git a/gfs2/tune/main.c b/gfs2/tune/main.c
index aa7bf45..7b4b53d 100644
--- a/gfs2/tune/main.c
+++ b/gfs2/tune/main.c
@@ -9,8 +9,7 @@
 
 #include <libintl.h>
 #define _(String) gettext(String)
-//#include <libgfs2.h>
-//
+
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
@@ -58,11 +57,9 @@ static void usage(char *name)
 
 static void version(void)
 {
-	printf( _("GFS2 tunefs (built %s %s)\n"),
-	       __DATE__, __TIME__);
+	printf("tunegfs2 (%s %s)\n"), __DATE__, __TIME__);
 }
 
-
 int main(int argc, char **argv)
 {
 	int c, status = 0;
@@ -146,8 +143,10 @@ int main(int argc, char **argv)
 			goto out;
 	}
 
-	if (tfs->opt_list)
+	if (tfs->opt_list) {
+		version();
 		print_super(tfs);
+	}
 
 	close(tfs->fd);
 out:
diff --git a/gfs2/tune/super.c b/gfs2/tune/super.c
index 1d3e99e..056e868 100644
--- a/gfs2/tune/super.c
+++ b/gfs2/tune/super.c
@@ -46,7 +46,7 @@ static const char *uuid2str(const unsigned char *uuid)
 	memset(str, 0, 64);
 	ch = str;
 	for (i = 0; i < 16; i++) {
-		sprintf(ch, "%02X", uuid[i]);
+		sprintf(ch, "%02x", uuid[i]);
 		ch += 2;
 		if ((i == 3) || (i == 5) || (i == 7) || (i == 9)) {
 			*ch = '-';
@@ -90,34 +90,33 @@ static int str2uuid(const char *newval, char *uuid)
 
 int read_super(struct tunegfs2 *tfs)
 {
-	char *block;
+	void *block;
 	int n;
        	tfs->sb_start = GFS2_SB_ADDR << GFS2_BASIC_BLOCK_SHIFT;
-	block = (char *)malloc(sizeof(char) * GFS2_DEFAULT_BSIZE);
+	block = malloc(sizeof(char) * GFS2_DEFAULT_BSIZE);
 	n = pread(tfs->fd, block, GFS2_DEFAULT_BSIZE, tfs->sb_start);
 	if (n < 0) {
 		fprintf(stderr, _("Error reading from device"));
 		return errno;
 	}
-	tfs->sb = (struct gfs2_sb *)(block);
-	if (be32_to_cpu(tfs->sb->sb_header.mh_magic != GFS_MAGIC) &&
-	(be32_to_cpu(tfs->sb->sb_header.mh_magic) != GFS2_MAGIC)) {
-		fprintf(stderr, _("Not a GFS2 device\n"));
+	tfs->sb = block;
+	if (be32_to_cpu(tfs->sb->sb_header.mh_magic) != GFS2_MAGIC) {
+		fprintf(stderr, _("Not a GFS/GFS2 device\n"));
 		return -EINVAL;
 	}
 	return 0;
 }
 
-int print_super(struct tunegfs2 *tfs)
+static int is_gfs2(const struct tunegfs2 *tfs)
+{
+	return be32_to_cpu(tfs->sb->sb_fs_format) == GFS2_FORMAT_FS;
+}
+
+int print_super(const struct tunegfs2 *tfs)
 {
 	char *fsname = NULL;
 	int table_len = 0, fsname_len = 0;
 
-	fprintf(stdout, _("Superblock Details\n"));
-	fprintf(stdout, _("Block size: %d\n"), be32_to_cpu(tfs->sb->sb_bsize));
-	fprintf(stdout, _("Block shift: %d\n"), be32_to_cpu(tfs->sb->sb_bsize_shift));
-	fprintf(stdout, _("Locking Protocol: %.*s\n"), GFS2_LOCKNAME_LEN,
-			tfs->sb->sb_lockproto);
 	fsname = strchr(tfs->sb->sb_locktable, ':');
 	if (fsname) {
 		table_len = fsname - tfs->sb->sb_locktable;
@@ -125,20 +124,26 @@ int print_super(struct tunegfs2 *tfs)
 		fsname++;
 	}
 
-	fprintf(stdout, _("lock table: %.*s\n"), table_len, 
-				tfs->sb->sb_locktable);
-	fprintf(stdout, _("fsname: %.*s\n"), fsname_len, fsname);
-	if (be32_to_cpu(tfs->sb->sb_header.mh_magic) == GFS2_MAGIC)
-		fprintf(stdout, _("Superblock UUID: %s\n"),
-			uuid2str(tfs->sb->sb_uuid));
+	printf(_("Filesystem volume name: %.*s\n"), fsname_len, fsname);
+	if (is_gfs2(tfs))
+		printf(_("Filesystem UUID: %s\n"), uuid2str(tfs->sb->sb_uuid));
+	printf( _("Filesystem magic number: 0x%X\n"), be32_to_cpu(tfs->sb->sb_header.mh_magic));
+	printf(_("Block size: %d\n"), be32_to_cpu(tfs->sb->sb_bsize));
+	printf(_("Block shift: %d\n"), be32_to_cpu(tfs->sb->sb_bsize_shift));
+	printf(_("Root inode: %llu\n"), (unsigned long long)be64_to_cpu(tfs->sb->sb_root_dir.no_addr));
+	if (is_gfs2(tfs))
+		printf(_("Master inode: %llu\n"), (unsigned long long)be64_to_cpu(tfs->sb->sb_master_dir.no_addr));
+	printf(_("Lock Protocol: %.*s\n"), GFS2_LOCKNAME_LEN,
+		tfs->sb->sb_lockproto);
+	printf(_("Lock table: %.*s\n"), table_len, tfs->sb->sb_locktable);
+
 	return 0;
 }
 
-int write_super(struct tunegfs2 *tfs)
+int write_super(const struct tunegfs2 *tfs)
 {
-	char *block = (char *)tfs->sb;
 	int n;
-	n = pwrite(tfs->fd, block, GFS2_DEFAULT_BSIZE, tfs->sb_start);
+	n = pwrite(tfs->fd, tfs->sb, GFS2_DEFAULT_BSIZE, tfs->sb_start);
 	if (n<0) {
 		fprintf(stderr, _("Unable to write super block\n"));
 		return -errno;
@@ -146,7 +151,7 @@ int write_super(struct tunegfs2 *tfs)
 	return 0;
 }
 
-int change_label(struct tunegfs2 *tfs, char *fsname)
+int change_label(struct tunegfs2 *tfs, const char *fsname)
 {
 	char *sb_fsname = NULL;
 	int l = strlen(fsname), table_len = 0, fsname_len = 0;
@@ -166,7 +171,7 @@ int change_label(struct tunegfs2 *tfs, char *fsname)
 	return 0;
 }
 
-int change_uuid(struct tunegfs2 *tfs, char *str)
+int change_uuid(struct tunegfs2 *tfs, const char *str)
 {
 	char uuid[16];
 	int status = 0;
@@ -176,20 +181,18 @@ int change_uuid(struct tunegfs2 *tfs, char *str)
 		return -EINVAL;
 	}
 	status = str2uuid(str, uuid);
-	if (!status) {
-		memset(tfs->sb->sb_uuid , '\0', 16);
-		strncpy((char *)tfs->sb->sb_uuid, uuid, 16);
-	}
+	if (!status)
+		memcpy(tfs->sb->sb_uuid, uuid, 16);
 	return status;
 }
 
 
-int change_lockproto(struct tunegfs2 *tfs, char *lockproto)
+int change_lockproto(struct tunegfs2 *tfs, const char *lockproto)
 {
 	int l = strlen(lockproto);
 	if (strncmp(lockproto, "lock_dlm", 8) 
 			&& strncmp(lockproto, "lock_nolock", 11)) {
-		fprintf(stderr, _("Incorrect lockproto specified\n"));
+		fprintf(stderr, _("Incorrect lock protocol specified\n"));
 		return -EINVAL;
 	}
 	memset(tfs->sb->sb_lockproto, '\0', GFS2_LOCKNAME_LEN);
@@ -197,7 +200,7 @@ int change_lockproto(struct tunegfs2 *tfs, char *lockproto)
 	return 0;
 }
 
-int change_locktable(struct tunegfs2 *tfs, char *locktable)
+int change_locktable(struct tunegfs2 *tfs, const char *locktable)
 {
 	char *sb_fsname = NULL;
 	char t_fsname[GFS2_LOCKNAME_LEN];
diff --git a/gfs2/tune/tunegfs2.h b/gfs2/tune/tunegfs2.h
index e42de24..8fe7e07 100644
--- a/gfs2/tune/tunegfs2.h
+++ b/gfs2/tune/tunegfs2.h
@@ -1,10 +1,8 @@
-
 #ifndef __GFS2_TUNE_DOT_H__
 #define __GFS2_TUNE_DOT_H__
 
 #define GFS2_DEFAULT_BSIZE	4096
-#define GFS_MAGIC               (0x01161970) /* GFS1 magic, because we are */ 
-					/* not including any GFS1 headers */
+
 struct tunegfs2 {
 	char *devicename;
 	int fd;
@@ -22,13 +20,13 @@ struct tunegfs2 {
 	int opt_table;
 };
 
-int print_super(struct tunegfs2 *);
-int read_super(struct tunegfs2 *);
-int write_super(struct tunegfs2 *);
-int change_uuid(struct tunegfs2 *, char *uuid);
-int change_label(struct tunegfs2 *, char *label);
-int change_lockproto(struct tunegfs2 *, char *label);
-int change_locktable(struct tunegfs2 *, char *label);
+extern int print_super(const struct tunegfs2 *);
+extern int read_super(struct tunegfs2 *);
+extern int write_super(const struct tunegfs2 *);
+extern int change_uuid(struct tunegfs2 *, const char *uuid);
+extern int change_label(struct tunegfs2 *, const char *label);
+extern int change_lockproto(struct tunegfs2 *, const char *label);
+extern int change_locktable(struct tunegfs2 *, const char *label);
 
 #endif
 
diff --git a/po/gfs2-utils.pot b/po/gfs2-utils.pot
index c1357c2..4572655 100644
--- a/po/gfs2-utils.pot
+++ b/po/gfs2-utils.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-10-18 11:57+0100\n"
+"POT-Creation-Date: 2010-12-02 13:23+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
 "Language-Team: LANGUAGE <LL at li.org>\n"
@@ -21,7 +21,7 @@ msgstr ""
 msgid "I don't know who I am!\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:51
+#: gfs2/mkfs/main_grow.c:52
 #, c-format
 msgid ""
 "Usage:\n"
@@ -36,98 +36,98 @@ msgid ""
 "  -v               Verbose, increase verbosity\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:76 gfs2/mkfs/main_jadd.c:124
+#: gfs2/mkfs/main_grow.c:77 gfs2/mkfs/main_jadd.c:124
 #: gfs2/mkfs/main_mkfs.c:145 gfs2/fsck/main.c:59
 #, c-format
 msgid "\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:85
+#: gfs2/mkfs/main_grow.c:86
 #, c-format
 msgid "(Test mode--File system will not be changed)\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:95 gfs2/mkfs/main_jadd.c:132
+#: gfs2/mkfs/main_grow.c:96 gfs2/mkfs/main_jadd.c:132
 #: gfs2/mkfs/main_mkfs.c:155 gfs2/fsck/main.c:102 gfs2/fsck/main.c:114
 #, c-format
 msgid "Please use '-h' for usage.\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:98 gfs2/fsck/main.c:105
+#: gfs2/mkfs/main_grow.c:99 gfs2/fsck/main.c:105
 #, c-format
 msgid "Bad programmer! You forgot to catch the %c flag\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:194
+#: gfs2/mkfs/main_grow.c:196
 #, c-format
 msgid "%d new rindex entries.\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:198
+#: gfs2/mkfs/main_grow.c:200
 #, c-format
 msgid "Out of memory in %s\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:275 gfs2/mkfs/main_jadd.c:503
+#: gfs2/mkfs/main_grow.c:305 gfs2/mkfs/main_jadd.c:503
 #, c-format
 msgid "Not a valid GFS2 mount point: %s\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:284 gfs2/mkfs/main_mkfs.c:562
+#: gfs2/mkfs/main_grow.c:314 gfs2/mkfs/main_mkfs.c:562
 #, c-format
 msgid "can't open device %s: %s\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:287 gfs2/mkfs/main_mkfs.c:601
+#: gfs2/mkfs/main_grow.c:317 gfs2/mkfs/main_mkfs.c:601
 #: gfs2/fsck/rgrepair.c:342
 #, c-format
 msgid "Geometry error\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:290 gfs2/fsck/initialize.c:998
+#: gfs2/mkfs/main_grow.c:320 gfs2/fsck/initialize.c:998
 msgid "Initializing lists...\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:296 gfs2/mkfs/main_jadd.c:519
+#: gfs2/mkfs/main_grow.c:326 gfs2/mkfs/main_jadd.c:519
 #: gfs2/mkfs/main_mkfs.c:593 gfs2/fsck/initialize.c:1014
 #, c-format
 msgid "Bad constants (1)\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:300
+#: gfs2/mkfs/main_grow.c:330
 msgid "gfs: Error reading superblock.\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:303 gfs2/mkfs/main_mkfs.c:618
+#: gfs2/mkfs/main_grow.c:333 gfs2/mkfs/main_mkfs.c:618
 #: gfs2/fsck/rgrepair.c:346
 #, c-format
 msgid "Device is too small (%<PRIu64> bytes)\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:309 gfs2/mkfs/main_jadd.c:513
+#: gfs2/mkfs/main_grow.c:339 gfs2/mkfs/main_jadd.c:513
 #, c-format
 msgid "Error mounting GFS2 metafs: %s\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:318
+#: gfs2/mkfs/main_grow.c:348
 msgid "GFS2 rindex not found.  Please run gfs2_fsck.\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:334
+#: gfs2/mkfs/main_grow.c:364
 msgid "Error: The device has grown by less than one Resource Group (RG).\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:336
+#: gfs2/mkfs/main_grow.c:366
 #, c-format
 msgid "The device grew by %<PRIu64>MB.  "
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:338
+#: gfs2/mkfs/main_grow.c:368
 #, c-format
 msgid "One RG is %uMB for this file system.\n"
 msgstr ""
 
-#: gfs2/mkfs/main_grow.c:358
+#: gfs2/mkfs/main_grow.c:388
 msgid "gfs2_grow complete.\n"
 msgstr ""
 
@@ -509,17 +509,12 @@ msgstr ""
 msgid "error closing device (%d): %s\n"
 msgstr ""
 
-#: gfs2/tune/main.c:61
-#, c-format
-msgid "GFS2 tunefs (built %s %s)\n"
-msgstr ""
-
-#: gfs2/tune/main.c:94
+#: gfs2/tune/main.c:91
 #, c-format
 msgid "Invalid option.\n"
 msgstr ""
 
-#: gfs2/tune/main.c:105
+#: gfs2/tune/main.c:102
 #, c-format
 msgid "Unable to open device %s\n"
 msgstr ""
@@ -544,72 +539,82 @@ msgstr ""
 msgid "Error reading from device"
 msgstr ""
 
-#: gfs2/tune/super.c:105
+#: gfs2/tune/super.c:104
 #, c-format
-msgid "Not a GFS2 device\n"
+msgid "Not a GFS/GFS2 device\n"
 msgstr ""
 
-#: gfs2/tune/super.c:116
+#: gfs2/tune/super.c:127
 #, c-format
-msgid "Superblock Details\n"
+msgid "Filesystem volume name: %.*s\n"
 msgstr ""
 
-#: gfs2/tune/super.c:117
+#: gfs2/tune/super.c:129
+#, c-format
+msgid "Filesystem UUID: %s\n"
+msgstr ""
+
+#: gfs2/tune/super.c:130
+#, c-format
+msgid "Filesystem magic number: 0x%X\n"
+msgstr ""
+
+#: gfs2/tune/super.c:131
 #, c-format
 msgid "Block size: %d\n"
 msgstr ""
 
-#: gfs2/tune/super.c:118
+#: gfs2/tune/super.c:132
 #, c-format
 msgid "Block shift: %d\n"
 msgstr ""
 
-#: gfs2/tune/super.c:119
+#: gfs2/tune/super.c:133
 #, c-format
-msgid "Locking Protocol: %.*s\n"
+msgid "Root inode: %llu\n"
 msgstr ""
 
-#: gfs2/tune/super.c:128
+#: gfs2/tune/super.c:135
 #, c-format
-msgid "lock table: %.*s\n"
+msgid "Master inode: %llu\n"
 msgstr ""
 
-#: gfs2/tune/super.c:130
+#: gfs2/tune/super.c:136
 #, c-format
-msgid "fsname: %.*s\n"
+msgid "Lock Protocol: %.*s\n"
 msgstr ""
 
-#: gfs2/tune/super.c:132
+#: gfs2/tune/super.c:138
 #, c-format
-msgid "Superblock UUID: %s\n"
+msgid "Lock table: %.*s\n"
 msgstr ""
 
-#: gfs2/tune/super.c:143
+#: gfs2/tune/super.c:148
 #, c-format
 msgid "Unable to write super block\n"
 msgstr ""
 
-#: gfs2/tune/super.c:161
+#: gfs2/tune/super.c:166
 #, c-format
 msgid "Label too long\n"
 msgstr ""
 
-#: gfs2/tune/super.c:174
+#: gfs2/tune/super.c:179
 #, c-format
 msgid "UUID can be changed for a GFS2"
 msgstr ""
 
-#: gfs2/tune/super.c:175
+#: gfs2/tune/super.c:180
 #, c-format
 msgid " device only\n"
 msgstr ""
 
-#: gfs2/tune/super.c:192
+#: gfs2/tune/super.c:195
 #, c-format
-msgid "Incorrect lockproto specified\n"
+msgid "Incorrect lock protocol specified\n"
 msgstr ""
 
-#: gfs2/tune/super.c:219
+#: gfs2/tune/super.c:222
 #, c-format
 msgid "Lock table name too big\n"
 msgstr ""


More information about the cluster-commits mailing list