FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 03-23-2009, 04:21 PM
Steven Whitehouse
 
Default mkfs.gfs2: Add gettext support

>From 770f813b787ce5c3ae2cbf56cd16d6ad824e04da Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <steve@dolmen.chygwyn.com>
Date: Mon, 23 Mar 2009 17:04:13 +0000
Subject: [PATCH] mkfs.gfs2: Add gettext support

Same as for gfs2_tool. I hope that by adding the markup for
gettext it will encourage better English by making people think
a bit about how the message would need to be translated as well
as paving the way for later translations.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
---
gfs2/mkfs/main.c | 9 ++-
gfs2/mkfs/main_grow.c | 46 ++++++++-------
gfs2/mkfs/main_jadd.c | 135 ++++++++++++++++++++----------------------
gfs2/mkfs/main_mkfs.c | 157 ++++++++++++++++++++++++-------------------------
4 files changed, 172 insertions(+), 175 deletions(-)

diff --git a/gfs2/mkfs/main.c b/gfs2/mkfs/main.c
index 9471c6f..1e9d225 100644
--- a/gfs2/mkfs/main.c
+++ b/gfs2/mkfs/main.c
@@ -10,6 +10,8 @@
#include <time.h>
#include <errno.h>
#include <libgen.h>
+#include <libintl.h>
+#define _(String) gettext(String)

