cluster: RHEL56 - gfs2: fix build warnings spotted by paranoia cflags
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 2040434f74cb6cd43e3b7781c7f6c11d3adfaa2b
Parent: 0fb59c1416efb28367ca5fb06221edb9ecf49423
Author: Bob Peterson <bob(a)ganesha.peterson>
AuthorDate: Mon Feb 15 15:36:31 2010 -0600
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Fri Apr 9 22:38:17 2010 -0500
gfs2: fix build warnings spotted by paranoia cflags
This is a RHEL55 crosswrite of STABLE3 commit id c091d13.
This is done in order to make the RHEL55 branch closer to
the STABLE3 branch for easier back-porting.
rhbz#455300
---
gfs2/convert/gfs2_convert.c | 54 ++++----
gfs2/edit/gfs2hex.c | 71 +++++-----
gfs2/edit/gfs2hex.h | 2 +-
gfs2/edit/hexedit.c | 358 ++++++++++++++++++++++---------------------
gfs2/edit/hexedit.h | 1 -
gfs2/edit/savemeta.c | 73 +++++-----
gfs2/fsck/fs_recovery.c | 9 +-
gfs2/fsck/initialize.c | 2 +-
gfs2/fsck/main.c | 28 ++--
gfs2/fsck/metawalk.c | 57 ++++----
gfs2/fsck/pass1.c | 10 +-
gfs2/fsck/pass1b.c | 6 +-
gfs2/fsck/pass2.c | 18 +--
gfs2/fsck/pass3.c | 4 +-
gfs2/fsck/pass4.c | 4 +-
gfs2/fsck/pass5.c | 6 +-
gfs2/fsck/rgrepair.c | 10 +-
gfs2/libgfs2/block_list.c | 10 +-
gfs2/libgfs2/buf.c | 4 +-
gfs2/libgfs2/fs_geometry.c | 10 +-
gfs2/libgfs2/fs_ops.c | 107 ++++++-------
gfs2/libgfs2/gfs1.c | 8 +-
gfs2/libgfs2/gfs2_log.c | 8 +-
gfs2/libgfs2/libgfs2.h | 11 +-
gfs2/libgfs2/misc.c | 15 +--
gfs2/libgfs2/rgrp.c | 8 +-
gfs2/libgfs2/size.c | 6 +-
gfs2/mkfs/main.c | 2 +-
gfs2/mkfs/main_grow.c | 12 +-
gfs2/mkfs/main_jadd.c | 26 ++--
gfs2/mkfs/main_mkfs.c | 4 +-
gfs2/mount/mount.gfs2.c | 2 +-
gfs2/mount/umount.gfs2.c | 2 +-
gfs2/mount/util.c | 8 +-
gfs2/quota/check.c | 2 +-
gfs2/quota/gfs2_quota.h | 2 +-
gfs2/quota/main.c | 2 +-
gfs2/tool/gfs2_tool.h | 1 -
gfs2/tool/main.c | 2 +-
gfs2/tool/sb.c | 2 +-
40 files changed, 471 insertions(+), 496 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 5223590..48b4087 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -140,7 +140,7 @@ int seconds;
struct timeval tv;
uint64_t dirs_fixed;
uint64_t dirents_fixed;
-char *prog_name = "gfs2_convert"; /* needed by libgfs2 */
+const char *prog_name = "gfs2_convert"; /* needed by libgfs2 */
struct gfs1_jindex *sd_jindex = NULL; /* gfs1 journal index in memory */
int gfs2_inptrs;
uint64_t gfs2_heightsize[GFS2_MAX_META_HEIGHT];
@@ -166,7 +166,7 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)
/* Fixes all unallocated metadata bitmap states (which are */
/* valid in gfs1 but invalid in gfs2). */
/* ------------------------------------------------------------------------- */
-void convert_bitmaps(struct gfs2_sbd *sdp, struct rgrp_list *rgd2,
+static void convert_bitmaps(struct gfs2_sbd *sdp, struct rgrp_list *rgd2,
int read_disk)
{
uint32_t blk;
@@ -247,7 +247,7 @@ static int convert_rgs(struct gfs2_sbd *sbp)
/* This is similar to calc_tree_height in libgfs2 but at the point this */
/* function is called, I have the wrong (gfs1 not gfs2) constants in place. */
/* ------------------------------------------------------------------------- */
-unsigned int calc_gfs2_tree_height(struct gfs2_inode *ip, uint64_t size)
+static unsigned int calc_gfs2_tree_height(struct gfs2_inode *ip, uint64_t size)
{
uint64_t *arr;
unsigned int max, height;
@@ -273,7 +273,7 @@ unsigned int calc_gfs2_tree_height(struct gfs2_inode *ip, uint64_t size)
/* ------------------------------------------------------------------------- */
/* mp_gfs1_to_gfs2 - convert a gfs1 metapath to a gfs2 metapath. */
/* ------------------------------------------------------------------------- */
-void mp_gfs1_to_gfs2(struct gfs2_sbd *sbp, int gfs1_h, int gfs2_h,
+static void mp_gfs1_to_gfs2(struct gfs2_sbd *sbp, int gfs1_h, int gfs2_h,
struct metapath *gfs1mp, struct metapath *gfs2mp)
{
uint64_t lblock;
@@ -313,7 +313,7 @@ void mp_gfs1_to_gfs2(struct gfs2_sbd *sbp, int gfs1_h, int gfs2_h,
/* interested in rearranging the metadata while leaving the */
/* actual data blocks intact. */
/* ------------------------------------------------------------------------- */
-void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
+static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
struct blocklist *blk, uint64_t *first_nonzero_ptr,
unsigned int size)
{
@@ -427,7 +427,7 @@ void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
/* */
/* Adapted from gfs2_fsck metawalk.c's build_and_check_metalist */
/* ------------------------------------------------------------------------- */
-int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_buffer_head *dibh,
+static int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_buffer_head *dibh,
struct gfs2_inode *ip)
{
uint32_t gfs2_hgt;
@@ -879,7 +879,7 @@ out:
/* */
/* Returns: 0 on success, -1 on failure */
/* ------------------------------------------------------------------------- */
-int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
+static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
{
struct gfs2_inode *inode;
struct inode_block *fixdir;
@@ -974,7 +974,7 @@ int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
/* */
/* Returns: 0 on success, -1 on failure */
/* ------------------------------------------------------------------------- */
-int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr)
+static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr)
{
struct rgrp_list *rgd;
osi_list_t *tmp;
@@ -1065,7 +1065,7 @@ int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr)
/* ------------------------------------------------------------------------- */
/* fetch_inum - fetch an inum entry from disk, given its block */
/* ------------------------------------------------------------------------- */
-int fetch_inum(struct gfs2_sbd *sbp, uint64_t iblock,
+static int fetch_inum(struct gfs2_sbd *sbp, uint64_t iblock,
struct gfs2_inum *inum)
{
struct gfs2_buffer_head *bh_fix;
@@ -1087,7 +1087,7 @@ int fetch_inum(struct gfs2_sbd *sbp, uint64_t iblock,
/* */
/* Returns: 0 on success, -1 on failure */
/* ------------------------------------------------------------------------- */
-int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
+static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
struct gfs2_buffer_head *bh, int dir_entries)
{
int error;
@@ -1176,7 +1176,7 @@ int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
/* */
/* Returns: 0 on success, -1 on failure */
/* ------------------------------------------------------------------------- */
-int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip)
+static int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip)
{
struct gfs2_buffer_head *bh_leaf;
int error;
@@ -1222,7 +1222,7 @@ int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip)
/* fix_directory_info - sync new inode numbers with directory info */
/* Returns: 0 on success, -1 on failure */
/* ------------------------------------------------------------------------- */
-int fix_directory_info(struct gfs2_sbd *sbp, osi_list_t *dirs_to_fix)
+static int fix_directory_info(struct gfs2_sbd *sbp, osi_list_t *dir_to_fix)
{
osi_list_t *tmp, *fix;
struct inode_block *dir_iblk;
@@ -1239,7 +1239,7 @@ int fix_directory_info(struct gfs2_sbd *sbp, osi_list_t *dirs_to_fix)
offset = 0;
tmp = NULL;
/* for every directory in the list */
- for (fix = dirs_to_fix->next; fix != dirs_to_fix; fix = fix->next) {
+ for (fix = dir_to_fix->next; fix != dir_to_fix; fix = fix->next) {
if (tmp) {
osi_list_del(tmp);
free(tmp);
@@ -1280,7 +1280,7 @@ int fix_directory_info(struct gfs2_sbd *sbp, osi_list_t *dirs_to_fix)
/* ------------------------------------------------------------------------- */
/* Fetch gfs1 jindex structure from buffer */
/* ------------------------------------------------------------------------- */
-void gfs1_jindex_in(struct gfs1_jindex *jindex, char *buf)
+static void gfs1_jindex_in(struct gfs1_jindex *jindex, char *buf)
{
struct gfs1_jindex *str = (struct gfs1_jindex *)buf;
@@ -1293,7 +1293,7 @@ void gfs1_jindex_in(struct gfs1_jindex *jindex, char *buf)
/* read_gfs1_jiindex - read the gfs1 jindex file. */
/* Returns: 0 on success, -1 on failure */
/* ------------------------------------------------------------------------- */
-int read_gfs1_jiindex(struct gfs2_sbd *sdp)
+static int read_gfs1_jiindex(struct gfs2_sbd *sdp)
{
struct gfs2_inode *ip = sdp->md.jiinode;
char buf[sizeof(struct gfs1_jindex)];
@@ -1461,7 +1461,7 @@ static int init(struct gfs2_sbd *sbp)
/* ------------------------------------------------------------------------- */
/* give_warning - give the all-important warning message. */
/* ------------------------------------------------------------------------- */
-void give_warning(void)
+static void give_warning(void)
{
printf("This program will convert a gfs1 filesystem to a " \
"gfs2 filesystem.\n");
@@ -1476,7 +1476,7 @@ void give_warning(void)
/* ------------------------------------------------------------------------- */
/* version - print version information */
/* ------------------------------------------------------------------------- */
-void version(void)
+static void version(void)
{
log_notice("gfs2_convert version %s (built %s %s)\n", GFS2_RELEASE_NAME,
__DATE__, __TIME__);
@@ -1486,7 +1486,7 @@ void version(void)
/* ------------------------------------------------------------------------- */
/* usage - print usage information */
/* ------------------------------------------------------------------------- */
-void usage(const char *name)
+static void usage(const char *name)
{
give_warning();
printf("\nUsage:\n");
@@ -1503,7 +1503,7 @@ void usage(const char *name)
/* ------------------------------------------------------------------------- */
/* process_parameters */
/* ------------------------------------------------------------------------- */
-void process_parameters(int argc, char **argv, struct gfs2_options *opts)
+static void process_parameters(int argc, char **argv, struct gfs2_options *opts)
{
int c;
@@ -1559,7 +1559,7 @@ void process_parameters(int argc, char **argv, struct gfs2_options *opts)
/* rgrp_length - Calculate the length of a resource group */
/* @size: The total size of the resource group */
/* ------------------------------------------------------------------------- */
-uint64_t rgrp_length(uint64_t size, struct gfs2_sbd *sdp)
+static uint64_t rgrp_length(uint64_t size, struct gfs2_sbd *sdp)
{
uint64_t bitbytes = RGRP_BITMAP_BLKS(&sdp->sd_sb) + 1;
uint64_t stuff = RGRP_STUFFED_BLKS(&sdp->sd_sb) + 1;
@@ -1588,7 +1588,7 @@ uint64_t rgrp_length(uint64_t size, struct gfs2_sbd *sdp)
/* */
/* Returns: 0 on success, -1 on failure */
/* ------------------------------------------------------------------------- */
-int journ_space_to_rg(struct gfs2_sbd *sdp)
+static int journ_space_to_rg(struct gfs2_sbd *sdp)
{
int error = 0;
int j, x;
@@ -1670,7 +1670,7 @@ int journ_space_to_rg(struct gfs2_sbd *sdp)
/* ------------------------------------------------------------------------- */
/* update_inode_file - update the inode file with the new next_inum */
/* ------------------------------------------------------------------------- */
-void update_inode_file(struct gfs2_sbd *sdp)
+static void update_inode_file(struct gfs2_sbd *sdp)
{
struct gfs2_inode *ip = sdp->md.inum;
uint64_t buf;
@@ -1687,7 +1687,7 @@ void update_inode_file(struct gfs2_sbd *sdp)
/* ------------------------------------------------------------------------- */
/* write_statfs_file - write the statfs file */
/* ------------------------------------------------------------------------- */
-void write_statfs_file(struct gfs2_sbd *sdp)
+static void write_statfs_file(struct gfs2_sbd *sdp)
{
struct gfs2_inode *ip = sdp->md.statfs;
struct gfs2_statfs_change sc;
@@ -1707,7 +1707,7 @@ void write_statfs_file(struct gfs2_sbd *sdp)
/* ------------------------------------------------------------------------- */
/* remove_obsolete_gfs1 - remove obsolete gfs1 inodes. */
/* ------------------------------------------------------------------------- */
-void remove_obsolete_gfs1(struct gfs2_sbd *sbp)
+static void remove_obsolete_gfs1(struct gfs2_sbd *sbp)
{
struct gfs2_inum inum;
@@ -1733,7 +1733,7 @@ void remove_obsolete_gfs1(struct gfs2_sbd *sbp)
/* ------------------------------------------------------------------------- */
/* lifted from libgfs2/structures.c */
/* ------------------------------------------------------------------------- */
-void conv_build_jindex(struct gfs2_sbd *sdp)
+static void conv_build_jindex(struct gfs2_sbd *sdp)
{
struct gfs2_inode *jindex;
unsigned int j;
@@ -1781,10 +1781,10 @@ int main(int argc, char **argv)
/* Make them seal their fate. */
/* ---------------------------------------------- */
if (!error) {
- int abort;
+ int do_abort;
give_warning();
- if (!gfs2_query(&abort, &opts,
+ if (!gfs2_query(&do_abort, &opts,
"Convert %s from GFS1 to GFS2? (y/n)",
device)) {
log_crit("%s not converted.\n", device);
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 7f6790d..055e227 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -113,7 +113,7 @@ void print_gfs2(const char *fmt, ...)
va_end(args);
}
-void check_highlight(int highlight)
+static void check_highlight(int highlight)
{
if (!termlines || line >= termlines) /* If printing or out of bounds */
return;
@@ -217,7 +217,7 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)
}
}
-int indirect_dirent(struct indirect_info *indir, char *ptr, int d)
+static int indirect_dirent(struct indirect_info *indir, char *ptr, int d)
{
struct gfs2_dirent de;
@@ -253,20 +253,20 @@ int indirect_dirent(struct indirect_info *indir, char *ptr, int d)
**
*******************************************************************************
******************************************************************************/
-void do_dinode_extended(struct gfs2_dinode *di, char *buf)
+void do_dinode_extended(struct gfs2_dinode *dine, char *dinebuf)
{
unsigned int x, y, ptroff = 0;
uint64_t p, last;
- int isdir = !!(S_ISDIR(di->di_mode)) ||
- (gfs1 && di->__pad1 == GFS_FILE_DIR);
+ int isdir = !!(S_ISDIR(dine->di_mode)) ||
+ (gfs1 && dine->__pad1 == GFS_FILE_DIR);
indirect_blocks = 0;
memset(indirect, 0, sizeof(indirect));
- if (di->di_height > 0) {
+ if (dine->di_height > 0) {
/* Indirect pointers */
for (x = sizeof(struct gfs2_dinode); x < sbd.bsize;
x += sizeof(uint64_t)) {
- p = be64_to_cpu(*(uint64_t *)(buf + x));
+ p = be64_to_cpu(*(uint64_t *)(dinebuf + x));
if (p) {
indirect->ii[indirect_blocks].block = p;
indirect->ii[indirect_blocks].mp.mp_list[0] =
@@ -277,7 +277,7 @@ void do_dinode_extended(struct gfs2_dinode *di, char *buf)
ptroff++;
}
}
- else if (isdir && !(di->di_flags & GFS2_DIF_EXHASH)) {
+ else if (isdir && !(dine->di_flags & GFS2_DIF_EXHASH)) {
int skip = 0;
/* Directory Entries: */
@@ -286,25 +286,25 @@ void do_dinode_extended(struct gfs2_dinode *di, char *buf)
indirect->ii[0].is_dir = TRUE;
for (x = sizeof(struct gfs2_dinode); x < sbd.bsize; x += skip) {
skip = indirect_dirent(indirect->ii,
- buf + x,
+ dinebuf + x,
indirect->ii[0].dirents);
if (skip <= 0)
break;
}
}
else if (isdir &&
- (di->di_flags & GFS2_DIF_EXHASH) &&
- di->di_height == 0) {
+ (dine->di_flags & GFS2_DIF_EXHASH) &&
+ dine->di_height == 0) {
/* Leaf Pointers: */
- last = be64_to_cpu(*(uint64_t *)(buf + sizeof(struct gfs2_dinode)));
+ last = be64_to_cpu(*(uint64_t *)(dinebuf + sizeof(struct gfs2_dinode)));
for (x = sizeof(struct gfs2_dinode), y = 0;
- y < (1 << di->di_depth);
+ y < (1 << dine->di_depth);
x += sizeof(uint64_t), y++) {
- p = be64_to_cpu(*(uint64_t *)(buf + x));
+ p = be64_to_cpu(*(uint64_t *)(dinebuf + x));
- if (p != last || ((y + 1) * sizeof(uint64_t) == di->di_size)) {
+ if (p != last || ((y + 1) * sizeof(uint64_t) == dine->di_size)) {
struct gfs2_buffer_head *tmp_bh;
int skip = 0, direntcount = 0;
struct gfs2_leaf leaf;
@@ -392,7 +392,7 @@ int do_indirect_extended(char *buf, struct iinfo *iinf, int hgt)
**
*******************************************************************************
******************************************************************************/
-void do_leaf_extended(char *buf, struct iinfo *indir)
+void do_leaf_extended(char *dlebuf, struct iinfo *indir)
{
int x, i;
struct gfs2_dirent de;
@@ -402,14 +402,14 @@ void do_leaf_extended(char *buf, struct iinfo *indir)
/* Directory Entries: */
for (i = sizeof(struct gfs2_leaf); i < sbd.bsize;
i += de.de_rec_len) {
- gfs2_dirent_in(&de, buf + i);
+ gfs2_dirent_in(&de, dlebuf + i);
if (de.de_inum.no_addr) {
indir->ii[0].block = de.de_inum.no_addr;
indir->ii[0].dirent[x].block = de.de_inum.no_addr;
memcpy(&indir->ii[0].dirent[x].dirent,
&de, sizeof(struct gfs2_dirent));
memcpy(&indir->ii[0].dirent[x].filename,
- buf + i + sizeof(struct gfs2_dirent),
+ dlebuf + i + sizeof(struct gfs2_dirent),
de.de_name_len);
indir->ii[0].dirent[x].filename[de.de_name_len] = '\0';
indir->ii[0].is_dir = TRUE;
@@ -438,7 +438,7 @@ void do_leaf_extended(char *buf, struct iinfo *indir)
*******************************************************************************
******************************************************************************/
-void do_eattr_extended(char *buf)
+static void do_eattr_extended(char *deebuf)
{
struct gfs2_ea_header ea;
unsigned int x;
@@ -450,12 +450,12 @@ void do_eattr_extended(char *buf)
for (x = sizeof(struct gfs2_meta_header); x < sbd.bsize; x += ea.ea_rec_len)
{
eol(0);
- gfs2_ea_header_in(&ea, buf + x);
- gfs2_ea_header_print(&ea, buf + x + sizeof(struct gfs2_ea_header));
+ gfs2_ea_header_in(&ea, deebuf + x);
+ gfs2_ea_header_print(&ea, deebuf + x + sizeof(struct gfs2_ea_header));
}
}
-void gfs2_inum_print2(const char *title,struct gfs2_inum *no)
+static void gfs2_inum_print2(const char *title,struct gfs2_inum *no)
{
if (termlines) {
check_highlight(TRUE);
@@ -475,40 +475,41 @@ void gfs2_inum_print2(const char *title,struct gfs2_inum *no)
* gfs2_sb_print2 - Print out a superblock
* @sb: the cpu-order buffer
*/
-void gfs2_sb_print2(struct gfs2_sb *sb)
+static void gfs2_sb_print2(struct gfs2_sb *sbp2)
{
- gfs2_meta_header_print(&sb->sb_header);
+ gfs2_meta_header_print(&sbp2->sb_header);
+
+ pv(sbp2, sb_fs_format, "%u", "0x%x");
+ pv(sbp2, sb_multihost_format, "%u", "0x%x");
- pv(sb, sb_fs_format, "%u", "0x%x");
- pv(sb, sb_multihost_format, "%u", "0x%x");
if (gfs1)
pv(sbd1, sb_flags, "%u", "0x%x");
- pv(sb, sb_bsize, "%u", "0x%x");
- pv(sb, sb_bsize_shift, "%u", "0x%x");
+ pv(sbp2, sb_bsize, "%u", "0x%x");
+ pv(sbp2, sb_bsize_shift, "%u", "0x%x");
if (gfs1) {
pv(sbd1, sb_seg_size, "%u", "0x%x");
gfs2_inum_print2("jindex ino", &sbd1->sb_jindex_di);
gfs2_inum_print2("rindex ino", &sbd1->sb_rindex_di);
}
else
- gfs2_inum_print2("master dir", &sb->sb_master_dir);
- gfs2_inum_print2("root dir ", &sb->sb_root_dir);
+ gfs2_inum_print2("master dir", &sbp2->sb_master_dir);
+ gfs2_inum_print2("root dir ", &sbp2->sb_root_dir);
- pv(sb, sb_lockproto, "%s", NULL);
- pv(sb, sb_locktable, "%s", NULL);
+ pv(sbp2, sb_lockproto, "%s", NULL);
+ pv(sbp2, sb_locktable, "%s", NULL);
if (gfs1) {
gfs2_inum_print2("quota ino ", &gfs1_quota_di);
gfs2_inum_print2("license ", &gfs1_license_di);
}
#ifdef GFS2_HAS_UUID
- print_it(" sb_uuid", "%s", NULL, str_uuid(sb->sb_uuid));
+ print_it(" sb_uuid", "%s", NULL, str_uuid(sbp2->sb_uuid));
#endif
}
/**
* gfs1_rgrp_in - read in a gfs1 rgrp
*/
-void gfs1_rgrp_in(struct gfs1_rgrp *rgrp, char *rbuf)
+static void gfs1_rgrp_in(struct gfs1_rgrp *rgrp, char *rbuf)
{
struct gfs1_rgrp *str = (struct gfs1_rgrp *)rbuf;
@@ -526,7 +527,7 @@ void gfs1_rgrp_in(struct gfs1_rgrp *rgrp, char *rbuf)
/**
* gfs_rgrp_print - Print out a resource group header
*/
-void gfs1_rgrp_print(struct gfs1_rgrp *rg)
+static void gfs1_rgrp_print(struct gfs1_rgrp *rg)
{
gfs2_meta_header_print(&rg->rg_header);
pv(rg, rg_flags, "%u", "0x%x");
diff --git a/gfs2/edit/gfs2hex.h b/gfs2/edit/gfs2hex.h
index 68b98ea..a35fce5 100644
--- a/gfs2/edit/gfs2hex.h
+++ b/gfs2/edit/gfs2hex.h
@@ -20,7 +20,7 @@ int display_gfs2(void);
int edit_gfs2(void);
void do_dinode_extended(struct gfs2_dinode *di, char *buf);
void print_gfs2(const char *fmt, ...);
-int do_indirect_extended(char *buf, struct iinfo *iinf, int hgt);
+int do_indirect_extended(char *diebuf, struct iinfo *iinf, int hgt);
void do_leaf_extended(char *dlebuf, struct iinfo *indir);
void eol(int col);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 49577f9..99b42bf 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -48,6 +48,8 @@ const char *allocdesc[2][5] = {
{"Free ", "Data ", "Unlnk", "Meta ", "Resrv"},
{"Free ", "Data ", "FreeM", "Meta ", "Resrv"},};
+const char *prog_name;
+
int display(int identify_only);
extern void savemeta(const char *out_fn, int slow);
extern void restoremeta(const char *in_fn, const char *out_device,
@@ -90,58 +92,58 @@ extern void restoremeta(const char *in_fn, const char *out_device,
} \
} while(0)
-int gfs2_dinode_printval(struct gfs2_dinode *di, const char *strfield)
-{
- checkprint(strfield, di, di_mode);
- checkprint(strfield, di, di_uid);
- checkprint(strfield, di, di_gid);
- checkprint(strfield, di, di_nlink);
- checkprint(strfield, di, di_size);
- checkprint(strfield, di, di_blocks);
- checkprint(strfield, di, di_atime);
- checkprint(strfield, di, di_mtime);
- checkprint(strfield, di, di_ctime);
- checkprint(strfield, di, di_major);
- checkprint(strfield, di, di_minor);
- checkprint(strfield, di, di_goal_meta);
- checkprint(strfield, di, di_goal_data);
- checkprint(strfield, di, di_flags);
- checkprint(strfield, di, di_payload_format);
- checkprint(strfield, di, di_height);
- checkprint(strfield, di, di_depth);
- checkprint(strfield, di, di_entries);
- checkprint(strfield, di, di_eattr);
+static int gfs2_dinode_printval(struct gfs2_dinode *dip, const char *strfield)
+{
+ checkprint(strfield, dip, di_mode);
+ checkprint(strfield, dip, di_uid);
+ checkprint(strfield, dip, di_gid);
+ checkprint(strfield, dip, di_nlink);
+ checkprint(strfield, dip, di_size);
+ checkprint(strfield, dip, di_blocks);
+ checkprint(strfield, dip, di_atime);
+ checkprint(strfield, dip, di_mtime);
+ checkprint(strfield, dip, di_ctime);
+ checkprint(strfield, dip, di_major);
+ checkprint(strfield, dip, di_minor);
+ checkprint(strfield, dip, di_goal_meta);
+ checkprint(strfield, dip, di_goal_data);
+ checkprint(strfield, dip, di_flags);
+ checkprint(strfield, dip, di_payload_format);
+ checkprint(strfield, dip, di_height);
+ checkprint(strfield, dip, di_depth);
+ checkprint(strfield, dip, di_entries);
+ checkprint(strfield, dip, di_eattr);
return -1;
}
-int gfs2_dinode_assignval(struct gfs2_dinode *di, const char *strfield,
+static int gfs2_dinode_assignval(struct gfs2_dinode *dia, const char *strfield,
uint64_t value)
{
- checkassign(strfield, di, di_mode, value);
- checkassign(strfield, di, di_uid, value);
- checkassign(strfield, di, di_gid, value);
- checkassign(strfield, di, di_nlink, value);
- checkassign(strfield, di, di_size, value);
- checkassign(strfield, di, di_blocks, value);
- checkassign(strfield, di, di_atime, value);
- checkassign(strfield, di, di_mtime, value);
- checkassign(strfield, di, di_ctime, value);
- checkassign(strfield, di, di_major, value);
- checkassign(strfield, di, di_minor, value);
- checkassign(strfield, di, di_goal_meta, value);
- checkassign(strfield, di, di_goal_data, value);
- checkassign(strfield, di, di_flags, value);
- checkassign(strfield, di, di_payload_format, value);
- checkassign(strfield, di, di_height, value);
- checkassign(strfield, di, di_depth, value);
- checkassign(strfield, di, di_entries, value);
- checkassign(strfield, di, di_eattr, value);
+ checkassign(strfield, dia, di_mode, value);
+ checkassign(strfield, dia, di_uid, value);
+ checkassign(strfield, dia, di_gid, value);
+ checkassign(strfield, dia, di_nlink, value);
+ checkassign(strfield, dia, di_size, value);
+ checkassign(strfield, dia, di_blocks, value);
+ checkassign(strfield, dia, di_atime, value);
+ checkassign(strfield, dia, di_mtime, value);
+ checkassign(strfield, dia, di_ctime, value);
+ checkassign(strfield, dia, di_major, value);
+ checkassign(strfield, dia, di_minor, value);
+ checkassign(strfield, dia, di_goal_meta, value);
+ checkassign(strfield, dia, di_goal_data, value);
+ checkassign(strfield, dia, di_flags, value);
+ checkassign(strfield, dia, di_payload_format, value);
+ checkassign(strfield, dia, di_height, value);
+ checkassign(strfield, dia, di_depth, value);
+ checkassign(strfield, dia, di_entries, value);
+ checkassign(strfield, dia, di_eattr, value);
return -1;
}
-int gfs2_rgrp_printval(struct gfs2_rgrp *rg, const char *strfield)
+static int gfs2_rgrp_printval(struct gfs2_rgrp *rg, const char *strfield)
{
checkprint(strfield, rg, rg_flags);
checkprint(strfield, rg, rg_free);
@@ -150,7 +152,7 @@ int gfs2_rgrp_printval(struct gfs2_rgrp *rg, const char *strfield)
return -1;
}
-int gfs2_rgrp_assignval(struct gfs2_rgrp *rg, const char *strfield,
+static int gfs2_rgrp_assignval(struct gfs2_rgrp *rg, const char *strfield,
uint64_t value)
{
checkassign(strfield, rg, rg_flags, value);
@@ -163,7 +165,7 @@ int gfs2_rgrp_assignval(struct gfs2_rgrp *rg, const char *strfield,
/* ------------------------------------------------------------------------ */
/* UpdateSize - screen size changed, so update it */
/* ------------------------------------------------------------------------ */
-void UpdateSize(int sig)
+static void UpdateSize(int sig)
{
static char term_buffer[2048];
int rc;
@@ -174,10 +176,10 @@ void UpdateSize(int sig)
return;
rc=tgetent(term_buffer,termtype);
if (rc>=0) {
- termlines = tgetnum("li");
+ termlines = tgetnum((char *)"li");
if (termlines < 10)
termlines = 30;
- termcols = tgetnum("co");
+ termcols = tgetnum((char *)"co");
if (termcols < 80)
termcols = 80;
}
@@ -191,7 +193,7 @@ void UpdateSize(int sig)
/* ------------------------------------------------------------------------- */
/* erase - clear the screen */
/* ------------------------------------------------------------------------- */
-void Erase(void)
+static void Erase(void)
{
int i;
char spaces[256];
@@ -210,7 +212,7 @@ void Erase(void)
/* ------------------------------------------------------------------------- */
/* display_title_lines */
/* ------------------------------------------------------------------------- */
-void display_title_lines(void)
+static void display_title_lines(void)
{
Erase();
COLORS_TITLE;
@@ -226,7 +228,7 @@ void display_title_lines(void)
/* returns: 1 if user exited by hitting enter */
/* 0 if user exited by hitting escape */
/* ------------------------------------------------------------------------- */
-int bobgets(char string[],int x,int y,int sz,int *ch)
+static int bobgets(char string[],int x,int y,int sz,int *ch)
{
int done,runningy,rc;
@@ -367,7 +369,7 @@ int bobgets(char string[],int x,int y,int sz,int *ch)
/******************************************************************************
** instr - instructions
******************************************************************************/
-void gfs2instr(const char *s1, const char *s2)
+static void gfs2instr(const char *s1, const char *s2)
{
COLORS_HIGHLIGHT;
move(line,0);
@@ -389,7 +391,7 @@ void gfs2instr(const char *s1, const char *s2)
*******************************************************************************
******************************************************************************/
-void print_usage(void)
+static void print_usage(void)
{
int ch;
@@ -442,7 +444,7 @@ void print_usage(void)
/* returns: metatype if block is a GFS2 structure block type */
/* 0 if block is not a GFS2 structure */
/* ------------------------------------------------------------------------ */
-int get_block_type(const char *lpBuffer)
+static int get_block_type(const char *lpBuffer)
{
int ret_type = 0;
@@ -653,7 +655,7 @@ int display_block_type(const char *lpBuffer, int from_restore)
/* ------------------------------------------------------------------------ */
/* hexdump - hex dump the filesystem block to the screen */
/* ------------------------------------------------------------------------ */
-int hexdump(uint64_t startaddr, const char *lpBuffer, int len)
+static int hexdump(uint64_t startaddr, const char *lpBuffer, int len)
{
const unsigned char *pointer,*ptr2;
int i;
@@ -794,7 +796,7 @@ static int risize(void)
/* ------------------------------------------------------------------------ */
/* rgcount - return how many rgrps there are. */
/* ------------------------------------------------------------------------ */
-void rgcount(void)
+static void rgcount(void)
{
printf("%lld RGs in this file system.\n",
(unsigned long long)sbd.md.riinode->i_di.di_size / risize());
@@ -806,36 +808,36 @@ void rgcount(void)
/* ------------------------------------------------------------------------ */
/* find_rgrp_block - locate the block for a given rgrp number */
/* ------------------------------------------------------------------------ */
-uint64_t find_rgrp_block(struct gfs2_inode *di, int rg)
+static uint64_t find_rgrp_block(struct gfs2_inode *dif, int rg)
{
int amt;
- struct gfs2_rindex buf, ri;
- uint64_t offset, gfs1_adj = 0;
+ struct gfs2_rindex fbuf, ri;
+ uint64_t foffset, gfs1_adj = 0;
- offset = rg * risize();
+ foffset = rg * risize();
if (gfs1) {
uint64_t sd_jbsize =
(sbd.bsize - sizeof(struct gfs2_meta_header));
- gfs1_adj = (offset / sd_jbsize) *
+ gfs1_adj = (foffset / sd_jbsize) *
sizeof(struct gfs2_meta_header);
gfs1_adj += sizeof(struct gfs2_meta_header);
}
- amt = gfs2_readi(di, (void *)&buf, offset + gfs1_adj, risize());
+ amt = gfs2_readi(dif, (void *)&fbuf, foffset + gfs1_adj, risize());
if (!amt) /* end of file */
return 0;
- gfs2_rindex_in(&ri, (void *)&buf);
+ gfs2_rindex_in(&ri, (void *)&fbuf);
return ri.ri_addr;
}
/* ------------------------------------------------------------------------ */
/* gfs_rgrp_in - Read in a resource group header */
/* ------------------------------------------------------------------------ */
-void gfs_rgrp_in(struct gfs_rgrp *rgrp, char *buf)
+static void gfs_rgrp_in(struct gfs_rgrp *rgrp, char *gbuf)
{
- struct gfs_rgrp *str = (struct gfs_rgrp *)buf;
+ struct gfs_rgrp *str = (struct gfs_rgrp *)gbuf;
- gfs2_meta_header_in(&rgrp->rg_header, buf);
+ gfs2_meta_header_in(&rgrp->rg_header, gbuf);
rgrp->rg_flags = be32_to_cpu(str->rg_flags);
rgrp->rg_free = be32_to_cpu(str->rg_free);
rgrp->rg_useddi = be32_to_cpu(str->rg_useddi);
@@ -848,11 +850,11 @@ void gfs_rgrp_in(struct gfs_rgrp *rgrp, char *buf)
/* ------------------------------------------------------------------------ */
/* gfs_rgrp_out */
/* ------------------------------------------------------------------------ */
-void gfs_rgrp_out(struct gfs_rgrp *rgrp, char *buf)
+static void gfs_rgrp_out(struct gfs_rgrp *rgrp, char *gbuf)
{
- struct gfs_rgrp *str = (struct gfs_rgrp *)buf;
+ struct gfs_rgrp *str = (struct gfs_rgrp *)gbuf;
- gfs2_meta_header_out(&rgrp->rg_header, buf);
+ gfs2_meta_header_out(&rgrp->rg_header, gbuf);
str->rg_flags = cpu_to_be32(rgrp->rg_flags);
str->rg_free = cpu_to_be32(rgrp->rg_free);
str->rg_useddi = cpu_to_be32(rgrp->rg_useddi);
@@ -865,7 +867,7 @@ void gfs_rgrp_out(struct gfs_rgrp *rgrp, char *buf)
/* ------------------------------------------------------------------------ */
/* gfs_rgrp_print - print a gfs1 resource group */
/* ------------------------------------------------------------------------ */
-void gfs_rgrp_print(struct gfs_rgrp *rg)
+static void gfs_rgrp_print(struct gfs_rgrp *rg)
{
gfs2_meta_header_print(&rg->rg_header);
pv(rg, rg_flags, "%u", "0x%x");
@@ -880,17 +882,17 @@ void gfs_rgrp_print(struct gfs_rgrp *rg)
/* ------------------------------------------------------------------------ */
/* get_rg_addr */
/* ------------------------------------------------------------------------ */
-uint64_t get_rg_addr(int rgnum)
+static uint64_t get_rg_addr(int rgnum)
{
struct gfs2_buffer_head *bh;
- uint64_t rgblk = 0, block;
+ uint64_t rgblk = 0, gblock;
struct gfs2_inode *riinode;
if (gfs1)
- block = sbd1->sb_rindex_di.no_addr;
+ gblock = sbd1->sb_rindex_di.no_addr;
else
- block = masterblock("rindex");
- bh = bread(&sbd.buf_list, block);
+ gblock = masterblock("rindex");
+ bh = bread(&sbd.buf_list, gblock);
riinode = inode_get(&sbd, bh);
if (rgnum < riinode->i_di.di_size / risize())
rgblk = find_rgrp_block(riinode, rgnum);
@@ -908,7 +910,7 @@ uint64_t get_rg_addr(int rgnum)
/* modify: TRUE if the value is to be modified, FALSE if it's to be printed */
/* full: TRUE if the full RG should be printed. */
/* ------------------------------------------------------------------------ */
-void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full)
+static void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full)
{
union {
struct gfs2_rgrp rg2;
@@ -956,32 +958,32 @@ void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full)
/* ------------------------------------------------------------------------ */
/* parse_rindex - print the rgindex file. */
/* ------------------------------------------------------------------------ */
-int parse_rindex(struct gfs2_inode *di, int print_rindex)
+static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
{
int error, start_line;
struct gfs2_rindex ri;
- char buf[sizeof(struct gfs_rindex)];
+ char rbuf[sizeof(struct gfs_rindex)];
char highlighted_addr[32];
start_line = line;
error = 0;
- print_gfs2("RG index entries found: %d.", di->i_di.di_size / risize());
+ print_gfs2("RG index entries found: %d.", dip->i_di.di_size / risize());
eol(0);
lines_per_row[dmode] = 6;
memset(highlighted_addr, 0, sizeof(highlighted_addr));
for (print_entry_ndx=0; ; print_entry_ndx++) {
- uint64_t offset;
+ uint64_t roff;
- offset = print_entry_ndx * risize();
+ roff = print_entry_ndx * risize();
if (gfs1)
- error = gfs1_readi(di, (void *)&buf, offset, risize());
+ error = gfs1_readi(dip, (void *)&rbuf, roff, risize());
else
- error = gfs2_readi(di, (void *)&buf, offset, risize());
+ error = gfs2_readi(dip, (void *)&rbuf, roff, risize());
if (!error) /* end of file */
break;
- gfs2_rindex_in(&ri, buf);
+ gfs2_rindex_in(&ri, rbuf);
if (!termlines ||
(print_entry_ndx >= start_row[dmode] &&
((print_entry_ndx - start_row[dmode])+1) * lines_per_row[dmode] <=
@@ -1025,9 +1027,9 @@ int parse_rindex(struct gfs2_inode *di, int print_rindex)
/* ------------------------------------------------------------------------ */
/* gfs_jindex_in - read in a gfs1 jindex structure. */
/* ------------------------------------------------------------------------ */
-void gfs_jindex_in(struct gfs_jindex *jindex, char *buf)
+void gfs_jindex_in(struct gfs_jindex *jindex, char *jbuf)
{
- struct gfs_jindex *str = (struct gfs_jindex *) buf;
+ struct gfs_jindex *str = (struct gfs_jindex *) jbuf;
jindex->ji_addr = be64_to_cpu(str->ji_addr);
jindex->ji_nsegment = be32_to_cpu(str->ji_nsegment);
@@ -1038,7 +1040,7 @@ void gfs_jindex_in(struct gfs_jindex *jindex, char *buf)
/* ------------------------------------------------------------------------ */
/* gfs_jindex_print - print an jindex entry. */
/* ------------------------------------------------------------------------ */
-void gfs_jindex_print(struct gfs_jindex *ji)
+static void gfs_jindex_print(struct gfs_jindex *ji)
{
pv((unsigned long long)ji, ji_addr, "%llu", "0x%llx");
pv(ji, ji_nsegment, "%u", "0x%x");
@@ -1048,23 +1050,23 @@ void gfs_jindex_print(struct gfs_jindex *ji)
/* ------------------------------------------------------------------------ */
/* print_jindex - print the jindex file. */
/* ------------------------------------------------------------------------ */
-int print_jindex(struct gfs2_inode *di)
+static int print_jindex(struct gfs2_inode *dij)
{
int error, start_line;
struct gfs_jindex ji;
- char buf[sizeof(struct gfs_jindex)];
+ char jbuf[sizeof(struct gfs_jindex)];
start_line = line;
error = 0;
print_gfs2("Journal index entries found: %d.",
- di->i_di.di_size / sizeof(struct gfs_jindex));
+ dij->i_di.di_size / sizeof(struct gfs_jindex));
eol(0);
lines_per_row[dmode] = 4;
for (print_entry_ndx=0; ; print_entry_ndx++) {
- error = gfs2_readi(di, (void *)&buf,
+ error = gfs2_readi(dij, (void *)&jbuf,
print_entry_ndx*sizeof(struct gfs_jindex),
sizeof(struct gfs_jindex));
- gfs_jindex_in(&ji, buf);
+ gfs_jindex_in(&ji, jbuf);
if (!error) /* end of file */
break;
if (!termlines ||
@@ -1091,23 +1093,23 @@ int print_jindex(struct gfs2_inode *di)
/* ------------------------------------------------------------------------ */
/* print_inum - print the inum file. */
/* ------------------------------------------------------------------------ */
-int print_inum(struct gfs2_inode *di)
+static int print_inum(struct gfs2_inode *dii)
{
- uint64_t buf, inodenum;
+ uint64_t inum, inodenum;
int rc;
- rc = gfs2_readi(di, (void *)&buf, 0, sizeof(buf));
+ rc = gfs2_readi(dii, (void *)&inum, 0, sizeof(inum));
if (!rc) {
print_gfs2("The inum file is empty.");
eol(0);
return 0;
}
- if (rc != sizeof(buf)) {
+ if (rc != sizeof(inum)) {
print_gfs2("Error reading inum file.");
eol(0);
return -1;
}
- inodenum = be64_to_cpu(buf);
+ inodenum = be64_to_cpu(inum);
print_gfs2("Next inode num = %lld (0x%llx)", inodenum, inodenum);
eol(0);
return 0;
@@ -1116,23 +1118,23 @@ int print_inum(struct gfs2_inode *di)
/* ------------------------------------------------------------------------ */
/* print_statfs - print the statfs file. */
/* ------------------------------------------------------------------------ */
-int print_statfs(struct gfs2_inode *di)
+static int print_statfs(struct gfs2_inode *dis)
{
- struct gfs2_statfs_change buf, sfc;
+ struct gfs2_statfs_change sfb, sfc;
int rc;
- rc = gfs2_readi(di, (void *)&buf, 0, sizeof(buf));
+ rc = gfs2_readi(dis, (void *)&sfb, 0, sizeof(sfb));
if (!rc) {
print_gfs2("The statfs file is empty.");
eol(0);
return 0;
}
- if (rc != sizeof(buf)) {
+ if (rc != sizeof(sfb)) {
print_gfs2("Error reading statfs file.");
eol(0);
return -1;
}
- gfs2_statfs_change_in(&sfc, (char *)&buf);
+ gfs2_statfs_change_in(&sfc, (char *)&sfb);
print_gfs2("statfs file contents:");
eol(0);
gfs2_statfs_change_print(&sfc);
@@ -1142,25 +1144,25 @@ int print_statfs(struct gfs2_inode *di)
/* ------------------------------------------------------------------------ */
/* print_quota - print the quota file. */
/* ------------------------------------------------------------------------ */
-int print_quota(struct gfs2_inode *di)
+static int print_quota(struct gfs2_inode *diq)
{
- struct gfs2_quota buf, q;
+ struct gfs2_quota qbuf, q;
int i, error;
print_gfs2("quota file contents:");
eol(0);
- print_gfs2("quota entries found: %d.", di->i_di.di_size / sizeof(q));
+ print_gfs2("quota entries found: %d.", diq->i_di.di_size / sizeof(q));
eol(0);
for (i=0; ; i++) {
- error = gfs2_readi(di, (void *)&buf, i * sizeof(q), sizeof(buf));
+ error = gfs2_readi(diq, (void *)&qbuf, i * sizeof(q), sizeof(qbuf));
if (!error)
break;
- if (error != sizeof(buf)) {
+ if (error != sizeof(qbuf)) {
print_gfs2("Error reading quota file.");
eol(0);
return -1;
}
- gfs2_quota_in(&q, (char *)&buf);
+ gfs2_quota_in(&q, (char *)&qbuf);
print_gfs2("Entry #%d", i + 1);
eol(0);
gfs2_quota_print(&q);
@@ -1171,7 +1173,7 @@ int print_quota(struct gfs2_inode *di)
/* ------------------------------------------------------------------------ */
/* has_indirect_blocks */
/* ------------------------------------------------------------------------ */
-int has_indirect_blocks(void)
+static int has_indirect_blocks(void)
{
if (indirect_blocks || gfs2_struct_type == GFS2_METATYPE_SB ||
gfs2_struct_type == GFS2_METATYPE_LF ||
@@ -1184,7 +1186,7 @@ int has_indirect_blocks(void)
/* ------------------------------------------------------------------------ */
/* print_inode_type */
/* ------------------------------------------------------------------------ */
-void print_inode_type(__be16 de_type)
+static void print_inode_type(__be16 de_type)
{
if (gfs1) {
switch(de_type) {
@@ -1252,7 +1254,7 @@ void print_inode_type(__be16 de_type)
/* ------------------------------------------------------------------------ */
/* display_leaf - display directory leaf */
/* ------------------------------------------------------------------------ */
-int display_leaf(struct iinfo *ind)
+static int display_leaf(struct iinfo *ind)
{
int start_line, total_dirents = start_row[dmode];
int d;
@@ -1308,7 +1310,7 @@ int display_leaf(struct iinfo *ind)
/* ------------------------------------------------------------------------ */
/* metapath_to_lblock - convert from metapath, height to logical block */
/* ------------------------------------------------------------------------ */
-uint64_t metapath_to_lblock(struct metapath *mp, int hgt)
+static uint64_t metapath_to_lblock(struct metapath *mp, int hgt)
{
int h;
uint64_t lblock = 0;
@@ -1329,7 +1331,7 @@ uint64_t metapath_to_lblock(struct metapath *mp, int hgt)
/* ------------------------------------------------------------------------ */
/* dinode_valid - check if we have a dinode in recent history */
/* ------------------------------------------------------------------------ */
-int dinode_valid(void)
+static int dinode_valid(void)
{
int i;
@@ -1347,7 +1349,7 @@ int dinode_valid(void)
/* ------------------------------------------------------------------------ */
/* get_height */
/* ------------------------------------------------------------------------ */
-int get_height(void)
+static int get_height(void)
{
int cur_height = 0, i;
@@ -1366,7 +1368,7 @@ int get_height(void)
/* ------------------------------------------------------------------------ */
/* display_indirect */
/* ------------------------------------------------------------------------ */
-int display_indirect(struct iinfo *ind, int indblocks, int level, uint64_t startoff)
+static int display_indirect(struct iinfo *ind, int indblocks, int level, uint64_t startoff)
{
int start_line, total_dirents;
int cur_height = -1, pndx;
@@ -1541,7 +1543,7 @@ int block_is_rindex(void)
/* special case meant to parse the rindex and follow the */
/* blocks to the real rgs. */
/* ------------------------------------------------------------------------ */
-int block_is_rglist(void)
+static int block_is_rglist(void)
{
if (block == RGLIST_DUMMY_BLOCK)
return TRUE;
@@ -1630,7 +1632,7 @@ int block_is_in_per_node(void)
/* ------------------------------------------------------------------------ */
/* block_has_extended_info */
/* ------------------------------------------------------------------------ */
-int block_has_extended_info(void)
+static int block_has_extended_info(void)
{
if (has_indirect_blocks() ||
block_is_rindex() ||
@@ -1646,7 +1648,7 @@ int block_has_extended_info(void)
/* ------------------------------------------------------------------------ */
/* display_extended */
/* ------------------------------------------------------------------------ */
-int display_extended(void)
+static int display_extended(void)
{
struct gfs2_inode *tmp_inode;
struct gfs2_buffer_head *tmp_bh;
@@ -1703,7 +1705,7 @@ int display_extended(void)
/* ------------------------------------------------------------------------ */
/* read_superblock - read the superblock */
/* ------------------------------------------------------------------------ */
-void read_superblock(int fd)
+static void read_superblock(int fd)
{
int count;
@@ -1776,7 +1778,7 @@ void read_superblock(int fd)
/* ------------------------------------------------------------------------ */
/* read_master_dir - read the master directory */
/* ------------------------------------------------------------------------ */
-void read_master_dir(void)
+static void read_master_dir(void)
{
ioctl(sbd.device_fd, BLKFLSBUF, 0);
lseek(sbd.device_fd, sbd.sd_sb.sb_master_dir.no_addr * sbd.bsize,
@@ -1903,7 +1905,7 @@ int display(int identify_only)
/* ------------------------------------------------------------------------ */
/* push_block - push a block onto the block stack */
/* ------------------------------------------------------------------------ */
-void push_block(uint64_t blk)
+static void push_block(uint64_t blk)
{
int i, bhst;
@@ -1930,7 +1932,7 @@ void push_block(uint64_t blk)
/* ------------------------------------------------------------------------ */
/* pop_block - pop a block off the block stack */
/* ------------------------------------------------------------------------ */
-uint64_t pop_block(void)
+static uint64_t pop_block(void)
{
int i, bhst;
@@ -1954,7 +1956,7 @@ uint64_t pop_block(void)
/* find_journal_block - figure out where a journal starts, given the name */
/* Returns: journal block number, changes j_size to the journal size */
/* ------------------------------------------------------------------------ */
-uint64_t find_journal_block(const char *journal, uint64_t *j_size)
+static uint64_t find_journal_block(const char *journal, uint64_t *j_size)
{
int journal_num;
uint64_t jindex_block, jblock = 0;
@@ -2010,7 +2012,7 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
/* This is used to find blocks that aren't represented in the bitmaps, such */
/* as the RGs and bitmaps or the superblock. */
/* ------------------------------------------------------------------------ */
-uint64_t find_metablockoftype_slow(uint64_t startblk, int metatype, int print)
+static uint64_t find_metablockoftype_slow(uint64_t startblk, int metatype, int print)
{
uint64_t blk, last_fs_block;
int found = 0;
@@ -2051,7 +2053,7 @@ uint64_t find_metablockoftype_slow(uint64_t startblk, int metatype, int print)
/* all, if we're searching for a dinode, we want a real allocated inode, */
/* not just some block that used to be an inode in a previous incarnation. */
/* ------------------------------------------------------------------------ */
-uint64_t find_metablockoftype_rg(uint64_t startblk, int metatype, int print)
+static uint64_t find_metablockoftype_rg(uint64_t startblk, int metatype, int print)
{
uint64_t blk;
int first = 1, found = 0;
@@ -2112,7 +2114,7 @@ uint64_t find_metablockoftype_rg(uint64_t startblk, int metatype, int print)
/* ------------------------------------------------------------------------ */
/* Find next metadata block AFTER a given point in the fs */
/* ------------------------------------------------------------------------ */
-uint64_t find_metablockoftype(const char *strtype, int print)
+static uint64_t find_metablockoftype(const char *strtype, int print)
{
int mtype = 0;
uint64_t startblk, blk = 0;
@@ -2211,7 +2213,7 @@ uint64_t check_keywords(const char *kword)
/* ------------------------------------------------------------------------ */
/* goto_block - go to a desired block entered by the user */
/* ------------------------------------------------------------------------ */
-uint64_t goto_block(void)
+static uint64_t goto_block(void)
{
char string[256];
int ch;
@@ -2248,7 +2250,7 @@ uint64_t goto_block(void)
/* ------------------------------------------------------------------------ */
/* init_colors */
/* ------------------------------------------------------------------------ */
-void init_colors()
+static void init_colors(void)
{
if (color_scheme) {
@@ -2274,7 +2276,7 @@ void init_colors()
/* ------------------------------------------------------------------------ */
/* hex_edit - Allow the user to edit the page by entering hex digits */
/* ------------------------------------------------------------------------ */
-void hex_edit(int *exitch)
+static void hex_edit(int *exitch)
{
int left_off;
int ch;
@@ -2330,7 +2332,7 @@ void hex_edit(int *exitch)
/* ------------------------------------------------------------------------ */
/* page up */
/* ------------------------------------------------------------------------ */
-void pageup(void)
+static void pageup(void)
{
if (dmode == EXTENDED_MODE) {
if (edit_row[dmode] - (dsplines / lines_per_row[dmode]) > 0)
@@ -2362,7 +2364,7 @@ void pageup(void)
/* ------------------------------------------------------------------------ */
/* page down */
/* ------------------------------------------------------------------------ */
-void pagedn(void)
+static void pagedn(void)
{
if (dmode == EXTENDED_MODE) {
if ((edit_row[dmode] + dsplines) / lines_per_row[dmode] + 1 <=
@@ -2391,7 +2393,7 @@ void pagedn(void)
/* ------------------------------------------------------------------------ */
/* jump - jump to the address the cursor is on */
/* ------------------------------------------------------------------------ */
-void jump(void)
+static void jump(void)
{
if (dmode == HEX_MODE) {
unsigned int col2;
@@ -2421,30 +2423,30 @@ void jump(void)
/* ------------------------------------------------------------------------ */
/* print block type */
/* ------------------------------------------------------------------------ */
-void print_block_type(uint64_t block, int type, const char *additional)
+static void print_block_type(uint64_t tblock, int type, const char *additional)
{
if (type <= GFS2_METATYPE_QC)
printf("%d (Block %lld is type %d: %s%s)\n", type,
- (unsigned long long)block, type, block_type_str[type],
+ (unsigned long long)tblock, type, block_type_str[type],
additional);
else
printf("%d (Block %lld is type %d: unknown%s)\n", type,
- (unsigned long long)block, type, additional);
+ (unsigned long long)tblock, type, additional);
}
/* ------------------------------------------------------------------------ */
/* find_print block type */
/* ------------------------------------------------------------------------ */
-void find_print_block_type(void)
+static void find_print_block_type(void)
{
- uint64_t block;
+ uint64_t tblock;
struct gfs2_buffer_head *bh;
int type;
- block = blockstack[blockhist % BLOCK_STACK_SIZE].block;
- bh = bread(&sbd.buf_list, block);
+ tblock = blockstack[blockhist % BLOCK_STACK_SIZE].block;
+ bh = bread(&sbd.buf_list, tblock);
type = get_block_type(bh->b_data);
- print_block_type(block, type, "");
+ print_block_type(tblock, type, "");
brelse(bh, NOT_UPDATED);
gfs2_rgrp_free(&sbd.rglist, not_updated);
exit(0);
@@ -2453,17 +2455,17 @@ void find_print_block_type(void)
/* ------------------------------------------------------------------------ */
/* Find and print the resource group associated with a given block */
/* ------------------------------------------------------------------------ */
-void find_print_block_rg(int bitmap)
+static void find_print_block_rg(int bitmap)
{
- uint64_t block, rgblock;
+ uint64_t rblock, rgblock;
int i;
struct rgrp_list *rgd;
- block = blockstack[blockhist % BLOCK_STACK_SIZE].block;
- if (block == sbd.sb_addr)
+ rblock = blockstack[blockhist % BLOCK_STACK_SIZE].block;
+ if (rblock == sbd.sb_addr)
printf("0 (the superblock is not in the bitmap)\n");
else {
- rgd = gfs2_blk2rgrpd(&sbd, block);
+ rgd = gfs2_blk2rgrpd(&sbd, rblock);
if (rgd) {
rgblock = rgd->ri.ri_addr;
if (bitmap) {
@@ -2471,7 +2473,7 @@ void find_print_block_rg(int bitmap)
for (i = 0; i < rgd->ri.ri_length; i++) {
bits = &(rgd->bits[i]);
- if (block - rgd->ri.ri_data0 <
+ if (rblock - rgd->ri.ri_data0 <
((bits->bi_start + bits->bi_len) *
GFS2_NBBY)) {
break;
@@ -2496,9 +2498,9 @@ void find_print_block_rg(int bitmap)
/* ------------------------------------------------------------------------ */
/* find/change/print block allocation (what the bitmap says about block) */
/* ------------------------------------------------------------------------ */
-void find_change_block_alloc(int *newval)
+static void find_change_block_alloc(int *newval)
{
- uint64_t block;
+ uint64_t ablock;
int type;
struct rgrp_list *rgd;
@@ -2513,19 +2515,19 @@ void find_change_block_alloc(int *newval)
gfs2_rgrp_free(&sbd.rglist, not_updated);
exit(-1);
}
- block = blockstack[blockhist % BLOCK_STACK_SIZE].block;
- if (block == sbd.sb_addr)
+ ablock = blockstack[blockhist % BLOCK_STACK_SIZE].block;
+ if (ablock == sbd.sb_addr)
printf("3 (the superblock is not in the bitmap)\n");
else {
if (newval) {
- if (gfs2_set_bitmap(&sbd, block, *newval))
+ if (gfs2_set_bitmap(&sbd, ablock, *newval))
printf("-1 (block invalid or part of an rgrp).\n");
else
printf("%d\n", *newval);
} else {
- rgd = gfs2_blk2rgrpd(&sbd, block);
+ rgd = gfs2_blk2rgrpd(&sbd, ablock);
if (rgd) {
- type = gfs2_get_bitmap(&sbd, block, rgd);
+ type = gfs2_get_bitmap(&sbd, ablock, rgd);
printf("%d (%s)\n", type, allocdesc[gfs1][type]);
gfs2_rgrp_relse(rgd, not_updated);
} else {
@@ -2544,20 +2546,20 @@ void find_change_block_alloc(int *newval)
/* ------------------------------------------------------------------------ */
/* process request to print a certain field from a previously pushed block */
/* ------------------------------------------------------------------------ */
-void process_field(const char *field, uint64_t *newval, int print_field)
+static void process_field(const char *field, uint64_t *newval, int print_field)
{
- uint64_t block;
+ uint64_t fblock;
struct gfs2_buffer_head *bh;
int type;
struct gfs2_rgrp rg;
- block = blockstack[blockhist % BLOCK_STACK_SIZE].block;
- bh = bread(&sbd.buf_list, block);
+ fblock = blockstack[blockhist % BLOCK_STACK_SIZE].block;
+ bh = bread(&sbd.buf_list, fblock);
type = get_block_type(bh->b_data);
switch (type) {
case GFS2_METATYPE_SB:
if (print_field)
- print_block_type(block, type,
+ print_block_type(fblock, type,
" which is not implemented");
break;
case GFS2_METATYPE_RG:
@@ -2574,7 +2576,7 @@ void process_field(const char *field, uint64_t *newval, int print_field)
break;
case GFS2_METATYPE_RB:
if (print_field)
- print_block_type(block, type,
+ print_block_type(fblock, type,
" which is not implemented");
break;
case GFS2_METATYPE_DI:
@@ -2600,7 +2602,7 @@ void process_field(const char *field, uint64_t *newval, int print_field)
case GFS2_METATYPE_QC:
default:
if (print_field)
- print_block_type(block, type,
+ print_block_type(fblock, type,
" which is not implemented");
break;
}
@@ -2611,7 +2613,7 @@ void process_field(const char *field, uint64_t *newval, int print_field)
/* ------------------------------------------------------------------------ */
/* interactive_mode - accept keystrokes from user and display structures */
/* ------------------------------------------------------------------------ */
-void interactive_mode(void)
+static void interactive_mode(void)
{
int ch, Quit;
@@ -2876,11 +2878,11 @@ void interactive_mode(void)
/* ------------------------------------------------------------------------ */
/* gfs_log_header_in - read in a gfs1-style log header */
/* ------------------------------------------------------------------------ */
-void gfs_log_header_in(struct gfs_log_header *head, char *buf)
+void gfs_log_header_in(struct gfs_log_header *head, char *inbuf)
{
- struct gfs_log_header *str = (struct gfs_log_header *) buf;
+ struct gfs_log_header *str = (struct gfs_log_header *) inbuf;
- gfs2_meta_header_in(&head->lh_header, buf);
+ gfs2_meta_header_in(&head->lh_header, inbuf);
head->lh_flags = be32_to_cpu(str->lh_flags);
head->lh_pad = be32_to_cpu(str->lh_pad);
@@ -2913,7 +2915,7 @@ void gfs_log_header_print(struct gfs_log_header *lh)
/* print_ld_blocks - print all blocks given in a log descriptor */
/* returns: the number of block numbers it printed */
/* ------------------------------------------------------------------------ */
-int print_ld_blocks(const uint64_t *b, const char *end, int start_line)
+static int print_ld_blocks(const uint64_t *b, const char *end, int start_line)
{
int bcount = 0, i = 0;
static char str[256];
@@ -2945,7 +2947,7 @@ int print_ld_blocks(const uint64_t *b, const char *end, int start_line)
/* fsck_readi - same as libgfs2's gfs2_readi, but sets absolute block # */
/* of the first bit of data read. */
/* ------------------------------------------------------------------------ */
-int fsck_readi(struct gfs2_inode *ip, void *buf, uint64_t offset,
+static int fsck_readi(struct gfs2_inode *ip, void *rbuf, uint64_t roffset,
unsigned int size, uint64_t *abs_block)
{
struct gfs2_sbd *sdp = ip->i_sbd;
@@ -2959,18 +2961,18 @@ int fsck_readi(struct gfs2_inode *ip, void *buf, uint64_t offset,
int copied = 0;
*abs_block = 0;
- if (offset >= ip->i_di.di_size)
+ if (roffset >= ip->i_di.di_size)
return 0;
- if ((offset + size) > ip->i_di.di_size)
- size = ip->i_di.di_size - offset;
+ if ((roffset + size) > ip->i_di.di_size)
+ size = ip->i_di.di_size - roffset;
if (!size)
return 0;
if (isdir) {
- o = offset % sdp->sd_jbsize;
- lblock = offset / sdp->sd_jbsize;
+ o = roffset % sdp->sd_jbsize;
+ lblock = roffset / sdp->sd_jbsize;
} else {
- lblock = offset >> sdp->sd_sb.sb_bsize_shift;
- o = offset & (sdp->bsize - 1);
+ lblock = roffset >> sdp->sd_sb.sb_bsize_shift;
+ o = roffset & (sdp->bsize - 1);
}
if (!ip->i_di.di_height) /* inode_is_stuffed */
@@ -2994,10 +2996,10 @@ int fsck_readi(struct gfs2_inode *ip, void *buf, uint64_t offset,
} else
bh = NULL;
if (bh) {
- memcpy(buf, bh->b_data + o, amount);
+ memcpy(rbuf, bh->b_data + o, amount);
brelse(bh, not_updated);
} else {
- memset(buf, 0, amount);
+ memset(rbuf, 0, amount);
}
copied += amount;
lblock++;
@@ -3006,7 +3008,7 @@ int fsck_readi(struct gfs2_inode *ip, void *buf, uint64_t offset,
return copied;
}
-void check_journal_wrap(uint64_t seq, uint64_t *highest_seq)
+static void check_journal_wrap(uint64_t seq, uint64_t *highest_seq)
{
if (seq < *highest_seq) {
print_gfs2("------------------------------------------------"
@@ -3024,7 +3026,7 @@ void check_journal_wrap(uint64_t seq, uint64_t *highest_seq)
/* ------------------------------------------------------------------------ */
/* dump_journal - dump a journal file's contents. */
/* ------------------------------------------------------------------------ */
-void dump_journal(const char *journal)
+static void dump_journal(const char *journal)
{
struct gfs2_buffer_head *j_bh = NULL;
uint64_t jblock, j_size, jb, abs_block;
@@ -3149,7 +3151,7 @@ void dump_journal(const char *journal)
/* ------------------------------------------------------------------------ */
/* usage - print command line usage */
/* ------------------------------------------------------------------------ */
-void usage(void)
+static void usage(void)
{
fprintf(stderr,"\nFormat is: gfs2_edit [-c 1] [-V] [-x] [-h] [identify] [-p structures|blocks][blocktype][blockalloc [val]][blockbits][blockrg][find sb|rg|rb|di|in|lf|jd|lh|ld|ea|ed|lb|13|qc][field <f>[val]] /dev/device\n\n");
fprintf(stderr,"If only the device is specified, it enters into hexedit mode.\n");
@@ -3224,7 +3226,7 @@ void usage(void)
/* ------------------------------------------------------------------------ */
/* parameterpass1 - pre-processing for command-line parameters */
/* ------------------------------------------------------------------------ */
-void parameterpass1(int argc, char *argv[], int i)
+static void parameterpass1(int argc, char *argv[], int i)
{
if (!strcasecmp(argv[i], "-V")) {
printf("%s version %s (built %s %s)\n",
@@ -3281,7 +3283,7 @@ void parameterpass1(int argc, char *argv[], int i)
/* normals parameters, device name, etc. The second pass is for */
/* figuring out what structures to print out. */
/* ------------------------------------------------------------------------ */
-void process_parameters(int argc, char *argv[], int pass)
+static void process_parameters(int argc, char *argv[], int pass)
{
int i;
uint64_t keyword_blk;
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 68116f5..c508345 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -66,7 +66,6 @@ enum dsp_mode { HEX_MODE = 0, GFS2_MODE = 1, EXTENDED_MODE = 2, INIT_MODE = 3 };
#define GFS_LOG_DESC_Q (402) /* quota */
#define GFS_LOG_DESC_LAST (500) /* final in a logged transaction */
-EXTERN char *prog_name;
EXTERN uint64_t block INIT(0);
EXTERN int blockhist INIT(0);
EXTERN int edit_mode INIT(0);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 6c36b69..1983ba3 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -64,14 +64,14 @@ uint64_t masterblock(const char *fn);
* returns: 0 if successful
* -1 if this isn't gfs metadata.
*/
-int get_gfs_struct_info(char *buf, int *block_type, int *struct_len)
+static int get_gfs_struct_info(char *gbuf, int *block_type, int *gstruct_len)
{
struct gfs2_meta_header mh, mhbuf;
*block_type = 0;
- *struct_len = sbd.bsize;
+ *gstruct_len = sbd.bsize;
- memcpy(&mhbuf, buf, sizeof(mhbuf));
+ memcpy(&mhbuf, gbuf, sizeof(mhbuf));
gfs2_meta_header_in(&mh, (void *)&mhbuf);
if (mh.mh_magic != GFS2_MAGIC)
return -1;
@@ -80,46 +80,46 @@ int get_gfs_struct_info(char *buf, int *block_type, int *struct_len)
switch (mh.mh_type) {
case GFS2_METATYPE_SB: /* 1 (superblock) */
- *struct_len = sizeof(struct gfs_sb);
+ *gstruct_len = sizeof(struct gfs_sb);
break;
case GFS2_METATYPE_RG: /* 2 (rsrc grp hdr) */
- *struct_len = sbd.bsize; /*sizeof(struct gfs_rgrp);*/
+ *gstruct_len = sbd.bsize; /*sizeof(struct gfs_rgrp);*/
break;
case GFS2_METATYPE_RB: /* 3 (rsrc grp bitblk) */
- *struct_len = sbd.bsize;
+ *gstruct_len = sbd.bsize;
break;
case GFS2_METATYPE_DI: /* 4 (disk inode) */
- *struct_len = sbd.bsize; /*sizeof(struct gfs_dinode);*/
+ *gstruct_len = sbd.bsize; /*sizeof(struct gfs_dinode);*/
break;
case GFS2_METATYPE_IN: /* 5 (indir inode blklst) */
- *struct_len = sbd.bsize; /*sizeof(struct gfs_indirect);*/
+ *gstruct_len = sbd.bsize; /*sizeof(struct gfs_indirect);*/
break;
case GFS2_METATYPE_LF: /* 6 (leaf dinode blklst) */
- *struct_len = sbd.bsize; /*sizeof(struct gfs_leaf);*/
+ *gstruct_len = sbd.bsize; /*sizeof(struct gfs_leaf);*/
break;
case GFS2_METATYPE_JD: /* 7 (journal data) */
- *struct_len = sbd.bsize;
+ *gstruct_len = sbd.bsize;
break;
case GFS2_METATYPE_LH: /* 8 (log header) */
if (gfs1)
- *struct_len = 512; /* gfs copies the log header
- twice and compares the copy,
- so we need to save all 512
- bytes of it. */
+ *gstruct_len = 512; /* gfs copies the log header
+ twice and compares the copy,
+ so we need to save all 512
+ bytes of it. */
else
- *struct_len = sizeof(struct gfs2_log_header);
+ *gstruct_len = sizeof(struct gfs2_log_header);
break;
case GFS2_METATYPE_LD: /* 9 (log descriptor) */
- *struct_len = sbd.bsize;
+ *gstruct_len = sbd.bsize;
break;
case GFS2_METATYPE_EA: /* 10 (extended attr hdr) */
- *struct_len = sbd.bsize;
+ *gstruct_len = sbd.bsize;
break;
case GFS2_METATYPE_ED: /* 11 (extended attr data) */
- *struct_len = sbd.bsize;
+ *gstruct_len = sbd.bsize;
break;
default:
- *struct_len = sbd.bsize;
+ *gstruct_len = sbd.bsize;
break;
}
return 0;
@@ -131,12 +131,12 @@ int get_gfs_struct_info(char *buf, int *block_type, int *struct_len)
/* checking every block kills performance. We only report */
/* every second because we don't need 100 extra messages in */
/* logs made from verbose mode. */
-void warm_fuzzy_stuff(uint64_t block, int force, int save)
+static void warm_fuzzy_stuff(uint64_t wfsblock, int force, int save)
{
static struct timeval tv;
static uint32_t seconds = 0;
- last_reported_block = block;
+ last_reported_block = wfsblock;
gettimeofday(&tv, NULL);
if (!seconds)
seconds = tv.tv_sec;
@@ -147,9 +147,9 @@ void warm_fuzzy_stuff(uint64_t block, int force, int save)
if (last_fs_block) {
printf("\r");
if (save) {
- percent = (block * 100) / last_fs_block;
+ percent = (wfsblock * 100) / last_fs_block;
printf("%" PRIu64 " metadata blocks (%"
- PRIu64 "%%) processed, ", block,
+ PRIu64 "%%) processed, ", wfsblock,
percent);
}
if (total_out < 1024 * 1024)
@@ -169,7 +169,7 @@ void warm_fuzzy_stuff(uint64_t block, int force, int save)
}
}
-int block_is_a_journal(void)
+static int block_is_a_journal(void)
{
int j;
@@ -179,7 +179,7 @@ int block_is_a_journal(void)
return FALSE;
}
-int block_is_systemfile(void)
+static int block_is_systemfile(void)
{
return block_is_jindex() || block_is_inum_file() ||
block_is_statfs_file() || block_is_quota_file() ||
@@ -187,7 +187,7 @@ int block_is_systemfile(void)
block_is_per_node() || block_is_in_per_node();
}
-int save_block(int fd, int out_fd, uint64_t blk)
+static int save_block(int fd, int out_fd, uint64_t blk)
{
int blktype, blklen, outsz;
uint16_t trailing0;
@@ -232,7 +232,7 @@ int save_block(int fd, int out_fd, uint64_t blk)
/*
* save_ea_block - save off an extended attribute block
*/
-void save_ea_block(int out_fd, struct gfs2_buffer_head *metabh)
+static void save_ea_block(int out_fd, struct gfs2_buffer_head *metabh)
{
int i, e, ea_len = sbd.bsize;
struct gfs2_ea_header ea;
@@ -261,7 +261,7 @@ void save_ea_block(int out_fd, struct gfs2_buffer_head *metabh)
/*
* save_indirect_blocks - save all indirect blocks for the given buffer
*/
-void save_indirect_blocks(int out_fd, osi_list_t *cur_list,
+static void save_indirect_blocks(int out_fd, osi_list_t *cur_list,
struct gfs2_buffer_head *mybh, int height, int hgt)
{
uint64_t old_block = 0, indir_block;
@@ -311,7 +311,7 @@ void save_indirect_blocks(int out_fd, osi_list_t *cur_list,
* For file system journals, the "data" is a mixture of metadata and
* journaled data. We want all the metadata and none of the user data.
*/
-void save_inode_data(int out_fd)
+static void save_inode_data(int out_fd)
{
uint32_t height;
struct gfs2_inode *inode;
@@ -399,7 +399,7 @@ void save_inode_data(int out_fd)
inode_put(inode, not_updated);
}
-void get_journal_inode_blocks(void)
+static void get_journal_inode_blocks(void)
{
int journal;
struct gfs2_buffer_head *bh;
@@ -449,14 +449,14 @@ void get_journal_inode_blocks(void)
}
}
-int next_rg_freemeta(struct rgrp_list *rgd, uint64_t *block, int first)
+static int next_rg_freemeta(struct rgrp_list *rgd, uint64_t *nrfblock, int first)
{
struct gfs2_bitmap *bits = NULL;
uint32_t length = rgd->ri.ri_length;
- uint32_t blk = (first)? 0: (uint32_t)((*block+1)-rgd->ri.ri_data0);
+ uint32_t blk = (first)? 0: (uint32_t)((*nrfblock+1)-rgd->ri.ri_data0);
int i;
- if(!first && (*block < rgd->ri.ri_data0)) {
+ if(!first && (*nrfblock < rgd->ri.ri_data0)) {
log_err("next_rg_freemeta: Start block is outside rgrp "
"bounds.\n");
exit(1);
@@ -473,7 +473,8 @@ int next_rg_freemeta(struct rgrp_list *rgd, uint64_t *block, int first)
bits->bi_offset, bits->bi_len, blk,
GFS2_BLKST_UNLINKED);
if(blk != BFITNOENT){
- *block = blk + (bits->bi_start * GFS2_NBBY) + rgd->ri.ri_data0;
+ *nrfblock = blk + (bits->bi_start * GFS2_NBBY) +
+ rgd->ri.ri_data0;
break;
}
blk=0;
@@ -694,7 +695,7 @@ static const char *anthropomorphize(unsigned long long inhuman_value)
return out_val;
}
-int restore_data(int fd, int in_fd, int printblocksonly)
+static int restore_data(int fd, int in_fd, int printblocksonly)
{
size_t rs;
uint64_t buf64, writes = 0, highest_valid_block = 0;
@@ -832,7 +833,7 @@ int restore_data(int fd, int in_fd, int printblocksonly)
return 0;
}
-void complain(const char *complaint)
+static void complain(const char *complaint)
{
fprintf(stderr, "%s\n", complaint);
die("Format is: \ngfs2_edit restoremeta <file to restore> "
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index e6e0396..a225eb1 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -73,7 +73,7 @@ int gfs2_revoke_check(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int where)
{
osi_list_t *tmp;
struct gfs2_revoke_replay *rr;
- int wrap, a, b, revoke;
+ int wrap, a, b;
int found = 0;
osi_list_foreach(tmp, &sd_revoke_list) {
@@ -90,8 +90,7 @@ int gfs2_revoke_check(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int where)
wrap = (rr->rr_where < sd_replay_tail);
a = (sd_replay_tail < where);
b = (where < rr->rr_where);
- revoke = (wrap) ? (a || b) : (a && b);
- return revoke;
+ return (wrap) ? (a || b) : (a && b);
}
void gfs2_revoke_clean(struct gfs2_sbd *sdp)
@@ -261,7 +260,7 @@ static int databuf_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
* Returns: errno
*/
-int foreach_descriptor(struct gfs2_inode *ip, unsigned int start,
+static int foreach_descriptor(struct gfs2_inode *ip, unsigned int start,
unsigned int end, int pass)
{
struct gfs2_buffer_head *bh;
@@ -336,7 +335,7 @@ int foreach_descriptor(struct gfs2_inode *ip, unsigned int start,
* fix_journal_seq_no - Fix log header sequencing problems
* @ip: the journal incore inode
*/
-int fix_journal_seq_no(struct gfs2_inode *ip)
+static int fix_journal_seq_no(struct gfs2_inode *ip)
{
int error = 0, wrapped = 0;
uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 48e71c3..a12deed 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -46,7 +46,7 @@ static int was_mounted_ro = 0;
* Change the lock protocol so nobody can mount the fs
*
*/
-int block_mounters(struct gfs2_sbd *sbp, int block_em)
+static int block_mounters(struct gfs2_sbd *sbp, int block_em)
{
if(block_em) {
/* verify it starts with lock_ */
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index b2fba6c..718aa8f 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -39,7 +39,7 @@ int errors_found = 0, errors_corrected = 0;
const char *pass = "";
uint64_t last_data_block;
uint64_t first_data_block;
-char *prog_name = "gfs2_fsck"; /* needed by libgfs2 */
+const char *prog_name = "gfs2_fsck"; /* needed by libgfs2 */
int preen = 0, force_check = 0;
/* This function is for libgfs2's sake. */
@@ -53,19 +53,19 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)
va_end(args);
}
-void usage(char *name)
+static void usage(char *name)
{
printf("Usage: %s [-afhnpqvVy] <device> \n", basename(name));
}
-void version(void)
+static void version(void)
{
printf("GFS2 fsck %s (built %s %s)\n",
GFS_RELEASE_NAME, __DATE__, __TIME__);
printf("%s\n", REDHAT_COPYRIGHT);
}
-int read_cmdline(int argc, char **argv, struct gfs2_options *opts)
+static int read_cmdline(int argc, char **argv, struct gfs2_options *gopts)
{
int c;
@@ -74,7 +74,7 @@ int read_cmdline(int argc, char **argv, struct gfs2_options *opts)
case 'a':
preen = 1;
- opts->yes = 1;
+ gopts->yes = 1;
break;
case 'f':
force_check = 1;
@@ -84,11 +84,11 @@ int read_cmdline(int argc, char **argv, struct gfs2_options *opts)
exit(FSCK_OK);
break;
case 'n':
- opts->no = 1;
+ gopts->no = 1;
break;
case 'p':
preen = 1;
- opts->yes = 1;
+ gopts->yes = 1;
break;
case 'q':
decrease_verbosity();
@@ -101,7 +101,7 @@ int read_cmdline(int argc, char **argv, struct gfs2_options *opts)
exit(FSCK_OK);
break;
case 'y':
- opts->yes = 1;
+ gopts->yes = 1;
break;
case ':':
case '?':
@@ -115,9 +115,9 @@ int read_cmdline(int argc, char **argv, struct gfs2_options *opts)
}
}
if(argc > optind) {
- opts->device = (argv[optind]);
- if(!opts->device) {
- fprintf(stderr, "Please use '-h' for usage.\n");
+ gopts->device = (argv[optind]);
+ if(!gopts->device) {
+ fprintf(stderr, _("Please use '-h' for usage.\n"));
return FSCK_USAGE;
}
} else {
@@ -127,7 +127,7 @@ int read_cmdline(int argc, char **argv, struct gfs2_options *opts)
return 0;
}
-void interrupt(int sig)
+static void interrupt(int sig)
{
char response;
char progress[PATH_MAX];
@@ -154,7 +154,7 @@ void interrupt(int sig)
/* Check system inode and verify it's marked "in use" in the bitmap: */
/* Should work for all system inodes: root, master, jindex, per_node, etc. */
-int check_system_inode(struct gfs2_inode *sysinode, const char *filename,
+static int check_system_inode(struct gfs2_inode *sysinode, const char *filename,
void builder(struct gfs2_sbd *sbp),
enum gfs2_mark_block mark)
{
@@ -224,7 +224,7 @@ int check_system_inode(struct gfs2_inode *sysinode, const char *filename,
return 0;
}
-int check_system_inodes(struct gfs2_sbd *sdp)
+static int check_system_inodes(struct gfs2_sbd *sdp)
{
/*******************************************************************
******* Check the system inode integrity *************
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index a0ac86b..70c3be6 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -116,7 +116,7 @@ void fsck_inode_put(struct gfs2_inode *ip, enum update_flags update)
* This function tries to repair a corrupt directory entry. All we
* know at this point is that the length field is wrong.
*/
-int dirent_repair(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
+static int dirent_repair(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
struct gfs2_dirent *de, struct gfs2_dirent *dent,
int type, int first)
{
@@ -186,7 +186,7 @@ static void dirblk_truncate(struct gfs2_inode *ip, struct gfs2_dirent *fixb,
* returns: 0 - good block or it was repaired to be good
* -1 - error occurred
*/
-int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
+static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
int type, enum update_flags *update,
uint16_t *count, struct metawalk_fxns *pass)
{
@@ -333,9 +333,9 @@ int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
/* so that they replace the bad ones. We have to hack up the old */
/* leaf a bit, but it's better than deleting the whole directory, */
/* which is what used to happen before. */
-void warn_and_patch(struct gfs2_inode *ip, uint64_t *leaf_no,
- uint64_t *bad_leaf, uint64_t old_leaf,
- uint64_t first_ok_leaf, int index, const char *msg)
+static void warn_and_patch(struct gfs2_inode *ip, uint64_t *leaf_no,
+ uint64_t *bad_leaf, uint64_t old_leaf,
+ uint64_t first_ok_leaf, int pindex, const char *msg)
{
if (*bad_leaf != *leaf_no) {
log_err( _("Directory Inode %llu (0x%llx) points to leaf %llu"
@@ -350,12 +350,12 @@ void warn_and_patch(struct gfs2_inode *ip, uint64_t *leaf_no,
query(&opts, _("Attempt to patch around it? (y/n) "))) {
errors_corrected++;
if (gfs2_check_range(ip->i_sbd, old_leaf) == 0)
- gfs2_put_leaf_nr(ip, index, old_leaf);
+ gfs2_put_leaf_nr(ip, pindex, old_leaf);
else
- gfs2_put_leaf_nr(ip, index, first_ok_leaf);
- log_err( _("Directory Inode %" PRIu64 "(0x%" PRIx64
- ") repaired.\n"), ip->i_di.di_num.no_addr,
- ip->i_di.di_num.no_addr);
+ gfs2_put_leaf_nr(ip, pindex, first_ok_leaf);
+ log_err( _("Directory Inode %llu (0x%llx) repaired.\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
}
else
log_err( _("Bad leaf left in place.\n"));
@@ -364,15 +364,15 @@ void warn_and_patch(struct gfs2_inode *ip, uint64_t *leaf_no,
}
/* Checks exhash directory entries */
-int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
- struct metawalk_fxns *pass)
+static int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
+ struct metawalk_fxns *pass)
{
int error;
struct gfs2_leaf leaf, oldleaf;
uint64_t leaf_no, old_leaf, bad_leaf = -1;
uint64_t first_leaf_ptr = -1, first_ok_leaf = -1;
struct gfs2_buffer_head *lbh;
- int index;
+ int lindex;
struct gfs2_sbd *sbp = ip->i_sbd;
uint16_t count;
int ref_count = 0, exp_count = 0;
@@ -381,8 +381,8 @@ int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
leaf. That way, bad blocks at the beginning will be overwritten
with the first valid leaf. */
first_ok_leaf = -1;
- for(index = 0; index < (1 << ip->i_di.di_depth); index++) {
- gfs2_get_leaf_nr(ip, index, &first_ok_leaf);
+ for(lindex = 0; lindex < (1 << ip->i_di.di_depth); lindex++) {
+ gfs2_get_leaf_nr(ip, lindex, &first_ok_leaf);
if (first_leaf_ptr == -1)
first_leaf_ptr = first_ok_leaf;
if(gfs2_check_range(ip->i_sbd, first_ok_leaf) == 0) {
@@ -397,16 +397,16 @@ int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
}
old_leaf = -1;
memset(&oldleaf, 0, sizeof(oldleaf));
- for(index = 0; index < (1 << ip->i_di.di_depth); index++) {
+ for(lindex = 0; lindex < (1 << ip->i_di.di_depth); lindex++) {
if (fsck_abort)
break;
- gfs2_get_leaf_nr(ip, index, &leaf_no);
+ gfs2_get_leaf_nr(ip, lindex, &leaf_no);
/* GFS has multiple indirect pointers to the same leaf
* until those extra pointers are needed, so skip the
* dups */
if (leaf_no == bad_leaf) {
- gfs2_put_leaf_nr(ip, index, old_leaf); /* fill w/old
+ gfs2_put_leaf_nr(ip, lindex, old_leaf); /* fill w/old
leaf info */
ref_count++;
continue;
@@ -462,8 +462,8 @@ int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
(unsigned long long)
ip->i_di.di_num.no_addr);
warn_and_patch(ip, &leaf_no, &bad_leaf,
- old_leaf, first_ok_leaf,
- index, _("that is out of range"));
+ old_leaf, first_ok_leaf, lindex,
+ _("that is out of range"));
memcpy(&leaf, &oldleaf, sizeof(oldleaf));
break;
}
@@ -474,7 +474,7 @@ int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
/* Make sure it's really a valid leaf block. */
if (gfs2_check_meta(lbh, GFS2_METATYPE_LF)) {
warn_and_patch(ip, &leaf_no, &bad_leaf,
- old_leaf, first_ok_leaf, index,
+ old_leaf, first_ok_leaf, lindex,
_("that is not really a leaf"));
memcpy(&leaf, &oldleaf, sizeof(oldleaf));
brelse(lbh, not_updated);
@@ -667,9 +667,7 @@ static int check_eattr_entries(struct gfs2_inode *ip,
}
offset += be32_to_cpu(ea_hdr->ea_rec_len);
if(ea_hdr->ea_flags & GFS2_EAFLAG_LAST ||
- offset >= ip->i_sbd->sd_sb.sb_bsize ||
- ea_hdr->ea_rec_len == 0) {
-
+ offset >= ip->i_sbd->sd_sb.sb_bsize || ea_hdr->ea_rec_len == 0){
break;
}
ea_hdr_prev = ea_hdr;
@@ -1062,7 +1060,7 @@ end:
}
/* Checks stuffed inode directories */
-int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
+static int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
enum update_flags *update, struct metawalk_fxns *pass)
{
int error = 0;
@@ -1267,19 +1265,19 @@ int delete_blocks(struct gfs2_inode *ip, uint64_t block,
int delete_metadata(struct gfs2_inode *ip, uint64_t block,
struct gfs2_buffer_head **bh, void *private)
{
- return delete_blocks(ip, block, bh, "metadata", private);
+ return delete_blocks(ip, block, bh, _("metadata"), private);
}
int delete_data(struct gfs2_inode *ip, uint64_t block, void *private)
{
- return delete_blocks(ip, block, NULL, "data", private);
+ return delete_blocks(ip, block, NULL, _("data"), private);
}
int delete_eattr_indir(struct gfs2_inode *ip, uint64_t block, uint64_t parent,
struct gfs2_buffer_head **bh,
enum update_flags *want_updated, void *private)
{
- return delete_blocks(ip, block, NULL, "indirect extended attribute",
+ return delete_blocks(ip, block, NULL, _("indirect extended attribute"),
private);
}
@@ -1287,5 +1285,6 @@ int delete_eattr_leaf(struct gfs2_inode *ip, uint64_t block, uint64_t parent,
struct gfs2_buffer_head **bh,
enum update_flags *want_updated, void *private)
{
- return delete_blocks(ip, block, NULL, "extended attribute", private);
+ return delete_blocks(ip, block, NULL, _("extended attribute"),
+ private);
}
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index edcb7ec..a23da46 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -599,7 +599,7 @@ static int check_eattr_entries(struct gfs2_inode *ip,
return 0;
}
-int clear_metalist(struct gfs2_inode *ip, uint64_t block,
+static int clear_metalist(struct gfs2_inode *ip, uint64_t block,
struct gfs2_buffer_head **bh, void *private)
{
struct gfs2_block_query q = {0};
@@ -617,7 +617,7 @@ int clear_metalist(struct gfs2_inode *ip, uint64_t block,
return 0;
}
-int clear_data(struct gfs2_inode *ip, uint64_t block, void *private)
+static int clear_data(struct gfs2_inode *ip, uint64_t block, void *private)
{
struct gfs2_block_query q = {0};
@@ -633,7 +633,7 @@ int clear_data(struct gfs2_inode *ip, uint64_t block, void *private)
}
-int clear_leaf(struct gfs2_inode *ip, uint64_t block,
+static int clear_leaf(struct gfs2_inode *ip, uint64_t block,
struct gfs2_buffer_head *bh, void *private)
{
struct gfs2_block_query q = {0};
@@ -687,7 +687,7 @@ int add_to_dir_list(struct gfs2_sbd *sbp, uint64_t block)
return 0;
}
-int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
+static int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
uint64_t block)
{
struct gfs2_block_query q = {0};
@@ -927,7 +927,7 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
return 0;
}
-int scan_meta(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
+static int scan_meta(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
uint64_t block)
{
if (gfs2_check_meta(bh, 0)) {
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index ff59968..5e75ae3 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -336,7 +336,7 @@ static int clear_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_data_ptr,
}
/* Finds all references to duplicate blocks in the metadata */
-int find_block_ref(struct gfs2_sbd *sbp, uint64_t inode, struct dup_blocks *b)
+static int find_block_ref(struct gfs2_sbd *sbp, uint64_t inode, struct dup_blocks *b)
{
struct gfs2_inode *ip;
struct fxn_info myfi = {b->block_no, 0, 1};
@@ -391,7 +391,7 @@ int find_block_ref(struct gfs2_sbd *sbp, uint64_t inode, struct dup_blocks *b)
return 0;
}
-int handle_dup_blk(struct gfs2_sbd *sbp, struct dup_blocks *b)
+static int handle_dup_blk(struct gfs2_sbd *sbp, struct dup_blocks *b)
{
osi_list_t *tmp;
struct inode_with_dups *id;
@@ -526,8 +526,8 @@ int pass1b(struct gfs2_sbd *sbp)
struct gfs2_block_query q;
osi_list_t *tmp = NULL, *x;
struct metawalk_fxns find_dirents = {0};
- find_dirents.check_dentry = &find_dentry;
int rc = FSCK_OK;
+ find_dirents.check_dentry = &find_dentry;
log_info( _("Looking for duplicate blocks...\n"));
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index a7dbb41..395ca2c 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -31,7 +31,7 @@
/* Set children's parent inode in dir_info structure - ext2 does not set
* dotdot inode here, but instead in pass3 - should we? */
-int set_parent_dir(struct gfs2_sbd *sbp, uint64_t childblock,
+static int set_parent_dir(struct gfs2_sbd *sbp, uint64_t childblock,
uint64_t parentblock)
{
struct dir_info *di;
@@ -58,7 +58,7 @@ int set_parent_dir(struct gfs2_sbd *sbp, uint64_t childblock,
}
/* Set's the child's '..' directory inode number in dir_info structure */
-int set_dotdot_dir(struct gfs2_sbd *sbp, uint64_t childblock,
+static int set_dotdot_dir(struct gfs2_sbd *sbp, uint64_t childblock,
uint64_t parentblock)
{
struct dir_info *di;
@@ -105,13 +105,12 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
return 0;
}
-const char *de_type_string(uint8_t de_type)
+static const char *de_type_string(uint8_t de_type)
{
- const char *de_types[15] =
- {"unknown", "fifo", "chrdev", "invalid",
- "directory", "invalid", "blkdev", "invalid",
- "file", "invalid", "symlink", "invalid",
- "socket", "invalid", "wht"};
+ const char *de_types[15] = {"unknown", "fifo", "chrdev", "invalid",
+ "directory", "invalid", "blkdev", "invalid",
+ "file", "invalid", "symlink", "invalid",
+ "socket", "invalid", "wht"};
if (de_type < 15)
return de_types[de_type];
return de_types[3]; /* invalid */
@@ -166,7 +165,7 @@ struct metawalk_fxns pass2_fxns_delete = {
/* FIXME: should maybe refactor this a bit - but need to deal with
* FIXMEs internally first */
-int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
+static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
struct gfs2_dirent *prev_de,
struct gfs2_buffer_head *bh, char *filename,
enum update_flags *update, uint16_t *count, void *priv)
@@ -313,7 +312,6 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
dirent2_del(ip, bh, prev_de, dent);
*update = updated;
log_warn( _("Directory entry '%s' cleared\n"), tmp_name);
-
/* If it was previously marked invalid (i.e. known
to be bad, not just a free block, etc.) then
delete any metadata it holds. If not, return. */
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index 46bd3aa..48f6135 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -27,7 +27,7 @@
#include "metawalk.h"
static int attach_dotdot_to(struct gfs2_sbd *sbp, uint64_t newdotdot,
- uint64_t olddotdot, uint64_t block)
+ uint64_t olddotdot, uint64_t block)
{
char *filename;
int filename_len;
@@ -69,7 +69,7 @@ static int attach_dotdot_to(struct gfs2_sbd *sbp, uint64_t newdotdot,
return 0;
}
-struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
+static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
struct dir_info *di)
{
struct dir_info *pdi;
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index e217236..fd0ac0e 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -33,7 +33,7 @@ struct metawalk_fxns pass4_fxns_delete = {
/* Updates the link count of an inode to what the fsck has seen for
* link count */
-int fix_inode_count(struct gfs2_sbd *sbp, struct inode_info *ii,
+static int fix_inode_count(struct gfs2_sbd *sbp, struct inode_info *ii,
struct gfs2_inode *ip)
{
log_info( _("Fixing inode count for %llu (0x%llx) \n"),
@@ -50,7 +50,7 @@ int fix_inode_count(struct gfs2_sbd *sbp, struct inode_info *ii,
return 0;
}
-int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
+static int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
osi_list_t *tmp;
struct inode_info *ii;
struct gfs2_inode *ip;
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index aa9d3bd..a533536 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -23,7 +23,7 @@
#include "fs_bits.h"
#include "util.h"
-int convert_mark(struct gfs2_block_query *q, uint32_t *count)
+static int convert_mark(struct gfs2_block_query *q, uint32_t *count)
{
if (q->eattr_block) {
count[2]++;
@@ -66,7 +66,7 @@ int convert_mark(struct gfs2_block_query *q, uint32_t *count)
return -1;
}
-int check_block_status(struct gfs2_sbd *sbp, char *buffer, unsigned int buflen,
+static int check_block_status(struct gfs2_sbd *sbp, char *buffer, unsigned int buflen,
uint64_t *rg_block, uint64_t rg_data, uint32_t *count)
{
unsigned char *byte, *end;
@@ -165,7 +165,7 @@ int check_block_status(struct gfs2_sbd *sbp, char *buffer, unsigned int buflen,
return 0;
}
-enum update_flags update_rgrp(struct gfs2_sbd *sbp, struct rgrp_list *rgp,
+static enum update_flags update_rgrp(struct gfs2_sbd *sbp, struct rgrp_list *rgp,
uint32_t *count)
{
uint32_t i;
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 35e7811..9d28b1a 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -49,7 +49,7 @@ struct special_blocks false_rgrps;
* for a real RG block. These are "fake" RGs that need to be ignored for
* the purposes of finding where things are.
*/
-void find_journaled_rgs(struct gfs2_sbd *sdp)
+static void find_journaled_rgs(struct gfs2_sbd *sdp)
{
int j, new = 0;
unsigned int jblocks;
@@ -79,7 +79,7 @@ void find_journaled_rgs(struct gfs2_sbd *sdp)
}
}
-int is_false_rg(uint64_t block)
+static int is_false_rg(uint64_t block)
{
if (blockfind(&false_rgrps, block))
return 1;
@@ -111,7 +111,7 @@ int is_false_rg(uint64_t block)
* same RG size determined by the original mkfs, so recovery is easier.
*
*/
-int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
+static int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
int *num_rgs)
{
struct gfs2_buffer_head *bh;
@@ -352,7 +352,7 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
* Sets: sdp->rglist to a linked list of fsck_rgrp structs representing
* what we think the rindex should really look like.
*/
-int gfs2_rindex_calculate(struct gfs2_sbd *sdp, osi_list_t *ret_list,
+static int gfs2_rindex_calculate(struct gfs2_sbd *sdp, osi_list_t *ret_list,
int *num_rgs)
{
osi_list_init(ret_list);
@@ -386,7 +386,7 @@ int gfs2_rindex_calculate(struct gfs2_sbd *sdp, osi_list_t *ret_list,
* rewrite_rg_block - rewrite ("fix") a buffer with rg or bitmap data
* returns: 0 if the rg was repaired, otherwise 1
*/
-int rewrite_rg_block(struct gfs2_sbd *sdp, struct rgrp_list *rg,
+static int rewrite_rg_block(struct gfs2_sbd *sdp, struct rgrp_list *rg,
uint64_t errblock)
{
int x = errblock - rg->ri.ri_addr;
diff --git a/gfs2/libgfs2/block_list.c b/gfs2/libgfs2/block_list.c
index 9fc3ac5..b0d7000 100644
--- a/gfs2/libgfs2/block_list.c
+++ b/gfs2/libgfs2/block_list.c
@@ -63,7 +63,7 @@ void gfs2_special_free(struct special_blocks *blist)
}
}
-void gfs2_dup_free(struct dup_blocks *blist)
+static void gfs2_dup_free(struct dup_blocks *blist)
{
struct dup_blocks *f;
@@ -90,7 +90,7 @@ struct special_blocks *blockfind(struct special_blocks *blist, uint64_t num)
return NULL;
}
-struct dup_blocks *dupfind(struct dup_blocks *blist, uint64_t num)
+static struct dup_blocks *dupfind(struct dup_blocks *blist, uint64_t num)
{
osi_list_t *head = &blist->list;
osi_list_t *tmp;
@@ -119,7 +119,7 @@ void gfs2_special_set(struct special_blocks *blocklist, uint64_t block)
return;
}
-void gfs2_dup_set(struct dup_blocks *blocklist, uint64_t block)
+static void gfs2_dup_set(struct dup_blocks *blocklist, uint64_t block)
{
struct dup_blocks *b;
@@ -135,7 +135,7 @@ void gfs2_dup_set(struct dup_blocks *blocklist, uint64_t block)
return;
}
-void gfs2_special_clear(struct special_blocks *blocklist, uint64_t block)
+static void gfs2_special_clear(struct special_blocks *blocklist, uint64_t block)
{
struct special_blocks *b;
@@ -146,7 +146,7 @@ void gfs2_special_clear(struct special_blocks *blocklist, uint64_t block)
}
}
-void gfs2_dup_clear(struct dup_blocks *blocklist, uint64_t block)
+static void gfs2_dup_clear(struct dup_blocks *blocklist, uint64_t block)
{
struct dup_blocks *b;
diff --git a/gfs2/libgfs2/buf.c b/gfs2/libgfs2/buf.c
index 3f9e748..6c7e181 100644
--- a/gfs2/libgfs2/buf.c
+++ b/gfs2/libgfs2/buf.c
@@ -161,11 +161,11 @@ struct gfs2_buffer_head *bhold(struct gfs2_buffer_head *bh)
return bh;
}
-void brelse(struct gfs2_buffer_head *bh, enum update_flags updated)
+void brelse(struct gfs2_buffer_head *bh, enum update_flags is_updated)
{
/* We can't just say b_changed = updated because we don't want to */
/* set it FALSE if it's TRUE until we write the changed data to disk. */
- if (updated)
+ if (is_updated)
bh->b_changed = TRUE;
if (!bh->b_count) {
stack;
diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c
index 4501a84..0ad7df4 100644
--- a/gfs2/libgfs2/fs_geometry.c
+++ b/gfs2/libgfs2/fs_geometry.c
@@ -33,8 +33,7 @@
* Returns: the number of RGs
*/
-uint64_t
-how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev, int rgsize_specified)
+static uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev, int rgsize_specified)
{
uint64_t nrgrp;
@@ -63,8 +62,7 @@ how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev, int rgsize_specified)
* Returns: a list of rgrp_list_t structures
*/
-void
-compute_rgrp_layout(struct gfs2_sbd *sdp, int rgsize_specified)
+void compute_rgrp_layout(struct gfs2_sbd *sdp, int rgsize_specified)
{
struct device *dev;
struct rgrp_list *rl, *rlast = NULL, *rlast2 = NULL;
@@ -187,7 +185,7 @@ rgblocks2bitblocks(unsigned int bsize, uint32_t *rgblocks, uint32_t *bitblocks)
* If fd > 0, write the data to the given file handle.
* Otherwise, use gfs2 buffering in buf.c.
*/
-void build_rgrps(struct gfs2_sbd *sdp, int write)
+void build_rgrps(struct gfs2_sbd *sdp, int do_write)
{
osi_list_t *tmp, *head;
struct rgrp_list *rl;
@@ -224,7 +222,7 @@ void build_rgrps(struct gfs2_sbd *sdp, int write)
rg->rg_flags = rl->rgf_flags;
rg->rg_free = rgblocks;
- if (write) {
+ if (do_write) {
for (x = 0; x < bitblocks; x++) {
bh = bget(&sdp->nvbuf_list, rl->start + x);
if (x)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 675dcd6..7dacd43 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -26,7 +26,7 @@
#include "libgfs2.h"
/* Detect directory is a stuffed inode */
-int inode_is_stuffed(struct gfs2_inode *ip)
+static int inode_is_stuffed(struct gfs2_inode *ip)
{
return !ip->i_di.di_height;
}
@@ -42,15 +42,15 @@ struct gfs2_inode *inode_get(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh)
return ip;
}
-void inode_put(struct gfs2_inode *ip, enum update_flags updated)
+void inode_put(struct gfs2_inode *ip, enum update_flags is_updated)
{
- if (updated)
+ if (is_updated)
gfs2_dinode_out(&ip->i_di, ip->i_bh->b_data);
- brelse(ip->i_bh, updated);
+ brelse(ip->i_bh, is_updated);
free(ip);
}
-uint64_t blk_alloc_i(struct gfs2_sbd *sdp, unsigned int type)
+static uint64_t blk_alloc_i(struct gfs2_sbd *sdp, unsigned int type)
{
osi_list_t *tmp, *head;
struct rgrp_list *rl = NULL;
@@ -627,9 +627,8 @@ int gfs2_dirent_next(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
return 0;
}
-static int
-dirent_alloc(struct gfs2_inode *dip, struct gfs2_buffer_head *bh, int name_len,
- struct gfs2_dirent **dent_out)
+static int dirent_alloc(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
+ int name_len, struct gfs2_dirent **dent_out)
{
struct gfs2_dirent *dent, *new;
unsigned int rec_len = GFS2_DIRENT_SIZE(name_len);
@@ -691,7 +690,7 @@ dirent_alloc(struct gfs2_inode *dip, struct gfs2_buffer_head *bh, int name_len,
}
void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
- struct gfs2_dirent *prev, struct gfs2_dirent *cur)
+ struct gfs2_dirent *prev, struct gfs2_dirent *cur)
{
uint16_t cur_rec_len, prev_rec_len;
@@ -709,14 +708,14 @@ void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
prev->de_rec_len = cpu_to_be16(prev_rec_len);
}
-void gfs2_get_leaf_nr(struct gfs2_inode *dip, uint32_t index,
+void gfs2_get_leaf_nr(struct gfs2_inode *dip, uint32_t lindex,
uint64_t *leaf_out)
{
uint64_t leaf_no;
int count;
count = gfs2_readi(dip, (char *)&leaf_no,
- index * sizeof(uint64_t),
+ lindex * sizeof(uint64_t),
sizeof(uint64_t));
if (count != sizeof(uint64_t))
die("gfs2_get_leaf_nr: Bad internal read.\n");
@@ -736,8 +735,7 @@ void gfs2_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out)
die("gfs2_put_leaf_nr: Bad internal write.\n");
}
-static void
-dir_split_leaf(struct gfs2_inode *dip, uint32_t index, uint64_t leaf_no)
+static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, uint64_t leaf_no)
{
struct gfs2_buffer_head *nbh, *obh;
struct gfs2_leaf *nleaf, *oleaf;
@@ -767,7 +765,7 @@ dir_split_leaf(struct gfs2_inode *dip, uint32_t index, uint64_t leaf_no)
len = 1 << (dip->i_di.di_depth - be16_to_cpu(oleaf->lf_depth));
half_len = len >> 1;
- start = (index & ~(len - 1));
+ start = (lindex & ~(len - 1));
zalloc(lp, half_len * sizeof(uint64_t));
@@ -839,8 +837,7 @@ dir_split_leaf(struct gfs2_inode *dip, uint32_t index, uint64_t leaf_no)
brelse(nbh, updated);
}
-static void
-dir_double_exhash(struct gfs2_inode *dip)
+static void dir_double_exhash(struct gfs2_inode *dip)
{
struct gfs2_sbd *sdp = dip->i_sbd;
uint64_t *buf;
@@ -910,12 +907,12 @@ int gfs2_get_leaf(struct gfs2_inode *dip, uint64_t leaf_no,
* Returns: 0 on success, error code otherwise
*/
-static int get_first_leaf(struct gfs2_inode *dip, uint32_t index,
- struct gfs2_buffer_head **bh_out)
+static int get_first_leaf(struct gfs2_inode *dip, uint32_t lindex,
+ struct gfs2_buffer_head **bh_out)
{
uint64_t leaf_no;
- gfs2_get_leaf_nr(dip, index, &leaf_no);
+ gfs2_get_leaf_nr(dip, lindex, &leaf_no);
*bh_out = bread(&dip->i_sbd->buf_list, leaf_no);
return 0;
}
@@ -930,7 +927,7 @@ static int get_first_leaf(struct gfs2_inode *dip, uint32_t index,
*/
static int get_next_leaf(struct gfs2_inode *dip,struct gfs2_buffer_head *bh_in,
- struct gfs2_buffer_head **bh_out)
+ struct gfs2_buffer_head **bh_out)
{
struct gfs2_leaf *leaf;
@@ -942,14 +939,13 @@ static int get_next_leaf(struct gfs2_inode *dip,struct gfs2_buffer_head *bh_in,
return 0;
}
-static void
-dir_e_add(struct gfs2_inode *dip, char *filename, int len,
- struct gfs2_inum *inum, unsigned int type)
+static void dir_e_add(struct gfs2_inode *dip, const char *filename, int len,
+ struct gfs2_inum *inum, unsigned int type)
{
struct gfs2_buffer_head *bh, *nbh;
struct gfs2_leaf *leaf, *nleaf;
struct gfs2_dirent *dent;
- uint32_t index;
+ uint32_t lindex;
uint32_t hash;
uint64_t leaf_no, bn;
@@ -957,11 +953,11 @@ dir_e_add(struct gfs2_inode *dip, char *filename, int len,
hash = gfs2_disk_hash(filename, len);
/* Have to kludge because (hash >> 32) gives hash for some reason. */
if (dip->i_di.di_depth)
- index = hash >> (32 - dip->i_di.di_depth);
+ lindex = hash >> (32 - dip->i_di.di_depth);
else
- index = 0;
+ lindex = 0;
- gfs2_get_leaf_nr(dip, index, &leaf_no);
+ gfs2_get_leaf_nr(dip, lindex, &leaf_no);
for (;;) {
bh = bread(&dip->i_sbd->buf_list, leaf_no);
@@ -971,7 +967,7 @@ dir_e_add(struct gfs2_inode *dip, char *filename, int len,
if (be16_to_cpu(leaf->lf_depth) < dip->i_di.di_depth) {
brelse(bh, not_updated);
- dir_split_leaf(dip, index, leaf_no);
+ dir_split_leaf(dip, lindex, leaf_no);
goto restart;
} else if (dip->i_di.di_depth < GFS2_DIR_MAX_DEPTH) {
@@ -1025,8 +1021,7 @@ dir_e_add(struct gfs2_inode *dip, char *filename, int len,
}
}
-static void
-dir_make_exhash(struct gfs2_inode *dip)
+static void dir_make_exhash(struct gfs2_inode *dip)
{
struct gfs2_sbd *sdp = dip->i_sbd;
struct gfs2_dirent *dent;
@@ -1213,7 +1208,8 @@ struct gfs2_inode *createi(struct gfs2_inode *dip, char *filename,
*
* Returns: 1 if the files are the same, otherwise 0.
*/
-int gfs2_filecmp(const char *file1, const char *file2, int len_of_file2)
+
+static int gfs2_filecmp(const char *file1, const char *file2, int len_of_file2)
{
if (strlen(file1) != len_of_file2)
return 0;
@@ -1231,11 +1227,10 @@ int gfs2_filecmp(const char *file1, const char *file2, int len_of_file2)
*
* Returns:
*/
-static int leaf_search(struct gfs2_inode *dip,
- struct gfs2_buffer_head *bh,
- const char *filename, int len,
- struct gfs2_dirent **dent_out,
- struct gfs2_dirent **dent_prev)
+static int leaf_search(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
+ const char *filename, int len,
+ struct gfs2_dirent **dent_out,
+ struct gfs2_dirent **dent_prev)
{
uint32_t hash;
struct gfs2_dirent *dent, *prev = NULL;
@@ -1289,14 +1284,14 @@ static int leaf_search(struct gfs2_inode *dip,
*
* Returns: 0 on sucess, error code otherwise
*/
-static int linked_leaf_search(struct gfs2_inode *dip,
- const char *filename, int len,
- struct gfs2_dirent **dent_out,
- struct gfs2_dirent **dent_prev,
- struct gfs2_buffer_head **bh_out)
+
+static int linked_leaf_search(struct gfs2_inode *dip, const char *filename,
+ int len, struct gfs2_dirent **dent_out,
+ struct gfs2_dirent **dent_prev,
+ struct gfs2_buffer_head **bh_out)
{
struct gfs2_buffer_head *bh = NULL, *bh_next;
- uint32_t hsize, index;
+ uint32_t hsize, lindex;
uint32_t hash;
int error = 0;
@@ -1307,9 +1302,9 @@ static int linked_leaf_search(struct gfs2_inode *dip,
/* Figure out the address of the leaf node. */
hash = gfs2_disk_hash(filename, len);
- index = hash >> (32 - dip->i_di.di_depth);
+ lindex = hash >> (32 - dip->i_di.di_depth);
- error = get_first_leaf(dip, index, &bh_next);
+ error = get_first_leaf(dip, lindex, &bh_next);
if (error)
return error;
@@ -1335,7 +1330,7 @@ static int linked_leaf_search(struct gfs2_inode *dip,
}
error = get_next_leaf(dip, bh, &bh_next);
- }while (!error);
+ } while (!error);
brelse(bh, not_updated);
@@ -1351,7 +1346,7 @@ static int linked_leaf_search(struct gfs2_inode *dip,
* Returns:
*/
static int dir_e_search(struct gfs2_inode *dip, const char *filename,
- int len, unsigned int *type, struct gfs2_inum *inum)
+ int len, unsigned int *type, struct gfs2_inum *inum)
{
struct gfs2_buffer_head *bh = NULL;
struct gfs2_dirent *dent;
@@ -1380,7 +1375,7 @@ static int dir_e_search(struct gfs2_inode *dip, const char *filename,
* Returns:
*/
static int dir_l_search(struct gfs2_inode *dip, const char *filename,
- int len, unsigned int *type, struct gfs2_inum *inum)
+ int len, unsigned int *type, struct gfs2_inum *inum)
{
struct gfs2_buffer_head *dibh;
struct gfs2_dirent *dent;
@@ -1413,8 +1408,8 @@ static int dir_l_search(struct gfs2_inode *dip, const char *filename,
*
* Returns: 0 if found, -1 on failure, -ENOENT if not found.
*/
-int dir_search(struct gfs2_inode *dip, const char *filename, int len,
- unsigned int *type, struct gfs2_inum *inum)
+static int dir_search(struct gfs2_inode *dip, const char *filename, int len,
+ unsigned int *type, struct gfs2_inum *inum)
{
int error;
@@ -1431,17 +1426,17 @@ int dir_search(struct gfs2_inode *dip, const char *filename, int len,
static int dir_e_del(struct gfs2_inode *dip, const char *filename, int len)
{
- int index;
+ int lindex;
int error;
int found = 0;
uint64_t leaf_no;
struct gfs2_buffer_head *bh = NULL;
struct gfs2_dirent *cur, *prev;
- index = (1 << (dip->i_di.di_depth))-1;
+ lindex = (1 << (dip->i_di.di_depth))-1;
- for(; (index >= 0) && !found; index--){
- gfs2_get_leaf_nr(dip, index, &leaf_no);
+ for(; (lindex >= 0) && !found; lindex--){
+ gfs2_get_leaf_nr(dip, lindex, &leaf_no);
while(leaf_no && !found){
bh = bread(&dip->i_sbd->buf_list, leaf_no);
@@ -1469,7 +1464,7 @@ static int dir_e_del(struct gfs2_inode *dip, const char *filename, int len)
}
static int dir_l_del(struct gfs2_inode *dip, struct gfs2_buffer_head *dibh,
- const char *filename, int len){
+ const char *filename, int len){
int error=0;
int got_buf = 0;
struct gfs2_dirent *cur, *prev;
@@ -1513,7 +1508,7 @@ static int dir_l_del(struct gfs2_inode *dip, struct gfs2_buffer_head *dibh,
* Returns: 0 on success (or if it doesn't already exist), -1 on failure
*/
int gfs2_dirent_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
- const char *filename, int len){
+ const char *filename, int len){
int error;
if(!S_ISDIR(dip->i_di.di_mode))
@@ -1536,7 +1531,7 @@ int gfs2_dirent_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
* Returns: 0 on success, -EXXXX on failure
*/
int gfs2_lookupi(struct gfs2_inode *dip, const char *filename, int len,
- struct gfs2_inode **ipp)
+ struct gfs2_inode **ipp)
{
struct gfs2_sbd *sdp = dip->i_sbd;
int error = 0;
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index bef6aef..f9e5a6e 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -156,7 +156,7 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
free(mp);
}
-int gfs1_readi(struct gfs2_inode *ip, void *buf,
+int gfs1_readi(struct gfs2_inode *ip, void *bufin,
uint64_t offset, unsigned int size)
{
struct gfs2_sbd *sdp = ip->i_sbd;
@@ -167,6 +167,7 @@ int gfs1_readi(struct gfs2_inode *ip, void *buf,
int not_new = 0;
int journaled = fs_is_jdata(ip);
int copied = 0;
+ char *buf = bufin;
if (offset >= ip->i_di.di_size)
return 0;
@@ -300,9 +301,6 @@ int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int quiet)
if (gfs1_rindex_read(sdp, fd, &count1))
goto fail;
for (tmp = sdp->rglist.next; tmp != &sdp->rglist; tmp = tmp->next) {
- enum update_flags f;
-
- f = not_updated;
rgd = osi_list_entry(tmp, struct rgrp_list, list);
errblock = gfs2_rgrp_read(sdp, rgd);
if (errblock)
@@ -328,7 +326,7 @@ int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int quiet)
/* ------------------------------------------------------------------------ */
/* gfs_dinode_in */
/* ------------------------------------------------------------------------ */
-void gfs_dinode_in(struct gfs_dinode *di, char *buf)
+static void gfs_dinode_in(struct gfs_dinode *di, char *buf)
{
struct gfs_dinode *str = (struct gfs_dinode *)buf;
diff --git a/gfs2/libgfs2/gfs2_log.c b/gfs2/libgfs2/gfs2_log.c
index 8103a62..f9f61b2 100644
--- a/gfs2/libgfs2/gfs2_log.c
+++ b/gfs2/libgfs2/gfs2_log.c
@@ -39,7 +39,7 @@ void decrease_verbosity(void)
_state.print_level--;
}
-void print_msg(int priority, char *file, int line, const char *format,
+void print_msg(int priority, const char *file, int line, const char *format,
va_list args) {
switch (priority) {
@@ -65,8 +65,8 @@ void print_msg(int priority, char *file, int line, const char *format,
}
-void print_fsck_log(int iif, int priority, char *file, int line,
- const char *format, ...)
+void print_fsck_log(int iif, int priority, const char *file, int line,
+ const char *format, ...)
{
va_list args;
@@ -83,7 +83,7 @@ void print_fsck_log(int iif, int priority, char *file, int line,
va_end(args);
}
-char gfs2_getch(void)
+static char gfs2_getch(void)
{
struct termios termattr, savetermattr;
char ch;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 167aef0..ffd673c 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -267,7 +267,7 @@ struct metapath {
unsigned int mp_list[GFS2_MAX_META_HEIGHT];
};
-extern char *prog_name;
+extern const char *prog_name;
#define GFS2_DEFAULT_BSIZE (4096)
#define GFS2_DEFAULT_JSIZE (128)
@@ -381,7 +381,6 @@ struct gfs2_block_list *gfs2_block_list_create(struct gfs2_sbd *sdp,
uint64_t *addl_mem_needed);
struct special_blocks *blockfind(struct special_blocks *blist, uint64_t num);
void gfs2_special_set(struct special_blocks *blocklist, uint64_t block);
-void gfs2_special_clear(struct special_blocks *blocklist, uint64_t block);
void gfs2_special_free(struct special_blocks *blist);
int gfs2_block_mark(struct gfs2_sbd *sdp, struct gfs2_block_list *il,
uint64_t block, enum gfs2_mark_block mark);
@@ -439,8 +438,6 @@ int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, int state);
/* fs_geometry.c */
void rgblocks2bitblocks(unsigned int bsize, uint32_t *rgblocks,
uint32_t *bitblocks);
-uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev,
- int rgsize_specified);
void compute_rgrp_layout(struct gfs2_sbd *sdp, int rgsize_specified);
void build_rgrps(struct gfs2_sbd *sdp, int write);
@@ -647,9 +644,8 @@ do { print_log(1, MSG_CRITICAL, format); } while(0)
void increase_verbosity(void);
void decrease_verbosity(void);
-void print_fsck_log(int iif, int priority, char *file, int line,
+void print_fsck_log(int iif, int priority, const char *file, int line,
const char *format, ...);
-char gfs2_getch(void);
char generic_interrupt(const char *caller, const char *where,
const char *progress, const char *question,
@@ -676,8 +672,7 @@ char *mp2fsname2(char *devname);
char *name2value(char *str, char *name);
uint32_t name2u32(char *str, char *name);
uint64_t name2u64(char *str, char *name);
-char *__get_sysfs(char *fsname, char *filename);
-char *get_sysfs(char *fsname, char *filename);
+char *get_sysfs(const char *fsname, const char *filename);
unsigned int get_sysfs_uint(char *fsname, char *filename);
void set_sysfs(char *fsname, char *filename, char *val);
char *do_basename(char *device);
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index 2c475a0..5a4e42b 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -60,8 +60,7 @@ uint32_t compute_heightsize(struct gfs2_sbd *sdp, uint64_t *heightsize,
return x;
}
-void
-compute_constants(struct gfs2_sbd *sdp)
+void compute_constants(struct gfs2_sbd *sdp)
{
uint32_t hash_blocks, ind_blocks, leaf_blocks;
uint32_t tmp_blocks;
@@ -239,8 +238,7 @@ mount_gfs2_meta(struct gfs2_sbd *sdp)
lock_for_admin(sdp);
}
-void
-cleanup_metafs(struct gfs2_sbd *sdp)
+void cleanup_metafs(struct gfs2_sbd *sdp)
{
int ret;
@@ -257,7 +255,7 @@ cleanup_metafs(struct gfs2_sbd *sdp)
rmdir(sdp->metafs_path);
}
-char *__get_sysfs(char *fsname, char *filename)
+static char *__get_sysfs(const char *fsname, const char *filename)
{
char path[PATH_MAX];
int fd, rv;
@@ -277,8 +275,7 @@ char *__get_sysfs(char *fsname, char *filename)
return sysfs_buf;
}
-char *
-get_sysfs(char *fsname, char *filename)
+char *get_sysfs(const char *fsname, const char *filename)
{
char *p = strchr(__get_sysfs(fsname, filename), '\n');
if (p)
@@ -581,8 +578,7 @@ int is_fsname(char *name)
* Returns: the fsname
*/
-char *
-mp2fsname(char *mp)
+char *mp2fsname(char *mp)
{
char device_id[PATH_MAX], *fsname = NULL;
struct stat statbuf;
@@ -627,7 +623,6 @@ mp2fsname2(char *mp)
struct stat statbuf;
DIR *d;
struct dirent *de;
- struct gfs2_sbd sb;
FILE *fp = fopen("/proc/mounts", "r");
char buffer[PATH_MAX], device_name[PATH_MAX];
int fsdump, fspass, ret, found = 0;
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index 800efcb..7bebb3f 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -149,15 +149,15 @@ uint64_t gfs2_rgrp_read(struct gfs2_sbd *sdp, struct rgrp_list *rgd)
return 0;
}
-void gfs2_rgrp_relse(struct rgrp_list *rgd, enum update_flags updated)
+void gfs2_rgrp_relse(struct rgrp_list *rgd, enum update_flags is_updated)
{
int x, length = rgd->ri.ri_length;
for (x = 0; x < length; x++)
- brelse(rgd->bh[x], updated);
+ brelse(rgd->bh[x], is_updated);
}
-void gfs2_rgrp_free(osi_list_t *rglist, enum update_flags updated)
+void gfs2_rgrp_free(osi_list_t *rglist, enum update_flags is_updated)
{
struct rgrp_list *rgd;
@@ -165,7 +165,7 @@ void gfs2_rgrp_free(osi_list_t *rglist, enum update_flags updated)
rgd = osi_list_entry(rglist->next, struct rgrp_list, list);
if (rgd->bh && rgd->bh[0] && /* if a buffer exists and */
rgd->bh[0]->b_count) /* the 1st buffer is allocated */
- gfs2_rgrp_relse(rgd, updated); /* free them all. */
+ gfs2_rgrp_relse(rgd, is_updated); /* free them all. */
if(rgd->bits)
free(rgd->bits);
if(rgd->bh) {
diff --git a/gfs2/libgfs2/size.c b/gfs2/libgfs2/size.c
index 12b40c5..4aa7d34 100644
--- a/gfs2/libgfs2/size.c
+++ b/gfs2/libgfs2/size.c
@@ -36,8 +36,7 @@
* Returns: -1 on error (with errno set), 0 on success (with @bytes set)
*/
-static int
-do_device_size(int fd, uint64_t *bytes)
+static int do_device_size(int fd, uint64_t *bytes)
{
off_t off;
#if 0
@@ -71,8 +70,7 @@ do_device_size(int fd, uint64_t *bytes)
* Returns: -1 on error (with errno set), 0 on success (with @bytes set)
*/
-int
-device_size(int fd, uint64_t *bytes)
+int device_size(int fd, uint64_t *bytes)
{
struct stat st;
int error;
diff --git a/gfs2/mkfs/main.c b/gfs2/mkfs/main.c
index 359b1c3..5a1ebba 100644
--- a/gfs2/mkfs/main.c
+++ b/gfs2/mkfs/main.c
@@ -31,7 +31,7 @@
#include "libgfs2.h"
#include "gfs2_mkfs.h"
-char *prog_name;
+const char *prog_name;
/**
* main - do everything
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 6e52a56..879f399 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -70,7 +70,7 @@ static void usage(void)
" -v Verbose, increase verbosity\n"));
}
-void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
+static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
{
int opt;
@@ -121,7 +121,7 @@ void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
/**
* figure_out_rgsize
*/
-void figure_out_rgsize(struct gfs2_sbd *sdp, unsigned int *rgsize)
+static void figure_out_rgsize(struct gfs2_sbd *sdp, unsigned int *orgsize)
{
osi_list_t *head = &sdp->rglist;
struct rgrp_list *r1, *r2;
@@ -130,7 +130,7 @@ void figure_out_rgsize(struct gfs2_sbd *sdp, unsigned int *rgsize)
r1 = osi_list_entry(head->next->next, struct rgrp_list, list);
r2 = osi_list_entry(head->next->next->next, struct rgrp_list, list);
- *rgsize = r2->ri.ri_addr - r1->ri.ri_addr;
+ *orgsize = r2->ri.ri_addr - r1->ri.ri_addr;
}
/**
@@ -142,7 +142,7 @@ void figure_out_rgsize(struct gfs2_sbd *sdp, unsigned int *rgsize)
* Returns: The calculated size
*/
-uint64_t filesystem_size(struct gfs2_sbd *sdp)
+static uint64_t filesystem_size(struct gfs2_sbd *sdp)
{
osi_list_t *tmp;
struct rgrp_list *rgl;
@@ -164,7 +164,7 @@ uint64_t filesystem_size(struct gfs2_sbd *sdp)
/**
* initialize_new_portion - Write the new rg information to disk buffers.
*/
-void initialize_new_portion(struct gfs2_sbd *sdp, int *old_rg_count)
+static void initialize_new_portion(struct gfs2_sbd *sdp, int *old_rg_count)
{
uint64_t rgrp = 0;
osi_list_t *head = &sdp->rglist;
@@ -193,7 +193,7 @@ void initialize_new_portion(struct gfs2_sbd *sdp, int *old_rg_count)
/**
* fix_rindex - Add the new entries to the end of the rindex file.
*/
-void fix_rindex(struct gfs2_sbd *sdp, int rindex_fd, int old_rg_count)
+static void fix_rindex(struct gfs2_sbd *sdp, int rindex_fd, int old_rg_count)
{
int count, rg;
struct rgrp_list *rl;
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index 4b5eb74..ce47ebd 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -36,8 +36,8 @@
#define BUF_SIZE 4096
-void
-make_jdata(int fd, char *value)
+static void
+make_jdata(int fd, const char *value)
{
int err;
uint32_t val;
@@ -54,8 +54,8 @@ make_jdata(int fd, char *value)
die( _("error doing set flags (%d): %s\n"), err, strerror(errno));
}
-int
-rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name)
+static int
+rename2system(struct gfs2_sbd *sdp, const char *new_dir, const char *new_name)
{
char oldpath[PATH_MAX], newpath[PATH_MAX];
int error = 0;
@@ -77,8 +77,7 @@ rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name)
*
*/
-static void
-print_usage(void)
+static void print_usage(void)
{
printf( _("Usage:\n\n"
"%s [options] /path/to/filesystem\n\n"
@@ -100,8 +99,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;
@@ -205,7 +203,7 @@ print_results(struct gfs2_sbd *sdp)
}
-int
+static int
create_new_inode(struct gfs2_sbd *sdp)
{
char name[PATH_MAX];
@@ -232,7 +230,7 @@ create_new_inode(struct gfs2_sbd *sdp)
return fd;
}
-void
+static void
add_ir(struct gfs2_sbd *sdp)
{
int fd;
@@ -257,7 +255,7 @@ add_ir(struct gfs2_sbd *sdp)
new_name, error, strerror(errno));
}
-void
+static void
add_sc(struct gfs2_sbd *sdp)
{
int fd;
@@ -283,7 +281,7 @@ add_sc(struct gfs2_sbd *sdp)
new_name, error, strerror(errno));
}
-void
+static void
add_qc(struct gfs2_sbd *sdp)
{
int fd;
@@ -376,7 +374,7 @@ gather_info(struct gfs2_sbd *sdp)
}
#endif
-void
+static void
find_current_journals(struct gfs2_sbd *sdp)
{
char jindex[PATH_MAX];
@@ -407,7 +405,7 @@ close:
sdp->orig_journals = existing_journals;
}
-void
+static void
add_j(struct gfs2_sbd *sdp)
{
int fd;
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 3456f6d..9eb4761 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -35,7 +35,7 @@
#include "gfs2_mkfs.h"
#include "libvolume_id.h"
-char *prog_name;
+const char *prog_name;
/**
* This function is for libgfs2's sake.
@@ -300,7 +300,7 @@ static void are_you_sure(struct gfs2_sbd *sdp)
*
*/
-void check_mount(char *device)
+static void check_mount(char *device)
{
struct stat st_buf;
int fd;
diff --git a/gfs2/mount/mount.gfs2.c b/gfs2/mount/mount.gfs2.c
index 4097915..d8a60c3 100644
--- a/gfs2/mount/mount.gfs2.c
+++ b/gfs2/mount/mount.gfs2.c
@@ -8,7 +8,7 @@
#include "util.h"
-char *prog_name;
+const char *prog_name;
char *fsname;
int verbose, fake_mount = 0, no_mtab = 0;
static sigset_t old_sigset;
diff --git a/gfs2/mount/umount.gfs2.c b/gfs2/mount/umount.gfs2.c
index acf91f0..c42b80e 100644
--- a/gfs2/mount/umount.gfs2.c
+++ b/gfs2/mount/umount.gfs2.c
@@ -8,7 +8,7 @@
#include "util.h"
-char *prog_name;
+const char *prog_name;
char *fsname;
char *expert;
int verbose;
diff --git a/gfs2/mount/util.c b/gfs2/mount/util.c
index 4c5bb06..2970d33 100644
--- a/gfs2/mount/util.c
+++ b/gfs2/mount/util.c
@@ -20,7 +20,7 @@ static int adding_another_mountpoint;
/* opt_map stuff from util-linux */
struct opt_map {
- char *opt; /* option name */
+ const char *opt; /* option name */
int skip; /* skip in mtab option string (gfs: not used) */
int inv; /* true if flag value should be inverted */
int mask; /* flag mask value */
@@ -237,7 +237,7 @@ void read_proc_mounts(struct mount_options *mo)
log_debug("read_proc_mounts: opts = \"%s\"", mo->opts);
}
-void gfs2_inum_in(struct gfs2_inum *no, char *buf)
+static void gfs2_inum_in(struct gfs2_inum *no, char *buf)
{
struct gfs2_inum *str = (struct gfs2_inum *)buf;
@@ -245,7 +245,7 @@ void gfs2_inum_in(struct gfs2_inum *no, char *buf)
no->no_addr = be64_to_cpu(str->no_addr);
}
-void gfs2_meta_header_in(struct gfs2_meta_header *mh, char *buf)
+static void gfs2_meta_header_in(struct gfs2_meta_header *mh, char *buf)
{
struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf;
@@ -254,7 +254,7 @@ void gfs2_meta_header_in(struct gfs2_meta_header *mh, char *buf)
mh->mh_format = be32_to_cpu(str->mh_format);
}
-void gfs2_sb_in(struct gfs2_sb *sb, char *buf)
+static void gfs2_sb_in(struct gfs2_sb *sb, char *buf)
{
struct gfs2_sb *str = (struct gfs2_sb *)buf;
diff --git a/gfs2/quota/check.c b/gfs2/quota/check.c
index 59c287f..0a1c1e3 100644
--- a/gfs2/quota/check.c
+++ b/gfs2/quota/check.c
@@ -320,7 +320,7 @@ print_list(char *str, osi_list_t *list)
*/
static int
-do_compare(char *type, osi_list_t *fs_list, osi_list_t *qf_list)
+do_compare(const char *type, osi_list_t *fs_list, osi_list_t *qf_list)
{
osi_list_t *tmp1, *tmp2;
values_t *v1, *v2;
diff --git a/gfs2/quota/gfs2_quota.h b/gfs2/quota/gfs2_quota.h
index a929dfa..064c813 100644
--- a/gfs2/quota/gfs2_quota.h
+++ b/gfs2/quota/gfs2_quota.h
@@ -79,7 +79,7 @@ extern char *prog_name;
void do_get_super(int fd, struct gfs2_sb *sb);
void do_sync(struct gfs2_sbd *sdp, commandline_t *comline);
-void cleanup();
+void cleanup(void);
void read_superblock(struct gfs2_sb *sb, struct gfs2_sbd *sdp);
inline void read_quota_internal(int fd, unsigned int id, int id_type,
struct gfs2_quota *q);
diff --git a/gfs2/quota/main.c b/gfs2/quota/main.c
index 36b6f2d..0136d18 100644
--- a/gfs2/quota/main.c
+++ b/gfs2/quota/main.c
@@ -43,7 +43,7 @@
#define OPTION_STRING ("bdf:g:hkl:mnsu:V")
#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
-char *prog_name;
+const char *prog_name;
/**
* This function is for libgfs2's sake.
diff --git a/gfs2/tool/gfs2_tool.h b/gfs2/tool/gfs2_tool.h
index e67da9c..2dd0f88 100644
--- a/gfs2/tool/gfs2_tool.h
+++ b/gfs2/tool/gfs2_tool.h
@@ -19,7 +19,6 @@
#define OUTPUT_K 1
#define OUTPUT_HUMAN 2
-extern char *prog_name;
extern char *action;
extern int override;
extern int expert;
diff --git a/gfs2/tool/main.c b/gfs2/tool/main.c
index a2529c2..7c37734 100644
--- a/gfs2/tool/main.c
+++ b/gfs2/tool/main.c
@@ -33,7 +33,7 @@
#include "gfs2_tool.h"
#include "libgfs2.h"
-char *prog_name;
+const char *prog_name;
char *action = NULL;
int override = FALSE;
int expert = FALSE;
diff --git a/gfs2/tool/sb.c b/gfs2/tool/sb.c
index cf76d6e..44f4443 100644
--- a/gfs2/tool/sb.c
+++ b/gfs2/tool/sb.c
@@ -49,7 +49,7 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)
* str_to_hexchar - convert a string consisting of two isxdigits back to hex.
* Returns: the hex character
*/
-int str_to_hexchar(const char *estring)
+static int str_to_hexchar(const char *estring)
{
int ch = 0;
14 years, 1 month
cluster: RHEL56 - gfs2: Add gettext support
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 0fb59c1416efb28367ca5fb06221edb9ecf49423
Parent: f35e432fd553ecc59486b56a91748097f10af96b
Author: Bob Peterson <bob(a)ganesha.peterson>
AuthorDate: Mon Feb 15 10:43:06 2010 -0600
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Fri Apr 9 22:36:19 2010 -0500
gfs2: Add gettext support
This patch is a crosswrite of patch ead42ed from STABLE3 to RHEL55.
This roughs in internationalization by translating the majority of
messages to use gettext. This is necessary because with it, GFS2
patches are very difficult to back-port from upstream.
rhbz#455300
---
gfs2/fsck/eattr.c | 9 +-
gfs2/fsck/fs_recovery.c | 100 +++++++-------
gfs2/fsck/initialize.c | 77 ++++++-----
gfs2/fsck/link.c | 28 ++--
gfs2/fsck/lost_n_found.c | 26 ++--
gfs2/fsck/main.c | 120 +++++++++--------
gfs2/fsck/metawalk.c | 199 +++++++++++++++------------
gfs2/fsck/pass1.c | 319 +++++++++++++++++++++++--------------------
gfs2/fsck/pass1b.c | 154 ++++++++++++---------
gfs2/fsck/pass1c.c | 64 +++++-----
gfs2/fsck/pass2.c | 248 +++++++++++++++++----------------
gfs2/fsck/pass3.c | 98 +++++++-------
gfs2/fsck/pass4.c | 80 ++++++-----
gfs2/fsck/pass5.c | 82 ++++++------
gfs2/fsck/rgrepair.c | 93 +++++++------
gfs2/fsck/test_block_list.c | 6 +-
gfs2/fsck/util.c | 4 +-
gfs2/mkfs/main.c | 7 +-
gfs2/mkfs/main_grow.c | 60 ++++----
gfs2/mkfs/main_jadd.c | 81 ++++++------
gfs2/mkfs/main_mkfs.c | 127 +++++++++---------
gfs2/tool/main.c | 10 +-
gfs2/tool/misc.c | 31 ++--
gfs2/tool/sb.c | 51 ++++----
gfs2/tool/tune.c | 14 +-
25 files changed, 1104 insertions(+), 984 deletions(-)
diff --git a/gfs2/fsck/eattr.c b/gfs2/fsck/eattr.c
index 5f43ba6..675a2fc 100644
--- a/gfs2/fsck/eattr.c
+++ b/gfs2/fsck/eattr.c
@@ -12,7 +12,8 @@
#include <stdint.h>
#include <string.h>
-#include <linux_endian.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "libgfs2.h"
#include "fsck.h"
@@ -27,7 +28,7 @@ static int clear_blk_nodup(struct gfs2_sbd *sbp, uint64_t block)
}
if(q.dup_block) {
- log_debug("Not clearing block with marked as a duplicate\n");
+ log_debug( _("Not clearing block with marked as a duplicate\n"));
return 1;
}
@@ -87,8 +88,8 @@ int clear_eattr_entry (struct gfs2_inode *ip,
if(max_ptrs > ea_hdr->ea_num_ptrs) {
return 1;
} else {
- log_debug(" Pointers Required: %d\n"
- " Pointers Reported: %d\n",
+ log_debug( _(" Pointers Required: %d\n"
+ " Pointers Reported: %d\n"),
max_ptrs,
ea_hdr->ea_num_ptrs);
}
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index a90aa77..e6e0396 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -18,6 +18,8 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "fsck.h"
#include "fs_recovery.h"
@@ -365,16 +367,16 @@ int fix_journal_seq_no(struct gfs2_inode *ip)
prev_seq = lh.lh_sequence;
continue;
}
- log_err("Journal block %u (0x%x): sequence no. 0x%llx out of "
- "order.\n", blk, blk, lh.lh_sequence);
- log_info("Low: 0x%llx, High: 0x%llx, Prev: 0x%llx\n",
- (unsigned long long)lowest_seq,
- (unsigned long long)highest_seq,
- (unsigned long long)prev_seq);
+ log_err( _("Journal block %u (0x%x): sequence no. 0x%llx "
+ "out of order.\n"), blk, blk, lh.lh_sequence);
+ log_info( _("Low: 0x%llx, High: 0x%llx, Prev: 0x%llx\n"),
+ (unsigned long long)lowest_seq,
+ (unsigned long long)highest_seq,
+ (unsigned long long)prev_seq);
highest_seq++;
lh.lh_sequence = highest_seq;
prev_seq = lh.lh_sequence;
- log_warn("Renumbering it as 0x%llx\n", lh.lh_sequence);
+ log_warn( _("Renumbering it as 0x%llx\n"), lh.lh_sequence);
block_map(ip, blk, &new, &dblock, &extlen, FALSE, not_updated);
bh = bread(&ip->i_sbd->buf_list, dblock);
gfs2_log_header_out(&lh, bh->b_data);
@@ -428,74 +430,76 @@ static int gfs2_recover_journal(struct gfs2_inode *ip, int j, int preen,
int error;
*was_clean = 0;
- log_info("jid=%u: Looking at journal...\n", j);
+ log_info( _("jid=%u: Looking at journal...\n"), j);
osi_list_init(&sd_revoke_list);
error = gfs2_find_jhead(ip, &head);
if (error) {
if (opts.no) {
- log_err("Journal #%d (\"journal%d\") is corrupt.\n"
- "Not fixing it due to the -n option.\n",
+ log_err( _("Journal #%d (\"journal%d\") is corrupt.\n"
+ "Not fixing it due to the -n option.\n"),
j+1, j);
goto out;
}
if (!preen_is_safe(sdp, preen, force_check)) {
- log_err("Journal #%d (\"journal%d\") is corrupt.\n",
+ log_err(_("Journal #%d (\"journal%d\") is corrupt.\n"),
j+1, j);
- log_err("I'm not fixing it because it may be unsafe:\n"
- "Locking protocol is not lock_nolock and "
- "the -a or -p option was specified.\n");
- log_err("Please make sure no node has the file system "
- "mounted then rerun fsck.gfs2 manually "
- "without -a or -p.\n");
+ log_err(_("I'm not fixing it because it may be unsafe:\n"
+ "Locking protocol is not lock_nolock and "
+ "the -a or -p option was specified.\n"));
+ log_err(_("Please make sure no node has the file system "
+ "mounted then rerun fsck.gfs2 manually "
+ "without -a or -p.\n"));
goto out;
}
- if (!query(&opts, "\nJournal #%d (\"journal%d\") is "
- "corrupt. Okay to repair it? (y/n)",
+ if (!query(&opts, _("\nJournal #%d (\"journal%d\") is "
+ "corrupt. Okay to repair it? (y/n)"),
j+1, j)) {
- log_err("jid=%u: The journal was not repaired.\n",
- j);
+ log_err( _("jid=%u: The journal was not repaired.\n"),
+ j);
goto out;
}
- log_info("jid=%u: Repairing journal...\n", j);
+ log_info( _("jid=%u: Repairing journal...\n"), j);
error = fix_journal_seq_no(ip);
if (error) {
- log_err("jid=%u: Unable to repair the bad journal.\n",
- j);
+ log_err( _("jid=%u: Unable to repair the bad "
+ "journal.\n"), j);
goto out;
}
error = gfs2_find_jhead(ip, &head);
if (error) {
- log_err("jid=%u: Unable to fix the bad journal.\n", j);
+ log_err( _("jid=%u: Unable to fix the bad journal.\n"),
+ j);
goto out;
}
- log_err("jid=%u: The journal was successfully fixed.\n", j);
+ log_err( _("jid=%u: The journal was successfully fixed.\n"),
+ j);
}
if (head.lh_flags & GFS2_LOG_HEAD_UNMOUNT) {
- log_info("jid=%u: Journal is clean.\n", j);
+ log_info( _("jid=%u: Journal is clean.\n"), j);
*was_clean = 1;
return 0;
}
if (opts.no) {
- log_err("Journal #%d (\"journal%d\") is dirty; not replaying"
- " due to the -n option.\n",
+ log_err(_("Journal #%d (\"journal%d\") is dirty; not replaying"
+ " due to the -n option.\n"),
j+1, j);
goto out;
}
if (!preen_is_safe(sdp, preen, force_check)) {
- log_err("Journal #%d (\"journal%d\") is dirty.\n", j+1, j);
- log_err("I'm not replaying it because it may be unsafe:\n"
- "Locking protocol is not lock_nolock and "
- "the -a or -p option was specified.\n");
- log_err("Please make sure no node has the file system "
- "mounted then rerun fsck.gfs2 manually "
- "without -a or -p.\n");
+ log_err( _("Journal #%d (\"journal%d\") is dirty.\n"), j+1, j);
+ log_err( _("I'm not replaying it because it may be unsafe:\n"
+ "Locking protocol is not lock_nolock and "
+ "the -a or -p option was specified.\n"));
+ log_err( _("Please make sure no node has the file system "
+ "mounted then rerun fsck.gfs2 manually "
+ "without -a or -p.\n"));
error = FSCK_ERROR;
goto out;
}
- if (query(&opts, "\nJournal #%d (\"journal%d\") is dirty. Okay to "
- "replay it? (y/n)", j+1, j)) {
- log_info("jid=%u: Replaying journal...\n", j);
+ if (query(&opts, _("\nJournal #%d (\"journal%d\") is dirty. Okay to "
+ "replay it? (y/n)"), j+1, j)) {
+ log_info( _("jid=%u: Replaying journal...\n"), j);
sd_found_jblocks = sd_replayed_jblocks = 0;
sd_found_metablocks = sd_replayed_metablocks = 0;
@@ -507,28 +511,28 @@ static int gfs2_recover_journal(struct gfs2_inode *ip, int j, int preen,
if (error)
goto out;
}
- log_info("jid=%u: Found %u revoke tags\n", j,
+ log_info( _("jid=%u: Found %u revoke tags\n"), j,
sd_found_revokes);
gfs2_revoke_clean(sdp);
error = clean_journal(ip, &head);
if (error)
goto out;
- log_err("jid=%u: Replayed %u of %u journaled data blocks\n",
+ log_err( _("jid=%u: Replayed %u of %u journaled data blocks\n"),
j, sd_replayed_jblocks, sd_found_jblocks);
- log_err("jid=%u: Replayed %u of %u metadata blocks\n",
+ log_err( _("jid=%u: Replayed %u of %u metadata blocks\n"),
j, sd_replayed_metablocks, sd_found_metablocks);
} else {
- if (query(&opts, "Do you want to clear the dirty journal instead? (y/n)")) {
+ if (query(&opts, _("Do you want to clear the dirty journal instead? (y/n)"))) {
write_journal(sdp, sdp->md.journal[j], j,
sdp->md.journal[j]->i_di.di_size /
sdp->sd_sb.sb_bsize);
} else
- log_err("jid=%u: Dirty journal not replayed or cleared.\n", j);
+ log_err( _("jid=%u: Dirty journal not replayed or cleared.\n"), j);
}
out:
- log_info("jid=%u: %s\n", j, (error) ? "Failed" : "Done");
+ log_info( _("jid=%u: %s\n"), j, (error) ? _("Failed") : _("Done"));
return error;
}
@@ -560,7 +564,7 @@ int replay_journals(struct gfs2_sbd *sdp, int preen, int force_check,
/* read in the journal index data */
if (ji_update(sdp)){
- log_err("Unable to read in jindex inode.\n");
+ log_err( _("Unable to read in jindex inode.\n"));
return -1;
}
@@ -574,8 +578,8 @@ int replay_journals(struct gfs2_sbd *sdp, int preen, int force_check,
if (!gave_msg && dirty_journals == 1 && !opts.no &&
preen_is_safe(sdp, preen, force_check)) {
gave_msg = 1;
- log_notice("Recovering journals (this may "
- "take a while)\n");
+ log_notice( _("Recovering journals (this may "
+ "take a while)\n"));
}
*clean_journals += clean;
}
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 93fef78..48e71c3 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -21,8 +21,11 @@
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
+#include <libintl.h>
#include <errno.h>
+#define _(String) gettext(String)
+
#include "libgfs2.h"
#include "fsck.h"
#include "util.h"
@@ -83,13 +86,13 @@ static void empty_super_block(struct gfs2_sbd *sdp)
{
uint32_t i;
- log_info("Freeing buffers.\n");
+ log_info( _("Freeing buffers.\n"));
while(!osi_list_empty(&sdp->rglist)){
struct rgrp_list *rgd;
rgd = osi_list_entry(sdp->rglist.next, struct rgrp_list, list);
- log_debug("Deleting rgd for 0x%p: rgd=0x%p bits=0x%p\n",
- rgd->ri.ri_addr, rgd, rgd->bits);
+ log_debug( _("Deleting rgd for 0x%llx: rgd=0x%p bits=0x%p\n"),
+ (unsigned long long)rgd->ri.ri_addr, rgd, rgd->bits);
osi_list_del(&rgd->list);
if(rgd->bits)
free(rgd->bits);
@@ -136,7 +139,7 @@ static int set_block_ranges(struct gfs2_sbd *sdp)
uint64_t rmin = 0;
int error;
- log_info("Setting block ranges...\n");
+ log_info( _("Setting block ranges...\n"));
for (tmp = sdp->rglist.next; tmp != &sdp->rglist; tmp = tmp->next)
{
@@ -150,9 +153,10 @@ static int set_block_ranges(struct gfs2_sbd *sdp)
last_fs_block = rmax;
if (last_fs_block > 0xffffffff && sizeof(unsigned long) <= 4) {
- log_crit("This file system is too big for this computer to handle.\n");
- log_crit("Last fs block = 0x%llx, but sizeof(unsigned long) is %d bytes.\n",
- last_fs_block, sizeof(unsigned long));
+ log_crit( _("This file system is too big for this computer to handle.\n"));
+ log_crit( _("Last fs block = 0x%llx, but sizeof(unsigned long) is %zu bytes.\n"),
+ (unsigned long long)last_fs_block,
+ sizeof(unsigned long));
goto fail;
}
@@ -160,16 +164,16 @@ static int set_block_ranges(struct gfs2_sbd *sdp)
first_data_block = rmin;
if(fsck_lseek(sdp->device_fd, (last_fs_block * sdp->sd_sb.sb_bsize))){
- log_crit("Can't seek to last block in file system: %"
- PRIu64" (0x%" PRIx64 ")\n", last_fs_block, last_fs_block);
+ log_crit( _("Can't seek to last block in file system: %"
+ PRIu64" (0x%" PRIx64 ")\n"), last_fs_block, last_fs_block);
goto fail;
}
memset(buf, 0, sdp->sd_sb.sb_bsize);
error = read(sdp->device_fd, buf, sdp->sd_sb.sb_bsize);
if (error != sdp->sd_sb.sb_bsize){
- log_crit("Can't read last block in file system (error %u), "
- "last_fs_block: %"PRIu64" (0x%" PRIx64 ")\n", error,
+ log_crit( _("Can't read last block in file system (error %u), "
+ "last_fs_block: %"PRIu64" (0x%" PRIx64 ")\n"), error,
last_fs_block, last_fs_block);
goto fail;
}
@@ -198,7 +202,7 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
****************** Initialize important inodes ******************
*******************************************************************/
- log_info("Initializing special inodes...\n");
+ log_info( _("Initializing special inodes...\n"));
/* Get master dinode */
sdp->master_dir = gfs2_load_inode(sdp,
@@ -237,41 +241,42 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
/* read in the ji data */
if (ji_update(sdp)){
- log_err("Unable to read in ji inode.\n");
+ log_err( _("Unable to read in ji inode.\n"));
return -1;
}
- log_warn("Validating Resource Group index.\n");
+ log_warn( _("Validating Resource Group index.\n"));
for (trust_lvl = blind_faith; trust_lvl <= distrust; trust_lvl++) {
- log_warn("Level %d RG check.\n", trust_lvl + 1);
+ log_warn( _("Level %d RG check.\n"), trust_lvl + 1);
if ((rg_repair(sdp, trust_lvl, &rgcount) == 0) &&
(ri_update(sdp, 0, &rgcount) == 0)) {
- log_warn("(level %d passed)\n", trust_lvl + 1);
+ log_warn( _("(level %d passed)\n"), trust_lvl + 1);
break;
}
else
- log_err("(level %d failed)\n", trust_lvl + 1);
+ log_err( _("(level %d failed)\n"), trust_lvl + 1);
}
if (trust_lvl > distrust) {
- log_err("RG recovery impossible; I can't fix this file system.\n");
+ log_err( _("RG recovery impossible; I can't fix this file system.\n"));
return -1;
}
- log_info("%u resource groups found.\n", rgcount);
+ log_info( _("%u resource groups found.\n"), rgcount);
/*******************************************************************
******* Now, set boundary fields in the super block *************
*******************************************************************/
if(set_block_ranges(sdp)){
- log_err("Unable to determine the boundaries of the"
- " file system.\n");
+ log_err( _("Unable to determine the boundaries of the"
+ " file system.\n"));
goto fail;
}
bl = gfs2_block_list_create(sdp, last_fs_block+1, &addl_mem_needed);
if (!bl) {
- log_crit("This system doesn't have enough memory + swap space to fsck this file system.\n");
- log_crit("Additional memory needed is approximately: %ldMB\n", addl_mem_needed / 1048576);
- log_crit("Please increase your swap space by that amount and run gfs2_fsck again.\n");
+ log_crit( _("This system doesn't have enough memory + swap space to fsck this file system.\n"));
+ log_crit( _("Additional memory needed is approximately: %lluMB\n"),
+ (unsigned long long)(addl_mem_needed / 1048576ULL));
+ log_crit( _("Please increase your swap space by that amount and run gfs2_fsck again.\n"));
goto fail;
}
return 0;
@@ -296,7 +301,7 @@ static int fill_super_block(struct gfs2_sbd *sdp)
/********************************************************************
***************** First, initialize all lists **********************
********************************************************************/
- log_info("Initializing lists...\n");
+ log_info( _("Initializing lists...\n"));
osi_list_init(&sdp->rglist);
init_buf_list(sdp, &sdp->buf_list, 128 << 20);
init_buf_list(sdp, &sdp->nvbuf_list, 0xffffffff);
@@ -312,8 +317,8 @@ static int fill_super_block(struct gfs2_sbd *sdp)
sdp->bsize = sdp->sd_sb.sb_bsize;
if(sizeof(struct gfs2_sb) > sdp->sd_sb.sb_bsize){
- log_crit("GFS superblock is larger than the blocksize!\n");
- log_debug("sizeof(struct gfs2_sb) > sdp->sd_sb.sb_bsize\n");
+ log_crit( _("GFS superblock is larger than the blocksize!\n"));
+ log_debug( _("sizeof(struct gfs2_sb) > sdp->sd_sb.sb_bsize\n"));
return -1;
}
@@ -346,7 +351,7 @@ int initialize(struct gfs2_sbd *sbp, int force_check, int preen,
int is_mounted, ro;
if (open_flag == O_RDONLY || errno != EBUSY) {
- log_crit("Unable to open device: %s\n", opts.device);
+ log_crit( _("Unable to open device: %s\n"), opts.device);
return FSCK_USAGE;
}
/* We can't open it EXCL. It may be already open rw (in which
@@ -388,7 +393,7 @@ int initialize(struct gfs2_sbd *sbp, int force_check, int preen,
/* Change lock protocol to be fsck_* instead of lock_* */
if(!opts.no && preen_is_safe(sbp, preen, force_check)) {
if(block_mounters(sbp, 1)) {
- log_err("Unable to block other mounters\n");
+ log_err( _("Unable to block other mounters\n"));
return FSCK_USAGE;
}
}
@@ -405,7 +410,7 @@ int initialize(struct gfs2_sbd *sbp, int force_check, int preen,
*all_clean = 1;
else {
if (force_check || !preen)
- log_notice("\nJournal recovery complete.\n");
+ log_notice( _("\nJournal recovery complete.\n"));
}
if (!force_check && *all_clean && preen)
@@ -417,7 +422,7 @@ int initialize(struct gfs2_sbd *sbp, int force_check, int preen,
return FSCK_OK;
mount_fail:
- log_crit("Device %s is busy.\n", opts.device);
+ log_crit( _("Device %s is busy.\n"), opts.device);
return FSCK_USAGE;
}
@@ -425,10 +430,10 @@ static void destroy_sbp(struct gfs2_sbd *sbp)
{
if(!opts.no) {
if(block_mounters(sbp, 0)) {
- log_warn("Unable to unblock other mounters - manual intervention required\n");
- log_warn("Use 'gfs2_tool sb <device> proto' to fix\n");
+ log_warn( _("Unable to unblock other mounters - manual intervention required\n"));
+ log_warn( _("Use 'gfs2_tool sb <device> proto' to fix\n"));
}
- log_info("Syncing the device.\n");
+ log_info( _("Syncing the device.\n"));
fsync(sbp->device_fd);
}
empty_super_block(sbp);
@@ -439,8 +444,8 @@ static void destroy_sbp(struct gfs2_sbd *sbp)
write(sbp->device_fd, "2", 1);
close(sbp->device_fd);
} else
- log_err("fsck.gfs2: Non-fatal error dropping "
- "caches.\n");
+ log_err( _("fsck.gfs2: Non-fatal error dropping "
+ "caches.\n"));
}
}
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index fa01b42..96dc261 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -16,6 +16,8 @@
#include <stdint.h>
#include <string.h>
#include <unistd.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "libgfs2.h"
#include "fsck.h"
@@ -25,15 +27,15 @@
int set_link_count(struct gfs2_sbd *sbp, uint64_t inode_no, uint32_t count)
{
struct inode_info *ii = NULL;
- log_debug("Setting link count to %u for %" PRIu64 " (0x%" PRIx64 ")\n",
+ log_debug( _("Setting link count to %u for %" PRIu64 " (0x%" PRIx64 ")\n"),
count, inode_no, inode_no);
/* If the list has entries, look for one that matches
* inode_no */
ii = inode_hash_search(inode_hash, inode_no);
if(ii) {
if(ii->link_count) {
- log_err("Link count already set for inode #%" PRIu64 " (0x%"
- PRIx64 ")!\n", inode_no, inode_no);
+ log_err( _("Link count already set for inode #%" PRIu64 " (0x%"
+ PRIx64 ")!\n"), inode_no, inode_no);
stack;
return -1;
}
@@ -44,7 +46,7 @@ int set_link_count(struct gfs2_sbd *sbp, uint64_t inode_no, uint32_t count)
/* If not match was found, add a new entry and set it's
* link count to count*/
if(!(ii = (struct inode_info *) malloc(sizeof(*ii)))) {
- log_err("Unable to allocate inode_info structure\n");
+ log_err( _("Unable to allocate inode_info structure\n"));
stack;
return -1;
}
@@ -65,21 +67,21 @@ int increment_link(struct gfs2_sbd *sbp, uint64_t inode_no)
* inode_no */
if(ii) {
ii->counted_links++;
- log_debug("Incremented counted links to %u for %"PRIu64" (0x%"
- PRIx64 ")\n", ii->counted_links, inode_no, inode_no);
+ log_debug( _("Incremented counted links to %u for %"PRIu64" (0x%"
+ PRIx64 ")\n"), ii->counted_links, inode_no, inode_no);
return 0;
}
- log_debug("No match found when incrementing link for %" PRIu64
- " (0x%" PRIx64 ")!\n", inode_no, inode_no);
+ log_debug( _("No match found when incrementing link for %" PRIu64
+ " (0x%" PRIx64 ")!\n"), inode_no, inode_no);
/* If no match was found, add a new entry and set its
* counted links to 1 */
if(!(ii = (struct inode_info *) malloc(sizeof(*ii)))) {
- log_err("Unable to allocate inode_info structure\n");
+ log_err( _("Unable to allocate inode_info structure\n"));
stack;
return -1;
}
if(!memset(ii, 0, sizeof(*ii))) {
- log_err("Unable to zero inode_info structure\n");
+ log_err( _("Unable to zero inode_info structure\n"));
stack;
return -1;
}
@@ -97,13 +99,13 @@ int decrement_link(struct gfs2_sbd *sbp, uint64_t inode_no)
ii = inode_hash_search(inode_hash, inode_no);
/* If the list has entries, look for one that matches
* inode_no */
- log_err("Decrementing %"PRIu64" (0x%" PRIx64 ")\n", inode_no, inode_no);
+ log_err( _("Decrementing %"PRIu64" (0x%" PRIx64 ")\n"), inode_no, inode_no);
if(ii) {
ii->counted_links--;
return 0;
}
- log_debug("No match found when decrementing link for %" PRIu64
- " (0x%" PRIx64 ")!\n", inode_no, inode_no);
+ log_debug( _("No match found when decrementing link for %" PRIu64
+ " (0x%" PRIx64 ")!\n"), inode_no, inode_no);
return -1;
}
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 3990e44..e55b5f2 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -18,6 +18,8 @@
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "fsck.h"
#include "libgfs2.h"
@@ -42,7 +44,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
if(!lf_dip) {
struct gfs2_block_query q = {0};
- log_info("Locating/Creating lost and found directory\n");
+ log_info( _("Locating/Creating lost and found directory\n"));
lf_dip = createi(ip->i_sbd->md.rooti, "lost+found", S_IFDIR | 0700, 0);
if(gfs2_block_check(ip->i_sbd, bl, lf_dip->i_di.di_num.no_addr, &q)) {
@@ -67,30 +69,30 @@ int add_inode_to_lf(struct gfs2_inode *ip){
}
}
if(ip->i_di.di_num.no_addr == lf_dip->i_di.di_num.no_addr) {
- log_err("Trying to add lost+found to itself...skipping");
+ log_err( _("Trying to add lost+found to itself...skipping"));
return 0;
}
switch(ip->i_di.di_mode & S_IFMT){
case S_IFDIR:
- log_info("Adding .. entry pointing to lost+found for %"PRIu64"\n",
- ip->i_di.di_num.no_addr);
+ log_info( _("Adding .. entry pointing to lost+found for %llu\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr);
sprintf(tmp_name, "..");
filename_len = strlen(tmp_name); /* no trailing NULL */
if(!(filename = malloc((sizeof(char) * filename_len) + 1))) {
- log_err("Unable to allocate name\n");
+ log_err( _("Unable to allocate name\n"));
stack;
return -1;
}
if(!memset(filename, 0, (sizeof(char) * filename_len) + 1)) {
- log_err("Unable to zero name\n");
+ log_err( _("Unable to zero name\n"));
stack;
return -1;
}
memcpy(filename, tmp_name, filename_len);
if(gfs2_dirent_del(ip, NULL, filename, filename_len))
- log_warn("add_inode_to_lf: "
- "Unable to remove \"..\" directory entry.\n");
+ log_warn( _("add_inode_to_lf: "
+ "Unable to remove \"..\" directory entry.\n"));
dir_add(ip, filename, filename_len, &(lf_dip->i_di.di_num), DT_DIR);
free(filename);
@@ -128,12 +130,12 @@ int add_inode_to_lf(struct gfs2_inode *ip){
}
filename_len = strlen(tmp_name); /* no trailing NULL */
if(!(filename = malloc(sizeof(char) * filename_len))) {
- log_err("Unable to allocate name\n");
+ log_err( _("Unable to allocate name\n"));
stack;
return -1;
}
if(!memset(filename, 0, sizeof(char) * filename_len)) {
- log_err("Unable to zero name\n");
+ log_err( _("Unable to zero name\n"));
stack;
return -1;
}
@@ -145,7 +147,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
increment_link(ip->i_sbd, lf_dip->i_di.di_num.no_addr);
free(filename);
- log_notice("Added inode #%"PRIu64" to lost+found dir\n",
- ip->i_di.di_num.no_addr);
+ log_notice( _("Added inode #%llu to lost+found dir\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr);
return 0;
}
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index 5f30f12..b2fba6c 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -19,6 +19,9 @@
#include <stdarg.h>
#include <ctype.h>
#include <signal.h>
+#include <libintl.h>
+#include <locale.h>
+#define _(String) gettext(String)
#include "copyright.cf"
#include "libgfs2.h"
@@ -102,11 +105,11 @@ int read_cmdline(int argc, char **argv, struct gfs2_options *opts)
break;
case ':':
case '?':
- fprintf(stderr, "Please use '-h' for usage.\n");
+ fprintf(stderr, _("Please use '-h' for usage.\n"));
return FSCK_USAGE;
default:
- fprintf(stderr, "Bad programmer! You forgot to catch"
- " the %c flag\n", c);
+ fprintf(stderr, _("Bad programmer! You forgot to catch"
+ " the %c flag\n"), c);
return FSCK_USAGE;
}
@@ -118,7 +121,7 @@ int read_cmdline(int argc, char **argv, struct gfs2_options *opts)
return FSCK_USAGE;
}
} else {
- fprintf(stderr, "No device specified. Use '-h' for usage.\n");
+ fprintf(stderr, _("No device specified. Use '-h' for usage.\n"));
return FSCK_USAGE;
}
return 0;
@@ -130,15 +133,15 @@ void interrupt(int sig)
char progress[PATH_MAX];
if (!last_reported_block || last_reported_block == last_fs_block)
- sprintf(progress, "progress unknown.\n");
+ sprintf(progress, _("progress unknown.\n"));
else
- sprintf(progress, "processing block %" PRIu64 " out of %"
- PRIu64 "\n", last_reported_block, last_fs_block);
+ sprintf(progress, _("processing block %" PRIu64 " out of %"
+ PRIu64 "\n"), last_reported_block, last_fs_block);
response = generic_interrupt("gfs2_fsck", pass, progress,
- "Do you want to abort gfs2_fsck, skip " \
+ _("Do you want to abort gfs2_fsck, skip " \
"the rest of this pass or continue " \
- "(a/s/c)?", "asc");
+ "(a/s/c)?"), "asc");
if(tolower(response) == 's') {
skip_this_pass = TRUE;
return;
@@ -158,20 +161,20 @@ int check_system_inode(struct gfs2_inode *sysinode, const char *filename,
uint64_t iblock = 0;
struct dir_status ds = {0};
- log_info("Checking system inode '%s'\n", filename);
+ log_info( _("Checking system inode '%s'\n"), filename);
if (sysinode) {
/* Read in the system inode, look at its dentries, and start
* reading through them */
iblock = sysinode->i_di.di_num.no_addr;
- log_info("System inode for '%s' is located at block %"
- PRIu64 " (0x%" PRIx64 ")\n", filename,
+ log_info( _("System inode for '%s' is located at block %"
+ PRIu64 " (0x%" PRIx64 ")\n"), filename,
iblock, iblock);
/* FIXME: check this block's validity */
if(gfs2_block_check(sysinode->i_sbd, bl, iblock, &ds.q)) {
- log_crit("Can't get %s inode block %" PRIu64 " (0x%"
- PRIx64 ") from block list\n", filename,
+ log_crit( _("Can't get %s inode block %" PRIu64 " (0x%"
+ PRIx64 ") from block list\n"), filename,
iblock, iblock);
return -1;
}
@@ -180,7 +183,7 @@ int check_system_inode(struct gfs2_inode *sysinode, const char *filename,
/* bitmap. In that case, don't rebuild the inode. */
/* Just reuse the inode and fix the bitmap. */
if (ds.q.block_type == gfs2_block_free) {
- log_info("The inode exists but the block is not marked 'in use'; fixing it.\n");
+ log_info( _("The inode exists but the block is not marked 'in use'; fixing it.\n"));
gfs2_block_set(sysinode->i_sbd, bl,
sysinode->i_di.di_num.no_addr,
mark);
@@ -191,15 +194,15 @@ int check_system_inode(struct gfs2_inode *sysinode, const char *filename,
}
}
else
- log_info("System inode for '%s' is missing.\n", filename);
+ log_info( _("System inode for '%s' is missing.\n"), filename);
/* If there are errors with the inode here, we need to
* create a new inode and get it all setup - of course,
* everything will be in lost+found then, but we *need* our
* system inodes before we can do any of that. */
if(!sysinode || ds.q.block_type != mark) {
- log_err("Invalid or missing %s system inode.\n", filename);
+ log_err( _("Invalid or missing %s system inode.\n"), filename);
errors_found++;
- if (query(&opts, "Create new %s system inode? (y/n) ",
+ if (query(&opts, _("Create new %s system inode? (y/n) "),
filename)) {
errors_corrected++;
builder(sysinode->i_sbd);
@@ -212,7 +215,7 @@ int check_system_inode(struct gfs2_inode *sysinode, const char *filename,
sysinode->i_di.di_num.no_addr);
}
else {
- log_err("Cannot continue without valid %s inode\n",
+ log_err( _("Cannot continue without valid %s inode\n"),
filename);
return -1;
}
@@ -301,35 +304,35 @@ void check_statfs(struct gfs2_sbd *sdp)
if (sc.sc_total == sdp->blks_total &&
sc.sc_free == (sdp->blks_total - sdp->blks_alloced) &&
sc.sc_dinodes == sdp->dinodes_alloced) {
- log_info("The statfs file is accurate.\n");
+ log_info( _("The statfs file is accurate.\n"));
return;
}
- log_err("The statfs file is wrong:\n\n");
- log_err("Current statfs values:\n");
- log_err("blocks: %lld (0x%llx)\n",
+ log_err( _("The statfs file is wrong:\n\n"));
+ log_err( _("Current statfs values:\n"));
+ log_err( _("blocks: %lld (0x%llx)\n"),
sc.sc_total, sc.sc_total);
- log_err("free: %lld (0x%llx)\n",
+ log_err( _("free: %lld (0x%llx)\n"),
sc.sc_free, sc.sc_free);
- log_err("dinodes: %lld (0x%llx)\n\n",
+ log_err( _("dinodes: %lld (0x%llx)\n\n"),
sc.sc_dinodes, sc.sc_dinodes);
- log_err("Calculated statfs values:\n");
- log_err("blocks: %lld (0x%llx)\n",
+ log_err( _("Calculated statfs values:\n"));
+ log_err( _("blocks: %lld (0x%llx)\n"),
sdp->blks_total, sdp->blks_total);
- log_err("free: %lld (0x%llx)\n",
+ log_err( _("free: %lld (0x%llx)\n"),
sdp->blks_total - sdp->blks_alloced,
sdp->blks_total - sdp->blks_alloced);
- log_err("dinodes: %lld (0x%llx)\n",
+ log_err( _("dinodes: %lld (0x%llx)\n"),
sdp->dinodes_alloced, sdp->dinodes_alloced);
errors_found++;
- if (!query(&opts, "Okay to fix the master statfs file? (y/n)")) {
- log_err("The statfs file was not fixed.\n");
+ if (!query(&opts, _("Okay to fix the master statfs file? (y/n)"))) {
+ log_err( _("The statfs file was not fixed.\n"));
return;
}
do_init_statfs(sdp);
- log_err("The statfs file was fixed.\n");
+ log_err( _("The statfs file was fixed.\n"));
errors_corrected++;
}
@@ -342,33 +345,36 @@ int main(int argc, char **argv)
int error = 0;
int all_clean = 0;
+ setlocale(LC_ALL, "");
+ textdomain("gfs2-utils");
+
memset(sbp, 0, sizeof(*sbp));
if((error = read_cmdline(argc, argv, &opts)))
exit(error);
setbuf(stdout, NULL);
- log_notice("Initializing fsck\n");
+ log_notice( _("Initializing fsck\n"));
if ((error = initialize(sbp, force_check, preen, &all_clean)))
exit(error);
if (!force_check && all_clean && preen) {
- log_err("%s: clean.\n", opts.device);
+ log_err( _("%s: clean.\n"), opts.device);
destroy(sbp);
exit(FSCK_OK);
}
signal(SIGINT, interrupt);
- log_notice("Starting pass1\n");
+ log_notice( _("Starting pass1\n"));
pass = "pass 1";
last_reported_block = 0;
if ((error = pass1(sbp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
- log_notice("Pass1 interrupted \n");
+ log_notice( _("Pass1 interrupted \n"));
}
else
- log_notice("Pass1 complete \n");
+ log_notice( _("Pass1 complete \n"));
/* Make sure the system inodes are okay & represented in the bitmap. */
check_system_inodes(sbp);
@@ -376,81 +382,81 @@ int main(int argc, char **argv)
if (!fsck_abort) {
last_reported_block = 0;
pass = "pass 1b";
- log_notice("Starting pass1b\n");
+ log_notice( _("Starting pass1b\n"));
if((error = pass1b(sbp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
- log_notice("Pass1b interrupted \n");
+ log_notice( _("Pass1b interrupted \n"));
}
else
- log_notice("Pass1b complete\n");
+ log_notice( _("Pass1b complete\n"));
}
if (!fsck_abort) {
last_reported_block = 0;
pass = "pass 1c";
- log_notice("Starting pass1c\n");
+ log_notice( _("Starting pass1c\n"));
if((error = pass1c(sbp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
- log_notice("Pass1c interrupted \n");
+ log_notice( _("Pass1c interrupted \n"));
}
else
- log_notice("Pass1c complete\n");
+ log_notice( _("Pass1c complete\n"));
}
if (!fsck_abort) {
last_reported_block = 0;
pass = "pass 2";
- log_notice("Starting pass2\n");
+ log_notice( _("Starting pass2\n"));
if ((error = pass2(sbp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
- log_notice("Pass2 interrupted \n");
+ log_notice( _("Pass2 interrupted \n"));
}
else
- log_notice("Pass2 complete \n");
+ log_notice( _("Pass2 complete \n"));
}
if (!fsck_abort) {
last_reported_block = 0;
pass = "pass 3";
- log_notice("Starting pass3\n");
+ log_notice( _("Starting pass3\n"));
if ((error = pass3(sbp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
- log_notice("Pass3 interrupted \n");
+ log_notice( _("Pass3 interrupted \n"));
}
else
- log_notice("Pass3 complete \n");
+ log_notice( _("Pass3 complete \n"));
}
if (!fsck_abort) {
last_reported_block = 0;
pass = "pass 4";
- log_notice("Starting pass4\n");
+ log_notice( _("Starting pass4\n"));
if ((error = pass4(sbp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
- log_notice("Pass4 interrupted \n");
+ log_notice( _("Pass4 interrupted \n"));
}
else
- log_notice("Pass4 complete \n");
+ log_notice( _("Pass4 complete \n"));
}
if (!fsck_abort) {
last_reported_block = 0;
pass = "pass 5";
- log_notice("Starting pass5\n");
+ log_notice( _("Starting pass5\n"));
if ((error = pass5(sbp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
- log_notice("Pass5 interrupted \n");
+ log_notice( _("Pass5 interrupted \n"));
error = FSCK_CANCELED;
}
else
- log_notice("Pass5 complete \n");
+ log_notice( _("Pass5 complete \n"));
} else {
error = FSCK_CANCELED;
}
@@ -473,12 +479,12 @@ int main(int argc, char **argv)
inode_put(lf_dip, update_sys_files);
if (!opts.no && errors_corrected)
- log_notice("Writing changes to disk\n");
+ log_notice( _("Writing changes to disk\n"));
bsync(&sbp->buf_list);
bsync(&sbp->nvbuf_list);
destroy(sbp);
- log_notice("gfs2_fsck complete \n");
+ log_notice( _("gfs2_fsck complete \n"));
if (!error) {
if (!errors_found)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index be62cfa..a0ac86b 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -18,6 +18,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "libgfs2.h"
#include "fsck.h"
@@ -204,11 +206,11 @@ int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
else if (type == DIR_EXHASH) {
dent = (struct gfs2_dirent *)(bh->b_data + sizeof(struct gfs2_leaf));
leaf = (struct gfs2_leaf *)bh->b_data;
- log_debug("Checking leaf %" PRIu64 " (0x%" PRIx64 ")\n",
+ log_debug( _("Checking leaf %" PRIu64 " (0x%" PRIx64 ")\n"),
bh->b_blocknr, bh->b_blocknr);
}
else {
- log_err("Invalid directory type %d specified\n", type);
+ log_err( _("Invalid directory type %d specified\n"), type);
return -1;
}
@@ -226,14 +228,16 @@ int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
if (de.de_rec_len < sizeof(struct gfs2_dirent) +
de.de_name_len ||
(de.de_inum.no_formal_ino && !de.de_name_len && !first)) {
- log_err("Directory block %" PRIu64 "(0x%"
- PRIx64 "), entry %d of directory %"
- PRIu64 "(0x%" PRIx64 ") is corrupt.\n",
- bh->b_blocknr, bh->b_blocknr, (*count) + 1,
- ip->i_di.di_num.no_addr,
- ip->i_di.di_num.no_addr);
+ log_err( _("Directory block %llu (0x%llx"
+ "), entry %d of directory %llu"
+ "(0x%llx) is corrupt.\n"),
+ (unsigned long long)bh->b_blocknr,
+ (unsigned long long)bh->b_blocknr,
+ (*count) + 1,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
errors_found++;
- if (query(&opts, "Attempt to repair it? (y/n) ")) {
+ if (query(&opts, _("Attempt to repair it? (y/n) "))) {
if (dirent_repair(ip, bh, &de, dent, type,
first)) {
if (first) /* make a new sentinel */
@@ -241,53 +245,54 @@ int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
else
dirblk_truncate(ip, prev, bh);
*update = updated;
- log_err("Unable to repair corrupt "
- "directory entry; the entry "
- "was removed instead.\n");
+ log_err( _("Unable to repair corrupt "
+ "directory entry; the "
+ "entry was removed "
+ "instead.\n"));
return 0;
} else {
- log_err("Corrupt directory entry "
- "repaired.\n");
+ log_err( _("Corrupt directory entry "
+ "repaired.\n"));
errors_corrected++;
*update = updated;
/* keep looping through dentries */
}
} else {
- log_err("Corrupt directory entry ignored, "
- "stopped after checking %d entries.\n",
+ log_err( _("Corrupt directory entry ignored, "
+ "stopped after checking %d entries.\n"),
*count);
return 0;
}
}
if (!de.de_inum.no_formal_ino){
if(first){
- log_debug("First dirent is a sentinel (place holder).\n");
+ log_debug( _("First dirent is a sentinel (place holder).\n"));
first = 0;
} else {
- log_err("Directory entry with inode number of "
- "zero in leaf %" PRIu64 "(0x%" PRIx64
- ") of directory %" PRIu64 " (0x%"
- PRIx64 ")!\n", bh->b_blocknr,
- bh->b_blocknr,
- ip->i_di.di_num.no_addr,
- ip->i_di.di_num.no_addr);
+ log_err( _("Directory entry with inode number of "
+ "zero in leaf %llu (0x%llx) of "
+ "directory %llu (0x%llx)!\n"),
+ (unsigned long long)bh->b_blocknr,
+ (unsigned long long)bh->b_blocknr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
if (query(&opts,
- "Attempt to remove it? (y/n) ")) {
+ _("Attempt to remove it? (y/n) "))) {
dirblk_truncate(ip, prev, bh);
*update = 1;
- log_err("The corrupt directory entry "
- "was removed.\n");
+ log_err(_("The corrupt directory "
+ "entry was removed.\n"));
} else {
- log_err("Corrupt directory entry "
- "ignored, stopped after "
- "checking %d entries.\n",
- *count);
+ log_err( _("Corrupt directory entry "
+ "ignored, stopped after "
+ "checking %d entries.\n"),
+ *count);
}
return 0;
}
} else {
if (!de.de_inum.no_addr && first) { /* reverse sentinel */
- log_debug("First dirent is a Sentinel (place holder).\n");
+ log_debug( _("First dirent is a Sentinel (place holder).\n"));
/* Swap the two to silently make it a proper sentinel */
de.de_inum.no_addr = de.de_inum.no_formal_ino;
de.de_inum.no_formal_ino = 0;
@@ -309,7 +314,7 @@ int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
}
if ((char *)dent + de.de_rec_len >= bh_end){
- log_debug("Last entry processed.\n");
+ log_debug( _("Last entry processed.\n"));
break;
}
@@ -333,25 +338,27 @@ void warn_and_patch(struct gfs2_inode *ip, uint64_t *leaf_no,
uint64_t first_ok_leaf, int index, const char *msg)
{
if (*bad_leaf != *leaf_no) {
- log_err("Directory Inode %" PRIu64 "(0x%"
- PRIx64 ") points to leaf %" PRIu64 " (0x%"
- PRIx64 ") %s.\n", ip->i_di.di_num.no_addr,
- ip->i_di.di_num.no_addr, *leaf_no, *leaf_no, msg);
+ log_err( _("Directory Inode %llu (0x%llx) points to leaf %llu"
+ " (0x%llx) %s.\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)*leaf_no,
+ (unsigned long long)*leaf_no, msg);
}
errors_found++;
if (*leaf_no == *bad_leaf ||
- query(&opts, "Attempt to patch around it? (y/n) ")) {
+ query(&opts, _("Attempt to patch around it? (y/n) "))) {
errors_corrected++;
if (gfs2_check_range(ip->i_sbd, old_leaf) == 0)
gfs2_put_leaf_nr(ip, index, old_leaf);
else
gfs2_put_leaf_nr(ip, index, first_ok_leaf);
- log_err("Directory Inode %" PRIu64 "(0x%" PRIx64
- ") repaired.\n", ip->i_di.di_num.no_addr,
+ log_err( _("Directory Inode %" PRIu64 "(0x%" PRIx64
+ ") repaired.\n"), ip->i_di.di_num.no_addr,
ip->i_di.di_num.no_addr);
}
else
- log_err("Bad leaf left in place.\n");
+ log_err( _("Bad leaf left in place.\n"));
*bad_leaf = *leaf_no;
*leaf_no = old_leaf;
}
@@ -410,14 +417,18 @@ int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
}
if (gfs2_check_range(ip->i_sbd, old_leaf) == 0 &&
ref_count != exp_count) {
- log_err("Dir #%" PRIu64 " (0x%" PRIx64 ") has an "
- "incorrect number of pointers to leaf #%"
- PRIu64 " (0x%" PRIx64 ")\n\tFound: %u, "
- "Expected: %u\n", ip->i_di.di_num.no_addr,
- ip->i_di.di_num.no_addr, old_leaf, old_leaf,
- ref_count, exp_count);
+ log_err( _("Dir #%llu (0x%llx) has an incorrect "
+ "number of pointers to leaf #%llu "
+ " (0x%llx)\n\tFound: %u, Expected: "
+ "%u\n"), (unsigned long long)
+ ip->i_di.di_num.no_addr,
+ (unsigned long long)
+ ip->i_di.di_num.no_addr,
+ (unsigned long long)old_leaf,
+ (unsigned long long)old_leaf,
+ ref_count, exp_count);
errors_found++;
- if (query(&opts, "Attempt to fix it? (y/n) ")) {
+ if (query(&opts, _("Attempt to fix it? (y/n) "))) {
int factor = 0, divisor = ref_count;
errors_corrected++;
@@ -442,15 +453,17 @@ int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
break;
/* Make sure the block number is in range. */
if(gfs2_check_range(ip->i_sbd, leaf_no)){
- log_err("Leaf block #%" PRIu64 " (0x%"
- PRIx64 ") is out of range for "
- "directory #%" PRIu64 " (0x%"
- PRIx64 ").\n", leaf_no, leaf_no,
+ log_err( _("Leaf block #%llu (0x%llx) is out "
+ "of range for directory #%llu (0x%llx"
+ ").\n"), (unsigned long long)leaf_no,
+ (unsigned long long)leaf_no,
+ (unsigned long long)
ip->i_di.di_num.no_addr,
+ (unsigned long long)
ip->i_di.di_num.no_addr);
warn_and_patch(ip, &leaf_no, &bad_leaf,
old_leaf, first_ok_leaf,
- index, "that is out of range");
+ index, _("that is out of range"));
memcpy(&leaf, &oldleaf, sizeof(oldleaf));
break;
}
@@ -462,7 +475,7 @@ int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
if (gfs2_check_meta(lbh, GFS2_METATYPE_LF)) {
warn_and_patch(ip, &leaf_no, &bad_leaf,
old_leaf, first_ok_leaf, index,
- "that is not really a leaf");
+ _("that is not really a leaf"));
memcpy(&leaf, &oldleaf, sizeof(oldleaf));
brelse(lbh, not_updated);
break;
@@ -481,26 +494,29 @@ int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
* values and replace them with the correct value. */
if (leaf.lf_dirent_format == (GFS2_FORMAT_DE << 16)) {
- log_debug("incorrect lf_dirent_format at leaf #%" PRIu64 "\n", leaf_no);
+ log_debug( _("incorrect lf_dirent_format at leaf #%" PRIu64 "\n"), leaf_no);
leaf.lf_dirent_format = GFS2_FORMAT_DE;
gfs2_leaf_out(&leaf, lbh->b_data);
- log_debug("Fixing lf_dirent_format.\n");
+ log_debug( _("Fixing lf_dirent_format.\n"));
*update = (opts.no ? not_updated : updated);
}
/* Make sure it's really a leaf. */
if (leaf.lf_header.mh_type != GFS2_METATYPE_LF) {
- log_err("Inode %" PRIu64 " (0x%"
- PRIx64 ") points to bad leaf "
- PRIu64 " (0x%" PRIx64 ").\n",
+ log_err( _("Inode %llu (0x%llx"
+ ") points to bad leaf %llu"
+ " (0x%llx).\n"),
+ (unsigned long long)
ip->i_di.di_num.no_addr,
+ (unsigned long long)
ip->i_di.di_num.no_addr,
- leaf_no, leaf_no);
+ (unsigned long long)leaf_no,
+ (unsigned long long)leaf_no);
brelse(lbh, *update);
break;
}
exp_count = (1 << (ip->i_di.di_depth - leaf.lf_depth));
- log_debug("expected count %u - di_depth %u, leaf depth %u\n",
+ log_debug( _("expected count %u - di_depth %u, leaf depth %u\n"),
exp_count, ip->i_di.di_depth, leaf.lf_depth);
if(pass->check_dentry &&
@@ -525,11 +541,11 @@ int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
lbh = bread(&sbp->buf_list, leaf_no);
gfs2_leaf_in(&leaf, lbh->b_data);
- log_err( "Leaf %llu (0x%llx) entry "
+ log_err( _("Leaf %llu (0x%llx) entry "
"count in directory %llu"
" (0x%llx) doesn't match "
"number of entries found "
- "- is %u, found %u\n",
+ "- is %u, found %u\n"),
(unsigned long long)leaf_no,
(unsigned long long)leaf_no,
(unsigned long long)
@@ -538,14 +554,14 @@ int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
ip->i_di.di_num.no_addr,
leaf.lf_entries, count);
errors_found++;
- if(query(&opts, "Update leaf entry count? (y/n) ")) {
+ if(query(&opts, _("Update leaf entry count? (y/n) "))) {
errors_corrected++;
leaf.lf_entries = count;
gfs2_leaf_out(&leaf, lbh->b_data);
- log_warn("Leaf entry count updated\n");
+ log_warn( _("Leaf entry count updated\n"));
f = updated;
} else
- log_err("Leaf entry count left in inconsistant state\n");
+ log_err( _("Leaf entry count left in inconsistant state\n"));
brelse(lbh, f);
}
/* FIXME: Need to get entry count and
@@ -556,7 +572,7 @@ int check_leaf_blks(struct gfs2_inode *ip, enum update_flags *update,
if(!leaf.lf_next)
break;
leaf_no = leaf.lf_next;
- log_debug("Leaf chain detected.\n");
+ log_debug( _("Leaf chain detected.\n"));
}
} while(1); /* while we have chained leaf blocks */
old_leaf = leaf_no;
@@ -621,9 +637,9 @@ static int check_eattr_entries(struct gfs2_inode *ip,
update_it,
pass->private)) {
errors_found++;
- if (query(&opts, "Repair the bad "
- "Extended Attribute? "
- "(y/n) ")) {
+ if (query(&opts, _("Repair the bad "
+ "Extended Attribute? "
+ "(y/n) "))) {
errors_corrected++;
ea_hdr->ea_num_ptrs = i;
ea_hdr->ea_data_len =
@@ -636,11 +652,12 @@ static int check_eattr_entries(struct gfs2_inode *ip,
gfs2_block_set(sdp, bl,
ip->i_di.di_eattr,
gfs2_meta_eattr);
- log_err("The EA was fixed.\n");
+ log_err( _("The EA was "
+ "fixed.\n"));
} else {
error = 1;
- log_err("The bad EA was not "
- "fixed.\n");
+ log_err( _("The bad EA was "
+ "not fixed.\n"));
}
}
tot_ealen += sdp->sd_sb.sb_bsize -
@@ -679,7 +696,7 @@ static int check_leaf_eattr(struct gfs2_inode *ip, uint64_t block,
int error = 0;
enum update_flags updated_this_leaf = not_updated;
- log_debug("Checking EA leaf block #%"PRIu64" (0x%" PRIx64 ").\n",
+ log_debug( _("Checking EA leaf block #%"PRIu64" (0x%" PRIx64 ").\n"),
block, block);
if(pass->check_eattr_leaf) {
@@ -732,7 +749,7 @@ static int check_indirect_eattr(struct gfs2_inode *ip, uint64_t indirect,
uint64_t di_eattr_save = ip->i_di.di_eattr;
*want_updated = not_updated;
- log_debug("Checking EA indirect block #%"PRIu64" (0x%" PRIx64 ").\n",
+ log_debug( _("Checking EA indirect block #%"PRIu64" (0x%" PRIx64 ").\n"),
indirect, indirect);
if (!pass->check_eattr_indir)
@@ -757,8 +774,8 @@ static int check_indirect_eattr(struct gfs2_inode *ip, uint64_t indirect,
leaf_pointer_errors++;
if (update_indir_block == not_updated) {
errors_found++;
- if (query(&opts, "Fix the indirect "
- "block too? (y/n) ")) {
+ if (query(&opts, _("Fix the indirect "
+ "block too? (y/n) "))) {
update_indir_block = updated;
errors_corrected++;
*ea_leaf_ptr = 0;
@@ -836,7 +853,7 @@ int check_inode_eattr(struct gfs2_inode *ip, enum update_flags *want_updated,
if(!ip->i_di.di_eattr)
return 0;
- log_debug("Extended attributes exist for inode #%llu (0x%llx).\n",
+ log_debug( _("Extended attributes exist for inode #%llu (0x%llx).\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
@@ -917,8 +934,8 @@ static int build_and_check_metalist(struct gfs2_inode *ip,
goto fail;
}
if(err > 0) {
- log_debug("Skipping block %" PRIu64
- " (0x%" PRIx64 ")\n",
+ log_debug( _("Skipping block %" PRIu64
+ " (0x%" PRIx64 ")\n"),
block, block);
continue;
}
@@ -979,7 +996,7 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
/* We don't need to record directory blocks - they will be
* recorded later...i think... */
if (S_ISDIR(ip->i_di.di_mode))
- log_debug( "Directory with height > 0 at %llu (0x%llx)\n",
+ log_debug( _("Directory with height > 0 at %llu (0x%llx)\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
@@ -1124,10 +1141,10 @@ int remove_dentry_from_dir(struct gfs2_sbd *sbp, uint64_t dir,
struct gfs2_block_query q;
int error;
- log_debug("Removing dentry %" PRIu64 " (0x%" PRIx64 ") from directory %"
- PRIu64" (0x%" PRIx64 ")\n", dentryblock, dentryblock, dir, dir);
+ log_debug( _("Removing dentry %" PRIu64 " (0x%" PRIx64 ") from directory %"
+ PRIu64" (0x%" PRIx64 ")\n"), dentryblock, dentryblock, dir, dir);
if(gfs2_check_range(sbp, dir)) {
- log_err("Parent directory out of range\n");
+ log_err( _("Parent directory out of range\n"));
return 1;
}
remove_dentry_fxns.private = &dentryblock;
@@ -1138,7 +1155,7 @@ int remove_dentry_from_dir(struct gfs2_sbd *sbp, uint64_t dir,
return -1;
}
if(q.block_type != gfs2_inode_dir) {
- log_info("Parent block is not a directory...ignoring\n");
+ log_info( _("Parent block is not a directory...ignoring\n"));
return 1;
}
/* Need to run check_dir with a private var of dentryblock,
@@ -1234,12 +1251,12 @@ int delete_blocks(struct gfs2_inode *ip, uint64_t block,
if (gfs2_block_check(ip->i_sbd, bl, block, &q))
return 0;
if (!q.dup_block) {
- log_info("Deleting %s block %lld (0x%llx) as part "
- "of inode %lld (0x%llx)\n", btype,
- (unsigned long long)block,
- (unsigned long long)block,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_info( _("Deleting %s block %lld (0x%llx) as part "
+ "of inode %lld (0x%llx)\n"), btype,
+ (unsigned long long)block,
+ (unsigned long long)block,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
gfs2_block_set(ip->i_sbd, bl, block, gfs2_block_free);
gfs2_free_block(ip->i_sbd, block);
}
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index af788e0..edcb7ec 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -29,6 +29,8 @@
#include <time.h>
#include <sys/ioctl.h>
#include <inttypes.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "libgfs2.h"
#include "fsck.h"
@@ -87,7 +89,7 @@ static int leaf(struct gfs2_inode *ip, uint64_t block,
{
struct block_count *bc = (struct block_count *) private;
- log_debug("\tLeaf block at %15" PRIu64 " (0x%" PRIx64 ")\n",
+ log_debug( _("\tLeaf block at %15" PRIu64 " (0x%" PRIx64 ")\n"),
block, block);
gfs2_block_set(ip->i_sbd, bl, block, gfs2_leaf_blk);
bc->indir_count++;
@@ -107,7 +109,7 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
if (gfs2_check_range(ip->i_sbd, block)){ /* blk outside of FS */
gfs2_block_set(ip->i_sbd, bl, ip->i_di.di_num.no_addr,
gfs2_bad_block);
- log_debug("Bad indirect block pointer (out of range).\n");
+ log_debug( _("Bad indirect block pointer (out of range).\n"));
return 1;
}
@@ -116,16 +118,16 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
return -1;
}
if(q.block_type != gfs2_block_free) {
- log_err("Found duplicate block referenced as metadata in "
- "indirect block - was marked %d\n", q.block_type);
+ log_err( _("Found duplicate block referenced as metadata in "
+ "indirect block - was marked %d\n"), q.block_type);
gfs2_block_mark(ip->i_sbd, bl, block, gfs2_dup_block);
found_dup = 1;
}
nbh = bread(&ip->i_sbd->buf_list, block);
if (gfs2_check_meta(nbh, GFS2_METATYPE_IN)){
- log_debug("Bad indirect block pointer (points to "
- "something that is not an indirect block).\n");
+ log_debug( _("Bad indirect block pointer (points to "
+ "something that is not an indirect block).\n"));
if(!found_dup) {
gfs2_block_set(ip->i_sbd, bl, block, gfs2_meta_inval);
brelse(nbh, not_updated);
@@ -136,8 +138,8 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
*bh = nbh;
if (!found_dup) {
- log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to indirect "
- "block.\n", block, block);
+ log_debug( _("Setting %" PRIu64 " (0x%" PRIx64 ") to indirect "
+ "block.\n"), block, block);
gfs2_block_set(ip->i_sbd, bl, block, gfs2_indir_blk);
}
bc->indir_count++;
@@ -152,11 +154,11 @@ static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
int error = 0, btype;
if (gfs2_check_range(ip->i_sbd, block)) {
- log_err("inode %lld (0x%llx) has a bad data block pointer "
- "%lld (out of range)\n",
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)block);
+ log_err( _("inode %lld (0x%llx) has a bad data block pointer "
+ "%lld (out of range)\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)block);
/* Mark the owner of this block with the bad_block
* designator so we know to check it for out of range
* blocks later */
@@ -166,13 +168,13 @@ static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
}
if(gfs2_block_check(ip->i_sbd, bl, block, &q)) {
stack;
- log_err("Found bad block referenced as data at %"
- PRIu64 " (0x%"PRIx64 ")\n", block, block);
+ log_err( _("Found bad block referenced as data at %"
+ PRIu64 " (0x%"PRIx64 ")\n"), block, block);
return -1;
}
if(q.block_type != gfs2_block_free) {
- log_err("Found duplicate block referenced as data at %"
- PRIu64 " (0x%"PRIx64 ")\n", block, block);
+ log_err( _("Found duplicate block referenced as data at %"
+ PRIu64 " (0x%"PRIx64 ")\n"), block, block);
if (q.block_type != gfs2_meta_inval) {
gfs2_block_mark(ip->i_sbd, bl, block, gfs2_dup_block);
/* If the prev ref was as data, this is likely a data
@@ -194,8 +196,8 @@ static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
gfs2_block_unmark(ip->i_sbd, bl, block, gfs2_meta_inval);
gfs2_block_mark(ip->i_sbd, bl, block, gfs2_dup_block);
}
- log_debug("Marking block %llu (0x%llx) as data block\n",
- (unsigned long long)block, (unsigned long long)block);
+ log_debug( _("Marking block %llu (0x%llx) as data block\n"),
+ (unsigned long long)block, (unsigned long long)block);
gfs2_block_mark(ip->i_sbd, bl, block, gfs2_block_used);
/* This is also confusing, so I'll clarify. There are two bitmaps:
@@ -220,15 +222,15 @@ static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
"metadata", "reserved"};
errors_found++;
- log_err("Block #%llu (0x%llx) seems to be data, but is marked "
- "as %s.\n", (unsigned long long)block,
- (unsigned long long)block, allocdesc[btype]);
- if(query(&opts, "Okay to mark it as 'data'? (y/n)")) {
+ log_err( _("Block %llu (0x%llx) seems to be data, but is "
+ "marked as %s.\n"), (unsigned long long)block,
+ (unsigned long long)block, allocdesc[btype]);
+ if(query(&opts, _("Okay to mark it as 'data'? (y/n)"))) {
errors_corrected++;
gfs2_set_bitmap(ip->i_sbd, block, GFS2_BLKST_USED);
- log_err("The block was reassigned as data.\n");
+ log_err( _("The block was reassigned as data.\n"));
} else {
- log_err("The invalid block was ignored.\n");
+ log_err( _("The invalid block was ignored.\n"));
}
}
bc->data_count++;
@@ -256,12 +258,12 @@ static int ask_remove_inode_eattr(struct gfs2_inode *ip,
struct block_count *bc,
enum update_flags *want_updated)
{
- log_err("Inode %lld (0x%llx) has unrecoverable Extended Attribute "
- "errors.\n", (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err( _("Inode %lld (0x%llx) has unrecoverable Extended Attribute "
+ "errors.\n"), (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
errors_found++;
- if (query(&opts, "Clear all Extended Attributes from the "
- "inode? (y/n) ")) {
+ if (query(&opts, _("Clear all Extended Attributes from the "
+ "inode? (y/n) "))) {
struct gfs2_block_query q;
errors_corrected++;
@@ -270,12 +272,12 @@ static int ask_remove_inode_eattr(struct gfs2_inode *ip,
return -1;
}
if (!remove_inode_eattr(ip, bc, q.dup_block, want_updated))
- log_err("Extended attributes were removed.\n");
+ log_err( _("Extended attributes were removed.\n"));
else
- log_err("Unable to remove inode eattr pointer; "
- "the error remains.\n");
+ log_err( _("Unable to remove inode eattr pointer; "
+ "the error remains.\n"));
} else {
- log_err("Extended attributes were not removed.\n");
+ log_err( _("Extended attributes were not removed.\n"));
}
return 0;
}
@@ -296,26 +298,28 @@ static int clear_eas(struct gfs2_inode *ip, struct block_count *bc,
struct gfs2_sbd *sdp = ip->i_sbd;
*want_updated = not_updated;
- log_err("Inode #%" PRIu64 " (0x%" PRIx64 "): %s",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, emsg);
- log_err(" at block #%lld (0x%llx).\n",
- (unsigned long long)block, (unsigned long long)block);
+ log_err( _("Inode #%llu (0x%llx): %s"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr, emsg);
+ log_err( _(" at block #%lld (0x%llx).\n"),
+ (unsigned long long)block, (unsigned long long)block);
errors_found++;
- if (query(&opts, "Clear the bad Extended Attribute? (y/n) ")) {
+ if (query(&opts, _("Clear the bad Extended Attribute? (y/n) "))) {
errors_corrected++;
if (block == ip->i_di.di_eattr) {
remove_inode_eattr(ip, bc, duplicate, want_updated);
- log_err("The bad extended attribute was removed.\n");
+ log_err( _("The bad extended attribute was "
+ "removed.\n"));
} else if (!duplicate) {
gfs2_block_set(sdp, bl, block, gfs2_block_free);
gfs2_set_bitmap(sdp, block, GFS2_BLKST_FREE);
- log_err("The bad Extended Attribute was "
- "removed.\n");
+ log_err( _("The bad Extended Attribute was "
+ "removed.\n"));
}
*want_updated = updated;
return 1;
} else {
- log_err("The bad Extended Attribute was not fixed.\n");
+ log_err( _("The bad Extended Attribute was not fixed.\n"));
bc->ea_count++;
return 0;
}
@@ -353,8 +357,8 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
if(gfs2_check_meta(*bh, GFS2_METATYPE_IN)) {
if(q.block_type != gfs2_block_free) { /* Duplicate? */
if (!clear_eas(ip, bc, indirect, 1, want_updated,
- "Bad indirect Extended Attribute "
- "duplicate found")) {
+ _("Bad indirect Extended Attribute "
+ "duplicate found"))) {
gfs2_block_mark(sdp, bl, indirect,
gfs2_dup_block);
bc->ea_count++;
@@ -362,23 +366,25 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
return 1;
}
clear_eas(ip, bc, indirect, 0, want_updated,
- "Extended Attribute indirect block has incorrect "
- "type");
+ _("Extended Attribute indirect block has incorrect "
+ "type"));
return 1;
}
if(q.block_type != gfs2_block_free) { /* Duplicate? */
- log_err("Inode #%" PRIu64 " (0x%" PRIx64
- "): Duplicate Extended Attribute indirect block "
- "found at #%" PRIu64 " (0x%" PRIx64 ").\n",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr,
- indirect, indirect);
+ log_err( _("Inode #%llu (0x%llx): Duplicate Extended "
+ "Attribute indirect block found at #%llu "
+ "(0x%llx).\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)indirect,
+ (unsigned long long)indirect);
gfs2_block_mark(sdp, bl, indirect, gfs2_dup_block);
bc->ea_count++;
ret = 1;
} else {
- log_debug("Setting #%" PRIu64 " (0x%" PRIx64
- ") to indirect Extended Attribute block\n",
- indirect, indirect);
+ log_debug( _("Setting #%" PRIu64 " (0x%" PRIx64
+ ") to indirect Extended Attribute block\n"),
+ indirect, indirect);
gfs2_block_set(sdp, bl, indirect, gfs2_indir_blk);
bc->ea_count++;
}
@@ -393,31 +399,31 @@ static int finish_eattr_indir(struct gfs2_inode *ip, int leaf_pointers,
if (leaf_pointer_errors == leaf_pointers) /* All eas were bad */
return ask_remove_inode_eattr(ip, bc, want_updated);
- log_debug("Marking inode #%lld (0x%llx) with extended "
- "attribute block\n",
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_debug( _("Marking inode #%llu (0x%llx) with extended "
+ "attribute block\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
/* Mark the inode as having an eattr in the block map
so pass1c can check it. */
gfs2_block_mark(ip->i_sbd, bl, ip->i_di.di_num.no_addr,
gfs2_eattr_block);
if (!leaf_pointer_errors)
return 0;
- log_err("Inode %lld (0x%llx) has recoverable indirect "
- "Extended Attribute errors.\n",
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err( _("Inode %lld (0x%llx) has recoverable indirect "
+ "Extended Attribute errors.\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
errors_found++;
- if (query(&opts, "Okay to fix the block count for the inode? "
- "(y/n) ")) {
+ if (query(&opts, _("Okay to fix the block count for the inode? "
+ "(y/n) "))) {
errors_corrected++;
ip->i_di.di_blocks = 1 + bc->indir_count +
bc->data_count + bc->ea_count;
*want_updated = updated;
- log_err("Block count fixed.\n");
+ log_err( _("Block count fixed.\n"));
return 1;
}
- log_err("Block count not fixed.\n");
+ log_err( _("Block count not fixed.\n"));
return 1;
}
@@ -441,19 +447,19 @@ static int check_leaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
if(gfs2_check_meta(leaf_bh, btype)) {
if(q.block_type != gfs2_block_free) { /* Duplicate? */
clear_eas(ip, bc, block, 1, want_updated,
- "Bad Extended Attribute duplicate found");
+ _("Bad Extended Attribute duplicate found"));
} else {
clear_eas(ip, bc, block, 0, want_updated,
- "Extended Attribute leaf block "
- "has incorrect type");
+ _("Extended Attribute leaf block "
+ "has incorrect type"));
}
brelse(leaf_bh, *want_updated);
return 1;
}
if(q.block_type != gfs2_block_free) { /* Duplicate? */
- log_debug("Duplicate block found at #%lld (0x%llx).\n",
- (unsigned long long)block,
- (unsigned long long)block);
+ log_debug( _("Duplicate block found at #%lld (0x%llx).\n"),
+ (unsigned long long)block,
+ (unsigned long long)block);
gfs2_block_mark(sdp, bl, block, gfs2_dup_block);
bc->ea_count++;
brelse(leaf_bh, not_updated);
@@ -464,13 +470,13 @@ static int check_leaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
errors that caused clear_eas to be called. What we
need to do here is remove the subsequent ea blocks. */
clear_eas(ip, bc, block, 0, want_updated,
- "Extended Attribute block removed due to "
- "previous errors.\n");
+ _("Extended Attribute block removed due to "
+ "previous errors.\n"));
brelse(leaf_bh, *want_updated);
return 1;
}
- log_debug("Setting block #%lld (0x%llx) to eattr block\n",
- (unsigned long long)block, (unsigned long long)block);
+ log_debug( _("Setting block #%lld (0x%llx) to eattr block\n"),
+ (unsigned long long)block, (unsigned long long)block);
/* Point of confusion: We've got to set the ea block itself to
gfs2_meta_eattr here. Elsewhere we mark the inode with
gfs2_eattr_block meaning it contains an eattr for pass1c. */
@@ -504,15 +510,15 @@ static int check_extended_leaf_eattr(struct gfs2_inode *ip, uint64_t *data_ptr,
int error;
if(gfs2_check_range(sdp, el_blk)){
- log_err("Inode #%llu (0x%llx): Extended Attribute block "
- "%llu (0x%llx) has an extended leaf block #%llu "
- "(0x%llx) that is out of range.\n",
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_eattr,
- (unsigned long long)ip->i_di.di_eattr,
- (unsigned long long)el_blk,
- (unsigned long long)el_blk);
+ log_err( _("Inode #%llu (0x%llx): Extended Attribute block "
+ "%llu (0x%llx) has an extended leaf block #%llu "
+ "(0x%llx) that is out of range.\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_eattr,
+ (unsigned long long)ip->i_di.di_eattr,
+ (unsigned long long)el_blk,
+ (unsigned long long)el_blk);
gfs2_block_set(sdp, bl, ip->i_di.di_eattr, gfs2_bad_block);
return 1;
}
@@ -534,13 +540,14 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
* Clarification: If we're here we're checking a leaf block, and the
* source dinode needs to be marked as having extended attributes.
* That instructs pass1c to check the contents of the ea blocks. */
- log_debug("Setting inode %lld (0x%llx) as having eattr "
- "block\n", (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_debug( _("Setting inode %lld (0x%llx) as having eattr "
+ "block(s) attached.\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
gfs2_block_mark(sdp, bl, ip->i_di.di_num.no_addr, gfs2_eattr_block);
if(gfs2_check_range(sdp, block)) {
- log_warn("Inode #%llu (0x%llx): Extended Attribute leaf "
- "block #%llu (0x%llx) is out of range.\n",
+ log_warn( _("Inode #%llu (0x%llx): Extended Attribute leaf "
+ "block #%llu (0x%llx) is out of range.\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)block, (unsigned long long)block);
@@ -585,7 +592,7 @@ static int check_eattr_entries(struct gfs2_inode *ip,
if(max_ptrs > ea_hdr->ea_num_ptrs) {
return 1;
} else {
- log_debug(" Pointers Required: %d\n Pointers Reported: %d\n",
+ log_debug( _(" Pointers Required: %d\n Pointers Reported: %d\n"),
max_ptrs, ea_hdr->ea_num_ptrs);
}
}
@@ -631,14 +638,15 @@ int clear_leaf(struct gfs2_inode *ip, uint64_t block,
{
struct gfs2_block_query q = {0};
- log_crit("Clearing leaf #%" PRIu64 " (0x%" PRIx64 ")\n", block, block);
+ log_crit( _("Clearing leaf #%" PRIu64 " (0x%" PRIx64 ")\n"),
+ block, block);
if(gfs2_block_check(ip->i_sbd, bl, block, &q)) {
stack;
return -1;
}
if(!q.dup_block) {
- log_crit("Setting leaf #%" PRIu64 " (0x%" PRIx64 ") invalid\n",
+ log_crit( _("Setting leaf #%" PRIu64 " (0x%" PRIx64 ") invalid\n"),
block, block);
if(gfs2_block_set(ip->i_sbd, bl, block, gfs2_block_free)) {
stack;
@@ -660,17 +668,17 @@ int add_to_dir_list(struct gfs2_sbd *sbp, uint64_t block)
* matter too much */
find_di(sbp, block, &di);
if(di) {
- log_err("Attempting to add directory block #%" PRIu64
- " (0x%" PRIx64 ") which is already in list\n", block, block);
+ log_err( _("Attempting to add directory block #%" PRIu64
+ " (0x%" PRIx64 ") which is already in list\n"), block, block);
return -1;
}
if(!(newdi = (struct dir_info *) malloc(sizeof(struct dir_info)))) {
- log_crit("Unable to allocate dir_info structure\n");
+ log_crit( _("Unable to allocate dir_info structure\n"));
return -1;
}
if(!memset(newdi, 0, sizeof(*newdi))) {
- log_crit("Error while zeroing dir_info structure\n");
+ log_crit( _("Error while zeroing dir_info structure\n"));
return -1;
}
@@ -696,20 +704,22 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
ip = fsck_inode_get(sdp, bh);
if (ip->i_di.di_num.no_addr != block) {
- log_err("Inode #%" PRIu64 " (0x%" PRIx64
- "): Bad inode address found: %" PRIu64 " (0x%" PRIx64 ")\n",
- block, block, ip->i_di.di_num.no_addr,
- ip->i_di.di_num.no_addr);
+ log_err( _("Inode #%llu (0x%llx): Bad inode address found: %llu "
+ "(0x%llx)\n"), (unsigned long long)block,
+ (unsigned long long)block,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
errors_found++;
- if(query(&opts, "Fix address in inode at block #%"
- PRIu64 " (0x%" PRIx64 ")? (y/n) ", block, block)) {
+ if(query(&opts, _("Fix address in inode at block #%"
+ PRIu64 " (0x%" PRIx64 ")? (y/n) "),
+ block, block)) {
errors_corrected++;
ip->i_di.di_num.no_addr = ip->i_di.di_num.no_formal_ino = block;
gfs2_dinode_out(&ip->i_di, ip->i_bh->b_data);
f = updated;
} else
- log_err("Address in inode at block #%" PRIu64
- " (0x%" PRIx64 ") not fixed\n", block, block);
+ log_err( _("Address in inode at block #%" PRIu64
+ " (0x%" PRIx64 ") not fixed\n"), block, block);
}
if(gfs2_block_check(sdp, bl, block, &q)) {
@@ -718,8 +728,8 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
return -1;
}
if(q.block_type != gfs2_block_free) {
- log_err("Found duplicate block referenced as an inode at #%"
- PRIu64 " (0x%" PRIx64 ")\n", block, block);
+ log_err( _("Found duplicate block referenced as an inode at "
+ "#%" PRIu64 " (0x%" PRIx64 ")\n"), block, block);
if(gfs2_block_mark(sdp, bl, block, gfs2_dup_block)) {
stack;
fsck_inode_put(ip, f);
@@ -732,7 +742,7 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
switch(ip->i_di.di_mode & S_IFMT) {
case S_IFDIR:
- log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to directory inode.\n",
+ log_debug( _("Setting %" PRIu64 " (0x%" PRIx64 ") to directory inode.\n"),
block, block);
if(gfs2_block_set(sdp, bl, block, gfs2_inode_dir)) {
stack;
@@ -746,7 +756,7 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
}
break;
case S_IFREG:
- log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to file inode.\n",
+ log_debug( _("Setting %" PRIu64 " (0x%" PRIx64 ") to file inode.\n"),
block, block);
if(gfs2_block_set(sdp, bl, block, gfs2_inode_file)) {
stack;
@@ -755,7 +765,7 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
}
break;
case S_IFLNK:
- log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to symlink inode.\n",
+ log_debug( _("Setting %" PRIu64 " (0x%" PRIx64 ") to symlink inode.\n"),
block, block);
if(gfs2_block_set(sdp, bl, block, gfs2_inode_lnk)) {
stack;
@@ -764,7 +774,7 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
}
break;
case S_IFBLK:
- log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to block dev inode.\n",
+ log_debug( _("Setting %" PRIu64 " (0x%" PRIx64 ") to block dev inode.\n"),
block, block);
if(gfs2_block_set(sdp, bl, block, gfs2_inode_blk)) {
stack;
@@ -773,7 +783,7 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
}
break;
case S_IFCHR:
- log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to char dev inode.\n",
+ log_debug( _("Setting %" PRIu64 " (0x%" PRIx64 ") to char dev inode.\n"),
block, block);
if(gfs2_block_set(sdp, bl, block, gfs2_inode_chr)) {
stack;
@@ -782,7 +792,7 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
}
break;
case S_IFIFO:
- log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to fifo inode.\n",
+ log_debug( _("Setting %" PRIu64 " (0x%" PRIx64 ") to fifo inode.\n"),
block, block);
if(gfs2_block_set(sdp, bl, block, gfs2_inode_fifo)) {
stack;
@@ -791,7 +801,7 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
}
break;
case S_IFSOCK:
- log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to socket inode.\n",
+ log_debug( _("Setting %" PRIu64 " (0x%" PRIx64 ") to socket inode.\n"),
block, block);
if(gfs2_block_set(sdp, bl, block, gfs2_inode_sock)) {
stack;
@@ -800,7 +810,7 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
}
break;
default:
- log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to invalid.\n",
+ log_debug( _("Setting %" PRIu64 " (0x%" PRIx64 ") to invalid.\n"),
block, block);
if(gfs2_block_set(sdp, bl, block, gfs2_meta_inval)) {
stack;
@@ -820,12 +830,12 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
/* FIXME: fix height and depth here - wasn't implemented in
* old fsck either, so no biggy... */
if (ip->i_di.di_height < compute_height(sdp, ip->i_di.di_size)){
- log_warn("Dinode #%" PRIu64 " (0x%" PRIx64 ") has bad height "
- "Found %u, Expected >= %u\n", ip->i_di.di_num.no_addr,
+ log_warn( _("Dinode #%" PRIu64 " (0x%" PRIx64 ") has bad height "
+ "Found %u, Expected >= %u\n"), ip->i_di.di_num.no_addr,
ip->i_di.di_num.no_addr, ip->i_di.di_height,
compute_height(sdp, ip->i_di.di_size));
/* once implemented, remove continue statement */
- log_warn("Marking inode invalid\n");
+ log_warn( _("Marking inode invalid\n"));
if(gfs2_block_set(sdp, bl, block, gfs2_meta_inval)) {
stack;
fsck_inode_put(ip, f);
@@ -839,13 +849,14 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
if (S_ISDIR(ip->i_di.di_mode) &&
(ip->i_di.di_flags & GFS2_DIF_EXHASH)) {
if (((1 << ip->i_di.di_depth) * sizeof(uint64_t)) != ip->i_di.di_size){
- log_warn("Directory dinode #%" PRIu64 " (0x%" PRIx64
- ") has bad depth. Found %u, Expected %u\n",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr,
- ip->i_di.di_depth,
- (1 >> (ip->i_di.di_size/sizeof(uint64_t))));
+ log_warn( _("Directory dinode #%llu (0x%llx"
+ ") has bad depth. Found %u, Expected %u\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ ip->i_di.di_depth,
+ (1 >> (ip->i_di.di_size/sizeof(uint64_t))));
/* once implemented, remove continue statement */
- log_warn("Marking inode invalid\n");
+ log_warn( _("Marking inode invalid\n"));
if(gfs2_block_set(sdp, bl, block, gfs2_meta_inval)) {
stack;
fsck_inode_put(ip, f);
@@ -865,9 +876,9 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
return 0;
}
if(error > 0) {
- log_warn("Marking inode #%lld (0x%llx) invalid\n",
+ log_warn( _("Marking inode #%llu (0x%llx) invalid\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
- ip->i_di.di_num.no_addr);
+ (unsigned long long)ip->i_di.di_num.no_addr);
/* FIXME: Must set all leaves invalid as well */
check_metatree(ip, &invalidate_metatree);
gfs2_block_set(sdp, bl, ip->i_di.di_num.no_addr,
@@ -885,26 +896,31 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
if (ip->i_di.di_blocks !=
(1 + bc.indir_count + bc.data_count + bc.ea_count)) {
- log_err("Inode #%" PRIu64 " (0x%" PRIx64 "): Ondisk block count (%"
- PRIu64 ") does not match what fsck found (%" PRIu64 ")\n",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr,
- ip->i_di.di_blocks,
- 1 + bc.indir_count + bc.data_count + bc.ea_count);
- log_info("inode has: %lld, but fsck counts: Dinode:1 + indir:"
- "%lld + data: %lld + ea: %lld\n",
- ip->i_di.di_blocks, bc.indir_count, bc.data_count,
- bc.ea_count);
+ log_err( _("Inode #%llu (0x%llx): Ondisk block count (%llu"
+ ") does not match what fsck found (%llu)\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_blocks,
+ (unsigned long long)1 + bc.indir_count +
+ bc.data_count + bc.ea_count);
+ log_info( _("inode has: %lld, but fsck counts: Dinode:1 + "
+ "indir:%lld + data: %lld + ea: %lld\n"),
+ (unsigned long long)ip->i_di.di_blocks,
+ (unsigned long long)bc.indir_count,
+ (unsigned long long)bc.data_count,
+ (unsigned long long)bc.ea_count);
errors_found++;
- if (query(&opts, "Fix ondisk block count? (y/n) ")) {
+ if (query(&opts, _("Fix ondisk block count? (y/n) "))) {
errors_corrected++;
ip->i_di.di_blocks = 1 + bc.indir_count + bc.data_count +
bc.ea_count;
gfs2_dinode_out(&ip->i_di, ip->i_bh->b_data);
f = updated;
} else
- log_err("Bad block count for #%" PRIu64 " (0x%" PRIx64
- ") not fixed\n", ip->i_di.di_num.no_addr,
- ip->i_di.di_num.no_addr);
+ log_err( _("Bad block count for #%llu (0x%llx"
+ ") not fixed\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
}
fsck_inode_put(ip, f);
@@ -917,23 +933,24 @@ int scan_meta(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
if (gfs2_check_meta(bh, 0)) {
errors_found++;
- log_err("Found invalid metadata block at #%llu (0x%llx)\n",
- (unsigned long long)block, (unsigned long long)block);
+ log_info( _("Found invalid metadata at #%llu (0x%llx)\n"),
+ (unsigned long long)block,
+ (unsigned long long)block);
if(gfs2_block_set(sdp, bl, block, gfs2_meta_inval)) {
stack;
return -1;
}
- if(query(&opts, "Okay to free the invalid block? (y/n)")) {
+ if(query(&opts, _("Okay to free the invalid block? (y/n)"))) {
errors_corrected++;
gfs2_set_bitmap(sdp, block, GFS2_BLKST_FREE);
- log_err("The invalid block was freed.\n");
+ log_err( _("The invalid block was freed.\n"));
} else {
- log_err("The invalid block was ignored.\n");
+ log_err( _("The invalid block was ignored.\n"));
}
return 0;
}
- log_debug("Checking metadata block #%" PRIu64 " (0x%" PRIx64 ")\n", block,
+ log_debug( _("Checking metadata block #%" PRIu64 " (0x%" PRIx64 ")\n"), block,
block);
if (!gfs2_check_meta(bh, GFS2_METATYPE_DI)) {
@@ -997,15 +1014,17 @@ int pass1(struct gfs2_sbd *sbp)
for (tmp = sbp->rglist.next; tmp != &sbp->rglist;
tmp = tmp->next, rg_count++){
- log_info("Checking metadata in Resource Group #%" PRIu64 "\n",
+ log_info( _("Checking metadata in Resource Group #%" PRIu64 "\n"),
rg_count);
rgd = osi_list_entry(tmp, struct rgrp_list, list);
if(gfs2_rgrp_read(sbp, rgd)){
stack;
return FSCK_ERROR;
}
- log_debug("RG at %" PRIu64 " (0x%" PRIx64 ") is %u long\n",
- rgd->ri.ri_addr, rgd->ri.ri_addr, rgd->ri.ri_length);
+ log_debug( _("RG at %llu (0x%llx) is %u long\n"),
+ (unsigned long long)rgd->ri.ri_addr,
+ (unsigned long long)rgd->ri.ri_addr,
+ rgd->ri.ri_length);
for (i = 0; i < rgd->ri.ri_length; i++) {
if(gfs2_block_set(sbp, bl, rgd->ri.ri_addr + i,
gfs2_meta_other)){
@@ -1028,7 +1047,7 @@ int pass1(struct gfs2_sbd *sbp)
return FSCK_OK;
}
if (skip_this_pass) {
- printf("Skipping pass 1 is not a good idea.\n");
+ printf( _("Skipping pass 1 is not a good idea.\n"));
skip_this_pass = FALSE;
fflush(stdout);
}
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index 9b11cab..ff59968 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -16,6 +16,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "libgfs2.h"
#include "fsck.h"
@@ -146,11 +148,16 @@ static int find_dentry(struct gfs2_inode *ip, struct gfs2_dirent *de,
if(id->block_no == de->de_inum.no_addr) {
id->name = strdup(filename);
id->parent = ip->i_di.di_num.no_addr;
- log_debug("Duplicate block %" PRIu64 " (0x%" PRIx64
- ") is in file or directory %" PRIu64
- " (0x%" PRIx64 ") named %s\n", id->block_no,
- id->block_no, ip->i_di.di_num.no_addr,
- ip->i_di.di_num.no_addr, filename);
+ log_debug( _("Duplicate block %llu (0x%llx"
+ ") is in file or directory %llu"
+ " (0x%llx) named %s\n"),
+ (unsigned long long)id->block_no,
+ (unsigned long long)id->block_no,
+ (unsigned long long)
+ ip->i_di.di_num.no_addr,
+ (unsigned long long)
+ ip->i_di.di_num.no_addr,
+ filename);
/* If there are duplicates of
* duplicates, I guess we'll miss them
* here */
@@ -173,15 +180,15 @@ static int clear_dup_metalist(struct gfs2_inode *ip, uint64_t block,
if(dh->ref_count == 1)
return 1;
if(block == dh->b->block_no) {
- log_err("Found duplicate reference in inode \"%s\" at block #%"
- PRIu64 " (0x%" PRIx64 ") to block #%" PRIu64 " (0x%"
- PRIx64 ")\n",
- dh->id->name ? dh->id->name : "unknown name",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr,
- block, block);
- log_err("Inode %s is in directory %"PRIu64" (0x%" PRIx64 ")\n",
- dh->id->name ? dh->id->name : "", dh->id->parent,
- dh->id->parent);
+ log_err( _("Found duplicate reference in inode \"%s\" at "
+ "block #%llu (0x%llx) to block #%llu (0x%llx)\n"),
+ dh->id->name ? dh->id->name : _("unknown name"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)block, (unsigned long long)block);
+ log_err( _("Inode %s is in directory %"PRIu64" (0x%" PRIx64 ")\n"),
+ dh->id->name ? dh->id->name : "", dh->id->parent,
+ dh->id->parent);
inode_hash_remove(inode_hash, ip->i_di.di_num.no_addr);
/* Setting the block to invalid means the inode is
* cleared in pass2 */
@@ -209,12 +216,14 @@ static int clear_dup_eattr_indir(struct gfs2_inode *ip, uint64_t block,
if(dh->ref_count == 1)
return 1;
if(block == dh->b->block_no) {
- log_err("Found dup in inode \"%s\" with address #%" PRIu64
- " (0x%" PRIx64 ") with block #%" PRIu64 " (0x%" PRIx64 ")\n",
- dh->id->name ? dh->id->name : "unknown name",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, block,
- block);
- log_err("Inode %s is in directory %" PRIu64 " (0x%" PRIx64 ")\n",
+ log_err( _("Found dup in inode \"%s\" with address #%llu"
+ " (0x%llx) with block #%llu (0x%llx)\n"),
+ dh->id->name ? dh->id->name : _("unknown name"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)block,
+ (unsigned long long)block);
+ log_err( _("Inode %s is in directory %" PRIu64 " (0x%" PRIx64 ")\n"),
dh->id->name ? dh->id->name : "",
dh->id->parent, dh->id->parent);
gfs2_block_set(ip->i_sbd, bl, ip->i_di.di_eattr,
@@ -234,12 +243,14 @@ static int clear_dup_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
if(dh->ref_count == 1)
return 1;
if(block == dh->b->block_no) {
- log_err("Found dup in inode \"%s\" with address #%" PRIu64
- " (0x%" PRIx64 ") with block #%" PRIu64 " (0x%" PRIx64 ")\n",
- dh->id->name ? dh->id->name : "unknown name",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, block,
- block);
- log_err("Inode %s is in directory %" PRIu64 " (0x%" PRIx64 ")\n",
+ log_err( _("Found dup in inode \"%s\" with address #%llu"
+ " (0x%llx) with block #%llu (0x%llx)\n"),
+ dh->id->name ? dh->id->name : _("unknown name"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)block,
+ (unsigned long long)block);
+ log_err( _("Inode %s is in directory %" PRIu64 " (0x%" PRIx64 ")\n"),
dh->id->name ? dh->id->name : "",
dh->id->parent, dh->id->parent);
/* mark the main eattr block invalid */
@@ -285,7 +296,7 @@ static int clear_eattr_entry (struct gfs2_inode *ip,
if(max_ptrs > ea_hdr->ea_num_ptrs)
return 1;
else {
- log_debug(" Pointers Required: %d\n Pointers Reported: %d\n",
+ log_debug( _(" Pointers Required: %d\n Pointers Reported: %d\n"),
max_ptrs, ea_hdr->ea_num_ptrs);
}
}
@@ -306,12 +317,13 @@ static int clear_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_data_ptr,
if(dh->ref_count == 1)
return 1;
if(block == dh->b->block_no) {
- log_err("Found dup in inode \"%s\" with address #%" PRIu64
- " (0x%" PRIx64 ") with block #%" PRIu64 " (0x%" PRIx64 ")\n",
- dh->id->name ? dh->id->name : "unknown name",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, block,
- block);
- log_err("Inode %s is in directory %" PRIu64 " (0x%" PRIx64 ")\n",
+ log_err( _("Found dup in inode \"%s\" with address #%llu"
+ " (0x%llx) with block #%llu (0x%llx)\n"),
+ dh->id->name ? dh->id->name : _("unknown name"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)block, (unsigned long long)block);
+ log_err( _("Inode %s is in directory %" PRIu64 " (0x%" PRIx64 ")\n"),
dh->id->name ? dh->id->name : "",
dh->id->parent, dh->id->parent);
/* mark the main eattr block invalid */
@@ -343,15 +355,15 @@ int find_block_ref(struct gfs2_sbd *sbp, uint64_t inode, struct dup_blocks *b)
enum update_flags update;
ip = fsck_load_inode(sbp, inode); /* bread, inode_get */
- log_debug("Checking inode %" PRIu64 " (0x%" PRIx64 ")'s "
- "metatree for references to block %" PRIu64" (0x% " PRIx64
- ")\n", inode, inode, b->block_no, b->block_no);
+ log_debug( _("Checking inode %" PRIu64 " (0x%" PRIx64 ")'s "
+ "metatree for references to block %" PRIu64 " (0x%" PRIx64
+ ")\n"), inode, inode, b->block_no, b->block_no);
if(check_metatree(ip, &find_refs)) {
stack;
fsck_inode_put(ip, not_updated); /* out, brelse, free */
return -1;
}
- log_debug("Done checking metatree\n");
+ log_debug( _("Done checking metatree\n"));
/* Check for ea references in the inode */
if(check_inode_eattr(ip, &update, &find_refs) < 0){
stack;
@@ -360,15 +372,15 @@ int find_block_ref(struct gfs2_sbd *sbp, uint64_t inode, struct dup_blocks *b)
}
if (myfi.found) {
if(!(id = malloc(sizeof(*id)))) {
- log_crit("Unable to allocate inode_with_dups structure\n");
+ log_crit( _("Unable to allocate inode_with_dups structure\n"));
return -1;
}
if(!(memset(id, 0, sizeof(*id)))) {
- log_crit("Unable to zero inode_with_dups structure\n");
+ log_crit( _("Unable to zero inode_with_dups structure\n"));
return -1;
}
- log_debug("Found %d entries with block %" PRIu64
- " (0x%" PRIx64 ") in inode #%" PRIu64 " (0x%" PRIx64 ")\n",
+ log_debug( _("Found %d entries with block %" PRIu64
+ " (0x%" PRIx64 ") in inode #%" PRIu64 " (0x%" PRIx64 ")\n"),
myfi.found, b->block_no, b->block_no, inode, inode);
id->dup_count = myfi.found;
id->block_no = inode;
@@ -421,15 +433,17 @@ int handle_dup_blk(struct gfs2_sbd *sbp, struct dup_blocks *b)
if (be32_to_cpu(cmagic) == GFS2_MAGIC) {
tmp = b->ref_inode_list.next;
id = osi_list_entry(tmp, struct inode_with_dups, list);
- log_warn("Inode %s (%lld/0x%llx) has a reference to "
- "data block %"PRIu64" (0x%" PRIx64 "), but "
- "the block is really metadata.\n",
- id->name, id->block_no, id->block_no,
- b->block_no, b->block_no);
+ log_warn( _("Inode %s (%lld/0x%llx) has a reference to"
+ " data block %llu (0x%llx), "
+ "but the block is really metadata.\n"),
+ id->name, (unsigned long long)id->block_no,
+ (unsigned long long)id->block_no,
+ (unsigned long long)b->block_no,
+ (unsigned long long)b->block_no);
errors_found++;
- if (query(&opts, "Clear the inode? (y/n) ")) {
+ if (query(&opts, _("Clear the inode? (y/n) "))) {
errors_corrected++;
- log_warn("Clearing inode %lld (0x%llx)...\n",
+ log_warn( _("Clearing inode %lld (0x%llx)...\n"),
(unsigned long long)id->block_no,
(unsigned long long)id->block_no);
ip = fsck_load_inode(sbp, id->block_no);
@@ -442,33 +456,39 @@ int handle_dup_blk(struct gfs2_sbd *sbp, struct dup_blocks *b)
gfs2_meta_inval);
fsck_inode_put(ip, updated);
} else {
- log_warn("The bad inode was not cleared.");
+ log_warn( _("The bad inode was not cleared."));
}
return 0;
}
}
- log_notice("Block %" PRIu64 " (0x%" PRIx64 ") has %d inodes referencing it"
- " for a total of %d duplicate references\n",
- b->block_no, b->block_no, dh.ref_inode_count,
- dh.ref_count);
+ log_notice( _("Block %llu (0x%llx) has %d inodes referencing it"
+ " for a total of %d duplicate references\n"),
+ (unsigned long long)b->block_no,
+ (unsigned long long)b->block_no,
+ dh.ref_inode_count, dh.ref_count);
+
osi_list_foreach(tmp, &b->ref_inode_list) {
id = osi_list_entry(tmp, struct inode_with_dups, list);
- log_warn("Inode %s (%lld/0x%llx) has %d reference(s) to "
- "block %"PRIu64" (0x%" PRIx64 ")\n",
- id->name, id->block_no, id->block_no,
- id->dup_count, b->block_no, b->block_no);
+ log_warn( _("Inode %s (%lld/0x%llx) has %d reference(s) to "
+ "block %llu (0x%llx)\n"), id->name,
+ (unsigned long long)id->block_no,
+ (unsigned long long)id->block_no,
+ id->dup_count, (unsigned long long)b->block_no,
+ (unsigned long long)b->block_no);
}
osi_list_foreach(tmp, &b->ref_inode_list) {
id = osi_list_entry(tmp, struct inode_with_dups, list);
errors_found++;
- if (!(query(&opts, "Okay to clear inode %lld (0x%llx)? (y/n) ",
- id->block_no, id->block_no))) {
- log_warn("The bad inode was not cleared...\n");
+ if (!(query(&opts, _("Okay to clear inode %lld (0x%llx)? "
+ "(y/n) "),
+ (unsigned long long)id->block_no,
+ (unsigned long long)id->block_no))) {
+ log_warn( _("The bad inode was not cleared...\n"));
continue;
}
errors_corrected++;
- log_warn("Clearing inode %lld (0x%llx)...\n",
+ log_warn( _("Clearing inode %lld (0x%llx)...\n"),
(unsigned long long)id->block_no,
(unsigned long long)id->block_no);
ip = fsck_load_inode(sbp, id->block_no);
@@ -509,24 +529,24 @@ int pass1b(struct gfs2_sbd *sbp)
find_dirents.check_dentry = &find_dentry;
int rc = FSCK_OK;
- log_info("Looking for duplicate blocks...\n");
+ log_info( _("Looking for duplicate blocks...\n"));
/* If there were no dups in the bitmap, we don't need to do anymore */
if(osi_list_empty(&sbp->dup_blocks.list)) {
- log_info("No duplicate blocks found\n");
+ log_info( _("No duplicate blocks found\n"));
return FSCK_OK;
}
/* Rescan the fs looking for pointers to blocks that are in
* the duplicate block map */
- log_info("Scanning filesystem for inodes containing duplicate blocks...\n");
- log_debug("Filesystem has %"PRIu64" (0x%" PRIx64 ") blocks total\n",
+ log_info( _("Scanning filesystem for inodes containing duplicate blocks...\n"));
+ log_debug( _("Filesystem has %"PRIu64" (0x%" PRIx64 ") blocks total\n"),
last_fs_block, last_fs_block);
for(i = 0; i < last_fs_block; i += 1) {
warm_fuzzy_stuff(i);
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
goto out;
- log_debug("Scanning block %" PRIu64 " (0x%" PRIx64 ") for inodes\n",
+ log_debug( _("Scanning block %" PRIu64 " (0x%" PRIx64 ") for inodes\n"),
i, i);
if(gfs2_block_check(sbp, bl, i, &q)) {
stack;
@@ -557,7 +577,7 @@ int pass1b(struct gfs2_sbd *sbp)
/* Fix dups here - it's going to slow things down a lot to fix
* it later */
- log_info("Handling duplicate blocks\n");
+ log_info( _("Handling duplicate blocks\n"));
out:
osi_list_foreach_safe(tmp, &sbp->dup_blocks.list, x) {
b = osi_list_entry(tmp, struct dup_blocks, list);
diff --git a/gfs2/fsck/pass1c.c b/gfs2/fsck/pass1c.c
index 4736433..f707efc 100644
--- a/gfs2/fsck/pass1c.c
+++ b/gfs2/fsck/pass1c.c
@@ -15,6 +15,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "libgfs2.h"
#include "fsck.h"
@@ -35,9 +37,9 @@ static int remove_eattr_entry(struct gfs2_sbd *sdp,
if (curr->ea_flags & GFS2_EAFLAG_LAST)
prev->ea_flags |= GFS2_EAFLAG_LAST;
}
- log_err("Bad Extended Attribute at block #%"PRIu64
- " (0x%" PRIx64 ") removed.\n",
- leaf_bh->b_blocknr, leaf_bh->b_blocknr);
+ log_err( _("Bad Extended Attribute at block #%"PRIu64
+ " (0x%" PRIx64 ") removed.\n"),
+ leaf_bh->b_blocknr, leaf_bh->b_blocknr);
return 0;
}
@@ -48,8 +50,8 @@ static int ask_remove_eattr_entry(struct gfs2_sbd *sdp,
int fix_curr, int fix_curr_len)
{
errors_found++;
- if (query(&opts, "Remove the bad Extended Attribute entry? "
- "(y/n) ")) {
+ if (query(&opts, _("Remove the bad Extended Attribute entry? "
+ "(y/n) "))) {
errors_corrected++;
if (fix_curr)
curr->ea_flags |= GFS2_EAFLAG_LAST;
@@ -64,7 +66,7 @@ static int ask_remove_eattr_entry(struct gfs2_sbd *sdp,
return -1;
}
} else {
- log_err("Bad Extended Attribute not removed.\n");
+ log_err( _("Bad Extended Attribute not removed.\n"));
}
return 1;
}
@@ -73,13 +75,13 @@ static int ask_remove_eattr(struct gfs2_inode *ip,
enum update_flags *need_update)
{
errors_found++;
- if (query(&opts, "Remove the bad Extended Attribute? (y/n) ")) {
+ if (query(&opts, _("Remove the bad Extended Attribute? (y/n) "))) {
errors_corrected++;
ip->i_di.di_eattr = 0;
*need_update = updated;
- log_err("Bad Extended Attribute removed.\n");
+ log_err( _("Bad Extended Attribute removed.\n"));
} else
- log_err("Bad Extended Attribute not removed.\n");
+ log_err( _("Bad Extended Attribute not removed.\n"));
return 1;
}
@@ -93,9 +95,9 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
*need_update = not_updated;
if(gfs2_check_range(sbp, block)) {
- log_err("Extended attributes indirect block #%llu"
+ log_err( _("Extended attributes indirect block #%llu"
" (0x%llx) for inode #%llu"
- " (0x%llx) out of range...removing\n",
+ " (0x%llx) out of range...removing\n"),
(unsigned long long)block,
(unsigned long long)block,
(unsigned long long)ip->i_di.di_num.no_addr,
@@ -107,9 +109,9 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
return -1;
}
else if(q.block_type != gfs2_indir_blk) {
- log_err("Extended attributes indirect block #%llu"
+ log_err( _("Extended attributes indirect block #%llu"
" (0x%llx) for inode #%llu"
- " (0x%llx) invalid.\n",
+ " (0x%llx) invalid.\n"),
(unsigned long long)block,
(unsigned long long)block,
(unsigned long long)ip->i_di.di_num.no_addr,
@@ -131,8 +133,8 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
struct gfs2_block_query q;
if(gfs2_check_range(sbp, block)) {
- log_err("Extended attributes block for inode #%llu"
- " (0x%llx) out of range.\n",
+ log_err( _("Extended attributes block for inode #%llu"
+ " (0x%llx) out of range.\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
return ask_remove_eattr(ip, need_update);
@@ -142,8 +144,8 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
return -1;
}
else if(q.block_type != gfs2_meta_eattr) {
- log_err("Extended attributes block for inode #%llu"
- " (0x%llx) invalid.\n",
+ log_err( _("Extended attributes block for inode #%llu"
+ " (0x%llx) invalid.\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
return ask_remove_eattr(ip, need_update);
@@ -167,23 +169,23 @@ static int check_eattr_entry(struct gfs2_inode *ip,
uint32_t max_size = sdp->sd_sb.sb_bsize;
if(!ea_hdr->ea_name_len){
- log_err("EA has name length == 0\n");
+ log_err( _("EA has name length == 0\n"));
return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr,
ea_hdr_prev, 1, 1);
}
if(offset + be32_to_cpu(ea_hdr->ea_rec_len) > max_size){
- log_err("EA rec length too long\n");
+ log_err( _("EA rec length too long\n"));
return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr,
ea_hdr_prev, 1, 1);
}
if(offset + be32_to_cpu(ea_hdr->ea_rec_len) == max_size &&
(ea_hdr->ea_flags & GFS2_EAFLAG_LAST) == 0){
- log_err("last EA has no last entry flag\n");
+ log_err( _("last EA has no last entry flag\n"));
return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr,
ea_hdr_prev, 0, 0);
}
if(!ea_hdr->ea_name_len){
- log_err("EA has name length == 0\n");
+ log_err( _("EA has name length == 0\n"));
return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr,
ea_hdr_prev, 0, 0);
}
@@ -194,7 +196,7 @@ static int check_eattr_entry(struct gfs2_inode *ip,
if(!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
((ea_hdr_prev) || (!ea_hdr_prev && ea_hdr->ea_type))){
- log_err("EA (%s) type is invalid (%d > %d).\n",
+ log_err( _("EA (%s) type is invalid (%d > %d).\n"),
ea_name, ea_hdr->ea_type, GFS2_EATYPE_LAST);
return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr,
ea_hdr_prev, 0, 0);
@@ -208,16 +210,14 @@ static int check_eattr_entry(struct gfs2_inode *ip,
max_ptrs = (be32_to_cpu(ea_hdr->ea_data_len)+avail_size-1)/avail_size;
if(max_ptrs > ea_hdr->ea_num_ptrs){
- log_err("EA (%s) has incorrect number of pointers.\n",
- ea_name);
- log_err(" Required: %d\n Reported: %d\n",
- max_ptrs, ea_hdr->ea_num_ptrs);
+ log_err( _("EA (%s) has incorrect number of pointers.\n"), ea_name);
+ log_err( _(" Required: %d\n Reported: %d\n"),
+ max_ptrs, ea_hdr->ea_num_ptrs);
return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr,
ea_hdr_prev, 0, 0);
} else {
- log_debug(" Pointers Required: %d\n"
- "Pointers Reported: %d\n",
- max_ptrs, ea_hdr->ea_num_ptrs);
+ log_debug( _(" Pointers Required: %d\n Pointers Reported: %d\n"),
+ max_ptrs, ea_hdr->ea_num_ptrs);
}
}
return 0;
@@ -265,7 +265,7 @@ int pass1c(struct gfs2_sbd *sbp)
pass1c_fxns.check_eattr_extentry = &check_eattr_extentry;
pass1c_fxns.private = NULL;
- log_info("Looking for inodes containing ea blocks...\n");
+ log_info( _("Looking for inodes containing ea blocks...\n"));
osi_list_foreach_safe(tmp, &sbp->eattr_blocks.list, x) {
ea_block = osi_list_entry(tmp, struct special_blocks, list);
block_no = ea_block->block;
@@ -275,12 +275,12 @@ int pass1c(struct gfs2_sbd *sbp)
return FSCK_OK;
bh = bread(&sbp->buf_list, block_no);
if (!gfs2_check_meta(bh, GFS2_METATYPE_DI)) { /* if a dinode */
- log_info("EA in inode %"PRIu64" (0x%" PRIx64 ")\n",
+ log_info( _("EA in inode %"PRIu64" (0x%" PRIx64 ")\n"),
block_no, block_no);
gfs2_block_unmark(sbp, bl, block_no, gfs2_eattr_block);
ip = fsck_inode_get(sbp, bh);
- log_debug("Found eattr at %llu (0x%llx)\n",
+ log_debug( _("Found eattr at %llu (0x%llx)\n"),
(unsigned long long)ip->i_di.di_eattr,
(unsigned long long)ip->i_di.di_eattr);
/* FIXME: Handle walking the eattr here */
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index c664226..a7dbb41 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -17,6 +17,8 @@
#include <string.h>
#include <inttypes.h>
#include <sys/stat.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "libgfs2.h"
#include "fsck.h"
@@ -37,9 +39,9 @@ int set_parent_dir(struct gfs2_sbd *sbp, uint64_t childblock,
if(!find_di(sbp, childblock, &di)) {
if(di->dinode == childblock) {
if (di->treewalk_parent) {
- log_err("Another directory at block %" PRIu64
+ log_err( _("Another directory at block %" PRIu64
" (0x%" PRIx64 ") already contains"
- " this child - checking %" PRIu64 " (0x%" PRIx64 ")\n",
+ " this child - checking %" PRIu64 " (0x%" PRIx64 ")\n"),
di->treewalk_parent, di->treewalk_parent,
parentblock, parentblock);
return 1;
@@ -47,8 +49,8 @@ int set_parent_dir(struct gfs2_sbd *sbp, uint64_t childblock,
di->treewalk_parent = parentblock;
}
} else {
- log_err("Unable to find block %"PRIu64" (0x%" PRIx64
- ") in dir_info list\n", childblock, childblock);
+ log_err( _("Unable to find block %"PRIu64" (0x%" PRIx64
+ ") in dir_info list\n"), childblock, childblock);
return -1;
}
@@ -68,17 +70,17 @@ int set_dotdot_dir(struct gfs2_sbd *sbp, uint64_t childblock,
if(di->dotdot_parent && sbp->md.rooti->i_di.di_num.no_addr
!= di->dinode) {
/* This should never happen */
- log_crit("Dotdot parent already set for"
+ log_crit( _("Dotdot parent already set for"
" block %"PRIu64" (0x%" PRIx64 ") -> %" PRIu64
- " (0x%" PRIx64 ")\n", childblock, childblock,
+ " (0x%" PRIx64 ")\n"), childblock, childblock,
di->dotdot_parent, di->dotdot_parent);
return -1;
}
di->dotdot_parent = parentblock;
}
} else {
- log_err("Unable to find block %"PRIu64" (0x%" PRIx64
- ") in dir_info list\n", childblock, childblock);
+ log_err( _("Unable to find block %"PRIu64" (0x%" PRIx64
+ ") in dir_info list\n"), childblock, childblock);
return -1;
}
@@ -147,7 +149,7 @@ static int check_file_type(uint8_t de_type, uint8_t block_type)
return 1;
break;
default:
- log_err("Invalid block type\n");
+ log_err( _("Invalid block type\n"));
return -1;
break;
}
@@ -193,9 +195,9 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* Start of checks */
if (de->de_rec_len < GFS2_DIRENT_SIZE(de->de_name_len)){
- log_err("Dir entry with bad record or name length\n"
+ log_err( _("Dir entry with bad record or name length\n"
"\tRecord length = %u\n"
- "\tName length = %u\n",
+ "\tName length = %u\n"),
de->de_rec_len,
de->de_name_len);
gfs2_block_set(sbp, bl, ip->i_di.di_num.no_addr,
@@ -207,23 +209,23 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
calculated_hash = gfs2_disk_hash(filename, de->de_name_len);
if (de->de_hash != calculated_hash){
- log_err("Dir entry with bad hash or name length\n"
+ log_err( _("Dir entry with bad hash or name length\n"
"\tHash found = %u (0x%x)\n"
- "\tFilename = %s\n", de->de_hash, de->de_hash,
+ "\tFilename = %s\n"), de->de_hash, de->de_hash,
filename);
- log_err("\tName length found = %u\n"
- "\tHash expected = %u (0x%x)\n",
+ log_err( _("\tName length found = %u\n"
+ "\tHash expected = %u (0x%x)\n"),
de->de_name_len, calculated_hash, calculated_hash);
errors_found++;
- if(query(&opts, "Fix directory hash for %s? (y/n) ",
+ if(query(&opts, _("Fix directory hash for %s? (y/n) "),
filename)) {
errors_corrected++;
de->de_hash = calculated_hash;
gfs2_dirent_out(de, (char *)dent);
- log_err("Directory entry hash for %s fixed.\n", filename);
+ log_err( _("Directory entry hash for %s fixed.\n"), filename);
}
else {
- log_err("Directory entry hash for %s not fixed.\n", filename);
+ log_err( _("Directory entry hash for %s not fixed.\n"), filename);
return 1;
}
}
@@ -236,18 +238,18 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
strncpy(tmp_name, filename, MAX_FILENAME - 1);
if(gfs2_check_range(ip->i_sbd, entryblock)) {
- log_err("Block # referenced by directory entry %s is out of range\n",
+ log_err( _("Block # referenced by directory entry %s is out of range\n"),
tmp_name);
errors_found++;
if(query(&opts,
- "Clear directory entry tp out of range block? (y/n) ")) {
+ _("Clear directory entry tp out of range block? (y/n) "))) {
errors_corrected++;
- log_err("Clearing %s\n", tmp_name);
+ log_err( _("Clearing %s\n"), tmp_name);
dirent2_del(ip, bh, prev_de, dent);
*update = updated;
return 1;
} else {
- log_err("Directory entry to out of range block remains\n");
+ log_err( _("Directory entry to out of range block remains\n"));
(*count)++;
ds->entry_count++;
return 0;
@@ -262,10 +264,10 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* This entry's inode has bad blocks in it */
/* Handle bad blocks */
- log_err("Found a bad directory entry: %s\n", filename);
+ log_err( _("Found a bad directory entry: %s\n"), filename);
errors_found++;
- if(query(&opts, "Delete inode containing bad blocks? (y/n)")) {
+ if(query(&opts, _("Delete inode containing bad blocks? (y/n)"))) {
errors_corrected++;
entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
check_inode_eattr(entry_ip, update,
@@ -276,11 +278,11 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
gfs2_block_set(sbp, bl, de->de_inum.no_addr,
gfs2_block_free);
*update = updated;
- log_warn("The inode containing bad blocks was "
- "deleted.\n");
+ log_warn( _("The inode containing bad blocks was "
+ "deleted.\n"));
return 1;
} else {
- log_warn("Entry to inode containing bad blocks remains\n");
+ log_warn( _("Entry to inode containing bad blocks remains\n"));
(*count)++;
ds->entry_count++;
return 0;
@@ -291,23 +293,26 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
q.block_type != gfs2_inode_lnk && q.block_type != gfs2_inode_blk &&
q.block_type != gfs2_inode_chr && q.block_type != gfs2_inode_fifo &&
q.block_type != gfs2_inode_sock) {
- log_err("Directory entry '%s' for block %" PRIu64
- " (0x%" PRIx64 ") in dir inode %" PRIu64 " (0x%" PRIx64
- ") block type %d: %s.\n", tmp_name,
- de->de_inum.no_addr, de->de_inum.no_addr,
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr,
- q.block_type, q.block_type == gfs2_meta_inval ?
- "previously marked invalid" : "is not an inode");
+ log_err( _("Directory entry '%s' at block %llu (0x%llx"
+ ") in dir inode %llu (0x%llx"
+ ") block type %d: %s.\n"), tmp_name,
+ (unsigned long long)de->de_inum.no_addr,
+ (unsigned long long)de->de_inum.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ q.block_type, q.block_type == gfs2_meta_inval ?
+ _("previously marked invalid") :
+ _("is not an inode"));
errors_found++;
- if(query(&opts, "Clear directory entry to non-inode block? "
- "(y/n) ")) {
+ if(query(&opts, _("Clear directory entry to non-inode block? "
+ "(y/n) "))) {
struct gfs2_buffer_head *bhi;
errors_corrected++;
dirent2_del(ip, bh, prev_de, dent);
*update = updated;
- log_warn("Directory entry '%s' cleared\n", tmp_name);
+ log_warn( _("Directory entry '%s' cleared\n"), tmp_name);
/* If it was previously marked invalid (i.e. known
to be bad, not just a free block, etc.) then
@@ -332,7 +337,7 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
return 1;
} else {
- log_err("Directory entry to non-inode block remains\n");
+ log_err( _("Directory entry to non-inode block remains\n"));
(*count)++;
ds->entry_count++;
return 0;
@@ -345,13 +350,14 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
return -1;
}
if(error > 0) {
- log_warn("Type '%s' in dir entry (%s, %" PRIu64 "/0x%" PRIx64 ") "
- "conflicts with type '%s' in dinode. (Dir entry is stale.)\n",
- de_type_string(de->de_type), tmp_name,
- de->de_inum.no_addr, de->de_inum.no_addr,
- block_type_string(&q));
+ log_warn( _("Type '%s' in dir entry (%s, %llu/0x%llx) conflicts"
+ " with type '%s' in dinode. (Dir entry is stale.)\n"),
+ de_type_string(de->de_type), tmp_name,
+ (unsigned long long)de->de_inum.no_addr,
+ (unsigned long long)de->de_inum.no_addr,
+ block_type_string(&q));
errors_found++;
- if(query(&opts, "Clear stale directory entry? (y/n) ")) {
+ if(query(&opts, _("Clear stale directory entry? (y/n) "))) {
errors_corrected++;
entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
check_inode_eattr(entry_ip, update, &clear_eattrs);
@@ -359,10 +365,10 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
dirent2_del(ip, bh, prev_de, dent);
*update = updated;
- log_err("Stale directory entry deleted\n");
+ log_err( _("Stale directory entry deleted\n"));
return 1;
} else {
- log_err("Stale directory entry remains\n");
+ log_err( _("Stale directory entry remains\n"));
(*count)++;
ds->entry_count++;
return 0;
@@ -370,14 +376,15 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
if(!strcmp(".", tmp_name)) {
- log_debug("Found . dentry\n");
+ log_debug( _("Found . dentry\n"));
if(ds->dotdir) {
- log_err("Already found '.' entry in directory %" PRIu64 " (0x%"
- PRIx64 ")\n",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr);
+ log_err( _("Already found '.' entry in directory %llu"
+ " (0x%llx)\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
errors_found++;
- if(query(&opts, "Clear duplicate '.' entry? (y/n) ")) {
+ if(query(&opts, _("Clear duplicate '.' entry? (y/n) "))) {
errors_corrected++;
entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
@@ -389,7 +396,7 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
*update = updated;
return 1;
} else {
- log_err("Duplicate '.' entry remains\n");
+ log_err( _("Duplicate '.' entry remains\n"));
/* FIXME: Should we continue on here
* and check the rest of the '.'
* entry? */
@@ -405,10 +412,10 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* check that '.' refers to this inode */
if(de->de_inum.no_addr != ip->i_di.di_num.no_addr) {
- log_err("'.' entry's value incorrect in directory %llu"
+ log_err( _("'.' entry's value incorrect in directory %llu"
" (0x%llx). Points to %llu"
" (0x%llx) when it should point to %llu"
- " (0x%llx).\n",
+ " (0x%llx).\n"),
(unsigned long long)de->de_inum.no_addr,
(unsigned long long)de->de_inum.no_addr,
(unsigned long long)de->de_inum.no_addr,
@@ -416,7 +423,7 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
errors_found++;
- if(query(&opts, "Remove '.' reference? (y/n) ")) {
+ if(query(&opts, _("Remove '.' reference? (y/n) "))) {
errors_corrected++;
entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
check_inode_eattr(entry_ip, update,
@@ -428,7 +435,7 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
return 1;
} else {
- log_err("Invalid '.' reference remains\n");
+ log_err( _("Invalid '.' reference remains\n"));
/* Not setting ds->dotdir here since
* this '.' entry is invalid */
increment_link(sbp, de->de_inum.no_addr);
@@ -446,13 +453,14 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
return 0;
}
if(!strcmp("..", tmp_name)) {
- log_debug("Found .. dentry\n");
+ log_debug( _("Found .. dentry\n"));
if(ds->dotdotdir) {
- log_err("Already found '..' entry in directory %" PRIu64 " (0x%"
- PRIx64 ")\n",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr);
+ log_err( _("Already found '..' entry in directory %llu"
+ "(0x%llx)\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
errors_found++;
- if(query(&opts, "Clear duplicate '..' entry? (y/n) ")) {
+ if(query(&opts, _("Clear duplicate '..' entry? (y/n) "))) {
errors_corrected++;
entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
@@ -464,7 +472,7 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
*update = 1;
return 1;
} else {
- log_err("Duplicate '..' entry remains\n");
+ log_err( _("Duplicate '..' entry remains\n"));
/* FIXME: Should we continue on here
* and check the rest of the '..'
* entry? */
@@ -476,12 +484,12 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
if(q.block_type != gfs2_inode_dir) {
- log_err("Found '..' entry in directory %" PRIu64 " (0x%"
- PRIx64 ") pointing to"
- " something that's not a directory",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr);
+ log_err( _("Found '..' entry in directory %llu (0x%llx) "
+ "pointing to something that's not a directory"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
errors_found++;
- if(query(&opts, "Clear bad '..' directory entry? (y/n) ")) {
+ if(query(&opts, _("Clear bad '..' directory entry? (y/n) "))) {
errors_corrected++;
entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
check_inode_eattr(entry_ip, update,
@@ -492,7 +500,7 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
*update = 1;
return 1;
} else {
- log_err("Bad '..' directory entry remains\n");
+ log_err( _("Bad '..' directory entry remains\n"));
increment_link(sbp, de->de_inum.no_addr);
(*count)++;
ds->entry_count++;
@@ -521,7 +529,7 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* After this point we're only concerned with
* directories */
if(q.block_type != gfs2_inode_dir) {
- log_debug("Found non-dir inode dentry\n");
+ log_debug( _("Found non-dir inode dentry\n"));
increment_link(sbp, de->de_inum.no_addr);
*update = (opts.no ? not_updated : updated);
(*count)++;
@@ -529,23 +537,23 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
return 0;
}
- log_debug("Found plain directory dentry\n");
+ log_debug( _("Found plain directory dentry\n"));
error = set_parent_dir(sbp, entryblock, ip->i_di.di_num.no_addr);
if(error > 0) {
- log_err("%s: Hard link to block %" PRIu64" (0x%" PRIx64
- ") detected.\n", filename, entryblock, entryblock);
+ log_err( _("%s: Hard link to block %" PRIu64" (0x%" PRIx64
+ ") detected.\n"), filename, entryblock, entryblock);
errors_found++;
- if(query(&opts, "Clear hard link to directory? (y/n) ")) {
+ if(query(&opts, _("Clear hard link to directory? (y/n) "))) {
errors_corrected++;
*update = 1;
dirent2_del(ip, bh, prev_de, dent);
- log_warn("Directory entry %s cleared\n", filename);
+ log_warn( _("Directory entry %s cleared\n"), filename);
return 1;
} else {
- log_err("Hard link to directory remains\n");
+ log_err( _("Hard link to directory remains\n"));
(*count)++;
ds->entry_count++;
return 0;
@@ -589,7 +597,7 @@ int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
enum update_flags update = not_updated;
int error = 0;
- log_info("Checking system directory inode '%s'\n", dirname);
+ log_info( _("Checking system directory inode '%s'\n"), dirname);
if (sysinode) {
iblock = sysinode->i_di.di_num.no_addr;
@@ -619,25 +627,25 @@ int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
return -1;
}
if(!ds.dotdir) {
- log_err("No '.' entry found for %s directory.\n", dirname);
+ log_err( _("No '.' entry found for %s directory.\n"), dirname);
errors_found++;
- if (query(&opts, "Is it okay to add '.' entry? (y/n) ")) {
+ if (query(&opts, _("Is it okay to add '.' entry? (y/n) "))) {
errors_corrected++;
sprintf(tmp_name, ".");
filename_len = strlen(tmp_name); /* no trailing NULL */
if(!(filename = malloc(sizeof(char) * filename_len))) {
- log_err("Unable to allocate name string\n");
+ log_err( _("Unable to allocate name string\n"));
stack;
return -1;
}
if(!(memset(filename, 0, sizeof(char) *
filename_len))) {
- log_err("Unable to zero name string\n");
+ log_err( _("Unable to zero name string\n"));
stack;
return -1;
}
memcpy(filename, tmp_name, filename_len);
- log_warn("Adding '.' entry\n");
+ log_warn( _("Adding '.' entry\n"));
dir_add(sysinode, filename, filename_len,
&(sysinode->i_di.di_num), DT_DIR);
increment_link(sysinode->i_sbd,
@@ -646,28 +654,30 @@ int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
free(filename);
update = 1;
} else
- log_err("The directory was not fixed.\n");
+ log_err( _("The directory was not fixed.\n"));
}
if(sysinode->i_di.di_entries != ds.entry_count) {
- log_err("%s inode %" PRIu64 " (0x%" PRIx64
- "): Entries is %d - should be %d\n", dirname,
- sysinode->i_di.di_num.no_addr,
- sysinode->i_di.di_num.no_addr,
+ log_err( _("%s inode %llu (0x%llx"
+ "): Entries is %d - should be %d\n"), dirname,
+ (unsigned long long)sysinode->i_di.di_num.no_addr,
+ (unsigned long long)sysinode->i_di.di_num.no_addr,
sysinode->i_di.di_entries, ds.entry_count);
errors_found++;
- if(query(&opts, "Fix entries for %s inode %" PRIu64 " (0x%"
- PRIx64 ")? (y/n) ", dirname,
- sysinode->i_di.di_num.no_addr,
- sysinode->i_di.di_num.no_addr)) {
+ if(query(&opts, _("Fix entries for %s inode %llu (0x%llx"
+ ")? (y/n) "), dirname,
+ (unsigned long long)sysinode->i_di.di_num.no_addr,
+ (unsigned long long)sysinode->i_di.di_num.no_addr)) {
errors_corrected++;
sysinode->i_di.di_entries = ds.entry_count;
- log_warn("Entries updated\n");
+ log_warn( _("Entries updated\n"));
update = 1;
} else {
- log_err("Entries for inode %" PRIu64 " (0x%" PRIx64
- ") left out of sync\n",
- sysinode->i_di.di_num.no_addr,
- sysinode->i_di.di_num.no_addr);
+ log_err( _("Entries for inode %llu (0x%llx"
+ ") left out of sync\n"),
+ (unsigned long long)
+ sysinode->i_di.di_num.no_addr,
+ (unsigned long long)
+ sysinode->i_di.di_num.no_addr);
}
}
@@ -730,7 +740,7 @@ int pass2(struct gfs2_sbd *sbp)
stack;
return FSCK_ERROR;
}
- log_info("Checking directory inodes.\n");
+ log_info( _("Checking directory inodes.\n"));
/* Grab each directory inode, and run checks on it */
for(i = 0; i < last_fs_block; i++) {
need_update = 0;
@@ -743,16 +753,16 @@ int pass2(struct gfs2_sbd *sbp)
continue;
if(gfs2_block_check(sbp, bl, i, &q)) {
- log_err("Can't get block %"PRIu64 " (0x%" PRIx64
- ") from block list\n", i, i);
+ log_err( _("Can't get block %"PRIu64 " (0x%" PRIx64
+ ") from block list\n"), i, i);
return FSCK_ERROR;
}
if(q.block_type != gfs2_inode_dir)
continue;
- log_debug("Checking directory inode at block %"PRIu64" (0x%"
- PRIx64 ")\n", i, i);
+ log_debug( _("Checking directory inode at block %"PRIu64" (0x%"
+ PRIx64 ")\n"), i, i);
memset(&ds, 0, sizeof(ds));
pass2_fxns.private = (void *) &ds;
@@ -782,9 +792,9 @@ int pass2(struct gfs2_sbd *sbp)
if(error == 0) {
/* FIXME: factor */
errors_found++;
- if(query(&opts, "Remove directory entry for bad"
+ if(query(&opts, _("Remove directory entry for bad"
" inode %"PRIu64" (0x%" PRIx64 ") in %"PRIu64
- " (0x%" PRIx64 ")? (y/n)", i, i, di->treewalk_parent,
+ " (0x%" PRIx64 ")? (y/n)"), i, i, di->treewalk_parent,
di->treewalk_parent)) {
errors_corrected++;
error = remove_dentry_from_dir(sbp, di->treewalk_parent,
@@ -794,39 +804,39 @@ int pass2(struct gfs2_sbd *sbp)
return FSCK_ERROR;
}
if(error > 0) {
- log_warn("Unable to find dentry for %"
+ log_warn( _("Unable to find dentry for %"
PRIu64 " (0x%" PRIx64 ") in %" PRIu64
- " (0x%" PRIx64 ")\n", i, i,
+ " (0x%" PRIx64 ")\n"), i, i,
di->treewalk_parent, di->treewalk_parent);
}
- log_warn("Directory entry removed\n");
+ log_warn( _("Directory entry removed\n"));
} else
- log_err("Directory entry to invalid inode remains.\n");
+ log_err( _("Directory entry to invalid inode remains.\n"));
}
gfs2_block_set(sbp, bl, i, gfs2_meta_inval);
}
bh = bread(&sbp->buf_list, i);
ip = fsck_inode_get(sbp, bh);
if(!ds.dotdir) {
- log_err("No '.' entry found for directory inode at "
- "block %"PRIu64" (0x%" PRIx64 ")\n", i, i);
+ log_err(_("No '.' entry found for directory inode at "
+ "block %"PRIu64" (0x%" PRIx64 ")\n"), i, i);
errors_found++;
if (query(&opts,
- "Is it okay to add '.' entry? (y/n) ")) {
+ _("Is it okay to add '.' entry? (y/n) "))) {
errors_corrected++;
sprintf(tmp_name, ".");
filename_len = strlen(tmp_name); /* no trailing
NULL */
if(!(filename = malloc(sizeof(char) *
filename_len))) {
- log_err("Unable to allocate name\n");
+ log_err(_("Unable to allocate name\n"));
stack;
return FSCK_ERROR;
}
if(!memset(filename, 0, sizeof(char) *
filename_len)) {
- log_err("Unable to zero name\n");
+ log_err( _("Unable to zero name\n"));
stack;
return FSCK_ERROR;
}
@@ -838,27 +848,27 @@ int pass2(struct gfs2_sbd *sbp)
ip->i_di.di_num.no_addr);
ds.entry_count++;
free(filename);
- log_err("The directory was fixed.\n");
+ log_err( _("The directory was fixed.\n"));
need_update = UPDATED;
} else {
- log_err("The directory was not fixed.\n");
+ log_err( _("The directory was not fixed.\n"));
}
}
if(ip->i_di.di_entries != ds.entry_count) {
- log_err("Entries is %d - should be %d for inode "
- "block %" PRIu64 " (0x%" PRIx64 ")\n",
+ log_err( _("Entries is %d - should be %d for inode "
+ "block %llu (0x%llx)\n"),
ip->i_di.di_entries, ds.entry_count,
- ip->i_di.di_num.no_addr,
- ip->i_di.di_num.no_addr);
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
errors_found++;
if (query(&opts,
- "Fix the entry count? (y/n) ")) {
+ _("Fix the entry count? (y/n) "))) {
errors_corrected++;
ip->i_di.di_entries = ds.entry_count;
need_update = UPDATED;
} else {
- log_err("The entry count was not fixed.\n");
+ log_err( _("The entry count was not fixed.\n"));
}
}
fsck_inode_put(ip, need_update); /* does a gfs2_dinode_out,
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index a78d81e..46bd3aa 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -16,6 +16,8 @@
#include <inttypes.h>
#include <string.h>
#include <dirent.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "libgfs2.h"
#include "osi_list.h"
@@ -42,14 +44,14 @@ static int attach_dotdot_to(struct gfs2_sbd *sbp, uint64_t newdotdot,
filename_len = strlen("..");
if(!(filename = malloc((sizeof(char) * filename_len) + 1))) {
- log_err("Unable to allocate name\n");
+ log_err( _("Unable to allocate name\n"));
fsck_inode_put(ip, not_updated);
fsck_inode_put(pip, not_updated);
stack;
return -1;
}
if(!memset(filename, 0, (sizeof(char) * filename_len) + 1)) {
- log_err("Unable to zero name\n");
+ log_err( _("Unable to zero name\n"));
fsck_inode_put(ip, not_updated);
fsck_inode_put(pip, not_updated);
stack;
@@ -57,7 +59,7 @@ static int attach_dotdot_to(struct gfs2_sbd *sbp, uint64_t newdotdot,
}
memcpy(filename, "..", filename_len);
if(gfs2_dirent_del(ip, NULL, filename, filename_len))
- log_warn("Unable to remove \"..\" directory entry.\n");
+ log_warn( _("Unable to remove \"..\" directory entry.\n"));
else
decrement_link(sbp, olddotdot);
dir_add(ip, filename, filename_len, &pip->i_di.di_num, DT_DIR);
@@ -79,22 +81,22 @@ struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
return NULL;
if(di->dotdot_parent != di->treewalk_parent) {
- log_warn("Directory '..' and treewalk connections disagree for inode %"
- PRIu64 " (0x%" PRIx64 ")\n", di->dinode, di->dinode);
- log_notice("'..' has %" PRIu64" (0x%" PRIx64 "), treewalk has %"
- PRIu64" (0x%" PRIx64 ")\n", di->dotdot_parent,
+ log_warn( _("Directory '..' and treewalk connections disagree for inode %"
+ PRIu64 " (0x%" PRIx64 ")\n"), di->dinode, di->dinode);
+ log_notice( _("'..' has %" PRIu64" (0x%" PRIx64 "), treewalk has %"
+ PRIu64" (0x%" PRIx64 ")\n"), di->dotdot_parent,
di->dotdot_parent, di->treewalk_parent,
di->treewalk_parent);
if(gfs2_block_check(sbp, bl, di->dotdot_parent, &q_dotdot)) {
- log_err("Unable to find block %"PRIu64
- " (0x%" PRIx64 ") in block map.\n",
+ log_err( _("Unable to find block %"PRIu64
+ " (0x%" PRIx64 ") in block map.\n"),
di->dotdot_parent, di->dotdot_parent);
return NULL;
}
if(gfs2_block_check(sbp, bl, di->treewalk_parent,
&q_treewalk)) {
- log_err("Unable to find block %"PRIu64
- " (0x%" PRIx64 ") in block map\n",
+ log_err( _("Unable to find block %"PRIu64
+ " (0x%" PRIx64 ") in block map\n"),
di->treewalk_parent, di->treewalk_parent);
return NULL;
}
@@ -107,12 +109,12 @@ struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
*/
if(q_dotdot.block_type != gfs2_inode_dir) {
if(q_treewalk.block_type != gfs2_inode_dir) {
- log_err( "Orphaned directory, move to lost+found\n");
+ log_err( _("Orphaned directory, move to lost+found\n"));
return NULL;
}
else {
- log_warn("Treewalk parent is correct,"
- " fixing dotdot -> %"PRIu64" (0x%" PRIx64 ")\n",
+ log_warn( _("Treewalk parent is correct,"
+ " fixing dotdot -> %"PRIu64" (0x%" PRIx64 ")\n"),
di->treewalk_parent, di->treewalk_parent);
attach_dotdot_to(sbp, di->treewalk_parent,
di->dotdot_parent, di->dinode);
@@ -122,15 +124,15 @@ struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
else {
if(q_treewalk.block_type != gfs2_inode_dir) {
int error = 0;
- log_warn(".. parent is valid, but treewalk"
- "is bad - reattaching to lost+found");
+ log_warn( _(".. parent is valid, but treewalk"
+ "is bad - reattaching to lost+found"));
/* FIXME: add a dinode for this entry instead? */
errors_found++;
- if(query(&opts, "Remove directory entry for bad"
+ if(query(&opts, _("Remove directory entry for bad"
" inode %"PRIu64" (0x%" PRIx64 ") in %"PRIu64
- " (0x%" PRIx64 ")? (y/n)", di->dinode, di->dinode,
+ " (0x%" PRIx64 ")? (y/n)"), di->dinode, di->dinode,
di->treewalk_parent, di->treewalk_parent)) {
errors_corrected++;
error = remove_dentry_from_dir(sbp, di->treewalk_parent,
@@ -140,23 +142,23 @@ struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
return NULL;
}
if(error > 0) {
- log_warn("Unable to find dentry for block %"
+ log_warn( _("Unable to find dentry for block %"
PRIu64" (0x%" PRIx64 ") in %" PRIu64 " (0x%"
- PRIx64 ")\n",di->dinode, di->dinode,
+ PRIx64 ")\n"),di->dinode, di->dinode,
di->treewalk_parent, di->treewalk_parent);
}
- log_warn("Directory entry removed\n");
+ log_warn( _("Directory entry removed\n"));
} else {
- log_err("Directory entry to invalid inode remains\n");
+ log_err( _("Directory entry to invalid inode remains\n"));
}
- log_info("Marking directory unlinked\n");
+ log_info( _("Marking directory unlinked\n"));
return NULL;
}
else {
- log_err("Both .. and treewalk parents are "
+ log_err( _("Both .. and treewalk parents are "
"directories, going with treewalk for "
- "now...\n");
+ "now...\n"));
attach_dotdot_to(sbp, di->treewalk_parent,
di->dotdot_parent, di->dinode);
di->dotdot_parent = di->treewalk_parent;
@@ -165,14 +167,14 @@ struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
}
else {
if(gfs2_block_check(sbp, bl, di->dotdot_parent, &q_dotdot)) {
- log_err("Unable to find parent block %"PRIu64
- " (0x%" PRIx64 ") in block map\n",
+ log_err( _("Unable to find parent block %"PRIu64
+ " (0x%" PRIx64 ") in block map\n"),
di->dotdot_parent, di->dotdot_parent);
return NULL;
}
if(q_dotdot.block_type != gfs2_inode_dir) {
- log_err("Orphaned directory at block %" PRIu64 " (0x%" PRIx64
- ") moved to lost+found\n", di->dinode, di->dinode);
+ log_err( _("Orphaned directory at block %" PRIu64 " (0x%" PRIx64
+ ") moved to lost+found\n"), di->dinode, di->dinode);
return NULL;
}
}
@@ -197,12 +199,12 @@ int pass3(struct gfs2_sbd *sbp)
find_di(sbp, sbp->md.rooti->i_di.di_num.no_addr, &di);
if(di) {
- log_info("Marking root inode connected\n");
+ log_info( _("Marking root inode connected\n"));
di->checked = 1;
}
find_di(sbp, sbp->master_dir->i_di.di_num.no_addr, &di);
if(di) {
- log_info("Marking master directory inode connected\n");
+ log_info( _("Marking master directory inode connected\n"));
di->checked = 1;
}
@@ -210,7 +212,7 @@ int pass3(struct gfs2_sbd *sbp)
* until we find one that's been checked already. If we don't
* find a parent, put in lost+found.
*/
- log_info("Checking directory linkage.\n");
+ log_info( _("Checking directory linkage.\n"));
for(i = 0; i < FSCK_HASH_SIZE; i++) {
osi_list_foreach(tmp, &dir_hash[i]) {
di = osi_list_entry(tmp, struct dir_info, list);
@@ -229,17 +231,17 @@ int pass3(struct gfs2_sbd *sbp)
return FSCK_ERROR;
}
if(q.bad_block) {
- log_err("Found unlinked directory containing bad block\n");
+ log_err( _("Found unlinked directory containing bad block\n"));
errors_found++;
if(query(&opts,
- "Clear unlinked directory with bad blocks? (y/n) ")) {
+ _("Clear unlinked directory with bad blocks? (y/n) "))) {
errors_corrected++;
gfs2_block_set(sbp, bl,
di->dinode,
gfs2_block_free);
break;
} else
- log_err("Unlinked directory with bad block remains\n");
+ log_err( _("Unlinked directory with bad block remains\n"));
}
if(q.block_type != gfs2_inode_dir &&
q.block_type != gfs2_inode_file &&
@@ -248,22 +250,22 @@ int pass3(struct gfs2_sbd *sbp)
q.block_type != gfs2_inode_chr &&
q.block_type != gfs2_inode_fifo &&
q.block_type != gfs2_inode_sock) {
- log_err("Unlinked block marked as inode not an inode\n");
+ log_err( _("Unlinked block marked as inode not an inode\n"));
gfs2_block_set(sbp, bl, di->dinode,
gfs2_block_free);
- log_err("Cleared\n");
+ log_err( _("Cleared\n"));
break;
}
- log_err("Found unlinked directory at block %" PRIu64
- " (0x%" PRIx64 ")\n", di->dinode, di->dinode);
+ log_err( _("Found unlinked directory at block %" PRIu64
+ " (0x%" PRIx64 ")\n"), di->dinode, di->dinode);
ip = fsck_load_inode(sbp, di->dinode);
/* Don't skip zero size directories
* with eattrs */
if(!ip->i_di.di_size && !ip->i_di.di_eattr){
- log_err("Unlinked directory has zero size.\n");
+ log_err( _("Unlinked directory has zero size.\n"));
errors_found++;
- if(query(&opts, "Remove zero-size unlinked directory? (y/n) ")) {
+ if(query(&opts, _("Remove zero-size unlinked directory? (y/n) "))) {
errors_corrected++;
gfs2_block_set(sbp, bl,
di->dinode,
@@ -271,35 +273,35 @@ int pass3(struct gfs2_sbd *sbp)
fsck_inode_put(ip, not_updated);
break;
} else {
- log_err("Zero-size unlinked directory remains\n");
+ log_err( _("Zero-size unlinked directory remains\n"));
}
}
errors_found++;
- if(query(&opts, "Add unlinked directory to lost+found? (y/n) ")) {
+ if(query(&opts, _("Add unlinked directory to lost+found? (y/n) "))) {
errors_corrected++;
if(add_inode_to_lf(ip)) {
fsck_inode_put(ip, not_updated);
stack;
return FSCK_ERROR;
}
- log_warn("Directory relinked to lost+found\n");
+ log_warn( _("Directory relinked to lost+found\n"));
fsck_inode_put(ip, updated);
} else {
- log_err("Unlinked directory remains unlinked\n");
+ log_err( _("Unlinked directory remains unlinked\n"));
fsck_inode_put(ip, not_updated);
}
break;
}
else {
- log_debug("Directory at block %" PRIu64 " (0x%"
- PRIx64 ") connected\n", di->dinode, di->dinode);
+ log_debug( _("Directory at block %" PRIu64 " (0x%"
+ PRIx64 ") connected\n"), di->dinode, di->dinode);
}
di = tdi;
}
}
}
if(lf_dip)
- log_debug("At end of pass3, lost+found entries is %u\n",
+ log_debug( _("At end of pass3, lost+found entries is %u\n"),
lf_dip->i_di.di_entries);
return FSCK_OK;
}
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index a06647b..e217236 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -14,6 +14,8 @@
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "libgfs2.h"
#include "fsck.h"
@@ -34,15 +36,17 @@ struct metawalk_fxns pass4_fxns_delete = {
int fix_inode_count(struct gfs2_sbd *sbp, struct inode_info *ii,
struct gfs2_inode *ip)
{
- log_info("Fixing inode count for %" PRIu64 " (0x%" PRIx64 ") \n",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr);
+ log_info( _("Fixing inode count for %llu (0x%llx) \n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
if(ip->i_di.di_nlink == ii->counted_links)
return 0;
ip->i_di.di_nlink = ii->counted_links;
- log_debug("Changing inode %" PRIu64 " (0x%" PRIx64 ") to have %u links\n",
- ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr,
- ii->counted_links);
+ log_debug( _("Changing inode %llu (0x%llx) to have %u links\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ ii->counted_links);
return 0;
}
@@ -61,26 +65,26 @@ int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
return 0;
f = not_updated;
if(!(ii = osi_list_entry(tmp, struct inode_info, list))) {
- log_crit("osi_list_foreach broken in scan_info_list!!\n");
+ log_crit( _("osi_list_foreach broken in scan_info_list!!\n"));
exit(FSCK_ERROR);
}
- log_debug("Checking reference count on inode at block %" PRIu64
- " (0x%" PRIx64 ")\n", ii->inode, ii->inode);
+ log_debug( _("Checking reference count on inode at block %" PRIu64
+ " (0x%" PRIx64 ")\n"), ii->inode, ii->inode);
if(ii->counted_links == 0) {
- log_err("Found unlinked inode at %" PRIu64 " (0x%" PRIx64 ")\n",
+ log_err( _("Found unlinked inode at %" PRIu64 " (0x%" PRIx64 ")\n"),
ii->inode, ii->inode);
if(gfs2_block_check(sbp, bl, ii->inode, &q)) {
stack;
return -1;
}
if(q.bad_block) {
- log_err("Unlinked inode %llu (0x%llx) contains"
- "bad blocks\n",
+ log_err( _("Unlinked inode %llu (0x%llx) contains"
+ "bad blocks\n"),
(unsigned long long)ii->inode,
(unsigned long long)ii->inode);
errors_found++;
- if(query(&opts, "Delete unlinked inode with "
- "bad blocks? (y/n) ")) {
+ if(query(&opts,
+ _("Delete unlinked inode with bad blocks? (y/n) "))) {
errors_corrected++;
ip = fsck_load_inode(sbp, ii->inode);
check_inode_eattr(ip, &f,
@@ -91,7 +95,7 @@ int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
gfs2_block_free);
continue;
} else
- log_err("Unlinked inode with bad blocks not cleared\n");
+ log_err( _("Unlinked inode with bad blocks not cleared\n"));
}
if(q.block_type != gfs2_inode_dir &&
q.block_type != gfs2_inode_file &&
@@ -100,20 +104,22 @@ int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
q.block_type != gfs2_inode_chr &&
q.block_type != gfs2_inode_fifo &&
q.block_type != gfs2_inode_sock) {
- log_err("Unlinked block marked as inode is "
- "not an inode (%d)\n", q.block_type);
+ log_err( _("Unlinked block marked as inode is "
+ "not an inode (%d)\n"),
+ q.block_type);
ip = fsck_load_inode(sbp, ii->inode);
- if(query(&opts, "Delete unlinked inode "
- "? (y/n) ")) {
+ if(query(&opts, _("Delete unlinked inode "
+ "? (y/n) "))) {
check_inode_eattr(ip, &f,
&pass4_fxns_delete);
check_metatree(ip, &pass4_fxns_delete);
fsck_inode_put(ip, updated);
gfs2_block_set(sbp, bl, ii->inode,
gfs2_block_free);
- log_err("The inode was deleted\n");
+ log_err( _("The inode was deleted\n"));
} else {
- log_err("The inode was not deleted\n");
+ log_err( _("The inode was not "
+ "deleted\n"));
fsck_inode_put(ip, not_updated);
}
continue;
@@ -124,9 +130,9 @@ int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
* eattrs - there might be relevent info in
* them. */
if(!ip->i_di.di_size && !ip->i_di.di_eattr){
- log_err("Unlinked inode has zero size\n");
+ log_err( _("Unlinked inode has zero size\n"));
errors_found++;
- if(query(&opts, "Clear zero-size unlinked inode? (y/n) ")) {
+ if(query(&opts, _("Clear zero-size unlinked inode? (y/n) "))) {
errors_corrected++;
gfs2_block_set(sbp, bl, ii->inode,
gfs2_block_free);
@@ -136,7 +142,7 @@ int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
}
errors_found++;
- if(query(&opts, "Add unlinked inode to lost+found? (y/n)")) {
+ if(query(&opts, _("Add unlinked inode to lost+found? (y/n)"))) {
errors_corrected++;
f = updated;
if(add_inode_to_lf(ip)) {
@@ -149,37 +155,37 @@ int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
lf_addition = 1;
}
} else
- log_err("Unlinked inode left unlinked\n");
+ log_err( _("Unlinked inode left unlinked\n"));
fsck_inode_put(ip, f);
} /* if(ii->counted_links == 0) */
else if(ii->link_count != ii->counted_links) {
- log_err("Link count inconsistent for inode %" PRIu64
- " (0x%" PRIx64 ") has %u but fsck found %u.\n", ii->inode,
+ log_err( _("Link count inconsistent for inode %" PRIu64
+ " (0x%" PRIx64 ") has %u but fsck found %u.\n"), ii->inode,
ii->inode, ii->link_count, ii->counted_links);
/* Read in the inode, adjust the link count,
* and write it back out */
errors_found++;
- if(query(&opts, "Update link count for inode %"
- PRIu64 " (0x%" PRIx64 ") ? (y/n) ", ii->inode, ii->inode)) {
+ if(query(&opts, _("Update link count for inode %"
+ PRIu64 " (0x%" PRIx64 ") ? (y/n) "), ii->inode, ii->inode)) {
errors_corrected++;
ip = fsck_load_inode(sbp, ii->inode); /* bread, inode_get */
fix_inode_count(sbp, ii, ip);
fsck_inode_put(ip, updated); /* out, brelse, free */
- log_warn("Link count updated for inode %"
- PRIu64 " (0x%" PRIx64 ") \n", ii->inode, ii->inode);
+ log_warn( _("Link count updated for inode %"
+ PRIu64 " (0x%" PRIx64 ") \n"), ii->inode, ii->inode);
} else {
- log_err("Link count for inode %" PRIu64 " (0x%" PRIx64
- ") still incorrect\n", ii->inode, ii->inode);
+ log_err( _("Link count for inode %" PRIu64 " (0x%" PRIx64
+ ") still incorrect\n"), ii->inode, ii->inode);
}
}
- log_debug("block %" PRIu64 " (0x%" PRIx64 ") has link count %d\n",
+ log_debug( _("block %" PRIu64 " (0x%" PRIx64 ") has link count %d\n"),
ii->inode, ii->inode, ii->link_count);
} /* osi_list_foreach(tmp, list) */
if (lf_addition) {
if(!(ii = inode_hash_search(inode_hash,
lf_dip->i_di.di_num.no_addr))) {
- log_crit("Unable to find lost+found inode in inode_hash!!\n");
+ log_crit( _("Unable to find lost+found inode in inode_hash!!\n"));
return -1;
} else {
fix_inode_count(sbp, ii, lf_dip);
@@ -203,9 +209,9 @@ int pass4(struct gfs2_sbd *sbp)
uint32_t i;
osi_list_t *list;
if(lf_dip)
- log_debug("At beginning of pass4, lost+found entries is %u\n",
+ log_debug( _("At beginning of pass4, lost+found entries is %u\n"),
lf_dip->i_di.di_entries);
- log_info("Checking inode reference counts.\n");
+ log_info( _("Checking inode reference counts.\n"));
for (i = 0; i < FSCK_HASH_SIZE; i++) {
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
@@ -217,7 +223,7 @@ int pass4(struct gfs2_sbd *sbp)
}
if(lf_dip)
- log_debug("At end of pass4, lost+found entries is %u\n",
+ log_debug( _("At end of pass4, lost+found entries is %u\n"),
lf_dip->i_di.di_entries);
return FSCK_OK;
}
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index ec89adf..aa9d3bd 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -15,6 +15,8 @@
#include <string.h>
#include <inttypes.h>
#include <stdlib.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "libgfs2.h"
#include "fsck.h"
@@ -58,7 +60,7 @@ int convert_mark(struct gfs2_block_query *q, uint32_t *count)
return GFS2_BLKST_USED;
default:
- log_err("Invalid state %d found\n", q->block_type);
+ log_err( _("Invalid state %d found\n"), q->block_type);
return -1;
}
return -1;
@@ -98,61 +100,59 @@ int check_block_status(struct gfs2_sbd *sbp, char *buffer, unsigned int buflen,
block_status == GFS2_BLKST_FREE) {
errors_found++;
if (free_unlinked == -1) {
- log_err("Unlinked inode block found at block %"
- "llu (0x%llx).\n",
- (unsigned long long)block,
- (unsigned long long)block);
- if(query(&opts, "Do you want me to fix the "
- "bitmap for all unlinked blocks? "
- "(y/n) "))
+ log_err( _("Unlinked inode block found at "
+ "block %llu (0x%llx).\n"),
+ (unsigned long long)block,
+ (unsigned long long)block);
+ if(query(&opts, _("Do you want me to fix the "
+ "bitmap for all unlinked "
+ "blocks? (y/n) ")))
free_unlinked = 1;
else
free_unlinked = 0;
}
if (free_unlinked) {
if(gfs2_set_bitmap(sbp, block, block_status))
- log_err("Unlinked block %llu (0x%llx)"
- " bitmap not fixed.\n",
+ log_err(_("Unlinked block %llu "
+ "(0x%llx) bitmap not fixed."
+ "\n"),
(unsigned long long)block,
(unsigned long long)block);
else {
- log_err("Unlinked block %llu (0x%llx)"
- " bitmap fixed.\n",
+ log_err(_("Unlinked block %llu "
+ "(0x%llx) bitmap fixed.\n"),
(unsigned long long)block,
(unsigned long long)block);
errors_corrected++;
}
} else {
- log_info("Unlinked block found at block %"
- PRIu64" (0x%" PRIx64 "), left "
- "unchanged.\n", block, block);
+ log_info( _("Unlinked block found at block %"
+ PRIu64" (0x%" PRIx64 "), left "
+ "unchanged.\n"), block, block);
}
} else if (rg_status != block_status) {
const char *blockstatus[] = {"Free", "Data",
"Unlinked", "inode"};
- log_err("Ondisk and fsck bitmaps differ at"
- " block %"PRIu64" (0x%" PRIx64 ") \n",
- block, block);
- log_err("Ondisk status is %u (%s) but FSCK thinks it "
- "should be ",
- rg_status, blockstatus[rg_status]);
- log_err("%u (%s)\n", block_status,
- blockstatus[block_status]);
- log_err("Metadata type is %u (%s)\n", q.block_type,
- block_type_string(&q));
+ log_err( _("Ondisk and fsck bitmaps differ at"
+ " block %"PRIu64" (0x%" PRIx64 ") \n"), block, block);
+ log_err( _("Ondisk status is %u (%s) but FSCK thinks it should be "),
+ rg_status, blockstatus[rg_status]);
+ log_err("%u (%s)\n", block_status, blockstatus[block_status]);
+ log_err( _("Metadata type is %u (%s)\n"), q.block_type,
+ block_type_string(&q));
errors_found++;
- if(query(&opts, "Fix bitmap for block %"
- PRIu64" (0x%" PRIx64 ") ? (y/n) ", block, block)) {
+ if(query(&opts, _("Fix bitmap for block %"
+ PRIu64" (0x%" PRIx64 ") ? (y/n) "), block, block)) {
errors_corrected++;
if(gfs2_set_bitmap(sbp, block, block_status))
- log_err("Failed.\n");
+ log_err( _("Failed.\n"));
else
- log_err("Succeeded.\n");
+ log_err( _("Succeeded.\n"));
} else
- log_err("Bitmap at block %"PRIu64" (0x%" PRIx64
- ") left inconsistent\n", block, block);
+ log_err( _("Bitmap at block %"PRIu64" (0x%" PRIx64
+ ") left inconsistent\n"), block, block);
}
(*rg_block)++;
bit += GFS2_BIT_SIZE;
@@ -185,14 +185,16 @@ enum update_flags update_rgrp(struct gfs2_sbd *sbp, struct rgrp_list *rgp,
/* actually adjust counters and write out to disk */
if(rgp->rg.rg_free != count[0]) {
- log_err("RG #%" PRIu64 " (0x%" PRIx64
- ") free count inconsistent: is %u should be %u\n",
- rgp->ri.ri_addr, rgp->ri.ri_addr, rgp->rg.rg_free, count[0]);
+ log_err( _("RG #%llu (0x%llx) free count inconsistent: "
+ "is %u should be %u\n"),
+ (unsigned long long)rgp->ri.ri_addr,
+ (unsigned long long)rgp->ri.ri_addr,
+ rgp->rg.rg_free, count[0]);
rgp->rg.rg_free = count[0];
update = 1;
}
if(rgp->rg.rg_dinodes != count[1]) {
- log_err("Inode count inconsistent: is %u should be %u\n",
+ log_err( _("Inode count inconsistent: is %u should be %u\n"),
rgp->rg.rg_dinodes, count[1]);
rgp->rg.rg_dinodes = count[1];
update = 1;
@@ -201,19 +203,19 @@ enum update_flags update_rgrp(struct gfs2_sbd *sbp, struct rgrp_list *rgp,
/* FIXME not sure how to handle this case ATM - it
* means that the total number of blocks we've counted
* exceeds the blocks in the rg */
- log_err("Internal fsck error - AAHHH!\n");
+ log_err( _("Internal fsck error - AAHHH!\n"));
exit(FSCK_ERROR);
}
if(update) {
errors_found++;
- if(query(&opts, "Update resource group counts? (y/n) ")) {
+ if(query(&opts, _("Update resource group counts? (y/n) "))) {
errors_corrected++;
- log_warn("Resource group counts updated\n");
+ log_warn( _("Resource group counts updated\n"));
/* write out the rgrp */
gfs2_rgrp_out(&rgp->rg, rgp->bh[0]->b_data);
return updated;
} else
- log_err("Resource group counts left inconsistent\n");
+ log_err( _("Resource group counts left inconsistent\n"));
}
return not_updated;
}
@@ -237,7 +239,7 @@ int pass5(struct gfs2_sbd *sbp)
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
- log_info("Verifying Resource Group #%" PRIu64 "\n", rg_count);
+ log_info( _("Verifying Resource Group #%" PRIu64 "\n"), rg_count);
memset(count, 0, sizeof(count));
rgp = osi_list_entry(tmp, struct rgrp_list, list);
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index e8429a6..35e7811 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -18,6 +18,8 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "libgfs2.h"
#include "osi_list.h"
@@ -58,7 +60,7 @@ void find_journaled_rgs(struct gfs2_sbd *sdp)
osi_list_init(&false_rgrps.list);
for (j = 0; j < sdp->md.journals; j++) {
- log_debug("Checking for RGs in journal%d.\n", j);
+ log_debug( _("Checking for RGs in journal%d.\n"), j);
ip = sdp->md.journal[j];
jblocks = ip->i_di.di_size / sdp->sd_sb.sb_bsize;
for (b = 0; b < jblocks; b++) {
@@ -68,8 +70,8 @@ void find_journaled_rgs(struct gfs2_sbd *sdp)
break;
bh = bread(&sdp->buf_list, dblock);
if (!gfs2_check_meta(bh, GFS2_METATYPE_RG)) {
- log_debug("False RG found at block "
- "0x%" PRIx64 "\n", dblock);
+ log_debug( _("False RG found at block "
+ "0x%" PRIx64 "\n"), dblock);
gfs2_special_set(&false_rgrps, dblock);
}
brelse(bh, not_updated);
@@ -144,14 +146,15 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
if (((blk == sdp->sb_addr + 1) ||
(!gfs2_check_meta(bh, GFS2_METATYPE_RG))) &&
!is_false_rg(blk)) {
- log_debug("RG found at block 0x%" PRIx64 "\n", blk);
+ log_debug( _("RG found at block 0x%" PRIx64 "\n"), blk);
if (blk > sdp->sb_addr + 1) {
uint64_t rgdist;
rgdist = blk - block_of_last_rg;
- log_debug("dist 0x%" PRIx64 " = 0x% " PRIx64
- " - 0x%" PRIx64, rgdist,
- blk, block_of_last_rg);
+ log_debug("dist 0x%llx = 0x%llx - 0x%llx",
+ (unsigned long long)rgdist,
+ (unsigned long long)blk,
+ (unsigned long long)block_of_last_rg);
/* ----------------------------------------- */
/* We found an RG. Check to see if we need */
/* to set the first_rg_dist based on whether */
@@ -164,7 +167,7 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
first_rg_dist = rgdist;
if (rgdist < shortest_dist_btwn_rgs) {
shortest_dist_btwn_rgs = rgdist;
- log_debug("(shortest so far)\n");
+ log_debug( _("(shortest so far)\n"));
}
else
log_debug("\n");
@@ -183,8 +186,8 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
/* first_rg_dist would measure from #1 to #3, which would be bad. */
/* We need to take remedial measures to fix it (from the index). */
/* -------------------------------------------------------------- */
- log_debug("First RG distance: 0x%" PRIx64 "\n", first_rg_dist);
- log_debug("Distance between RGs: 0x%" PRIx64 "\n",
+ log_debug( _("First RG distance: 0x%" PRIx64 "\n"), first_rg_dist);
+ log_debug( _("Distance between RGs: 0x%" PRIx64 "\n"),
shortest_dist_btwn_rgs);
if (first_rg_dist >= shortest_dist_btwn_rgs +
(shortest_dist_btwn_rgs / 4)) {
@@ -194,18 +197,18 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
sizeof(struct gfs2_rindex));
gfs2_rindex_in(&tmpndx, (char *)&buf);
if (tmpndx.ri_addr > sdp->sb_addr + 1) { /* sanity check */
- log_warn("RG 2 is damaged: getting dist from index: ");
+ log_warn( _("RG 2 is damaged: getting dist from index: "));
first_rg_dist = tmpndx.ri_addr - (sdp->sb_addr + 1);
log_warn("0x%" PRIx64 "\n", first_rg_dist);
}
else {
- log_warn("RG index 2 is damaged: extrapolating dist: ");
+ log_warn( _("RG index 2 is damaged: extrapolating dist: "));
first_rg_dist = sdp->device.length -
(sdp->rgrps - 1) *
(sdp->device.length / sdp->rgrps);
log_warn("0x%" PRIx64 "\n", first_rg_dist);
}
- log_debug("Adjusted first RG distance: 0x%" PRIx64 "\n",
+ log_debug( _("Adjusted first RG distance: 0x%" PRIx64 "\n"),
first_rg_dist);
} /* if first RG distance is within tolerance */
/* -------------------------------------------------------------- */
@@ -216,14 +219,14 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
block_bump = first_rg_dist;
for (blk = sdp->sb_addr + 1; blk <= sdp->device.length;
blk += block_bump) {
- log_debug("Block 0x%" PRIx64 "\n", blk);
+ log_debug( _("Block 0x%" PRIx64 "\n"), blk);
bh = bread(&sdp->nvbuf_list, blk);
rg_was_fnd = (!gfs2_check_meta(bh, GFS2_METATYPE_RG));
brelse(bh, not_updated);
/* Allocate a new RG and index. */
calc_rgd = malloc(sizeof(struct rgrp_list));
if (!calc_rgd) {
- log_crit("Can't allocate memory for rg repair.\n");
+ log_crit( _("Can't allocate memory for rg repair.\n"));
return -1;
}
memset(calc_rgd, 0, sizeof(struct rgrp_list));
@@ -236,11 +239,11 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
/* ------------------------------------------------- */
corrupt_rgs++;
if (corrupt_rgs < 5)
- log_debug("Missing or damaged RG at block %"
- PRIu64 " (0x%" PRIx64 ")\n",
+ log_debug( _("Missing or damaged RG at block %"
+ PRIu64 " (0x%" PRIx64 ")\n"),
blk, blk);
else {
- log_crit("Error: too many bad RGs.\n");
+ log_crit( _("Error: too many bad RGs.\n"));
return -1;
}
}
@@ -262,10 +265,11 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
} /* for subsequent bitmaps */
gfs2_compute_bitstructs(sdp, calc_rgd);
- log_debug("Memory allocated for rg at 0x%p, bh:\n",
- calc_rgd->ri.ri_addr, calc_rgd->bh);
+ log_debug( _("Memory allocated for rg at 0x%llx, bh: %p\n"),
+ (unsigned long long)calc_rgd->ri.ri_addr,
+ calc_rgd->bh);
if (!calc_rgd->bh) {
- log_crit("Can't allocate memory for bitmap repair.\n");
+ log_crit( _("Can't allocate memory for bitmap repair.\n"));
return -1;
}
calc_rgd->ri.ri_data0 = calc_rgd->ri.ri_addr +
@@ -282,11 +286,11 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
GFS2_NBBY;
prev_rgd->ri.ri_bitbytes = prev_rgd->ri.ri_data /
GFS2_NBBY;
- log_debug("Prev ri_data set to: %" PRIx32 ".\n",
+ log_debug( _("Prev ri_data set to: %" PRIx32 ".\n"),
prev_rgd->ri.ri_data);
}
number_of_rgs++;
- log_warn("%c RG %d at block 0x%" PRIX64 " %s",
+ log_warn( _("%c RG %d at block 0x%" PRIX64 " %s"),
(rg_was_fnd ? ' ' : '*'), number_of_rgs, blk,
(rg_was_fnd ? "intact" : "*** DAMAGED ***"));
prev_rgd = calc_rgd;
@@ -297,7 +301,7 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
else
block_bump = shortest_dist_btwn_rgs;
if (block_bump != 1)
- log_warn(" [length 0x%" PRIx64 "]\n", block_bump);
+ log_warn( _(" [length 0x%" PRIx64 "]\n"), block_bump);
} /* for each rg block */
/* ----------------------------------------------------------------- */
/* If we got to the end of the fs, we still need to fix the */
@@ -313,20 +317,21 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list,
prev_rgd->ri.ri_data = rgblocks;
prev_rgd->ri.ri_data -= prev_rgd->ri.ri_data % GFS2_NBBY;
prev_rgd->ri.ri_bitbytes = prev_rgd->ri.ri_data / GFS2_NBBY;
- log_debug("Prev ri_data set to: %" PRIx32 ".\n",
+ log_debug( _("Prev ri_data set to: %" PRIx32 ".\n"),
prev_rgd->ri.ri_data);
prev_rgd = NULL; /* make sure we don't use it later */
}
/* ---------------------------------------------- */
/* Now dump out the information (if verbose mode) */
/* ---------------------------------------------- */
- log_debug("RG index rebuilt as follows:\n");
+ log_debug( _("RG index rebuilt as follows:\n"));
for (tmp = ret_list, rgi = 0; tmp != ret_list;
tmp = tmp->next, rgi++) {
calc_rgd = osi_list_entry(tmp, struct rgrp_list, list);
- log_debug("%d: 0x%" PRIx64 " / %x / 0x%"
- PRIx64 " / 0x%x / 0x%x\n", rgi + 1,
- calc_rgd->ri.ri_addr, calc_rgd->ri.ri_length,
+ log_debug("%d: 0x%llx / %x / 0x%llx"
+ " / 0x%x / 0x%x\n", rgi + 1,
+ (unsigned long long)calc_rgd->ri.ri_addr,
+ calc_rgd->ri.ri_length,
calc_rgd->ri.ri_data0, calc_rgd->ri.ri_data,
calc_rgd->ri.ri_bitbytes);
}
@@ -358,7 +363,7 @@ int gfs2_rindex_calculate(struct gfs2_sbd *sdp, osi_list_t *ret_list,
compute_rgrp_layout(sdp, FALSE);
build_rgrps(sdp, FALSE); /* FALSE = calc but don't write to disk. */
*num_rgs = 0;
- log_debug("fs_total_size = 0x%" PRIX64 " blocks.\n",
+ log_debug( _("fs_total_size = 0x%" PRIX64 " blocks.\n"),
sdp->device.length);
/* ----------------------------------------------------------------- */
/* Calculate how many RGs there are supposed to be based on the */
@@ -368,7 +373,7 @@ int gfs2_rindex_calculate(struct gfs2_sbd *sdp, osi_list_t *ret_list,
/* the index. */
/* ----------------------------------------------------------------- */
*num_rgs = sdp->md.riinode->i_di.di_size / sizeof(struct gfs2_rindex);
- log_warn("L2: number of rgs in the index = %d.\n", *num_rgs);
+ log_warn( _("L2: number of rgs in the index = %d.\n"), *num_rgs);
/* Move the rg list to the return list */
ret_list->next = sdp->rglist.next;
ret_list->prev = sdp->rglist.prev;
@@ -386,15 +391,15 @@ int rewrite_rg_block(struct gfs2_sbd *sdp, struct rgrp_list *rg,
{
int x = errblock - rg->ri.ri_addr;
- log_err("Block #%"PRIu64" (0x%" PRIx64") (%d of %d) is neither"
- " GFS2_METATYPE_RB nor GFS2_METATYPE_RG.\n",
+ log_err( _("Block #%"PRIu64" (0x%" PRIx64") (%d of %d) is neither"
+ " GFS2_METATYPE_RB nor GFS2_METATYPE_RG.\n"),
rg->bh[x]->b_blocknr, rg->bh[x]->b_blocknr,
(int)x+1, (int)rg->ri.ri_length);
errors_found++;
if (query(&opts, "Fix the RG? (y/n)")) {
errors_corrected++;
- log_err("Attempting to repair the RG.\n");
+ log_err( _("Attempting to repair the RG.\n"));
rg->bh[x] = bread(&sdp->nvbuf_list, rg->ri.ri_addr + x);
if (x) {
struct gfs2_meta_header mh;
@@ -448,7 +453,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count)
error = gfs2_rindex_rebuild(sdp, &expected_rglist,
&calc_rg_count);
if (error) {
- log_crit("Error rebuilding rg list.\n");
+ log_crit( _("Error rebuilding rg list.\n"));
gfs2_rgrp_free(&expected_rglist, not_updated);
return -1;
}
@@ -458,16 +463,16 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count)
osi_list_init(&sdp->rglist); /* Just to be safe */
rindex_read(sdp, 0, &rgcount_from_index);
if (sdp->md.riinode->i_di.di_size % sizeof(struct gfs2_rindex)) {
- log_warn("WARNING: rindex file is corrupt.\n");
+ log_warn( _("WARNING: rindex file is corrupt.\n"));
gfs2_rgrp_free(&expected_rglist, not_updated);
gfs2_rgrp_free(&sdp->rglist, not_updated);
return -1;
}
- log_warn("L%d: number of rgs expected = %d.\n", trust_lvl + 1,
- sdp->rgrps);
+ log_warn( _("L%d: number of rgs expected = %lld.\n"), trust_lvl + 1,
+ (unsigned long long)sdp->rgrps);
if (calc_rg_count != sdp->rgrps) {
- log_warn("L%d: They don't match; either (1) the fs was extended, (2) an odd\n", trust_lvl + 1);
- log_warn("L%d: rg size was used, or (3) we have a corrupt rg index.\n", trust_lvl + 1);
+ log_warn( _("L%d: They don't match; either (1) the fs was extended, (2) an odd\n"), trust_lvl + 1);
+ log_warn( _("L%d: rg size was used, or (3) we have a corrupt rg index.\n"), trust_lvl + 1);
gfs2_rgrp_free(&expected_rglist, not_updated);
gfs2_rgrp_free(&sdp->rglist, not_updated);
return -1;
@@ -496,9 +501,9 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count)
}
}
if (trust_lvl < distrust && descrepencies > (trust_lvl * 8)) {
- log_warn("Level %d didn't work. Too many descepencies.\n",
+ log_warn( _("Level %d didn't work. Too many descepencies.\n"),
trust_lvl + 1);
- log_warn("%d out of %d RGs did not match what was expected.\n",
+ log_warn( _("%d out of %d RGs did not match what was expected.\n"),
descrepencies, rg);
gfs2_rgrp_free(&expected_rglist, not_updated);
gfs2_rgrp_free(&sdp->rglist, not_updated);
@@ -525,7 +530,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count)
/* If we modified the index, write it back to disk. */
if (rindex_modified) {
errors_found++;
- if (query(&opts, "Fix the index? (y/n)")) {
+ if (query(&opts, _("Fix the index? (y/n)"))) {
errors_corrected++;
gfs2_rindex_out(&expected->ri, (char *)&buf);
gfs2_writei(sdp->md.riinode, (char *)&buf,
@@ -547,7 +552,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count)
free(actual->bits);
}
else
- log_err("RG index not fixed.\n");
+ log_err( _("RG index not fixed.\n"));
gfs2_compute_bitstructs(sdp, actual);
rindex_modified = FALSE;
}
diff --git a/gfs2/fsck/test_block_list.c b/gfs2/fsck/test_block_list.c
index 049eb91..b8e47e6 100644
--- a/gfs2/fsck/test_block_list.c
+++ b/gfs2/fsck/test_block_list.c
@@ -36,7 +36,7 @@ int main(int argc, char **argv)
block_mark(il, BITS-2, meta_inval);
block_mark(il, BITS-1, meta_free);
if(block_mark(il, BITS, meta_free)) {
- fprintf(stderr, "Block %d out of bounds\n", BITS);
+ fprintf(stderr, _("Block %d out of bounds\n"), BITS);
}
/*for(i = 0; i < BITS; i++) {
@@ -65,7 +65,7 @@ void print_map(struct block_list *il, int count)
int i, j;
struct block_query q;
- printf("Printing map of blocks - 60 blocks per row\n");
+ printf( _("Printing map of blocks - 60 blocks per row\n"));
j = 0;
for(i = 0; i < count; i++) {
@@ -83,7 +83,7 @@ void print_map(struct block_list *il, int count)
}
printf("\n");
- printf("Printing map of bad blocks - 60 blocks per row\n");
+ printf( _("Printing map of bad blocks - 60 blocks per row\n"));
j = 0;
for(i = 0; i < count; i++) {
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 074e6f9..ac609cb 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -18,6 +18,8 @@
#include <unistd.h>
#include <sys/time.h>
#include <stdio.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include "libgfs2.h"
#include "fs_bits.h"
@@ -75,7 +77,7 @@ void warm_fuzzy_stuff(uint64_t block)
seconds = tv.tv_sec;
if (last_fs_block) {
percent = (block * 100) / last_fs_block;
- log_notice("\r%" PRIu64 " percent complete.\r", percent);
+ log_notice( _("\r%" PRIu64 " percent complete.\r"), percent);
}
}
}
diff --git a/gfs2/mkfs/main.c b/gfs2/mkfs/main.c
index b8ff325..359b1c3 100644
--- a/gfs2/mkfs/main.c
+++ b/gfs2/mkfs/main.c
@@ -23,6 +23,9 @@
#include <time.h>
#include <errno.h>
#include <libgen.h>
+#include <libintl.h>
+#include <locale.h>
+#define _(String) gettext(String)
#include <linux/types.h>
#include "libgfs2.h"
@@ -44,6 +47,8 @@ main(int argc, char *argv[])
char *p, *whoami;
prog_name = argv[0];
+ setlocale(LC_ALL, "");
+ textdomain("gfs2-utils");
SRANDOM;
p = strdup(prog_name);
@@ -60,7 +65,7 @@ main(int argc, char *argv[])
main_shrink(argc, argv);
#endif
else
- die("I don't know who I am!\n");
+ die( _("I don't know who I am!\n"));
free(p);
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 1fe9e63..6e52a56 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -28,6 +28,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"
@@ -56,7 +58,7 @@ extern int rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name);
static void usage(void)
{
fprintf(stdout,
- "Usage:\n"
+ _("Usage:\n"
"\n"
"gfs2_grow [options] /path/to/filesystem\n"
"\n"
@@ -65,7 +67,7 @@ static void usage(void)
" -q Quiet, reduce verbosity\n"
" -T Test, do everything except update FS\n"
" -V Version information\n"
- " -v Verbose, increase verbosity\n");
+ " -v Verbose, increase verbosity\n"));
}
void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
@@ -90,8 +92,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)\n");
+ printf( _("(Test mode--File system will not "
+ "be changed)\n"));
test = 1;
break;
case 'v':
@@ -100,11 +102,11 @@ void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
case ':':
case '?':
/* Unknown flag */
- fprintf(stderr, "Please use '-h' for usage.\n");
+ fprintf(stderr, _("Please use '-h' for usage.\n"));
exit(EXIT_FAILURE);
default:
- fprintf(stderr, "Bad programmer! You forgot"
- " to catch the %c flag\n", opt);
+ fprintf(stderr, _("Bad programmer! You forgot"
+ " to catch the %c flag\n"), opt);
exit(EXIT_FAILURE);
break;
}
@@ -203,11 +205,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.\n", rg);
+ log_info( _("%d new rindex entries.\n"), rg);
writelen = rg * sizeof(struct gfs2_rindex);
zalloc(buf, writelen);
if (!buf)
- die("Unable to allocate memory for buffers.\n");
+ die( _("Unable to allocate memory for buffers.\n"));
/* Now add the new rg entries to the rg index. Here we */
/* need to use the gfs2 kernel code rather than the libgfs2 */
/* code so we have a live update while mounted. */
@@ -223,8 +225,8 @@ void fix_rindex(struct gfs2_sbd *sdp, int rindex_fd, int old_rg_count)
lseek(rindex_fd, 0, SEEK_END);
count = write(rindex_fd, buf, writelen);
if (count != writelen)
- log_crit("Error writing new rindex entries;"
- "aborted.\n");
+ log_crit( _("Error writing new rindex entries;"
+ "aborted.\n"));
fsync(rindex_fd);
}
free(buf);
@@ -236,14 +238,14 @@ void fix_rindex(struct gfs2_sbd *sdp, int rindex_fd, int old_rg_count)
*/
static void print_info(struct gfs2_sbd *sdp)
{
- log_notice("FS: Mount Point: %s\n", sdp->path_name);
- log_notice("FS: Device: %s\n", sdp->device_name);
- log_notice("FS: Size: %" PRIu64 " (0x%" PRIx64 ")\n",
+ log_notice( _("FS: Mount Point: %s\n"), sdp->path_name);
+ log_notice( _("FS: Device: %s\n"), sdp->device_name);
+ log_notice( _("FS: Size: %" PRIu64 " (0x%" PRIx64 ")\n"),
fssize, fssize);
- log_notice("FS: RG size: %u (0x%x)\n", rgsize, rgsize);
- log_notice("DEV: Size: %"PRIu64" (0x%" PRIx64")\n",
+ log_notice( _("FS: RG size: %u (0x%x)\n"), rgsize, rgsize);
+ log_notice( _("DEV: Size: %"PRIu64" (0x%" PRIx64")\n"),
sdp->device.length, sdp->device.length);
- log_notice("The file system grew by %" PRIu64 "MB.\n",
+ log_notice( _("The file system grew by %" PRIu64 "MB.\n"),
fsgrowth / MB);
}
@@ -272,17 +274,17 @@ main_grow(int argc, char *argv[])
sdp->path_name = argv[optind++];
sdp->path_fd = open(sdp->path_name, O_RDONLY);
if (sdp->path_fd < 0)
- die("can't open root directory %s: %s\n",
+ die( _("can't open root directory %s: %s\n"),
sdp->path_name, strerror(errno));
check_for_gfs2(sdp);
sdp->device_fd = open(sdp->device_name,
(test ? O_RDONLY : O_RDWR));
if (sdp->device_fd < 0)
- die("can't open device %s: %s\n",
+ die( _("can't open device %s: %s\n"),
sdp->device_name, strerror(errno));
device_geometry(sdp);
- log_info("Initializing lists...\n");
+ log_info( _("Initializing lists...\n"));
osi_list_init(&sdp->rglist);
init_buf_list(sdp, &sdp->buf_list, 128 << 20);
init_buf_list(sdp, &sdp->nvbuf_list, 0xffffffff);
@@ -291,7 +293,7 @@ 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.\n");
+ die( _("gfs: Error reading superblock.\n"));
fix_device_geometry(sdp);
mount_gfs2_meta(sdp);
@@ -300,7 +302,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.\n");
+ die( _("GFS2 rindex not found. Please run gfs2_fsck.\n"));
}
/* Get master dinode */
sdp->master_dir =
@@ -316,12 +318,12 @@ 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).\n");
- log_err("The device grew by %" PRIu64 "MB. ",
- fsgrowth / MB);
- log_err("One RG is %uMB for this file system.\n",
- (rgsize * sdp->bsize) / MB);
+ log_err( _("Error: The device has grown by less than "
+ "one Resource Group (RG).\n"));
+ log_err( _("The device grew by %" PRIu64 "MB. "),
+ fsgrowth / MB);
+ log_err( _("One RG is %uMB for this file system.\n"),
+ (rgsize * sdp->bsize) / MB);
}
else {
int old_rg_count;
@@ -340,5 +342,5 @@ main_grow(int argc, char *argv[])
}
close(sdp->path_fd);
sync();
- log_notice("gfs2_grow complete.\n");
+ log_notice( _("gfs2_grow complete.\n"));
}
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index e2bea53..4b5eb74 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -27,6 +27,8 @@
#include <time.h>
#include <errno.h>
#include <stdarg.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include <linux/types.h>
#include "libgfs2.h"
@@ -42,14 +44,14 @@ make_jdata(int fd, char *value)
err = ioctl(fd, FS_IOC_GETFLAGS, &val);
if (err)
- die("error doing get flags (%d): %s\n", err, strerror(errno));
+ die( _("error doing get flags (%d): %s\n"), 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\n", err, strerror(errno));
+ die( _("error doing set flags (%d): %s\n"), err, strerror(errno));
}
int
@@ -60,12 +62,12 @@ rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name)
error = snprintf(oldpath, PATH_MAX, "%s/new_inode",
sdp->metafs_path);
if (error >= PATH_MAX)
- die("rename2system (1)\n");
+ die( _("rename2system (1)\n"));
error = snprintf(newpath, PATH_MAX, "%s/%s/%s",
sdp->metafs_path, new_dir, new_name);
if (error >= PATH_MAX)
- die("rename2system (2)\n");
+ die( _("rename2system (2)\n"));
return rename(oldpath, newpath);
}
@@ -78,19 +80,16 @@ rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name)
static void
print_usage(void)
{
- printf("Usage:\n");
- printf("\n");
- printf("%s [options] /path/to/filesystem\n", prog_name);
- printf("\n");
- printf("Options:\n");
- printf("\n");
- printf(" -c <MB> Size of quota change file\n");
- printf(" -D Enable debugging code\n");
- printf(" -h Print this help, then exit\n");
- printf(" -J <MB> Size of journals\n");
- printf(" -j <num> Number of journals\n");
- printf(" -q Don't print anything\n");
- printf(" -V Print program version information, then exit\n");
+ printf( _("Usage:\n\n"
+ "%s [options] /path/to/filesystem\n\n"
+ "Options:\n\n"
+ " -c <MB> Size of quota change file\n"
+ " -D Enable debugging code\n"
+ " -h Print this help, then exit\n"
+ " -J <MB> Size of journals\n"
+ " -j <num> Number of journals\n"
+ " -q Don't print anything\n"
+ " -V Print program version information, then exit\n"), prog_name);
}
/**
@@ -148,7 +147,7 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
cont = FALSE;
break;
default:
- die("unknown option: %c\n", optchar);
+ die( _("unknown option: %c\n"), optchar);
break;
};
}
@@ -157,13 +156,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)\n");
+ die( _("no path specified (try -h for help)\n"));
if (optind < argc)
- die("Unrecognized option: %s\n", argv[optind]);
+ die( _("Unrecognized option: %s\n"), argv[optind]);
if (sdp->debug) {
- printf("Command Line Arguments:\n");
+ printf( _("Command Line Arguments:\n"));
printf(" qcsize = %u\n", sdp->qcsize);
printf(" jsize = %u\n", sdp->jsize);
printf(" journals = %u\n", sdp->md.journals);
@@ -176,11 +175,11 @@ static void
verify_arguments(struct gfs2_sbd *sdp)
{
if (!sdp->md.journals)
- die("no journals specified\n");
+ die( _("no journals specified\n"));
if (sdp->jsize < 32 || sdp->jsize > 1024)
- die("bad journal size\n");
+ die( _("bad journal size\n"));
if (!sdp->qcsize || sdp->qcsize > 64)
- die("bad quota change size\n");
+ die( _("bad quota change size\n"));
}
/**
@@ -200,9 +199,9 @@ print_results(struct gfs2_sbd *sdp)
if (sdp->expert)
printf("Expert mode: on\n");
- printf("Filesystem: %s\n", sdp->path_name);
- printf("Old Journals %u\n", sdp->orig_journals);
- printf("New Journals %u\n", sdp->md.journals);
+ printf( _("Filesystem: %s\n"), sdp->path_name);
+ printf( _("Old Journals %u\n"), sdp->orig_journals);
+ printf( _("New Journals %u\n"), sdp->md.journals);
}
@@ -224,10 +223,10 @@ create_new_inode(struct gfs2_sbd *sdp)
if (errno == EEXIST) {
error = unlink(name);
if (error)
- die("can't unlink %s: %s\n",
+ die( _("can't unlink %s: %s\n"),
name, strerror(errno));
} else
- die("can't create %s: %s\n", name, strerror(errno));
+ die( _("can't create %s: %s\n"), name, strerror(errno));
}
return fd;
@@ -254,7 +253,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\n",
+ die( _("can't rename2system %s (%d): %s\n"),
new_name, error, strerror(errno));
}
@@ -280,7 +279,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\n",
+ die( _("can't rename2system %s (%d): %s\n"),
new_name, error, strerror(errno));
}
@@ -321,7 +320,7 @@ add_qc(struct gfs2_sbd *sdp)
error = fsync(fd);
if (error)
- die("can't fsync: %s\n",
+ die( _("can't fsync: %s\n"),
strerror(errno));
}
@@ -330,7 +329,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\n",
+ die( _("can't rename2system %s (%d): %s\n"),
new_name, error, strerror(errno));
}
@@ -370,7 +369,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\n",
+ die( _("Could not statfs the filesystem %s: %s\n"),
sdp->path_name, strerror(errno));
}
sdp->bsize = statbuf.f_bsize;
@@ -388,8 +387,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\n", strerror(errno));
+ die( _("Could not find the jindex directory "
+ "in gfs2meta mount! error: %s\n"), strerror(errno));
}
while (dirp) {
if ((dp = readdir(dirp)) != NULL) {
@@ -401,8 +400,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?\n");
+ die( _("There are no journals for this "
+ "gfs2 fs! Did you mkfs.gfs2 correctly?\n"));
}
sdp->orig_journals = existing_journals;
@@ -456,7 +455,7 @@ add_j(struct gfs2_sbd *sdp)
error = fsync(fd);
if (error)
- die("can't fsync: %s\n",
+ die( _("can't fsync: %s\n"),
strerror(errno));
}
@@ -465,7 +464,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\n",
+ die( _("can't rename2system %s (%d): %s\n"),
new_name, error, strerror(errno));
}
@@ -492,7 +491,7 @@ 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\n",
+ die( _("can't open root directory %s: %s\n"),
sdp->path_name, strerror(errno));
check_for_gfs2(sdp);
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 615a17c..3456f6d 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -26,6 +26,9 @@
#include <mntent.h>
#include <ctype.h>
#include <sys/time.h>
+#include <libintl.h>
+#define _(String) gettext(String)
+
#include <linux/types.h>
#include "libgfs2.h"
@@ -55,25 +58,22 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)
static void
print_usage(void)
{
- printf("Usage:\n");
- printf("\n");
- printf("%s [options] <device> [ block-count ]\n", prog_name);
- printf("\n");
- printf("Options:\n");
- printf("\n");
- printf(" -b <bytes> Filesystem block size\n");
- printf(" -c <MB> Size of quota change file\n");
- printf(" -D Enable debugging code\n");
- printf(" -h Print this help, then exit\n");
- printf(" -J <MB> Size of journals\n");
- printf(" -j <num> Number of journals\n");
- printf(" -O Don't ask for confirmation\n");
- printf(" -p <name> Name of the locking protocol\n");
- printf(" -q Don't print anything\n");
- printf(" -r <MB> Resource Group Size\n");
- printf(" -t <name> Name of the lock table\n");
- printf(" -u <MB> Size of unlinked file\n");
- printf(" -V Print program version information, then exit\n");
+ printf( _("Usage:\n\n"
+ "%s [options] <device> [ block-count ]\n\n"
+ "Options:\n\n"
+ " -b <bytes> Filesystem block size\n"
+ " -c <MB> Size of quota change file\n"
+ " -D Enable debugging code\n"
+ " -h Print this help, then exit\n"
+ " -J <MB> Size of journals\n"
+ " -j <num> Number of journals\n"
+ " -O Don't ask for confirmation\n"
+ " -p <name> Name of the locking protocol\n"
+ " -q Don't print anything\n"
+ " -r <MB> Resource Group Size\n"
+ " -t <name> Name of the lock table\n"
+ " -u <MB> Size of unlinked file\n"
+ " -V Print program version information, then exit\n"), prog_name);
}
/**
@@ -129,7 +129,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\n",
+ die( _("lock protocol name %s is too long\n"),
optarg);
strcpy(sdp->lockproto, optarg);
break;
@@ -144,7 +144,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\n", optarg);
+ die( _("lock table name %s is too long\n"), optarg);
strcpy(sdp->locktable, optarg);
break;
@@ -165,7 +165,7 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
case ':':
case '?':
- fprintf(stderr, "Please use '-h' for usage.\n");
+ fprintf(stderr, _("Please use '-h' for usage.\n"));
exit(EXIT_FAILURE);
break;
@@ -182,11 +182,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)\n");
+ die( _("More than one device specified (try -h for help)\n"));
break;
default:
- die("unknown option: %c\n", optchar);
+ die( _("unknown option: %c\n"), optchar);
break;
};
}
@@ -195,16 +195,16 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
strcpy(sdp->device_name, argv[optind++]);
if (sdp->device_name[0] == '\0')
- die("no device specified (try -h for help)\n");
+ die( _("no device specified (try -h for help)\n"));
if (optind < argc)
sdp->orig_fssize = atol(argv[optind++]);
if (optind < argc)
- die("Unrecognized argument: %s\n", argv[optind]);
+ die( _("Unrecognized argument: %s\n"), argv[optind]);
if (sdp->debug) {
- printf("Command Line Arguments:\n");
+ printf( _("Command Line Arguments:\n"));
printf(" bsize = %u\n", sdp->bsize);
printf(" qcsize = %u\n", sdp->qcsize);
printf(" jsize = %u\n", sdp->jsize);
@@ -213,7 +213,7 @@ decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
printf(" proto = %s\n", sdp->lockproto);
printf(" quiet = %d\n", sdp->quiet);
if (sdp->rgsize==-1)
- printf(" rgsize = optimize for best performance\n");
+ printf( _(" rgsize = optimize for best performance\n"));
else
printf(" rgsize = %u\n", sdp->rgsize);
printf(" table = %s\n", sdp->locktable);
@@ -240,28 +240,28 @@ 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\n");
+ die( _("block size must be a power of two between 512 and 65536\n"));
/* 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\n");
+ die( _("bad resource group size\n"));
} else {
if (32 > sdp->rgsize || sdp->rgsize > 2048)
- die("bad resource group size\n");
+ die( _("bad resource group size\n"));
}
if (!sdp->md.journals)
- die("no journals specified\n");
+ die( _("no journals specified\n"));
if (sdp->jsize < 8 || sdp->jsize > 1024)
- die("bad journal size\n");
+ die( _("bad journal size\n"));
if (!sdp->utsize || sdp->utsize > 64)
- die("bad unlinked size\n");
+ die( _("bad unlinked size\n"));
if (!sdp->qcsize || sdp->qcsize > 64)
- die("bad quota change size\n");
+ die( _("bad quota change size\n"));
}
/**
@@ -277,19 +277,19 @@ static void are_you_sure(struct gfs2_sbd *sdp)
vid = volume_id_open_node(sdp->device_name);
if (vid == NULL)
- die("error identifying the contents of %s: %s\n",
- sdp->device_name, strerror(errno));
+ die( _("error identifying the contents of %s: %s\n"),
+ sdp->device_name, strerror(errno));
- printf("This will destroy any data on %s.\n", sdp->device_name);
+ printf( _("This will destroy any data on %s.\n"), sdp->device_name);
if (volume_id_probe_all(vid, 0, sdp->device_size) == 0)
- printf(" It appears to contain a %s %s.\n", vid->type,
- vid->usage_id == VOLUME_ID_OTHER? "partition" : vid->usage);
+ printf( _(" It appears to contain a %s %s.\n"), vid->type,
+ vid->usage_id == VOLUME_ID_OTHER? "partition" : vid->usage);
volume_id_close(vid);
- printf("\nAre you sure you want to proceed? [y/n] ");
+ printf(_("\nAre you sure you want to proceed? [y/n] "));
fgets(input, 32, stdin);
if (input[0] != 'y')
- die("aborted\n");
+ die( _("aborted\n"));
else
printf("\n");
}
@@ -306,15 +306,15 @@ void check_mount(char *device)
int fd;
if (stat(device, &st_buf) < 0)
- die("could not stat device %s\n", device);
+ die( _("could not stat device %s\n"), device);
if (!S_ISBLK(st_buf.st_mode))
- die("%s is not a block device\n", device);
+ die( _("%s is not a block device\n"), device);
fd = open(device, O_RDONLY | O_NONBLOCK | O_EXCL);
if (fd < 0) {
if (errno == EBUSY) {
- die("device %s is busy\n", device);
+ die( _("device %s is busy\n"), device);
}
}
else {
@@ -384,30 +384,31 @@ print_results(struct gfs2_sbd *sdp, uint64_t real_device_size,
return;
if (sdp->expert)
- printf("Expert mode: on\n");
+ printf( _("Expert mode: on\n"));
- printf("Device: %s\n", sdp->device_name);
+ printf( _("Device: %s\n"), sdp->device_name);
- printf("Blocksize: %u\n", sdp->bsize);
- printf("Device Size %.2f GB (%"PRIu64" blocks)\n",
+ printf( _("Blocksize: %u\n"), sdp->bsize);
+ printf( _("Device Size %.2f GB (%"PRIu64" blocks)\n"),
real_device_size / ((float)(1 << 30)),
real_device_size / sdp->bsize);
- printf("Filesystem Size: %.2f GB (%"PRIu64" blocks)\n",
+ printf( _("Filesystem Size: %.2f GB (%"PRIu64" blocks)\n"),
sdp->fssize / ((float)(1 << 30)) * sdp->bsize, sdp->fssize);
- printf("Journals: %u\n", sdp->md.journals);
- printf("Resource Groups: %"PRIu64"\n", sdp->rgrps);
+ printf( _("Journals: %u\n"), sdp->md.journals);
+ printf( _("Resource Groups: %"PRIu64"\n"), sdp->rgrps);
- printf("Locking Protocol: \"%s\"\n", sdp->lockproto);
- printf("Lock Table: \"%s\"\n", sdp->locktable);
+ printf( _("Locking Protocol: \"%s\"\n"), sdp->lockproto);
+ printf( _("Lock Table: \"%s\"\n"), sdp->locktable);
if (sdp->debug) {
printf("\n");
- printf("Spills: %u\n",
+ printf( _("Spills: %u\n"),
sdp->buf_list.spills);
- printf("Writes: %u\n", sdp->writes);
+ printf( _("Writes: %u\n"), sdp->writes);
}
- printf("UUID: %s\n", str_uuid(uuid));
+
+ printf( _("UUID: %s\n"), str_uuid(uuid));
printf("\n");
}
@@ -451,7 +452,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\n",
+ die( _("can't open device %s: %s\n"),
sdp->device_name, strerror(errno));
if (!sdp->override)
@@ -468,9 +469,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.\n", prog_name);
- die("Device Size is %.2f GB (%"PRIu64" blocks)\n",
+ fprintf(stderr, _("%s: Specified block count is bigger "
+ "than the actual device.\n"), argv[0]);
+ die( _("Device Size is %.2f GB (%"PRIu64" blocks)\n"),
real_device_size / ((float)(1 << 30)),
real_device_size / sdp->bsize);
}
@@ -512,11 +513,11 @@ main_mkfs(int argc, char *argv[])
error = fsync(sdp->device_fd);
if (error)
- die("can't fsync device (%d): %s\n",
+ die( _("can't fsync device (%d): %s\n"),
error, strerror(errno));
error = close(sdp->device_fd);
if (error)
- die("error closing device (%d): %s\n",
+ die( _("error closing device (%d): %s\n"),
error, strerror(errno));
print_results(sdp, real_device_size, uuid);
diff --git a/gfs2/tool/main.c b/gfs2/tool/main.c
index 8a8afaf..a2529c2 100644
--- a/gfs2/tool/main.c
+++ b/gfs2/tool/main.c
@@ -24,6 +24,9 @@
#include <limits.h>
#include <errno.h>
#include <linux/types.h>
+#include <libintl.h>
+#include <locale.h>
+#define _(String) gettext(String)
#include "copyright.cf"
@@ -206,15 +209,16 @@ decode_arguments(int argc, char *argv[])
break;
default:
- die("unknown option: %c\n", optchar);
+ die( _("unknown option: %c\n"), optchar);
};
}
if (optind < argc) {
action = argv[optind];
optind++;
- } else
- die("no action specified\n");
+ } else {
+ die( _("no action specified\n"));
+ }
}
/**
diff --git a/gfs2/tool/misc.c b/gfs2/tool/misc.c
index 940c2b7..4176882 100644
--- a/gfs2/tool/misc.c
+++ b/gfs2/tool/misc.c
@@ -25,6 +25,8 @@
#include <limits.h>
#include <errno.h>
#include <dirent.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#define __user
#include <linux/gfs2_ondisk.h>
@@ -128,8 +130,7 @@ print_lockdump(int argc, char **argv)
sprintf(debugfs, "/tmp/debugfs.XXXXXX");
if (!mkdtemp(debugfs)) {
- fprintf(stderr,
- "Can't create %s mount point.\n",
+ fprintf(stderr,_("Can't create %s mount point.\n"),
debugfs);
free(debugfs);
exit(-1);
@@ -138,8 +139,8 @@ print_lockdump(int argc, char **argv)
rc = mount("none", debugfs, "debugfs", 0, NULL);
if (rc) {
fprintf(stderr,
- "Can't mount debugfs. "
- "Maybe your kernel doesn't support it.\n");
+ _("Can't mount debugfs. "
+ "Maybe your kernel doesn't support it.\n"));
free(debugfs);
exit(-1);
}
@@ -151,15 +152,15 @@ print_lockdump(int argc, char **argv)
file = fopen(path, "rt");
if (file) {
while (fgets(line, PATH_MAX, file)) {
- printf(line);
+ printf("%s", line);
}
fclose(file);
} else {
- fprintf(stderr, "Can't open %s: %s\n", path,
+ fprintf(stderr, _("Can't open %s: %s\n"), path,
strerror(errno));
}
} else {
- fprintf(stderr, "Unable to locate sysfs for mount point %s.\n",
+ fprintf(stderr, _("Unable to locate sysfs for mount point %s.\n"),
argv[optind]);
}
/* Check if we mounted the debugfs and if so, unmount it. */
@@ -193,7 +194,7 @@ static void
print_flags(struct gfs2_dinode *di)
{
if (di->di_flags) {
- printf("Flags:\n");
+ printf( _("Flags:\n"));
if (di->di_flags & GFS2_DIF_JDATA)
printf(" jdata\n");
if (di->di_flags & GFS2_DIF_EXHASH)
@@ -259,22 +260,22 @@ set_flag(int argc, char **argv)
set = (strcmp(argv[optind -1], "setflag") == 0) ? 1 : 0;
flstr = argv[optind++];
if (!(flag = get_flag_from_name(flstr)))
- die("unrecognized flag %s\n", argv[optind -1]);
+ die( _("unrecognized flag %s\n"), argv[optind -1]);
for (; optind < argc; optind++) {
fd = open(argv[optind], O_RDONLY);
if (fd < 0)
- die("can't open %s: %s\n", argv[optind], strerror(errno));
+ die( _("can't open %s: %s\n"), argv[optind], strerror(errno));
/* first get the existing flags on the file */
error = ioctl(fd, FS_IOC_GETFLAGS, &newflags);
if (error)
- die("can't get flags on %s: %s\n",
+ die( _("can't get flags on %s: %s\n"),
argv[optind], strerror(errno));
newflags = set ? newflags | flag : newflags & ~flag;
/* new flags */
error = ioctl(fd, FS_IOC_SETFLAGS, &newflags);
if (error)
- die("can't set flags on %s: %s\n",
+ die( _("can't set flags on %s: %s\n"),
argv[optind], strerror(errno));
close(fd);
}
@@ -441,14 +442,14 @@ print_journals(int argc, char **argv)
check_for_gfs2(&sbd);
sbd.device_fd = open(sbd.device_name, O_RDONLY);
if (sbd.device_fd < 0)
- die("can't open device %s: %s\n",
+ die( _("can't open device %s: %s\n"),
sbd.device_name, strerror(errno));
mount_gfs2_meta(&sbd);
sprintf(jindex_name, "%s/jindex", sbd.metafs_path);
jindex = opendir(jindex_name);
if (!jindex) {
- die("Can't open %s\n", jindex_name);
+ die( _("Can't open %s\n"), jindex_name);
} else {
jcount = 0;
while ((journal = readdir(jindex))) {
@@ -464,7 +465,7 @@ print_journals(int argc, char **argv)
(unsigned long long)statbuf.st_size / 1048576);
}
- printf("%d journal(s) found.\n", jcount);
+ printf( _("%d journal(s) found.\n"), jcount);
closedir(jindex);
}
cleanup_metafs(&sbd);
diff --git a/gfs2/tool/sb.c b/gfs2/tool/sb.c
index ccf4039..cf76d6e 100644
--- a/gfs2/tool/sb.c
+++ b/gfs2/tool/sb.c
@@ -26,6 +26,8 @@
#include <limits.h>
#include <errno.h>
#include <ctype.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#include <linux/gfs2_ondisk.h>
@@ -105,12 +107,13 @@ do_sb(int argc, char **argv)
die("can't open %s: %s\n", device, strerror(errno));
if (newval && !override) {
- printf("You shouldn't change any of these values if the filesystem is mounted.\n");
- printf("\nAre you sure? [y/n] ");
- fgets((char*)input, 255, stdin);
+ printf( _("You shouldn't change any of these values if the filesystem is mounted.\n"));
+ printf( _("\nAre you sure? [y/n] "));
+ if(!fgets((char*)input, 255, stdin))
+ die( _("unable to read from stdin\n"));
if (input[0] != 'y')
- die("aborted\n");
+ die( _("aborted\n"));
printf("\n");
}
@@ -122,84 +125,84 @@ do_sb(int argc, char **argv)
if (sb.sb_header.mh_magic != GFS2_MAGIC ||
sb.sb_header.mh_type != GFS2_METATYPE_SB)
- die("there isn't a GFS2 filesystem on %s\n", device);
+ die( _("there isn't a GFS2 filesystem on %s\n"), device);
if (strcmp(field, "proto") == 0) {
- printf("current lock protocol name = \"%s\"\n",
+ printf( _("current lock protocol name = \"%s\"\n"),
sb.sb_lockproto);
if (newval) {
if (strlen(newval) >= GFS2_LOCKNAME_LEN)
- die("new lockproto name is too long\n");
+ die( _("new lockproto name is too long\n"));
strcpy(sb.sb_lockproto, newval);
- printf("new lock protocol name = \"%s\"\n",
+ printf( _("new lock protocol name = \"%s\"\n"),
sb.sb_lockproto);
}
} else if (strcmp(field, "table") == 0) {
- printf("current lock table name = \"%s\"\n",
+ printf( _("current lock table name = \"%s\"\n"),
sb.sb_locktable);
if (newval) {
if (strlen(newval) >= GFS2_LOCKNAME_LEN)
- die("new locktable name is too long\n");
+ die( _("new locktable name is too long\n"));
strcpy(sb.sb_locktable, newval);
- printf("new lock table name = \"%s\"\n",
+ printf( _("new lock table name = \"%s\"\n"),
sb.sb_locktable);
}
} else if (strcmp(field, "ondisk") == 0) {
- printf("current ondisk format = %u\n",
+ printf( _("current ondisk format = %u\n"),
sb.sb_fs_format);
if (newval) {
sb.sb_fs_format = atoi(newval);
- printf("new ondisk format = %u\n",
+ printf( _("new ondisk format = %u\n"),
sb.sb_fs_format);
}
} else if (strcmp(field, "multihost") == 0) {
- printf("current multihost format = %u\n",
+ printf( _("current multihost format = %u\n"),
sb.sb_multihost_format);
if (newval) {
sb.sb_multihost_format = atoi(newval);
- printf("new multihost format = %u\n",
+ printf( _("new multihost format = %u\n"),
sb.sb_multihost_format);
}
#ifdef GFS2_HAS_UUID
} else if (strcmp(field, "uuid") == 0) {
- printf("current uuid = %s\n", str_uuid(sb.sb_uuid));
+ printf( _("current uuid = %s\n"), str_uuid(sb.sb_uuid));
if (newval) {
int i;
unsigned char uuid[16], *cp;
if (strlen(newval) != 36)
- die("uuid %s is the wrong length; must be 36 "
- "hex characters long.\n", newval);
+ die( _("uuid %s is the wrong length; must be 36 "
+ "hex characters long.\n"), newval);
cp = uuid;
for (i = 0; i < 36; i++) {
if ((i == 8) || (i == 13) ||
(i == 18) || (i == 23)) {
if (newval[i] == '-')
continue;
- die("uuid %s has an invalid format.",
+ die( _("uuid %s has an invalid format."),
newval);
}
if (!isxdigit(newval[i]))
- die("uuid %s has an invalid hex "
- "digit '%c' at offset %d.\n",
+ die( _("uuid %s has an invalid hex "
+ "digit '%c' at offset %d.\n"),
newval, newval[i], i + 1);
*cp = str_to_hexchar(&newval[i++]);
cp++;
}
memcpy(sb.sb_uuid, uuid, 16);
- printf("new uuid = %s\n", str_uuid(sb.sb_uuid));
+ printf( _("new uuid = %s\n"), str_uuid(sb.sb_uuid));
}
#endif
} else if (strcmp(field, "all") == 0) {
gfs2_sb_print(&sb);
newval = FALSE;
} else
- die("unknown field %s\n", field);
+ die( _("unknown field %s\n"), field);
if (newval) {
gfs2_sb_out(&sb,(char*) buf);
@@ -209,7 +212,7 @@ do_sb(int argc, char **argv)
fsync(fd);
- printf("Done\n");
+ printf( _("Done\n"));
}
close(fd);
diff --git a/gfs2/tool/tune.c b/gfs2/tool/tune.c
index 294ff54..13b51f3 100644
--- a/gfs2/tool/tune.c
+++ b/gfs2/tool/tune.c
@@ -25,6 +25,8 @@
#include <limits.h>
#include <errno.h>
#include <dirent.h>
+#include <libintl.h>
+#define _(String) gettext(String)
#define __user
@@ -52,7 +54,7 @@ get_tune(int argc, char **argv)
struct gfs2_sbd sbd;
if (optind == argc)
- die("Usage: gfs2_tool gettune <mountpoint>\n");
+ die( _("Usage: gfs2_tool gettune <mountpoint>\n"));
sbd.path_name = argv[optind];
check_for_gfs2(&sbd);
@@ -62,7 +64,7 @@ get_tune(int argc, char **argv)
d = opendir(path);
if (!d)
- die("can't open %s: %s\n", path, strerror(errno));
+ die( _("can't open %s: %s\n"), path, strerror(errno));
while((de = readdir(d))) {
if (de->d_name[0] == '.')
@@ -72,7 +74,7 @@ get_tune(int argc, char **argv)
sscanf(get_sysfs(fs, "tune/quota_scale"), "%u %u",
&num, &den);
ratio = (double)num / den;
- printf("quota_scale = %.4f (%u, %u)\n", ratio, num,
+ printf( _("quota_scale = %.4f (%u, %u)\n"), ratio, num,
den);
} else
printf("%s = %s\n", de->d_name, get_sysfs(fs, path));
@@ -97,13 +99,13 @@ set_tune(int argc, char **argv)
struct gfs2_sbd sbd;
if (optind == argc)
- die("Usage: gfs2_tool settune <mountpoint> <parameter> <value>\n");
+ die( _("Usage: gfs2_tool settune <mountpoint> <parameter> <value>\n"));
sbd.path_name = argv[optind++];
if (optind == argc)
- die("Usage: gfs2_tool settune <mountpoint> <parameter> <value>\n");
+ die( _("Usage: gfs2_tool settune <mountpoint> <parameter> <value>\n"));
param = argv[optind++];
if (optind == argc)
- die("Usage: gfs2_tool settune <mountpoint> <parameter> <value>\n");
+ die( _("Usage: gfs2_tool settune <mountpoint> <parameter> <value>\n"));
value = argv[optind++];
check_for_gfs2(&sbd);
14 years, 1 month
gfs2-utils: master - libgfs2: fix build break caused by patch to bz 455300
by Abhijith Das
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 470299f2fcf2ac8c1ac4954112b1235b64c3b1dd
Parent: 4b29c515f2c2e22c55a6c3a0de0e219adbb6275a
Author: Abhijith Das <adas(a)redhat.com>
AuthorDate: Fri Apr 9 17:39:32 2010 -0500
Committer: Abhijith Das <adas(a)redhat.com>
CommitterDate: Fri Apr 9 17:50:03 2010 -0500
libgfs2: fix build break caused by patch to bz 455300
One of the patches checked in for bug 455300 overwrote
another patch to libgfs2 that correctly handled the removal
of the quota linked list from include/linux/gfs2_ondisk.h .
This patch brings back the relevant portion of the good
patch that was overwritten.
The kernel patch that removes the quota linked list
definition from include/linux/gfs2_ondisk.h only recently
went upstream so this bug only surfaced now. The build
fails with newer kernels or rawhide.
Resolves: rhbz#581038
Signed-off-by: Abhi Das <adas(a)redhat.com>
---
gfs2/libgfs2/ondisk.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 2896dfb..58af15a 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -266,8 +266,7 @@ void gfs2_quota_in(struct gfs2_quota *qu, char *buf)
CPIN_64(qu, str, qu_limit);
CPIN_64(qu, str, qu_warn);
CPIN_64(qu, str, qu_value);
- CPIN_32(qu, str, qu_ll_next);
- CPIN_08(qu, str, qu_reserved, 60);
+ CPIN_08(qu, str, qu_reserved, sizeof(qu->qu_reserved));
}
void gfs2_quota_out(struct gfs2_quota *qu, char *buf)
@@ -277,8 +276,7 @@ void gfs2_quota_out(struct gfs2_quota *qu, char *buf)
CPOUT_64(qu, str, qu_limit);
CPOUT_64(qu, str, qu_warn);
CPOUT_64(qu, str, qu_value);
- CPOUT_32(qu, str, qu_ll_next);
- CPOUT_08(qu, str, qu_reserved, 60);
+ memset(qu->qu_reserved, 0, sizeof(qu->qu_reserved));
}
void gfs2_quota_print(struct gfs2_quota *qu)
14 years, 1 month
cluster: STABLE3 - libgfs2: fix build break caused by patch to bz 455300
by Abhijith Das
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: dd9f2f2c9e524bf9eedadceb0714f1b04a26dd5b
Parent: e5e6b8a3620349e57dc1264dff3c0c613994c5fd
Author: Abhijith Das <adas(a)redhat.com>
AuthorDate: Fri Apr 9 17:39:32 2010 -0500
Committer: Abhijith Das <adas(a)redhat.com>
CommitterDate: Fri Apr 9 17:39:32 2010 -0500
libgfs2: fix build break caused by patch to bz 455300
One of the patches checked in for bug 455300 overwrote
another patch to libgfs2 that correctly handled the removal
of the quota linked list from include/linux/gfs2_ondisk.h .
This patch brings back the relevant portion of the good
patch that was overwritten.
The kernel patch that removes the quota linked list
definition from include/linux/gfs2_ondisk.h only recently
went upstream so this bug only surfaced now. The build
fails with newer kernels or rawhide.
Resolves: rhbz#581038
Signed-off-by: Abhi Das <adas(a)redhat.com>
---
gfs2/libgfs2/ondisk.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 829bb10..0d16c15 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -264,8 +264,7 @@ void gfs2_quota_in(struct gfs2_quota *qu, char *buf)
CPIN_64(qu, str, qu_limit);
CPIN_64(qu, str, qu_warn);
CPIN_64(qu, str, qu_value);
- CPIN_32(qu, str, qu_ll_next);
- CPIN_08(qu, str, qu_reserved, 60);
+ CPIN_08(qu, str, qu_reserved, sizeof(qu->qu_reserved));
}
void gfs2_quota_out(struct gfs2_quota *qu, char *buf)
@@ -275,8 +274,7 @@ void gfs2_quota_out(struct gfs2_quota *qu, char *buf)
CPOUT_64(qu, str, qu_limit);
CPOUT_64(qu, str, qu_warn);
CPOUT_64(qu, str, qu_value);
- CPOUT_32(qu, str, qu_ll_next);
- CPOUT_08(qu, str, qu_reserved, 60);
+ memset(qu->qu_reserved, 0, sizeof(qu->qu_reserved));
}
void gfs2_quota_print(struct gfs2_quota *qu)
14 years, 1 month
cluster: the annotated tag cluster-3.0.10 has been created
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 097b17a1ff1f8efb91bb4d3b424b51d5b7385f08
Parent: 0000000000000000000000000000000000000000
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: 2010-04-09 11:56 +0000
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: 2010-04-09 11:56 +0000
annotated tag: cluster-3.0.10 has been created
at 097b17a1ff1f8efb91bb4d3b424b51d5b7385f08 (tag)
tagging e5e6b8a3620349e57dc1264dff3c0c613994c5fd (commit)
replaces cluster-3.0.9
cluster-3.0.10 release
Abhijith Das (5):
gfs2_quota: Fix gfs2_quota to handle boundary conditions
gfs2_convert: gfs2_convert segfaults when converting filesystems of blocksize 512 bytes
gfs2_convert: gfs2_convert uses too much memory for jdata conversion
gfs2_convert: Fix conversion of gfs1 CDPNs
gfs2_convert: Doesn't convert indirectly-pointed extended attributes correctly
Bob Peterson (3):
gfs2: GFS2 utilities should make use of exported device topology
cman: gfs_controld dm suspend hangs withdrawn GFS file system
GFS2: fsck.gfs2 segfault - osi_tree "each_safe" patch
Christine Caulfield (3):
cman: Add improved cluster_id hash function
cman: move fnv hash function into its own file
ccs: Remove non-existant commands from ccs_tool man page.
David Teigland (7):
dlm_controld/libdlmcontrol/dlm_tool: separate plock debug buffer
dlm_controld: add more fs_notified debugging
dlm_controld/gfs_controld: avoid full plock unlock when no resource exists
dlm_controld: add plock checkpoint signatures
dlm_controld: set last_plock_time for ownership operations
dlm_controld: don't skip unlinking checkpoint
gfs_controld: set last_plock_time for ownership operations
Fabio M. Di Nitto (1):
dlm: bump libdlmcontrol sominor
Jan Friesse (1):
fencing: SNMP fence agents don't fail
Lon Hohberger (4):
config: Add hash_cluster_id to schema
rgmanager: Fix 2+ simultaneous relocation crash
rgmanager: Fix memory leaks during relocation
rgmanager: Fix tiny memory leak during reconfig
Marek 'marx' Grac (1):
fencing: Remove 'ipport' option from WTI fence agent
14 years, 1 month
cluster: STABLE3 - gfs2_convert: Doesn't convert indirectly-pointed extended attributes correctly
by Abhijith Das
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: e5e6b8a3620349e57dc1264dff3c0c613994c5fd
Parent: 410bdc8b5f565d26ffd8c26ce8b6b9393704bb72
Author: Abhijith Das <adas(a)redhat.com>
AuthorDate: Wed Apr 7 12:04:34 2010 -0500
Committer: Abhijith Das <adas(a)redhat.com>
CommitterDate: Wed Apr 7 12:04:34 2010 -0500
gfs2_convert: Doesn't convert indirectly-pointed extended attributes correctly
When the extended attributes for a file don't fit
in one fs block, the dinode->di_eattr block becomes
an indirect block that contains pointers to blocks
that actually contain the xattrs. The gfs1 indirect
block header is different (larger) than that of gfs2
and this causes an incorrect conversion. The
resulting gfs2 filesystem cannot display the xattrs
because of leading nulls in the indirect block. This
patch adjusts this correctly.
Resolves: rhbz#579626
Signed-off-by: Abhi Das <adas(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 45 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index a3e57fd..6543903 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -937,6 +937,45 @@ static int fix_cdpn_symlink(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, s
return ret;
}
+
+/*
+ * fix_xattr -
+ * Extended attributes can be either direct (in the ip->i_di.di_eattr block) or
+ * then can be at a maximum of 1 indirect level. Multiple levels of indirection
+ * are not supported. If the di_eattr block contains extended attribute data,
+ * i.e block type = GFS_METATYPE_EA, we ignore it.
+ * If the di_eattr block contains block pointers to extended attributes we need
+ * to fix the header. gfs1 uses gfs_indirect as the header which is 64 bytes
+ * bigger than gfs2_meta_header that gfs2 uses.
+ */
+static int fix_xattr(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, struct gfs2_inode *ip)
+{
+ int ret = 0, len, old_hdr_sz, new_hdr_sz;
+ struct gfs2_buffer_head *eabh;
+ char *buf;
+
+ /* Read in the i_di.di_eattr block */
+ eabh = bread(sbp, ip->i_di.di_eattr);
+ if (!gfs2_check_meta(eabh, GFS_METATYPE_IN)) {/* if it is an indirect block */
+ len = sbp->bsize - sizeof(struct gfs_indirect);
+ buf = malloc(len);
+ if (!buf) {
+ log_crit("Error: out of memory.\n");
+ return -1;
+ }
+ old_hdr_sz = sizeof(struct gfs_indirect);
+ new_hdr_sz = sizeof(struct gfs2_meta_header);
+ memcpy(buf, eabh->b_data + old_hdr_sz, sbp->bsize - old_hdr_sz);
+ memset(eabh->b_data + new_hdr_sz, 0, sbp->bsize - new_hdr_sz);
+ memcpy(eabh->b_data + new_hdr_sz, buf, len);
+ free(buf);
+ bmodified(eabh);
+ }
+ brelse(eabh);
+
+ return ret;
+}
+
/* ------------------------------------------------------------------------- */
/* adjust_inode - change an inode from gfs1 to gfs2 */
/* */
@@ -1028,6 +1067,12 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
if (ret)
return -1;
}
+ /* Check for extended attributes */
+ if (inode->i_di.di_eattr) {
+ ret = fix_xattr(sbp, bh, inode);
+ if (ret)
+ return -1;
+ }
}
bmodified(inode->i_bh);
14 years, 1 month
cluster: STABLE3 - gfs2_convert: Fix conversion of gfs1 CDPNs
by Abhijith Das
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 410bdc8b5f565d26ffd8c26ce8b6b9393704bb72
Parent: 7a9c8a7deae2dfc06723c7b1ee9fc4dcd9c87b68
Author: Abhijith Das <adas(a)redhat.com>
AuthorDate: Wed Apr 7 12:02:06 2010 -0500
Committer: Abhijith Das <adas(a)redhat.com>
CommitterDate: Wed Apr 7 12:02:06 2010 -0500
gfs2_convert: Fix conversion of gfs1 CDPNs
GFS2 does not support Context Dependent PathNames,
so we need a way to properly convert cdpns in gfs1
to gfs2. With this patch, we replace symlinks that
point to cdpns with empty directories and adjust
the dirents in the parent directories to reflect
this.
Resolves: rhbz#579625
Signed-off-by: Abhi Das <adas(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 224 +++++++++++++++++++++++++++++++++++++------
1 files changed, 193 insertions(+), 31 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index eca24a8..a3e57fd 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -19,6 +19,7 @@
#include <string.h>
#include <time.h>
#include <sys/time.h>
+#include <errno.h>
#include <linux/types.h>
#include <linux/gfs2_ondisk.h>
@@ -110,6 +111,12 @@ struct gfs1_sb {
char sb_reserved[96];
};
+struct inode_dir_block {
+ osi_list_t list;
+ uint64_t di_addr;
+ uint64_t di_paddr; /* Parent dir inode addr */
+};
+
struct inode_block {
osi_list_t list;
uint64_t di_addr;
@@ -127,9 +134,11 @@ struct gfs1_sb raw_gfs1_ondisk_sb;
struct gfs2_sbd sb2;
char device[256];
struct inode_block dirs_to_fix; /* linked list of directories to fix */
+struct inode_dir_block cdpns_to_fix; /* linked list of cdpn symlinks */
int seconds;
struct timeval tv;
uint64_t dirs_fixed;
+uint64_t cdpns_fixed;
uint64_t dirents_fixed;
struct gfs1_jindex *sd_jindex = NULL; /* gfs1 journal index in memory */
int gfs2_inptrs;
@@ -892,6 +901,42 @@ out:
return error;
}
+const char *cdpn[14] = {"{hostname}", "{mach}", "{os}", "{uid}", "{gid}", "{sys}", "{jid}",
+ "@hostname", "@mach", "@os", "@uid", "@gid", "@sys", "@jid"};
+static int has_cdpn(const char *str)
+{
+ int i;
+ for (i=0; i<14; i++)
+ if (strstr(str, cdpn[i]) != NULL)
+ return 1;
+ return 0;
+}
+
+static int fix_cdpn_symlink(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, struct gfs2_inode *ip)
+{
+ int ret = 0;
+ char *linkptr = NULL;
+
+ if (ip->i_di.di_height != 0)
+ return 0;
+
+ linkptr = bh->b_data + sizeof(struct gfs_dinode);
+ if (has_cdpn(linkptr)) {
+ struct inode_dir_block *fix;
+ /* Save the symlink di_addr. We'll find the parent di_addr later */
+ fix = malloc(sizeof(struct inode_dir_block));
+ if (!fix) {
+ log_crit("Error: out of memory.\n");
+ return -1;
+ }
+ memset(fix, 0, sizeof(struct inode_dir_block));
+ fix->di_addr = ip->i_di.di_num.no_addr;
+ osi_list_add_prev((osi_list_t *)&fix->list,
+ (osi_list_t *)&cdpns_to_fix);
+ }
+
+ return ret;
+}
/* ------------------------------------------------------------------------- */
/* adjust_inode - change an inode from gfs1 to gfs2 */
/* */
@@ -977,6 +1022,12 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
ret = adjust_indirect_blocks(sbp, inode);
if (ret)
return -1;
+ /* Check for cdpns */
+ if (inode->i_di.di_mode & S_IFLNK) {
+ ret = fix_cdpn_symlink(sbp, bh, inode);
+ if (ret)
+ return -1;
+ }
}
bmodified(inode->i_bh);
@@ -993,7 +1044,7 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
/* */
/* Returns: 0 on success, -1 on failure */
/* ------------------------------------------------------------------------- */
-static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr)
+static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr, osi_list_t *cdpn_to_fix)
{
struct rgrp_list *rgd;
osi_list_t *tmp;
@@ -1081,13 +1132,16 @@ static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr)
/* fetch_inum - fetch an inum entry from disk, given its block */
/* ------------------------------------------------------------------------- */
static int fetch_inum(struct gfs2_sbd *sbp, uint64_t iblock,
- struct gfs2_inum *inum)
+ struct gfs2_inum *inum, uint64_t *eablk)
{
struct gfs2_inode *fix_inode;
fix_inode = inode_read(sbp, iblock);
inum->no_formal_ino = fix_inode->i_di.di_num.no_formal_ino;
inum->no_addr = fix_inode->i_di.di_num.no_addr;
+ if (eablk)
+ *eablk = fix_inode->i_di.di_eattr;
+
inode_put(&fix_inode);
return 0;
}/* fetch_inum */
@@ -1098,12 +1152,12 @@ static int fetch_inum(struct gfs2_sbd *sbp, uint64_t iblock,
/* We changed inode numbers, so we must update that number into the */
/* directory entries themselves. */
/* */
-/* Returns: 0 on success, -1 on failure */
+/* Returns: 0 on success, -1 on failure, -EISDIR when dentmod marked DT_DIR */
/* ------------------------------------------------------------------------- */
static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
- struct gfs2_buffer_head *bh, int dir_entries)
+ struct gfs2_buffer_head *bh, int dir_entries, uint64_t dentmod)
{
- int error;
+ int error = 0;
struct gfs2_dirent *dent;
int de; /* directory entry index */
@@ -1112,12 +1166,23 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
log_crit("Error retrieving directory.\n");
return -1;
}
+ error = 0;
/* Go through every dirent in the buffer and process it. */
/* Turns out you can't trust dir_entries is correct. */
for (de = 0; ; de++) {
struct gfs2_inum inum;
int dent_was_gfs1;
-
+
+ if (dentmod) {
+ if (dent->de_type == cpu_to_be16(DT_LNK)
+ && cpu_to_be64(dent->de_inum.no_addr) == dentmod) {
+ dent->de_type = cpu_to_be16(DT_DIR);
+ error = -EISDIR;
+ break;
+ }
+ goto skip_next;
+ }
+
gettimeofday(&tv, NULL);
/* Do more warm fuzzy stuff for the customer. */
dirents_fixed++;
@@ -1131,7 +1196,7 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
gfs2_inum_in(&inum, (char *)&dent->de_inum);
dent_was_gfs1 = (dent->de_inum.no_addr == dent->de_inum.no_formal_ino);
if (inum.no_formal_ino) { /* if not a sentinel (placeholder) */
- error = fetch_inum(sbp, inum.no_addr, &inum);
+ error = fetch_inum(sbp, inum.no_addr, &inum, NULL);
if (error) {
log_crit("Error retrieving inode 0x%llx\n",
(unsigned long long)inum.no_addr);
@@ -1175,11 +1240,30 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
break;
}
}
+ /*
+ * Compare this dirent address with every one in the
+ * cdpns_to_fix list to find if this directory (dip) is
+ * a cdpn symlink's parent. If so add it to the list element
+ */
+ if (dent->de_type == cpu_to_be16(DT_LNK)) {
+ osi_list_t *tmp;
+ struct inode_dir_block *fix;
+ osi_list_foreach(tmp, &cdpns_to_fix.list) {
+ fix = osi_list_entry(tmp, struct inode_dir_block, list);
+ if (fix->di_addr == inum.no_addr)
+ fix->di_paddr = dip->i_di.di_num.no_addr;
+ }
+ }
+
+ skip_next:
error = gfs2_dirent_next(dip, bh, &dent);
- if (error)
+ if (error) {
+ if (error == -ENOENT) /* beyond the end of this bh */
+ error = 0;
break;
+ }
} /* for every directory entry */
- return 0;
+ return error;
}/* process_dirent_info */
/* ------------------------------------------------------------------------- */
@@ -1190,7 +1274,7 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
/* */
/* Returns: 0 on success, -1 on failure */
/* ------------------------------------------------------------------------- */
-static int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip)
+static int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip, uint64_t dentmod)
{
struct gfs2_buffer_head *bh_leaf;
int error;
@@ -1226,13 +1310,40 @@ static int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip
break;
}
gfs2_leaf_in(&leaf, bh_leaf); /* buffer to structure */
- error = process_dirent_info(dip, sbp, bh_leaf, leaf.lf_entries);
+ error = process_dirent_info(dip, sbp, bh_leaf, leaf.lf_entries, dentmod);
bmodified(bh_leaf);
brelse(bh_leaf);
+ if (dentmod && error == -EISDIR) /* dentmod was marked DT_DIR, break out */
+ break;
} /* for leaf_num */
return 0;
}/* fix_one_directory_exhash */
+static int process_directory(struct gfs2_sbd *sbp, uint64_t dirblock, uint64_t dentmod)
+{
+ struct gfs2_inode *dip;
+ int error = 0;
+ /* read in the directory inode */
+ dip = inode_read(sbp, dirblock);
+ /* fix the directory: either exhash (leaves) or linear (stuffed) */
+ if (dip->i_di.di_flags & GFS2_DIF_EXHASH) {
+ if (fix_one_directory_exhash(sbp, dip, dentmod)) {
+ log_crit("Error fixing exhash directory.\n");
+ inode_put(&dip);
+ return -1;
+ }
+ } else {
+ error = process_dirent_info(dip, sbp, dip->i_bh, dip->i_di.di_entries, dentmod);
+ if (error && error != -EISDIR) {
+ log_crit("Error fixing linear directory.\n");
+ inode_put(&dip);
+ return -1;
+ }
+ }
+ bmodified(dip->i_bh);
+ inode_put(&dip);
+ return 0;
+}
/* ------------------------------------------------------------------------- */
/* fix_directory_info - sync new inode numbers with directory info */
/* Returns: 0 on success, -1 on failure */
@@ -1242,7 +1353,6 @@ static int fix_directory_info(struct gfs2_sbd *sbp, osi_list_t *dir_to_fix)
osi_list_t *tmp, *fix;
struct inode_block *dir_iblk;
uint64_t offset, dirblock;
- struct gfs2_inode *dip;
dirs_fixed = 0;
dirents_fixed = 0;
@@ -1263,25 +1373,10 @@ static int fix_directory_info(struct gfs2_sbd *sbp, osi_list_t *dir_to_fix)
/* figure out the directory inode block and read it in */
dir_iblk = (struct inode_block *)fix;
dirblock = dir_iblk->di_addr; /* addr of dir inode */
- /* read in the directory inode */
- dip = inode_read(sbp, dirblock);
- /* fix the directory: either exhash (leaves) or linear (stuffed) */
- if (dip->i_di.di_flags & GFS2_DIF_EXHASH) {
- if (fix_one_directory_exhash(sbp, dip)) {
- log_crit("Error fixing exhash directory.\n");
- inode_put(&dip);
- return -1;
- }
- }
- else {
- if (process_dirent_info(dip, sbp, dip->i_bh,
- dip->i_di.di_entries)) {
- log_crit("Error fixing linear directory.\n");
- inode_put(&dip);
- return -1;
- }
+ if (process_directory(sbp, dirblock, 0)) {
+ log_crit("Error processing directory\n");
+ return -1;
}
- inode_put(&dip);
}
/* Free the last entry in memory: */
if (tmp) {
@@ -1292,6 +1387,60 @@ static int fix_directory_info(struct gfs2_sbd *sbp, osi_list_t *dir_to_fix)
}/* fix_directory_info */
/* ------------------------------------------------------------------------- */
+/* fix_cdpn_symlinks - convert cdpn symlinks to empty directories */
+/* Returns: 0 on success, -1 on failure */
+/* ------------------------------------------------------------------------- */
+static int fix_cdpn_symlinks(struct gfs2_sbd *sbp, osi_list_t *cdpn_to_fix)
+{
+ osi_list_t *tmp, *x;
+ int error = 0;
+
+ cdpns_fixed = 0;
+ osi_list_foreach_safe(tmp, cdpn_to_fix, x) {
+ struct gfs2_inum fix, dir;
+ struct inode_dir_block *l_fix;
+ struct gfs2_buffer_head *bh;
+ struct gfs2_inode *fix_inode;
+ uint64_t eablk;
+
+ l_fix = osi_list_entry(tmp, struct inode_dir_block, list);
+ osi_list_del(tmp);
+
+ /* convert symlink to empty dir */
+ error = fetch_inum(sbp, l_fix->di_addr, &fix, &eablk);
+ if (error) {
+ log_crit("Error retrieving inode at block %llx\n",
+ (unsigned long long)l_fix->di_addr);
+ break;
+ }
+ error = fetch_inum(sbp, l_fix->di_paddr, &dir, NULL);
+ if (error) {
+ log_crit("Error retrieving inode at block %llx\n",
+ (unsigned long long)l_fix->di_paddr);
+ break;
+ }
+
+ /* initialize the symlink inode to be a directory */
+ bh = init_dinode(sbp, &fix, S_IFDIR | 0755, 0, &dir);
+ fix_inode = inode_get(sbp, bh);
+ fix_inode->i_di.di_eattr = eablk; /*fix extended attribute */
+ inode_put(&fix_inode);
+ bmodified(bh);
+ brelse(bh);
+
+ /* fix the parent directory dirent entry for this inode */
+ error = process_directory(sbp, l_fix->di_paddr, l_fix->di_addr);
+ if (error) {
+ log_crit("Error trying to fix cdpn dentry\n");
+ break;
+ }
+ free(l_fix);
+ cdpns_fixed++;
+ }
+ return error;
+} /* fix_cdpn_symlinks */
+
+/* ------------------------------------------------------------------------- */
/* Fetch gfs1 jindex structure from buffer */
/* ------------------------------------------------------------------------- */
static void gfs1_jindex_in(struct gfs1_jindex *jindex, char *buf)
@@ -1389,6 +1538,7 @@ static int init(struct gfs2_sbd *sbp)
sbp->sd_sb.sb_header.mh_format = GFS2_FORMAT_SB;
osi_list_init((osi_list_t *)&dirs_to_fix);
+ osi_list_init((osi_list_t *)&cdpns_to_fix);
/* ---------------------------------------------- */
/* Initialize lists and read in the superblock. */
/* ---------------------------------------------- */
@@ -1859,7 +2009,8 @@ int main(int argc, char **argv)
/* Renumber the inodes consecutively. */
/* ---------------------------------------------- */
if (!error) {
- error = inode_renumber(&sb2, sb2.sd_sb.sb_root_dir.no_addr);
+ error = inode_renumber(&sb2, sb2.sd_sb.sb_root_dir.no_addr,
+ (osi_list_t *)&cdpns_to_fix);
if (error)
log_crit("\n%s: Error renumbering inodes.\n", device);
fsync(sb2.device_fd); /* write the buffers to disk */
@@ -1876,6 +2027,17 @@ int main(int argc, char **argv)
log_crit("\n%s: Error fixing directories.\n", device);
}
/* ---------------------------------------------- */
+ /* Convert cdpn symlinks to empty dirs */
+ /* ---------------------------------------------- */
+ if (!error) {
+ error = fix_cdpn_symlinks(&sb2, (osi_list_t *)&cdpns_to_fix);
+ log_notice("\r%" PRIu64 " cdpn symlinks moved to empty directories.",
+ cdpns_fixed);
+ fflush(stdout);
+ if (error)
+ log_crit("\n%s: Error fixing cdpn symlinks.\n", device);
+ }
+ /* ---------------------------------------------- */
/* Convert journal space to rg space */
/* ---------------------------------------------- */
if (!error) {
14 years, 1 month
cluster: STABLE3 - gfs2_convert: gfs2_convert uses too much memory for jdata conversion
by Abhijith Das
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 7a9c8a7deae2dfc06723c7b1ee9fc4dcd9c87b68
Parent: 20f1f8d55b7f96f7a64298d11fef47eca6890450
Author: Abhijith Das <adas(a)redhat.com>
AuthorDate: Wed Apr 7 11:57:32 2010 -0500
Committer: Abhijith Das <adas(a)redhat.com>
CommitterDate: Wed Apr 7 11:57:32 2010 -0500
gfs2_convert: gfs2_convert uses too much memory for jdata conversion
Moved some code around so that the data blocks of the
jdata file are not mapped into buffers in advance.
Instead, only indirect blocks one level below are mapped.
The data blocks are then mapped one-by-one while they're
copied onto the new converted jdata file.
Resolves: rhbz#579623
Signed-off-by: Abhi Das <adas(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 98 +++++++++++++++++++++++++++++-------------
gfs2/libgfs2/fs_ops.c | 1 +
2 files changed, 68 insertions(+), 31 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 52e44aa..eca24a8 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -313,8 +313,7 @@ static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
bh = ip->i_bh;
/* First, build up the metatree */
for (h = 0; h < blk->height; h++) {
- lookup_block(ip, ip->i_bh, h, &blk->mp, 1, &new,
- &block);
+ lookup_block(ip, bh, h, &blk->mp, 1, &new, &block);
if (bh != ip->i_bh)
brelse(bh);
if (!block)
@@ -645,8 +644,7 @@ static void fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
bh = ip->i_bh;
/* First, build up the metatree */
for (h = 0; h < blk->height; h++) {
- lookup_block(ip, ip->i_bh, h, &blk->mp, 1, &new,
- &block);
+ lookup_block(ip, bh, h, &blk->mp, 1, &new, &block);
if (bh != ip->i_bh)
brelse(bh);
if (!block)
@@ -739,16 +737,14 @@ static int adjust_jdata_inode(struct gfs2_sbd *sbp, struct gfs2_inode *ip)
sbp->bsize - sizeof(struct gfs_dinode));
osi_list_add_prev(&blk->list, &blocks.list);
- /* Now run the metadata chain and build lists of all data/metadata blocks */
+ /* Now run the metadata chain and build lists of all metadata blocks */
osi_list_foreach(tmp, &blocks.list) {
blk = osi_list_entry(tmp, struct blocklist, list);
- if (blk->height >= ip->i_di.di_height)
+ if (blk->height >= ip->i_di.di_height - 1)
continue;
-
header_size = (blk->height > 0 ? sizeof(struct gfs_indirect) :
sizeof(struct gfs_dinode));
-
for (ptr1 = (uint64_t *)blk->ptrbuf, ptrnum = 0;
ptrnum < sbp->sd_inptrs; ptr1++, ptrnum++) {
if (!*ptr1)
@@ -781,23 +777,13 @@ static int adjust_jdata_inode(struct gfs2_sbd *sbp, struct gfs2_inode *ip)
/* Queue it to be processed later on in the loop. */
osi_list_add_prev(&newblk->list, &blocks.list);
+ /* read the new metadata block's pointers */
bh = bread(sbp, block);
- if (newblk->height == ip->i_di.di_height) {
- /* read in the jdata block */
- memcpy(newblk->ptrbuf, bh->b_data +
- sizeof(struct gfs2_meta_header), bufsize);
- /* Zero the buffer so we can fill it in later */
- memset(bh->b_data + sizeof(struct gfs2_meta_header), 0,
- bufsize);
- } else {
- /* read the new metadata block's pointers */
- memcpy(newblk->ptrbuf, bh->b_data +
- sizeof(struct gfs_indirect),
- sbp->bsize - sizeof(struct gfs_indirect));
- /* Zero the buffer so we can fill it in later */
- memset(bh->b_data + sizeof(struct gfs_indirect), 0,
- sbp->bsize - sizeof(struct gfs_indirect));
- }
+ memcpy(newblk->ptrbuf, bh->b_data + sizeof(struct gfs_indirect),
+ sbp->bsize - sizeof(struct gfs_indirect));
+ /* Zero the buffer so we can fill it in later */
+ memset(bh->b_data + sizeof(struct gfs_indirect), 0,
+ sbp->bsize - sizeof(struct gfs_indirect));
bmodified(bh);
brelse(bh);
/* Free the block so we can reuse it. This allows us to
@@ -823,18 +809,68 @@ static int adjust_jdata_inode(struct gfs2_sbd *sbp, struct gfs2_inode *ip)
blk = osi_list_entry(tmp, struct blocklist, list);
/* If it's not a data block at the highest level */
- if (blk->height != di_height) {
+ if (blk->height != di_height - 1) {
osi_list_del(tmp);
free(blk->ptrbuf);
free(blk);
continue;
}
- len = bufsize;
- jdata_mp_gfs1_to_gfs2(sbp, di_height, gfs2_hgt, &blk->mp, &gfs2mp, &len, dinode_size);
- memcpy(&blk->mp, &gfs2mp, sizeof(struct metapath));
- blk->height -= di_height - gfs2_hgt;
- if (len)
- fix_jdatatree(sbp, ip, blk, blk->ptrbuf, len);
+ /*
+ * For each metadata block that holds jdata block pointers,
+ * get the blk pointers and copy them block by block
+ */
+ for (ptr1 = (uint64_t *) blk->ptrbuf, ptrnum = 0;
+ ptrnum < sbp->sd_inptrs; ptr1++, ptrnum++) {
+ if (!*ptr1)
+ continue;
+ block = be64_to_cpu(*ptr1);
+
+ newblk = malloc(sizeof(struct blocklist));
+ if (!newblk) {
+ log_crit("Error: Can't allocate memory"
+ " for indirect block fix.\n");
+ error = -1;
+ goto out;
+ }
+ memset(newblk, 0, sizeof(*newblk));
+ newblk->ptrbuf = malloc(bufsize);
+ if (!newblk->ptrbuf) {
+ log_crit("Error: Can't allocate memory"
+ " for file conversion.\n");
+ free(newblk);
+ goto out;
+ }
+ memset(newblk->ptrbuf, 0, bufsize);
+ newblk->block = block;
+ newblk->height = blk->height + 1;
+ /* Build the metapointer list from our predecessors */
+ for (h=0; h < blk->height; h++)
+ newblk->mp.mp_list[h] = blk->mp.mp_list[h];
+ newblk->mp.mp_list[h] = ptrnum;
+ bh = bread(sbp, block);
+ /* This is a data block. i.e newblk->height == ip->i_di.di_height */
+ /* read in the jdata block */
+ memcpy(newblk->ptrbuf, bh->b_data +
+ sizeof(struct gfs2_meta_header), bufsize);
+ memset(bh->b_data + sizeof(struct gfs2_meta_header), 0,
+ bufsize);
+ bmodified(bh);
+ brelse(bh);
+ /* Free the block so we can reuse it. This allows us to
+ convert a "full" file system */
+ ip->i_di.di_blocks--;
+ gfs2_free_block(sbp, block);
+
+ len = bufsize;
+ jdata_mp_gfs1_to_gfs2(sbp, di_height, gfs2_hgt, &newblk->mp, &gfs2mp,
+ &len, dinode_size);
+ memcpy(&newblk->mp, &gfs2mp, sizeof(struct metapath));
+ newblk->height -= di_height - gfs2_hgt;
+ if (len)
+ fix_jdatatree(sbp, ip, newblk, newblk->ptrbuf, len);
+ free(newblk->ptrbuf);
+ free(newblk);
+ }
osi_list_del(tmp);
free(blk->ptrbuf);
free(blk);
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 7c698ef..ed773b4 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -934,6 +934,7 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
dip->i_di.di_blocks++;
bmodified(dip->i_bh);
+ bmodified(obh); /* Need to do this in case nothing was moved */
brelse(obh);
bmodified(nbh);
brelse(nbh);
14 years, 1 month
cluster: STABLE3 - gfs2_convert: gfs2_convert segfaults when converting filesystems of blocksize 512 bytes
by Abhijith Das
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 20f1f8d55b7f96f7a64298d11fef47eca6890450
Parent: d443af4fa07c64dd50dae4ea771c8f93bfd7cba6
Author: Abhijith Das <adas(a)redhat.com>
AuthorDate: Wed Apr 7 11:51:47 2010 -0500
Committer: Abhijith Das <adas(a)redhat.com>
CommitterDate: Wed Apr 7 11:51:47 2010 -0500
gfs2_convert: gfs2_convert segfaults when converting filesystems of blocksize 512 bytes
gfs2_convert segfaults when the jindex inode is unstuffed.
i.e. if the block size is small enough such that the jindex
entries (directly proportional to the number of journals)
don't fit in the disk inode block, the jindex inode is
unstuffed. This is a journaled data file and the structures
are different for such files in gfs1 and gfs2 with respect
to metaheaders. gfs2_convert needs to trick the file
reading code in libgfs2 to think it's dealing with a gfs2
directory (whose structure is similar to a gfs1 jdata inode)
to operate on the file at the right offsets.
Resolves: rhbz#579621
Signed-off-by: adas(a)redhat.com
---
gfs2/convert/gfs2_convert.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 5e3d8f3..52e44aa 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1277,6 +1277,7 @@ static int read_gfs1_jiindex(struct gfs2_sbd *sdp)
char buf[sizeof(struct gfs1_jindex)];
unsigned int j;
int error=0;
+ unsigned int tmp_mode = 0;
if(ip->i_di.di_size % sizeof(struct gfs1_jindex) != 0){
log_crit("The size reported in the journal index"
@@ -1292,6 +1293,14 @@ static int read_gfs1_jiindex(struct gfs2_sbd *sdp)
log_crit("Unable to zero journal index\n");
return -1;
}
+ /* ugly hack
+ * Faking the gfs1_jindex inode as a directory to gfs2_readi
+ * so it skips the metaheader struct in the data blocks
+ * in the inode. gfs2_jindex inode doesn't have metaheaders
+ * in the data blocks */
+ tmp_mode = ip->i_di.di_mode;
+ ip->i_di.di_mode &= ~S_IFMT;
+ ip->i_di.di_mode |= S_IFDIR;
for (j = 0; ; j++) {
struct gfs1_jindex *journ;
@@ -1308,6 +1317,7 @@ static int read_gfs1_jiindex(struct gfs2_sbd *sdp)
gfs1_jindex_in(journ, buf);
sdp->jsize = (journ->ji_nsegment * 16 * sdp->bsize) >> 20;
}
+ ip->i_di.di_mode = tmp_mode;
if(j * sizeof(struct gfs1_jindex) != ip->i_di.di_size){
log_crit("journal inode size invalid\n");
goto fail;
14 years, 1 month
cluster: RHEL56 - fence_scsi: replace open3 calls with qx commands
by rohara
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: f35e432fd553ecc59486b56a91748097f10af96b
Parent: 78e7ffd2488b53e627482e78d9f7a23d0b4ba514
Author: Ryan O'Hara <rohara(a)redhat.com>
AuthorDate: Wed Apr 7 11:40:09 2010 -0500
Committer: Ryan O'Hara <rohara(a)redhat.com>
CommitterDate: Wed Apr 7 11:40:09 2010 -0500
fence_scsi: replace open3 calls with qx commands
The open3 calls will block when the buffer becomes full, which causes
fence_scsi to block. This can occur if fence_scsi needs to process
several devices. All open3 calls should be replaced with qx commands,
which does not suffer from this problem.
Resolves: rhbz#564468
Signed-off-by: Ryan O'Hara <rohara(a)redhat.com>
---
fence/agents/scsi/fence_scsi.pl | 100 ++++++++-------------------------------
1 files changed, 20 insertions(+), 80 deletions(-)
diff --git a/fence/agents/scsi/fence_scsi.pl b/fence/agents/scsi/fence_scsi.pl
index 0c2ff51..91f113d 100755
--- a/fence/agents/scsi/fence_scsi.pl
+++ b/fence/agents/scsi/fence_scsi.pl
@@ -2,7 +2,6 @@
use Getopt::Std;
use XML::LibXML;
-use IPC::Open3;
use POSIX;
my $ME = $0;
@@ -72,32 +71,23 @@ sub get_cluster_id
{
my $cluster_id;
- my ($in, $out, $err);
my $cmd = "cman_tool status";
-
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my @out = qx { $cmd };
die "Unable to execute cman_tool.\n" if ($?>>8);
- while (<$out>)
+ foreach (@out)
{
chomp;
- my ($name, $value) = split(/\s*:\s*/, $_);
+ my ($param, $value) = split(/\s*:\s*/, $_);
- if (uc($name) eq "CLUSTER ID")
- {
+ if ($param =~ /^cluster\s+id/i) {
$cluster_id = $value;
last;
}
}
- close($in);
- close($out);
- close($err);
-
print "[$pname]: get_cluster_id = $cluster_id\n" if $opt_v;
return $cluster_id;
@@ -130,32 +120,23 @@ sub get_host_id
{
my $host_id;
- my ($in, $out, $err);
my $cmd = "cman_tool status";
-
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my @out = qx { $cmd };
die "Unable to execute cman_tool.\n" if ($?>>8);
- while (<$out>)
+ foreach (@out)
{
chomp;
- my ($name, $value) = split(/\s*:\s*/, $_);
+ my ($param, $value) = split(/\s*:\s*/, $_);
- if (uc($name) eq "NODE ID")
- {
+ if ($param =~ /^node\s+id/i) {
$host_id = $value;
last;
}
}
- close($in);
- close($out);
- close($err);
-
print "[$pname]: get_host_id = $host_id\n" if $opt_v;
return $host_id;
@@ -165,32 +146,23 @@ sub get_host_name
{
my $host_name;
- my ($in, $out, $err);
my $cmd = "cman_tool status";
-
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my @out = qx { $cmd };
die "Unable to execute cman_tool.\n" if ($?>>8);
- while (<$out>)
+ foreach (@out)
{
chomp;
- my ($name, $value) = split(/\s*:\s*/, $_);
+ my ($param, $value) = split(/\s*:\s*/, $_);
- if (uc($name) eq "NODE NAME")
- {
+ if ($param =~ /^node\s+name/i) {
$host_name = $value;
last;
}
}
- close($in);
- close($out);
- close($err);
-
print "[$pname]: get_host_nam = $host_name\n" if $opt_v;
return $host_name;
@@ -269,18 +241,14 @@ sub get_key_list
{
($device) = @_;
- my ($in, $out, $err);
-
my $cmd = "sg_persist -d $device -i -k";
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my @out = qx { $cmd };
die "Unable to execute sg_persist.\n" if ($?>>8);
my %key_list;
- while (<$out>)
+ foreach (@out)
{
chomp;
@@ -309,33 +277,25 @@ sub get_key_list
}
}
- close($in);
- close($out);
- close($err);
-
return %key_list;
}
sub get_scsi_devices
{
- my ($in, $out, $err);
-
my $cmd = "vgs --config 'global { locking_type = 0 }'" .
- " --noheadings --separator : -o vg_attr,pv_name,pv_uuid 2> /dev/null";
-
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
+ " --noheadings --separator : -o vg_attr,pv_name,pv_uuid";
- waitpid($pid, 0);
+ my @out = qx { $cmd 2> /dev/null};
die "Unable to execute vgs.\n" if ($?>>8);
- while (<$out>)
+ foreach (@out)
{
chomp;
my ($vg_attrs, $pv_name, $pv_uuid) = split(/:/, $_);
- if ($vg_attrs =~ /.*c$/)
+ if ($vg_attrs =~ /c$/)
{
$device_list{"\U$pv_uuid"} = $pv_name;
}
@@ -356,26 +316,14 @@ sub get_scsi_devices
$index++;
}
}
-
- close($in);
- close($out);
- close($err);
}
sub check_sg_persist
{
- my ($in, $out, $err);
my $cmd = "sg_persist -V";
-
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my $out = qx { $cmd };
die "Unable to execute sg_persist.\n" if ($?>>8);
-
- close($in);
- close($out);
- close($err);
}
sub fence_node
@@ -386,8 +334,6 @@ sub fence_node
my $host_key = get_key($host_name);
my $node_key = get_key($node_name);
- my ($in, $out, $err);
-
for $uuid (sort keys %device_list)
{
my $device = $device_list{$uuid};
@@ -412,15 +358,9 @@ sub fence_node
$cmd = "sg_persist -n -d $device -o -A -K $host_key -S $node_key -T 5";
}
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my $out = qx { $cmd };
die "Unable to execute sg_persist ($dev).\n" if ($?>>8);
-
- close($in);
- close($out);
- close($err);
}
}
14 years, 1 month