From: Pedro Ribeiro
Date: Fri, 3 Oct 2008 06:46:36 +0000 (+0200)
Subject: raw: add NLS support
X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5dd48fb28f83d5b37bee5d9a242d06671df101b5;p=util-linux
raw: add NLS support
[kzak@redhat.com: - add setlocale(), ...
- remove tailing white spaces]
Signed-off-by: Pedro Ribeiro
Signed-off-by: Karel Zak
---
diff --git a/disk-utils/raw.c b/disk-utils/raw.c
index 9423f9e6..7c90f2b4 100644
--- a/disk-utils/raw.c
+++ b/disk-utils/raw.c
@@ -21,6 +21,7 @@
#include
#include
#include
+#include "nls.h"
#ifdef OLD_RAW_DEVS
#define RAWCTLDEV "/dev/raw"
@@ -48,11 +49,11 @@ int bind (int minor, int block_major, int block_minor);
static void usage(int err)
{
fprintf(stderr,
- "Usage:\n"
+ _("Usage:\n"
" %s " RAWDEVDIR "rawN \n"
" %s " RAWDEVDIR "rawN /dev/\n"
" %s -q " RAWDEVDIR "rawN\n"
- " %s -qa\n",
+ " %s -qa\n"),
progname, progname, progname, progname);
exit(err);
}
@@ -64,13 +65,17 @@ int main(int argc, char *argv[])
char * raw_name;
char * block_name;
int err;
- int block_major, block_minor;
+ int block_major, block_minor;
int i, rc;
struct stat statbuf;
-
+
+ setlocale(LC_MESSAGES, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
progname = argv[0];
-
+
while ((c = getopt(argc, argv, "ahq")) != -1) {
switch (c) {
case 'a':
@@ -85,13 +90,13 @@ int main(int argc, char *argv[])
usage(1);
}
}
-
+
/*
* Check for, and open, the master raw device, /dev/raw
*/
-
+
open_raw_ctl();
-
+
if (do_query_all) {
if (optind < argc)
usage(1);
@@ -99,7 +104,7 @@ int main(int argc, char *argv[])
query(i, 1);
exit(0);
}
-
+
/*
* It's a bind or a single query. Either way we need a raw device.
*/
@@ -115,27 +120,27 @@ int main(int argc, char *argv[])
*/
rc = sscanf(raw_name, RAWDEVDIR "raw%d", &raw_minor);
if (rc == 1 && raw_minor == 0) {
- fprintf (stderr,
- "Device '%s' is control raw dev "
- "(use raw where is greater than zero)\n",
- raw_name);
+ fprintf (stderr,
+ _("Device '%s' is control raw dev "
+ "(use raw where is greater than zero)\n"),
+ raw_name);
exit(2);
}
err = stat(raw_name, &statbuf);
if (err) {
- fprintf (stderr, "Cannot locate raw device '%s' (%s)\n",
+ fprintf (stderr, _("Cannot locate raw device '%s' (%s)\n"),
raw_name, strerror(errno));
exit(2);
}
-
+
if (!S_ISCHR(statbuf.st_mode)) {
- fprintf (stderr, "Raw device '%s' is not a character dev\n",
+ fprintf (stderr, _("Raw device '%s' is not a character dev\n"),
raw_name);
exit(2);
}
if (major(statbuf.st_rdev) != RAW_MAJOR) {
- fprintf (stderr, "Device '%s' is not a raw dev\n",
+ fprintf (stderr, _("Device '%s' is not a raw dev\n"),
raw_name);
exit(2);
}
@@ -145,9 +150,9 @@ int main(int argc, char *argv[])
if (do_query)
return query(raw_minor, 0);
- /*
+ /*
* It's not a query, so we still have some parsing to do. Have
- * we been given a block device filename or a major/minor pair?
+ * we been given a block device filename or a major/minor pair?
*/
switch (argc - optind) {
@@ -156,34 +161,34 @@ int main(int argc, char *argv[])
err = stat(block_name, &statbuf);
if (err) {
fprintf (stderr,
- "Cannot locate block device '%s' (%s)\n",
+ _("Cannot locate block device '%s' (%s)\n"),
block_name, strerror(errno));
exit(2);
}
-
+
if (!S_ISBLK(statbuf.st_mode)) {
- fprintf (stderr, "Device '%s' is not a block dev\n",
+ fprintf (stderr, _("Device '%s' is not a block dev\n"),
block_name);
exit(2);
}
-
+
block_major = major(statbuf.st_rdev);
block_minor = minor(statbuf.st_rdev);
break;
-
+
case 2:
block_major = strtol(argv[optind], 0, 0);
block_minor = strtol(argv[optind+1], 0, 0);
break;
-
+
default:
block_major = block_minor = 0; /* just to keep gcc happy */
usage(1);
}
-
+
return bind(raw_minor, block_major, block_minor);
return 0;
-
+
}
@@ -197,9 +202,9 @@ void open_raw_ctl(void)
master_fd = open(DEVFS_RAWCTLDEV, O_RDWR, 0);
if (master_fd < 0) {
fprintf (stderr,
- "Cannot open master raw device '"
+ _("Cannot open master raw device '"
RAWCTLDEV
- "' (%s)\n", strerror(errsv));
+ "' (%s)\n"), strerror(errsv));
exit(2);
}
}
@@ -219,7 +224,7 @@ int query(int minor, int quiet)
if (has_worked && errno == EINVAL)
return 0;
fprintf (stderr,
- "Error querying raw device (%s)\n",
+ _("Error querying raw device (%s)\n"),
strerror(errno));
exit(3);
}
@@ -229,7 +234,7 @@ int query(int minor, int quiet)
has_worked = 1;
if (quiet && !rq.block_major && !rq.block_minor)
return 0;
- printf (RAWDEVDIR "raw%d: bound to major %d, minor %d\n",
+ printf (_(RAWDEVDIR "raw%d: bound to major %d, minor %d\n"),
minor, (int) rq.block_major, (int) rq.block_minor);
return 0;
}
@@ -238,18 +243,18 @@ int bind(int minor, int block_major, int block_minor)
{
struct raw_config_request rq;
int err;
-
+
rq.raw_minor = minor;
rq.block_major = block_major;
rq.block_minor = block_minor;
err = ioctl(master_fd, RAW_SETBIND, &rq);
if (err < 0) {
- fprintf (stderr,
- "Error setting raw device (%s)\n",
+ fprintf (stderr,
+ _("Error setting raw device (%s)\n"),
strerror(errno));
exit(3);
}
- printf (RAWDEVDIR "raw%d: bound to major %d, minor %d\n",
+ printf (_(RAWDEVDIR "raw%d: bound to major %d, minor %d\n"),
raw_minor, (int) rq.block_major, (int) rq.block_minor);
return 0;
}