#include <linux/types.h>
#include "libgfs2.h"
@@ -30,6 +32,9 @@ main(int argc, char *argv[])
{
char *p, *whoami;

+ setlocale(LC_ALL, "");
+ textdomain("mkfs.gfs2");
+
prog_name = argv[0];
srandom(time(NULL) ^ getpid());

@@ -43,9 +48,9 @@ main(int argc, char *argv[])
else if (!strcmp(whoami, "gfs2_grow"))
main_grow(argc, argv);
else
- die("I don't know who I am!
");
+ die( _("I don't know who I am!
"));

free(p);

- return EXIT_SUCCESS;
+ return 0;
}
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 0e18d1a..e87623a 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -16,6 +16,8 @@
#include <errno.h>
#include <stdarg.h>
#include <linux/types.h>
+#include <libintl.h>
+#define _(String) gettext(String)

#include "libgfs2.h"
#include "gfs2_mkfs.h"
@@ -44,7 +46,7 @@ extern int rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name);
static void usage(void)
{
fprintf(stdout,
- "Usage:
"
+ _("Usage:
"
"
"
"gfs2_grow [options] /path/to/filesystem
"
"
"
@@ -53,7 +55,7 @@ static void usage(void)
" -q Quiet, reduce verbosity
"
" -T Test, do everything except update FS
"
" -V Version information
"
- " -v Verbose, increase verbosity
");
+ " -v Verbose, increase verbosity
"));
}

void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
@@ -69,7 +71,7 @@ void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
case 'V':
printf("%s %s (built %s %s)
", argv[0],
RELEASE_VERSION, __DATE__, __TIME__);
- printf("%s
", REDHAT_COPYRIGHT);
+ printf( _(REDHAT_COPYRIGHT "
"));
exit(0);
case 'h':
usage();
@@ -78,8 +80,8 @@ void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
decrease_verbosity();
break;
case 'T':
- printf("(Test mode--File system will not "
- "be changed)
");
+ printf( _("(Test mode--File system will not "
+ "be changed)
"));
test = 1;
break;
case 'v':
@@ -88,11 +90,11 @@ void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
case ':':
case '?':
/* Unknown flag */
- fprintf(stderr, "Please use '-h' for usage.
");
+ fprintf(stderr, _("Please use '-h' for usage.
"));
exit(EXIT_FAILURE);
default:
- fprintf(stderr, "Bad programmer! You forgot"
- " to catch the %c flag
", opt);
+ fprintf(stderr, _("Bad programmer! You forgot"
+ " to catch the %c flag
"), opt);
exit(EXIT_FAILURE);
break;
}
@@ -191,11 +193,11 @@ void fix_rindex(struct gfs2_sbd *sdp, int rindex_fd, int old_rg_count)
rg = 0;
osi_list_foreach(tmp, &sdp->rglist)
rg++;
- log_info("%d new rindex entries.
", rg);
+ log_info( _("%d new rindex entries.
"), rg);
writelen = rg * sizeof(struct gfs2_rindex);
buf = calloc(1, writelen);
if (buf == NULL) {
- fprintf(stderr, "Out of memory in %s
", __FUNCTION__);
+ fprintf(stderr, _("Out of memory in %s
"), __FUNCTION__);
exit(-1);
}
/* Now add the new rg entries to the rg index. Here we */
@@ -268,7 +270,7 @@ main_grow(int argc, char *argv[])
if (check_for_gfs2(sdp)) {
if (errno == EINVAL)
fprintf(stderr,
- "Not a valid GFS2 mount point: %s
",
+ _("Not a valid GFS2 mount point: %s
"),
sdp->path_name);
else
fprintf(stderr, "%s
", strerror(errno));
@@ -277,13 +279,13 @@ main_grow(int argc, char *argv[])
sdp->device_fd = open(sdp->device_name,
(test ? O_RDONLY : O_RDWR));
if (sdp->device_fd < 0)
- die("can't open device %s: %s
",
+ die( _("can't open device %s: %s
"),
sdp->device_name, strerror(errno));
if (device_geometry(sdp)) {
- fprintf(stderr, "Geometry error
");
+ fprintf(stderr, _("Geometry error
"));
exit(-1);
}
- log_info("Initializing lists...
");
+ log_info( _("Initializing lists...
"));
osi_list_init(&sdp->rglist);
init_buf_list(sdp, &sdp->buf_list, 128 << 20);
init_buf_list(sdp, &sdp->nvbuf_list, 0xffffffff);
@@ -292,11 +294,11 @@ main_grow(int argc, char *argv[])
sdp->bsize = sdp->sd_sb.sb_bsize;
compute_constants(sdp);
if(read_sb(sdp) < 0)
- die("gfs: Error reading superblock.
");
+ die( _("gfs: Error reading superblock.
"));

fix_device_geometry(sdp);
if (mount_gfs2_meta(sdp)) {
- fprintf(stderr, "Error mounting GFS2 metafs: %s
",
+ fprintf(stderr, _("Error mounting GFS2 metafs: %s
"),
strerror(errno));
exit(-1);
}
@@ -305,7 +307,7 @@ main_grow(int argc, char *argv[])
rindex_fd = open(rindex_name, (test ? O_RDONLY : O_RDWR));
if (rindex_fd < 0) {
cleanup_metafs(sdp);
- die("GFS2 rindex not found. Please run gfs2_fsck.
");
+ die( _("GFS2 rindex not found. Please run gfs2_fsck.
"));
}
/* Get master dinode */
sdp->master_dir =
@@ -321,11 +323,11 @@ main_grow(int argc, char *argv[])
figure_out_rgsize(sdp, &rgsize);
fsgrowth = ((sdp->device.length - fssize) * sdp->bsize);
if (fsgrowth < rgsize * sdp->bsize) {
- log_err("Error: The device has grown by less than "
- "one Resource Group (RG).
");
- log_err("The device grew by %" PRIu64 "MB. ",
+ log_err( _("Error: The device has grown by less than "
+ "one Resource Group (RG).
"));
+ log_err( _("The device grew by %" PRIu64 "MB. "),
fsgrowth / MB);
- log_err("One RG is %uMB for this file system.
",
+ log_err( _("One RG is %uMB for this file system.
"),
(rgsize * sdp->bsize) / MB);
}
else {
@@ -345,5 +347,5 @@ main_grow(int argc, char *argv[])
}
close(sdp->path_fd);
sync();
- log_notice("gfs2_grow complete.
");
+ log_notice( _("gfs2_grow complete.
"));
}
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index 3f574de..5f9e461 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -15,6 +15,8 @@
#include <time.h>
#include <errno.h>
#include <stdarg.h>
+#include <libintl.h>
+#define _(String) gettext(String)

#include <linux/types.h>
#include "libgfs2.h"
@@ -23,38 +25,36 @@
#define BUF_SIZE 4096
#define RANDOM(values) ((values) * (random() / (RAND_MAX + 1.0)))

-void
-make_jdata(int fd, char *value)
+void make_jdata(int fd, char *value)
{
int err;
uint32_t val;

err = ioctl(fd, FS_IOC_GETFLAGS, &val);
if (err)
- die("error doing get flags (%d): %s
", err, strerror(errno));
+ die( _("error doing get flags (%d): %s
"), err, strerror(errno));
if (strcmp(value, "set") == 0)
val |= FS_JOURNAL_DATA_FL;
if (strcmp(value, "clear") == 0)
val &= ~FS_JOURNAL_DATA_FL;
err = ioctl(fd, FS_IOC_SETFLAGS, &val);
if (err)
- die("error doing set flags (%d): %s
", err, strerror(errno));
+ die( _("error doing set flags (%d): %s
"), err, strerror(errno));
}

-int
-rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name)
+int rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name)
{
char oldpath[PATH_MAX], newpath[PATH_MAX];
int error = 0;
error = snprintf(oldpath, PATH_MAX, "%s/new_inode",
sdp->metafs_path);
if (error >= PATH_MAX)
- die("rename2system (1)
");
+ die( _("rename2system (1)
"));

error = snprintf(newpath, PATH_MAX, "%s/%s/%s",
sdp->metafs_path, new_dir, new_name);
if (error >= PATH_MAX)
- die("rename2system (2)
");
+ die( _("rename2system (2)
"));

return rename(oldpath, newpath);
}
@@ -64,22 +64,18 @@ rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name)
*
*/

-static void
-print_usage(void)
+static void print_usage(void)
{
- printf("Usage:
");
- printf("
");
- printf("%s [options] /path/to/filesystem
", prog_name);
- printf("
");
- printf("Options:
");
- printf("
");
- printf(" -c <MB> Size of quota change file
");
- printf(" -D Enable debugging code
");
- printf(" -h Print this help, then exit
");
- printf(" -J <MB> Size of journals
");
- printf(" -j <num> Number of journals
");
- printf(" -q Don't print anything
");
- printf(" -V Print program version information, then exit
");
+ printf( _("Usage:

"
+ "%s [options] /path/to/filesystem

"
+ "Options:

"
+ " -c <MB> Size of quota change file
"
+ " -D Enable debugging code
"
+ " -h Print this help, then exit
"
+ " -J <MB> Size of journals
"
+ " -j <num> Number of journals
"
+ " -q Don't print anything
"
+ " -V Print program version information, then exit
"), prog_name);
}

/**
@@ -90,8 +86,7 @@ print_usage(void)
*
*/

-static void
-decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
+static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
{
int cont = TRUE;
int optchar;
@@ -108,7 +103,7 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
break;
case 'h':
print_usage();
- exit(EXIT_SUCCESS);
+ exit(0);
break;
case 'J':
sdp->jsize = atoi(optarg);
@@ -122,22 +117,22 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
case 'V':
printf("gfs2_jadd %s (built %s %s)
", RELEASE_VERSION,
__DATE__, __TIME__);
- printf("%s
", REDHAT_COPYRIGHT);
- exit(EXIT_SUCCESS);
+ printf( _(REDHAT_COPYRIGHT "
"));
+ exit(0);
break;
case 'X':
sdp->expert = TRUE;
break;
case ':':
case '?':
- fprintf(stderr, "Please use '-h' for usage.
");
+ fprintf(stderr, _("Please use '-h' for usage.
"));
exit(EXIT_FAILURE);
break;
case EOF:
cont = FALSE;
break;
default:
- die("unknown option: %c
", optchar);
+ die( _("unknown option: %c
"), optchar);
break;
};
}
@@ -146,13 +141,13 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
sdp->path_name = argv[optind];
optind++;
} else
- die("no path specified (try -h for help)
");
+ die( _("no path specified (try -h for help)
"));

if (optind < argc)
- die("Unrecognized option: %s
", argv[optind]);
+ die( _("Unrecognized option: %s
"), argv[optind]);

if (sdp->debug) {
- printf("Command Line Arguments:
");
+ printf( _("Command Line Arguments:
"));
printf(" qcsize = %u
", sdp->qcsize);
printf(" jsize = %u
", sdp->jsize);
printf(" journals = %u
", sdp->md.journals);
@@ -165,11 +160,11 @@ static void
verify_arguments(struct gfs2_sbd *sdp)
{
if (!sdp->md.journals)
- die("no journals specified
");
+ die( _("no journals specified
"));
if (sdp->jsize < 32 || sdp->jsize > 1024)
- die("bad journal size
");
+ die( _("bad journal size
"));
if (!sdp->qcsize || sdp->qcsize > 64)
- die("bad quota change size
");
+ die( _("bad quota change size
"));
}

/**
@@ -189,9 +184,9 @@ print_results(struct gfs2_sbd *sdp)
if (sdp->expert)
printf("Expert mode: on
");

- printf("Filesystem: %s
", sdp->path_name);
- printf("Old Journals %u
", sdp->orig_journals);
- printf("New Journals %u
", sdp->md.journals);
+ printf( _("Filesystem: %s
"), sdp->path_name);
+ printf( _("Old Journals %u
"), sdp->orig_journals);
+ printf( _("New Journals %u
"), sdp->md.journals);

}

@@ -213,17 +208,16 @@ create_new_inode(struct gfs2_sbd *sdp)
if (errno == EEXIST) {
error = unlink(name);
if (error)
- die("can't unlink %s: %s
",
+ die( _("can't unlink %s: %s
"),
name, strerror(errno));
} else
- die("can't create %s: %s
", name, strerror(errno));
+ die( _("can't create %s: %s
"), name, strerror(errno));
}

return fd;
}

-void
-add_ir(struct gfs2_sbd *sdp)
+void add_ir(struct gfs2_sbd *sdp)
{
int fd;
char new_name[256];
@@ -237,8 +231,8 @@ add_ir(struct gfs2_sbd *sdp)
memset(&ir, 0, sizeof(struct gfs2_inum_range));
if (write(fd, (void*)&ir, sizeof(struct gfs2_inum_range)) !=
sizeof(struct gfs2_inum_range)) {
- fprintf(stderr, "write error: %s from %s:%d: "
- "offset 0
", strerror(errno),
+ fprintf(stderr, _( "write error: %s from %s:%d: "
+ "offset 0
"), strerror(errno),
__FUNCTION__, __LINE__);
exit(-1);
}
@@ -249,7 +243,7 @@ add_ir(struct gfs2_sbd *sdp)
sprintf(new_name, "inum_range%u", sdp->md.journals);
error = rename2system(sdp, "per_node", new_name);
if (error < 0 && errno != EEXIST)
- die("can't rename2system %s (%d): %s
",
+ die( _("can't rename2system %s (%d): %s
"),
new_name, error, strerror(errno));
}

@@ -269,8 +263,8 @@ add_sc(struct gfs2_sbd *sdp)
memset(&sc, 0, sizeof(struct gfs2_statfs_change));
if (write(fd, (void*)&sc, sizeof(struct gfs2_statfs_change)) !=
sizeof(struct gfs2_statfs_change)) {
- fprintf(stderr, "write error: %s from %s:%d: "
- "offset 0
", strerror(errno),
+ fprintf(stderr, _("write error: %s from %s:%d: "
+ "offset 0
"), strerror(errno),
__FUNCTION__, __LINE__);
exit(-1);
}
@@ -281,7 +275,7 @@ add_sc(struct gfs2_sbd *sdp)
sprintf(new_name, "statfs_change%u", sdp->md.journals);
error = rename2system(sdp, "per_node", new_name);
if (error < 0 && errno != EEXIST)
- die("can't rename2system %s (%d): %s
",
+ die( _("can't rename2system %s (%d): %s
"),
new_name, error, strerror(errno));
}

@@ -306,8 +300,8 @@ add_qc(struct gfs2_sbd *sdp)

for (x=0; x<blocks; x++) {
if (write(fd, buf, sdp->bsize) != sdp->bsize) {
- fprintf(stderr, "write error: %s from %s:%d: "
- "block %lld (0x%llx)
",
+ fprintf(stderr, _("write error: %s from %s:%d: "
+ "block %lld (0x%llx)
"),
strerror(errno),
__FUNCTION__, __LINE__,
(unsigned long long)x,
@@ -326,8 +320,8 @@ add_qc(struct gfs2_sbd *sdp)

for (x=0; x<blocks; x++) {
if (write(fd, buf, sdp->bsize) != sdp->bsize) {
- fprintf(stderr, "write error: %s from %s:%d: "
- "block %lld (0x%llx)
",
+ fprintf(stderr, _("write error: %s from %s:%d: "
+ "block %lld (0x%llx)
"),
strerror(errno),
__FUNCTION__, __LINE__,
(unsigned long long)x,
@@ -338,7 +332,7 @@ add_qc(struct gfs2_sbd *sdp)

error = fsync(fd);
if (error)
- die("can't fsync: %s
",
+ die( _("can't fsync: %s
"),
strerror(errno));
}

@@ -347,7 +341,7 @@ add_qc(struct gfs2_sbd *sdp)
sprintf(new_name, "quota_change%u", sdp->md.journals);
error = rename2system(sdp, "per_node", new_name);
if (error < 0 && errno != EEXIST)
- die("can't rename2system %s (%d): %s
",
+ die( _("can't rename2system %s (%d): %s
"),
new_name, error, strerror(errno));
}

@@ -356,7 +350,7 @@ gather_info(struct gfs2_sbd *sdp)
{
struct statfs statbuf;
if (statfs(sdp->path_name, &statbuf) < 0) {
- die("Could not statfs the filesystem %s: %s
",
+ die( _("Could not statfs the filesystem %s: %s
"),
sdp->path_name, strerror(errno));
}
sdp->bsize = statbuf.f_bsize;
@@ -373,8 +367,8 @@ find_current_journals(struct gfs2_sbd *sdp)
sprintf(jindex, "%s/jindex", sdp->metafs_path);
dirp = opendir(jindex);
if (!dirp) {
- die("Could not find the jindex directory "
- "in gfs2meta mount! error: %s
", strerror(errno));
+ die( _("Could not find the jindex directory "
+ "in gfs2meta mount! error: %s
"), strerror(errno));
}
while (dirp) {
if ((dp = readdir(dirp)) != NULL) {
@@ -386,8 +380,8 @@ find_current_journals(struct gfs2_sbd *sdp)
close:
closedir(dirp);
if (existing_journals <= 0) {
- die("There are no journals for this "
- "gfs2 fs! Did you mkfs.gfs2 correctly?
");
+ die( _("There are no journals for this "
+ "gfs2 fs! Did you mkfs.gfs2 correctly?
"));
}

sdp->orig_journals = existing_journals;
@@ -414,8 +408,8 @@ add_j(struct gfs2_sbd *sdp)
memset(buf, 0, sdp->bsize);
for (x=0; x<blocks; x++) {
if (write(fd, buf, sdp->bsize) != sdp->bsize) {
- fprintf(stderr, "write error: %s from %s:%d: "
- "block %lld (0x%llx)
",
+ fprintf(stderr, _("write error: %s from %s:%d: "
+ "block %lld (0x%llx)
"),
strerror(errno),
__FUNCTION__, __LINE__,
(unsigned long long)x,
@@ -442,8 +436,8 @@ add_j(struct gfs2_sbd *sdp)
((struct gfs2_log_header *)buf)->lh_hash = cpu_to_be32(hash);

if (write(fd, buf, sdp->bsize) != sdp->bsize) {
- fprintf(stderr, "write error: %s from %s:%d: "
- "block %lld (0x%llx)
",
+ fprintf(stderr, _("write error: %s from %s:%d: "
+ "block %lld (0x%llx)
"),
strerror(errno),
__FUNCTION__, __LINE__,
(unsigned long long)x,
@@ -457,7 +451,7 @@ add_j(struct gfs2_sbd *sdp)

error = fsync(fd);
if (error)
- die("can't fsync: %s
",
+ die( _("can't fsync: %s
"),
strerror(errno));
}

@@ -466,7 +460,7 @@ add_j(struct gfs2_sbd *sdp)
sprintf(new_name, "journal%u", sdp->md.journals);
error = rename2system(sdp, "jindex", new_name);
if (error < 0 && errno != EEXIST)
- die("can't rename2system %s (%d): %s
",
+ die( _("can't rename2system %s (%d): %s
"),
new_name, error, strerror(errno));
}

@@ -477,8 +471,7 @@ add_j(struct gfs2_sbd *sdp)
*
*/

-void
-main_jadd(int argc, char *argv[])
+void main_jadd(int argc, char *argv[])
{
struct gfs2_sbd sbd, *sdp = &sbd;
unsigned int total;
@@ -493,12 +486,12 @@ main_jadd(int argc, char *argv[])

sdp->path_fd = open(sdp->path_name, O_RDONLY);
if (sdp->path_fd < 0)
- die("can't open root directory %s: %s
",
+ die( _("can't open root directory %s: %s
"),
sdp->path_name, strerror(errno));

if (check_for_gfs2(sdp)) {
if (errno == EINVAL)
- fprintf(stderr, "Not a valid GFS2 mount point: %s
",
+ fprintf(stderr, _("Not a valid GFS2 mount point: %s
"),
sdp->path_name);
else
fprintf(stderr, "%s
", strerror(errno));
@@ -508,7 +501,7 @@ main_jadd(int argc, char *argv[])
gather_info(sdp);

if (mount_gfs2_meta(sdp)) {
- fprintf(stderr, "Error mounting GFS2 metafs: %s
",
+ fprintf(stderr, _("Error mounting GFS2 metafs: %s
"),
strerror(errno));
exit(-1);
}
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index cdc0068..edda1d0 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -13,6 +13,8 @@
#include <mntent.h>
#include <ctype.h>
#include <sys/time.h>
+#include <libintl.h>
+#define _(String) gettext(String)

#include <linux/types.h>
#include "libgfs2.h"
@@ -42,25 +44,22 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)
static void
print_usage(void)
{
- printf("Usage:
");
- printf("
");
- printf("%s [options] <device> [ block-count ]
", prog_name);
- printf("
");
- printf("Options:
");
- printf("
");
- printf(" -b <bytes> Filesystem block size
");
- printf(" -c <MB> Size of quota change file
");
- printf(" -D Enable debugging code
");
- printf(" -h Print this help, then exit
");
- printf(" -J <MB> Size of journals
");
- printf(" -j <num> Number of journals
");
- printf(" -O Don't ask for confirmation
");
- printf(" -p <name> Name of the locking protocol
");
- printf(" -q Don't print anything
");
- printf(" -r <MB> Resource Group Size
");
- printf(" -t <name> Name of the lock table
");
- printf(" -u <MB> Size of unlinked file
");
- printf(" -V Print program version information, then exit
");
+ printf( _("Usage:

"
+ "%s [options] <device> [ block-count ]

"
+ "Options:

"
+ " -b <bytes> Filesystem block size
"
+ " -c <MB> Size of quota change file
"
+ " -D Enable debugging code
"
+ " -h Print this help, then exit
"
+ " -J <MB> Size of journals
"
+ " -j <num> Number of journals
"
+ " -O Don't ask for confirmation
"
+ " -p <name> Name of the locking protocol
"
+ " -q Don't print anything
"
+ " -r <MB> Resource Group Size
"
+ " -t <name> Name of the lock table
"
+ " -u <MB> Size of unlinked file
"
+ " -V Print program version information, then exit
"), prog_name);
}

/**
@@ -71,8 +70,7 @@ print_usage(void)
*
*/

-static void
-decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
+static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
{
int cont = TRUE;
int optchar;
@@ -99,7 +97,7 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)

case 'h':
print_usage();
- exit(EXIT_SUCCESS);
+ exit(0);
break;

case 'J':
@@ -116,7 +114,7 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)

case 'p':
if (strlen(optarg) >= GFS2_LOCKNAME_LEN)
- die("lock protocol name %s is too long
",
+ die( _("lock protocol name %s is too long
"),
optarg);
strcpy(sdp->lockproto, optarg);
break;
@@ -131,7 +129,7 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)

case 't':
if (strlen(optarg) >= GFS2_LOCKNAME_LEN)
- die("lock table name %s is too long
", optarg);
+ die( _("lock table name %s is too long
"), optarg);
strcpy(sdp->locktable, optarg);
break;

@@ -142,7 +140,7 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
case 'V':
printf("gfs2_mkfs %s (built %s %s)
", RELEASE_VERSION,
__DATE__, __TIME__);
- printf("%s
", REDHAT_COPYRIGHT);
+ printf( _(REDHAT_COPYRIGHT "
"));
exit(EXIT_SUCCESS);
break;

@@ -152,7 +150,7 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)

case ':':
case '?':
- fprintf(stderr, "Please use '-h' for usage.
");
+ fprintf(stderr, _("Please use '-h' for usage.
"));
exit(EXIT_FAILURE);
break;

@@ -169,11 +167,11 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
isdigit(optarg[0]))
sdp->orig_fssize = atol(optarg);
else
- die("More than one device specified (try -h for help)
");
+ die( _("More than one device specified (try -h for help)
"));
break;

default:
- die("unknown option: %c
", optchar);
+ die( _("unknown option: %c
"), optchar);
break;
};
}
@@ -182,16 +180,16 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
strcpy(sdp->device_name, argv[optind++]);

if (sdp->device_name[0] == '')
- die("no device specified (try -h for help)
");
+ die( _("no device specified (try -h for help)
"));

if (optind < argc)
sdp->orig_fssize = atol(argv[optind++]);

if (optind < argc)
- die("Unrecognized argument: %s
", argv[optind]);
+ die( _("Unrecognized argument: %s
"), argv[optind]);

if (sdp->debug) {
- printf("Command Line Arguments:
");
+ printf( _("Command Line Arguments:
"));
printf(" bsize = %u
", sdp->bsize);
printf(" qcsize = %u
", sdp->qcsize);
printf(" jsize = %u
", sdp->jsize);
@@ -200,7 +198,7 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
printf(" proto = %s
", sdp->lockproto);
printf(" quiet = %d
", sdp->quiet);
if (sdp->rgsize==-1)
- printf(" rgsize = optimize for best performance
");
+ printf( _(" rgsize = optimize for best performance
"));
else
printf(" rgsize = %u
", sdp->rgsize);
printf(" table = %s
", sdp->locktable);
@@ -229,33 +227,33 @@ static void test_locking(char *lockproto, char *locktable)
strcmp(lockproto, "lock_dlm") == 0) {
for (c = locktable; *c; c++) {
if (isspace(*c))
- die("locktable error: contains space characters
");
+ die( _("locktable error: contains space characters
"));
if (!isprint(*c))
- die("locktable error: contains unprintable characters
");
+ die( _("locktable error: contains unprintable characters
"));
}

c = strstr(locktable, ":");
if (!c)
- die("locktable error: missing colon in the locktable
");
+ die( _("locktable error: missing colon in the locktable
"));

if (c == locktable)
- die("locktable error: missing cluster name
");
+ die( _("locktable error: missing cluster name
"));
if (c - locktable > 16)
- die("locktable error: cluster name too long
");
+ die( _("locktable error: cluster name too long
"));

c++;
if (!c)
- die("locktable error: missing filesystem name
");
+ die( _("locktable error: missing filesystem name
"));

if (strstr(c, ":"))
- die("locktable error: more than one colon present
");
+ die( _("locktable error: more than one colon present
"));

if (!strlen(c))
- die("locktable error: missing filesystem name
");
+ die( _("locktable error: missing filesystem name
"));
if (strlen(c) > 16)
- die("locktable error: filesystem name too long
");
+ die( _("locktable error: filesystem name too long
"));
} else {
- die("lockproto error: %s unknown
", lockproto);
+ die( _("lockproto error: %s unknown
"), lockproto);
}
}

@@ -273,28 +271,28 @@ static void verify_arguments(struct gfs2_sbd *sdp)
break;

if (!x || sdp->bsize > 65536)
- die("block size must be a power of two between 512 and 65536
");
+ die( _("block size must be a power of two between 512 and 65536
"));

/* Look at this! Why can't we go bigger than 2GB? */
if (sdp->expert) {
if (1 > sdp->rgsize || sdp->rgsize > 2048)
- die("bad resource group size
");
+ die( _("bad resource group size
"));
} else {
if (32 > sdp->rgsize || sdp->rgsize > 2048)
- die("bad resource group size
");
+ die( _("bad resource group size
"));
}

if (!sdp->md.journals)
- die("no journals specified
");
+ die( _("no journals specified
"));

if (sdp->jsize < 8 || sdp->jsize > 1024)
- die("bad journal size
");
+ die( _("bad journal size
"));

if (!sdp->utsize || sdp->utsize > 64)
- die("bad unlinked size
");
+ die( _("bad unlinked size
"));

if (!sdp->qcsize || sdp->qcsize > 64)
- die("bad quota change size
");
+ die( _("bad quota change size
"));
}

/**
@@ -311,14 +309,14 @@ static void are_you_sure(struct gfs2_sbd *sdp)

fd = open(sdp->device_name, O_RDONLY);
if (fd < 0)
- die("Error: device %s not found.
", sdp->device_name);
+ die( _("Error: device %s not found.
"), sdp->device_name);
vid = volume_id_open_fd(fd);
if (vid == NULL) {
close(fd);
- die("error identifying the contents of %s: %s
",
+ die( _("error identifying the contents of %s: %s
"),
sdp->device_name, strerror(errno));
}
- printf("This will destroy any data on %s.
", sdp->device_name);
+ printf( _("This will destroy any data on %s.
"), sdp->device_name);
if (volume_id_probe_all(vid, 0, sdp->device_size) == 0) {
const char *fstype, *fsusage;
int rc;
@@ -328,18 +326,18 @@ static void are_you_sure(struct gfs2_sbd *sdp)
rc = volume_id_get_usage(vid, &fsusage);
if (!rc || strncmp(fsusage, "other", 5) == 0)
fsusage = "partition";
- printf(" It appears to contain a %s %s.
", fstype,
+ printf( _(" It appears to contain a %s %s.
"), fstype,
fsusage);
}
}
volume_id_close(vid);
close(fd);
- printf("
Are you sure you want to proceed? [y/n] ");
+ printf( _("
Are you sure you want to proceed? [y/n] "));
if(!fgets(input, 32, stdin))
- die("unable to read from stdin
");
+ die( _("unable to read from stdin
"));

if (input[0] != 'y')
- die("aborted
");
+ die( _("aborted
"));
else
printf("
");
}
@@ -356,15 +354,15 @@ void check_mount(char *device)
int fd;

if (stat(device, &st_buf) < 0)
- die("could not stat device %s
", device);
+ die( _("could not stat device %s
"), device);
if (!S_ISBLK(st_buf.st_mode))
- die("%s is not a block device
", device);
+ die( _("%s is not a block device
"), device);

fd = open(device, O_RDONLY | O_NONBLOCK | O_EXCL);

if (fd < 0) {
if (errno == EBUSY) {
- die("device %s is busy
", device);
+ die( _("device %s is busy
"), device);
}
}
else {
@@ -434,31 +432,31 @@ print_results(struct gfs2_sbd *sdp, uint64_t real_device_size,
return;

if (sdp->expert)
- printf("Expert mode: on
");
+ printf( _("Expert mode: on
"));

- printf("Device: %s
", sdp->device_name);
+ printf( _("Device: %s
"), sdp->device_name);

- printf("Blocksize: %u
", sdp->bsize);
- printf("Device Size %.2f GB (%"PRIu64" blocks)
",
+ printf( _("Blocksize: %u
"), sdp->bsize);
+ printf( _("Device Size %.2f GB (%"PRIu64" blocks)
"),
real_device_size / ((float)(1 << 30)),
real_device_size / sdp->bsize);
- printf("Filesystem Size: %.2f GB (%"PRIu64" blocks)
",
+ printf( _("Filesystem Size: %.2f GB (%"PRIu64" blocks)
"),
sdp->fssize / ((float)(1 << 30)) * sdp->bsize, sdp->fssize);

- printf("Journals: %u
", sdp->md.journals);
- printf("Resource Groups: %"PRIu64"
", sdp->rgrps);
+ printf( _("Journals: %u
"), sdp->md.journals);
+ printf( _("Resource Groups: %"PRIu64"
"), sdp->rgrps);

- printf("Locking Protocol: "%s"
", sdp->lockproto);
- printf("Lock Table: "%s"
", sdp->locktable);
+ printf( _("Locking Protocol: "%s"
"), sdp->lockproto);
+ printf( _("Lock Table: "%s"
"), sdp->locktable);

if (sdp->debug) {
printf("
");
- printf("Spills: %u
",
+ printf( _("Spills: %u
"),
sdp->buf_list.spills);
- printf("Writes: %u
", sdp->writes);
+ printf( _("Writes: %u
"), sdp->writes);
}

- printf("UUID: %s
", str_uuid(uuid));
+ printf( _("UUID: %s
"), str_uuid(uuid));
printf("
");
}

@@ -469,8 +467,7 @@ print_results(struct gfs2_sbd *sdp, uint64_t real_device_size,
*
*/

-void
-main_mkfs(int argc, char *argv[])
+void main_mkfs(int argc, char *argv[])
{
struct gfs2_sbd sbd, *sdp = &sbd;
int error;
@@ -502,7 +499,7 @@ main_mkfs(int argc, char *argv[])

sdp->device_fd = open(sdp->device_name, O_RDWR);
if (sdp->device_fd < 0)
- die("can't open device %s: %s
",
+ die( _("can't open device %s: %s
"),
sdp->device_name, strerror(errno));

if (!sdp->override)
@@ -514,7 +511,7 @@ main_mkfs(int argc, char *argv[])

device_size(sdp->device_fd, &real_device_size);
if (device_geometry(sdp)) {
- fprintf(stderr, "Geometry error
");
+ fprintf(stderr, _("Geometry error
"));
exit(-1);
}
/* Convert optional block-count to basic blocks */
@@ -522,9 +519,9 @@ main_mkfs(int argc, char *argv[])
sdp->orig_fssize *= sdp->bsize;
sdp->orig_fssize >>= GFS2_BASIC_BLOCK_SHIFT;
if (sdp->orig_fssize > sdp->device.length) {
- fprintf(stderr, "%s: Specified block count is bigger "
- "than the actual device.
", prog_name);
- die("Device Size is %.2f GB (%"PRIu64" blocks)
",
+ fprintf(stderr, _("%s: Specified block count is bigger "
+ "than the actual device.
"), prog_name);
+ die( _("Device Size is %.2f GB (%"PRIu64" blocks)
"),
real_device_size / ((float)(1 << 30)),
real_device_size / sdp->bsize);
}
@@ -565,11 +562,11 @@ main_mkfs(int argc, char *argv[])

error = fsync(sdp->device_fd);
if (error)
- die("can't fsync device (%d): %s
",
+ die( _("can't fsync device (%d): %s
"),
error, strerror(errno));
error = close(sdp->device_fd);
if (error)
- die("error closing device (%d): %s
",
+ die( _("error closing device (%d): %s
"),
error, strerror(errno));

print_results(sdp, real_device_size, uuid);
--
1.6.0.6
 

Thread Tools




All times are GMT. The time now is 02:51 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org