From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19244 invoked by alias); 14 May 2009 03:12:25 -0000 Received: (qmail 19238 invoked by alias); 14 May 2009 03:12:25 -0000 X-SWARE-Spam-Status: Yes, hits=6.9 required=5.0 tests=AWL,BAYES_50,J_CHICKENPOX_13,J_CHICKENPOX_21,J_CHICKENPOX_22,J_CHICKENPOX_23,J_CHICKENPOX_24,J_CHICKENPOX_33,J_CHICKENPOX_35,J_CHICKENPOX_36,J_CHICKENPOX_42,J_CHICKENPOX_43,J_CHICKENPOX_44,J_CHICKENPOX_45,J_CHICKENPOX_46,J_CHICKENPOX_48,J_CHICKENPOX_52,J_CHICKENPOX_54,J_CHICKENPOX_55,J_CHICKENPOX_62,J_CHICKENPOX_63,J_CHICKENPOX_64,J_CHICKENPOX_66,J_CHICKENPOX_73,J_CHICKENPOX_74,J_CHICKENPOX_84,J_CHICKENPOX_93,SPF_HELO_PASS X-Spam-Status: Yes, hits=6.9 required=5.0 tests=AWL,BAYES_50,J_CHICKENPOX_13,J_CHICKENPOX_21,J_CHICKENPOX_22,J_CHICKENPOX_23,J_CHICKENPOX_24,J_CHICKENPOX_33,J_CHICKENPOX_35,J_CHICKENPOX_36,J_CHICKENPOX_42,J_CHICKENPOX_43,J_CHICKENPOX_44,J_CHICKENPOX_45,J_CHICKENPOX_46,J_CHICKENPOX_48,J_CHICKENPOX_52,J_CHICKENPOX_54,J_CHICKENPOX_55,J_CHICKENPOX_62,J_CHICKENPOX_63,J_CHICKENPOX_64,J_CHICKENPOX_66,J_CHICKENPOX_73,J_CHICKENPOX_74,J_CHICKENPOX_84,J_CHICKENPOX_93,SPF_HELO_PASS X-Spam-Flag: YES X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: STABLE3 - gfs2: fix build warnings spotted by paranoia cflags To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE3 X-Git-Reftype: branch X-Git-Oldrev: d77119849960b3b477f18879794c2b8f5c30d1db X-Git-Newrev: c091d13d40da0c8c78c571e3ce1e0689a666ba5a From: "Fabio M. Di Nitto" Message-Id: <20090514031149.6AEB612022E@lists.fedorahosted.org> Date: Thu, 14 May 2009 03:12:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q2/txt/msg00310.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=c091d13d40da0c8c78c571e3ce1e0689a666ba5a Commit: c091d13d40da0c8c78c571e3ce1e0689a666ba5a Parent: d77119849960b3b477f18879794c2b8f5c30d1db Author: Fabio M. Di Nitto AuthorDate: Thu May 14 05:10:53 2009 +0200 Committer: Fabio M. Di Nitto CommitterDate: Thu May 14 05:10:53 2009 +0200 gfs2: fix build warnings spotted by paranoia cflags Signed-off-by: Fabio M. Di Nitto --- gfs2/convert/gfs2_convert.c | 54 +++--- gfs2/edit/gfs2hex.c | 70 ++++---- gfs2/edit/gfs2hex.h | 4 + gfs2/edit/hexedit.c | 366 +++++++++++++++++++++--------------------- gfs2/edit/hexedit.h | 3 + gfs2/edit/savemeta.c | 67 ++++---- gfs2/fsck/eattr.c | 1 + gfs2/fsck/fs_recovery.c | 11 +- gfs2/fsck/initialize.c | 4 +- gfs2/fsck/main.c | 22 ++-- gfs2/fsck/metawalk.c | 30 ++-- gfs2/fsck/pass1.c | 10 +- gfs2/fsck/pass1b.c | 6 +- gfs2/fsck/pass1c.c | 12 +- gfs2/fsck/pass2.c | 10 +- gfs2/fsck/pass3.c | 2 +- gfs2/fsck/pass4.c | 4 +- gfs2/fsck/pass5.c | 6 +- gfs2/fsck/rgrepair.c | 12 +- gfs2/libgfs2/block_list.c | 6 +- gfs2/libgfs2/buf.c | 2 +- gfs2/libgfs2/fs_geometry.c | 4 +- gfs2/libgfs2/fs_ops.c | 57 ++++--- gfs2/libgfs2/gfs1.c | 5 +- gfs2/libgfs2/gfs2_log.c | 4 +- gfs2/libgfs2/libgfs2.h | 16 +- gfs2/libgfs2/misc.c | 8 +- gfs2/libgfs2/rgrp.c | 8 +- gfs2/mkfs/main_grow.c | 12 +- gfs2/mkfs/main_jadd.c | 22 ++-- gfs2/mkfs/main_mkfs.c | 2 +- gfs2/mount/mount.gfs2.c | 4 +- gfs2/mount/util.c | 10 +- gfs2/quota/check.c | 4 +- gfs2/quota/gfs2_quota.h | 4 +- gfs2/quota/main.c | 4 +- gfs2/tool/df.c | 8 +- gfs2/tool/sb.c | 2 +- 38 files changed, 444 insertions(+), 432 deletions(-) diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c index 3b9da3c..b7c84e3 100644 --- a/gfs2/convert/gfs2_convert.c +++ b/gfs2/convert/gfs2_convert.c @@ -131,7 +131,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]; @@ -157,7 +157,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; @@ -235,7 +235,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; @@ -261,7 +261,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; @@ -301,7 +301,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) { @@ -415,7 +415,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; @@ -593,7 +593,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; @@ -682,7 +682,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; @@ -773,7 +773,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; @@ -795,7 +795,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; @@ -885,7 +885,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; @@ -931,7 +931,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; @@ -948,7 +948,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); @@ -989,7 +989,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; @@ -1002,7 +1002,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)]; @@ -1181,7 +1181,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"); @@ -1196,7 +1196,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", RELEASE_VERSION, __DATE__, __TIME__); @@ -1206,7 +1206,7 @@ void version(void) /* ------------------------------------------------------------------------- */ /* usage - print usage information */ /* ------------------------------------------------------------------------- */ -void usage(const char *name) +static void usage(const char *name) { give_warning(); printf("\nUsage:\n"); @@ -1223,7 +1223,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) { char c; @@ -1279,7 +1279,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; @@ -1308,7 +1308,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; @@ -1391,7 +1391,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; @@ -1408,7 +1408,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; @@ -1428,7 +1428,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; @@ -1454,7 +1454,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; @@ -1502,10 +1502,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 158d8c1..c3bc513 100644 --- a/gfs2/edit/gfs2hex.c +++ b/gfs2/edit/gfs2hex.c @@ -115,7 +115,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; @@ -219,7 +219,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; @@ -255,20 +255,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; 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].is_dir = FALSE; @@ -276,7 +276,7 @@ void do_dinode_extended(struct gfs2_dinode *di, char *buf) } } } - else if (isdir && !(di->di_flags & GFS2_DIF_EXHASH)) { + else if (isdir && !(dine->di_flags & GFS2_DIF_EXHASH)) { int skip = 0; /* Directory Entries: */ @@ -285,25 +285,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; @@ -347,7 +347,7 @@ void do_dinode_extended(struct gfs2_dinode *di, char *buf) ** ******************************************************************************* ******************************************************************************/ -int do_indirect_extended(char *buf, struct iinfo *iinf) +int do_indirect_extended(char *diebuf, struct iinfo *iinf) { unsigned int x, y; uint64_t p; @@ -359,7 +359,7 @@ int do_indirect_extended(char *buf, struct iinfo *iinf) sizeof(struct gfs2_meta_header)), y = 0; x < sbd.bsize; x += sizeof(uint64_t), y++) { - p = be64_to_cpu(*(uint64_t *)(buf + x)); + p = be64_to_cpu(*(uint64_t *)(diebuf + x)); if (p) { iinf->ii[i_blocks].block = p; iinf->ii[i_blocks].is_dir = FALSE; @@ -384,7 +384,7 @@ int do_indirect_extended(char *buf, struct iinfo *iinf) ** ******************************************************************************* ******************************************************************************/ -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; @@ -394,14 +394,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; @@ -430,7 +430,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; @@ -442,12 +442,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); @@ -467,31 +467,31 @@ 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(sb, sb_fs_format, "%u", "0x%x"); - pv(sb, sb_multihost_format, "%u", "0x%x"); + pv(sbp2, sb_fs_format, "%u", "0x%x"); + pv(sbp2, sb_multihost_format, "%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) { 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 } diff --git a/gfs2/edit/gfs2hex.h b/gfs2/edit/gfs2hex.h index 4dd92d4..93ed134 100644 --- a/gfs2/edit/gfs2hex.h +++ b/gfs2/edit/gfs2hex.h @@ -1,10 +1,14 @@ #ifndef __GFS2HEX_DOT_H__ #define __GFS2HEX_DOT_H__ +#include "hexedit.h" 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 *diebuf, struct iinfo *iinf); +void do_leaf_extended(char *dlebuf, struct iinfo *indir); +void eol(int col); #endif /* __GFS2HEX_DOT_H__ */ diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index 8a5f3bb..c652472 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -35,7 +35,6 @@ const char *allocdesc[] = {"Free ", "Data ", "Unlnk", "Meta ", "Resrv"}; #define RGLIST_DUMMY_BLOCK -2 int display(int identify_only); -extern void eol(int col); extern void do_leaf_extended(char *buf, struct iinfo *indir); extern int do_indirect_extended(char *buf, struct iinfo *ii); extern void savemeta(char *out_fn, int slow); @@ -79,58 +78,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); @@ -139,7 +138,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); @@ -152,7 +151,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; @@ -163,10 +162,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; } @@ -180,7 +179,7 @@ void UpdateSize(int sig) /* ------------------------------------------------------------------------- */ /* erase - clear the screen */ /* ------------------------------------------------------------------------- */ -void Erase(void) +static void Erase(void) { int i; char spaces[256]; @@ -199,7 +198,7 @@ void Erase(void) /* ------------------------------------------------------------------------- */ /* display_title_lines */ /* ------------------------------------------------------------------------- */ -void display_title_lines(void) +static void display_title_lines(void) { Erase(); COLORS_TITLE; @@ -215,7 +214,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; @@ -356,7 +355,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); @@ -378,7 +377,7 @@ void gfs2instr(const char *s1, const char *s2) ******************************************************************************* ******************************************************************************/ -void print_usage(void) +static void print_usage(void) { int ch; @@ -433,7 +432,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; @@ -460,10 +459,10 @@ int get_block_type(const char *lpBuffer) * * Returns: state on success, -1 on error */ -int gfs2_get_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, +static int gfs2_get_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, struct rgrp_list *rgd) { - int buf, val; + int i, val; uint32_t rgrp_block; struct gfs2_bitmap *bits = NULL; unsigned int bit; @@ -483,19 +482,19 @@ int gfs2_get_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, rgrp_block = (uint32_t)(blkno - rgd->ri.ri_data0); - for(buf= 0; buf < rgd->ri.ri_length; buf++){ - bits = &(rgd->bits[buf]); + for(i= 0; i < rgd->ri.ri_length; i++){ + bits = &(rgd->bits[i]); if(rgrp_block < ((bits->bi_start + bits->bi_len)*GFS2_NBBY)){ break; } } - if(buf >= rgd->ri.ri_length){ + if(i >= rgd->ri.ri_length){ gfs2_rgrp_relse(rgd, not_updated); return -1; } - byte = (unsigned char *)(rgd->bh[buf]->b_data + bits->bi_offset) + + byte = (unsigned char *)(rgd->bh[i]->b_data + bits->bi_offset) + (rgrp_block/GFS2_NBBY - bits->bi_start); bit = (rgrp_block % GFS2_NBBY) * GFS2_BIT_SIZE; @@ -705,7 +704,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; @@ -846,7 +845,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()); @@ -858,37 +857,37 @@ 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) { - char buf[sizeof(struct gfs2_rindex)]; + char fbuf[sizeof(struct gfs2_rindex)]; int amt; struct gfs2_rindex ri; - uint64_t offset, gfs1_adj = 0; + 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, buf); + gfs2_rindex_in(&ri, 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); @@ -901,11 +900,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); @@ -918,7 +917,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"); @@ -933,17 +932,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); @@ -961,7 +960,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; @@ -1009,43 +1008,43 @@ 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)); if (gfs1) { /* gfs1 rindex files have the meta_header which is not accounted for in gfs2's dinode size. Therefore, adjust. */ - di->i_di.di_size += ((di->i_di.di_size / sbd.bsize) + 1) * + dip->i_di.di_size += ((dip->i_di.di_size / sbd.bsize) + 1) * sizeof(struct gfs2_meta_header); } for (print_entry_ndx=0; ; print_entry_ndx++) { uint64_t gfs1_adj = 0; - uint64_t offset = print_entry_ndx * risize(); + uint64_t roffset = print_entry_ndx * risize(); if (gfs1) { uint64_t sd_jbsize = (sbd.bsize - sizeof(struct gfs2_meta_header)); - gfs1_adj = (offset / sd_jbsize) * + gfs1_adj = (roffset / sd_jbsize) * sizeof(struct gfs2_meta_header); gfs1_adj += sizeof(struct gfs2_meta_header); } - error = gfs2_readi(di, (void *)&buf, offset + gfs1_adj, + error = gfs2_readi(dip, (void *)&rbuf, roffset + gfs1_adj, 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] <= @@ -1089,9 +1088,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); @@ -1102,7 +1101,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"); @@ -1112,23 +1111,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 || @@ -1155,23 +1154,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; @@ -1180,23 +1179,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); @@ -1206,25 +1205,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); @@ -1235,7 +1234,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 || @@ -1248,7 +1247,7 @@ int has_indirect_blocks(void) /* ------------------------------------------------------------------------ */ /* print_inode_type */ /* ------------------------------------------------------------------------ */ -void print_inode_type(__be16 de_type) +static void print_inode_type(__be16 de_type) { switch(de_type) { case DT_UNKNOWN: @@ -1284,7 +1283,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 = 0; int d; @@ -1342,7 +1341,7 @@ int display_leaf(struct iinfo *ind) /* ------------------------------------------------------------------------ */ /* 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 i, cur_height = -1, pndx; @@ -1447,10 +1446,11 @@ int display_indirect(struct iinfo *ind, int indblocks, int level, uint64_t start } if (!S_ISDIR(di.di_mode)) { int hgt; - file_offset = startoff; float human_off; char h; + file_offset = startoff; + /* Now divide by how deep we are at the moment. */ /* This is how much data is represented by each */ /* indirect pointer for each height we've traversed. */ @@ -1539,7 +1539,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; @@ -1628,7 +1628,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() || @@ -1644,7 +1644,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; @@ -1701,7 +1701,7 @@ int display_extended(void) /* ------------------------------------------------------------------------ */ /* read_superblock - read the superblock */ /* ------------------------------------------------------------------------ */ -void read_superblock(int fd) +static void read_superblock(int fd) { int count; @@ -1781,7 +1781,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, @@ -1902,7 +1902,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; @@ -1925,7 +1925,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; @@ -1949,7 +1949,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; @@ -2005,7 +2005,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; @@ -2046,7 +2046,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; @@ -2107,7 +2107,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; @@ -2142,7 +2142,7 @@ uint64_t find_metablockoftype(const char *strtype, int print) /* Check if the word is a keyword such as "sb" or "rindex" */ /* Returns: block number if it is, else 0 */ /* ------------------------------------------------------------------------ */ -uint64_t check_keywords(const char *kword) +static uint64_t check_keywords(const char *kword) { uint64_t blk = 0; @@ -2206,7 +2206,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; @@ -2243,7 +2243,7 @@ uint64_t goto_block(void) /* ------------------------------------------------------------------------ */ /* init_colors */ /* ------------------------------------------------------------------------ */ -void init_colors() +static void init_colors(void) { if (color_scheme) { @@ -2269,7 +2269,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; @@ -2325,7 +2325,7 @@ void hex_edit(int *exitch) /* ------------------------------------------------------------------------ */ /* page up */ /* ------------------------------------------------------------------------ */ -void pageup(void) +static void pageup(void) { if (dmode == EXTENDED_MODE) { int dsplines = termlines - 6; @@ -2359,7 +2359,7 @@ void pageup(void) /* ------------------------------------------------------------------------ */ /* page down */ /* ------------------------------------------------------------------------ */ -void pagedn(void) +static void pagedn(void) { if (dmode == EXTENDED_MODE) { int dsplines = termlines - 6; @@ -2387,7 +2387,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; @@ -2417,30 +2417,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); @@ -2449,17 +2449,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) { @@ -2467,7 +2467,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; @@ -2492,9 +2492,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; @@ -2509,19 +2509,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[type]); gfs2_rgrp_relse(rgd, not_updated); } else { @@ -2540,20 +2540,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; + fblock = blockstack[blockhist % BLOCK_STACK_SIZE].block; bh = bread(&sbd.buf_list, block); 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: @@ -2570,7 +2570,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: @@ -2596,7 +2596,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; } @@ -2607,7 +2607,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; @@ -2872,11 +2872,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); @@ -2909,7 +2909,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]; @@ -2941,7 +2941,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; @@ -2955,18 +2955,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 */ @@ -2990,10 +2990,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++; @@ -3002,7 +3002,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("------------------------------------------------" @@ -3020,7 +3020,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; @@ -3145,7 +3145,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 [val]] /dev/device\n\n"); fprintf(stderr,"If only the device is specified, it enters into hexedit mode.\n"); @@ -3220,7 +3220,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", @@ -3271,7 +3271,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 96b36c0..6977edf 100644 --- a/gfs2/edit/hexedit.h +++ b/gfs2/edit/hexedit.h @@ -159,6 +159,9 @@ extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf); extern void gfs_log_header_in(struct gfs_log_header *head, char *buf); extern void gfs_log_header_print(struct gfs_log_header *lh); extern void gfs_dinode_in(struct gfs_dinode *di, char *buf); +extern void savemeta(char *out_fn, int saveoption); +extern void restoremeta(const char *in_fn, const char *out_device, int printblocksonly); +extern uint64_t masterblock(const char *fn); struct gfs2_dirents { uint64_t block; diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 2f70a24..4a36652 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -40,7 +40,6 @@ uint64_t gfs1_journal_size = 0; /* in blocks */ int journals_found = 0; extern void read_superblock(void); -uint64_t masterblock(const char *fn); /* * get_gfs_struct_info - get block type and structure length @@ -51,14 +50,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; *block_type = 0; - *struct_len = sbd.bsize; + *gstruct_len = sbd.bsize; - gfs2_meta_header_in(&mh, buf); + gfs2_meta_header_in(&mh, gbuf); if (mh.mh_magic != GFS2_MAGIC) return -1; @@ -66,46 +65,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) */ /* GFS1 keeps indirect pointers in GFS2_METATYPE_JD blocks so we need to save the whole block. For GFS2, we don't want to, or we might capture user data, which is bad. */ if (gfs1) - *struct_len = sbd.bsize; + *gstruct_len = sbd.bsize; else - *struct_len = sizeof(struct gfs2_meta_header); + *gstruct_len = sizeof(struct gfs2_meta_header); break; case GFS2_METATYPE_LH: /* 8 (log header) */ - *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; @@ -117,12 +116,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; @@ -135,7 +134,7 @@ void warm_fuzzy_stuff(uint64_t block, int force, int save) if (save) { percent = (block * 100) / last_fs_block; printf("%" PRIu64 " metadata blocks (%" - PRIu64 "%%) processed, ", block, + PRIu64 "%%) processed, ", wfsblock, percent); } if (total_out < 1024 * 1024) @@ -155,7 +154,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; @@ -165,7 +164,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() || @@ -173,7 +172,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; @@ -253,7 +252,7 @@ int save_block(int fd, int out_fd, uint64_t blk) /* * 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; @@ -298,7 +297,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; @@ -388,7 +387,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; @@ -636,32 +635,32 @@ void savemeta(char *out_fn, int saveoption) exit(0); } -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; uint16_t buf16; int first = 1, pos; - char buf[256]; + char rdbuf[256]; char gfs_superblock_id[8] = {0x01, 0x16, 0x19, 0x70, 0x00, 0x00, 0x00, 0x01}; if (!printblocksonly) lseek(fd, 0, SEEK_SET); lseek(in_fd, 0, SEEK_SET); - rs = read(in_fd, buf, sizeof(buf)); - if (rs != sizeof(buf)) { + rs = read(in_fd, rdbuf, sizeof(rdbuf)); + if (rs != sizeof(rdbuf)) { fprintf(stderr, "Error: File is too small.\n"); return -1; } - for (pos = 0; pos < sizeof(buf) - sizeof(uint64_t) - sizeof(uint16_t); + for (pos = 0; pos < sizeof(rdbuf) - sizeof(uint64_t) - sizeof(uint16_t); pos++) { - if (!memcmp(&buf[pos + sizeof(uint64_t) + sizeof(uint16_t)], + if (!memcmp(&rdbuf[pos + sizeof(uint64_t) + sizeof(uint16_t)], gfs_superblock_id, sizeof(gfs_superblock_id))) { break; } } - if (pos == sizeof(buf) - sizeof(uint64_t) - sizeof(uint16_t)) + if (pos == sizeof(rdbuf) - sizeof(uint64_t) - sizeof(uint16_t)) pos = 0; if (lseek(in_fd, pos, SEEK_SET) != pos) { fprintf(stderr, "bad seek: %s from %s:%d: " @@ -782,7 +781,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 " diff --git a/gfs2/fsck/eattr.c b/gfs2/fsck/eattr.c index 0fe2421..d2a0d5e 100644 --- a/gfs2/fsck/eattr.c +++ b/gfs2/fsck/eattr.c @@ -3,6 +3,7 @@ #include "libgfs2.h" #include "fsck.h" +#include "eattr.h" static int clear_blk_nodup(struct gfs2_sbd *sbp, uint64_t block) { diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c index 637e8c1..9360164 100644 --- a/gfs2/fsck/fs_recovery.c +++ b/gfs2/fsck/fs_recovery.c @@ -55,7 +55,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) { @@ -72,8 +72,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) @@ -246,7 +245,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; @@ -321,7 +320,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; @@ -380,7 +379,7 @@ int fix_journal_seq_no(struct gfs2_inode *ip) * Returns: errno */ -int gfs2_recover_journal(struct gfs2_inode *ip, int j) +static int gfs2_recover_journal(struct gfs2_inode *ip, int j) { struct gfs2_sbd *sdp = ip->i_sbd; struct gfs2_log_header head; diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 1512933..9441bff 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -24,7 +24,7 @@ * * Go through journals and replay them - then clear them */ -int init_journals(struct gfs2_sbd *sbp) +static int init_journals(struct gfs2_sbd *sbp) { if(!opts.no) { if(replay_journals(sbp)) @@ -146,7 +146,7 @@ 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 %lu bytes.\n", + log_crit("Last fs block = 0x%llx, but sizeof(unsigned long) is %"PRIuFAST32" bytes.\n", (unsigned long long)last_fs_block, sizeof(unsigned long)); goto fail; diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index 3481b4f..d1995e7 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -24,7 +24,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 */ /* This function is for libgfs2's sake. */ void print_it(const char *label, const char *fmt, const char *fmt2, ...) @@ -37,19 +37,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 [-hnqvVy] \n", basename(name)); } -void version(void) +static void version(void) { printf("GFS2 fsck %s (built %s %s)\n", RELEASE_VERSION, __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; @@ -61,7 +61,7 @@ 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 'q': decrease_verbosity(); @@ -74,7 +74,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 '?': @@ -88,8 +88,8 @@ int read_cmdline(int argc, char **argv, struct gfs2_options *opts) } } if(argc > optind) { - opts->device = (argv[optind]); - if(!opts->device) { + gopts->device = (argv[optind]); + if(!gopts->device) { fprintf(stderr, "Please use '-h' for usage.\n"); return FSCK_USAGE; } @@ -100,7 +100,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]; @@ -127,7 +127,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, int builder(struct gfs2_sbd *sbp), enum gfs2_mark_block mark) { @@ -197,7 +197,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 bb5dbd5..41d5ca5 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -94,7 +94,7 @@ void fsck_inode_put(struct gfs2_inode *ip, enum update_flags update) } } -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) { @@ -133,8 +133,8 @@ int dirent_repair(struct gfs2_inode *ip, struct gfs2_buffer_head *bh, return 0; } -int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh, - int index, int type, enum update_flags *update, +static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh, + int eindex, int type, enum update_flags *update, uint16_t *count, struct metawalk_fxns *pass) { struct gfs2_leaf *leaf = NULL; @@ -258,8 +258,8 @@ 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, int index, +static void warn_and_patch(struct gfs2_inode *ip, uint64_t *leaf_no, + uint64_t *bad_leaf, uint64_t old_leaf, int pindex, const char *msg) { if (*bad_leaf != *leaf_no) { @@ -274,7 +274,7 @@ void warn_and_patch(struct gfs2_inode *ip, uint64_t *leaf_no, if (*leaf_no == *bad_leaf || query(&opts, "Attempt to patch around it? (y/n) ")) { errors_corrected++; - gfs2_put_leaf_nr(ip, index, old_leaf); + gfs2_put_leaf_nr(ip, pindex, old_leaf); } else log_err("Bad leaf left in place.\n"); @@ -283,28 +283,28 @@ void warn_and_patch(struct gfs2_inode *ip, uint64_t *leaf_no, } /* Checks exhash directory entries */ -int check_leaf(struct gfs2_inode *ip, enum update_flags *update, +static int check_leaf(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; 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; old_leaf = 0; memset(&oldleaf, 0, sizeof(oldleaf)); - for(index = 0; index < (1 << ip->i_di.di_depth); index++) { - gfs2_get_leaf_nr(ip, index, &leaf_no); + for(lindex = 0; lindex < (1 << ip->i_di.di_depth); lindex++) { + 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; @@ -359,7 +359,7 @@ int check_leaf(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, index, + old_leaf, lindex, "that is out of range"); memcpy(&leaf, &oldleaf, sizeof(oldleaf)); break; @@ -371,7 +371,7 @@ int check_leaf(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, index, + old_leaf, lindex, "that is not really a leaf"); memcpy(&leaf, &oldleaf, sizeof(oldleaf)); brelse(lbh, (opts.no ? not_updated : updated)); @@ -418,7 +418,7 @@ int check_leaf(struct gfs2_inode *ip, enum update_flags *update, if(pass->check_dentry && S_ISDIR(ip->i_di.di_mode)) { - error = check_entries(ip, lbh, index, + error = check_entries(ip, lbh, lindex, DIR_EXHASH, update, &count, pass); @@ -873,7 +873,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; diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c index 6a63338..f026b12 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -471,7 +471,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}; @@ -489,7 +489,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}; @@ -505,7 +505,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}; @@ -558,7 +558,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}; @@ -789,7 +789,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 02a5f9b..8d00d3c 100644 --- a/gfs2/fsck/pass1b.c +++ b/gfs2/fsck/pass1b.c @@ -341,7 +341,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}; @@ -396,7 +396,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; @@ -466,8 +466,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/pass1c.c b/gfs2/fsck/pass1c.c index 9fd21db..d2c8ece 100644 --- a/gfs2/fsck/pass1c.c +++ b/gfs2/fsck/pass1c.c @@ -19,15 +19,17 @@ static int remove_eattr_entry(struct gfs2_sbd *sdp, curr->ea_type = GFS2_EATYPE_UNUSED; else { prev->ea_rec_len = - cpu_to_be32(be32_to_cpu(curr->ea_rec_len) + - be32_to_cpu(prev->ea_rec_len)); + be32_to_cpu(curr->ea_rec_len); + be32_to_cpu(prev->ea_rec_len); + cpu_to_be32(curr->ea_rec_len + prev->ea_rec_len); + if (curr->ea_flags & GFS2_EAFLAG_LAST) prev->ea_flags |= GFS2_EAFLAG_LAST; } return 0; } -int check_eattr_indir(struct gfs2_inode *ip, uint64_t block, +static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block, uint64_t parent, struct gfs2_buffer_head **bh, enum update_flags *update, void *private) { @@ -71,7 +73,7 @@ int check_eattr_indir(struct gfs2_inode *ip, uint64_t block, return 0; } -int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block, +static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block, uint64_t parent, struct gfs2_buffer_head **bh, enum update_flags *update, void *private) { @@ -198,7 +200,7 @@ static int check_eattr_entry(struct gfs2_inode *ip, return 0; } -int check_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_ptr, +static int check_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_ptr, struct gfs2_buffer_head *leaf_bh, struct gfs2_ea_header *ea_hdr, struct gfs2_ea_header *ea_hdr_prev, diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c index 6047408..92fc782 100644 --- a/gfs2/fsck/pass2.c +++ b/gfs2/fsck/pass2.c @@ -16,7 +16,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; @@ -43,7 +43,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; @@ -90,7 +90,7 @@ 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", @@ -142,7 +142,7 @@ static int check_file_type(uint8_t de_type, uint8_t block_type) /* 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) @@ -540,7 +540,7 @@ struct metawalk_fxns pass2_fxns = { /* Check system directory inode */ /* Should work for all system directories: root, master, jindex, per_node */ -int check_system_dir(struct gfs2_inode *sysinode, const char *dirname, +static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname, int builder(struct gfs2_sbd *sbp)) { uint64_t iblock = 0; diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c index a5c0202..8e08700 100644 --- a/gfs2/fsck/pass3.c +++ b/gfs2/fsck/pass3.c @@ -54,7 +54,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 38cff40..e0ea14e 100644 --- a/gfs2/fsck/pass4.c +++ b/gfs2/fsck/pass4.c @@ -9,7 +9,7 @@ /* 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", @@ -26,7 +26,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 aa63f11..b07575e 100644 --- a/gfs2/fsck/pass5.c +++ b/gfs2/fsck/pass5.c @@ -8,7 +8,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]++; @@ -51,7 +51,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; @@ -119,7 +119,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 948d041..d7db173 100644 --- a/gfs2/fsck/rgrepair.c +++ b/gfs2/fsck/rgrepair.c @@ -34,7 +34,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; @@ -64,7 +64,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; @@ -96,7 +96,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; @@ -337,7 +337,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); @@ -374,7 +374,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; @@ -422,7 +422,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count) { int error, descrepencies; osi_list_t expected_rglist; - int calc_rg_count, rgcount_from_index, rg; + int calc_rg_count = 0, rgcount_from_index, rg; osi_list_t *exp, *act; /* expected, actual */ struct gfs2_rindex buf; diff --git a/gfs2/libgfs2/block_list.c b/gfs2/libgfs2/block_list.c index 092d045..2bea6aa 100644 --- a/gfs2/libgfs2/block_list.c +++ b/gfs2/libgfs2/block_list.c @@ -182,7 +182,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; @@ -209,7 +209,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; @@ -238,7 +238,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; diff --git a/gfs2/libgfs2/buf.c b/gfs2/libgfs2/buf.c index 6939c25..88f9326 100644 --- a/gfs2/libgfs2/buf.c +++ b/gfs2/libgfs2/buf.c @@ -172,7 +172,7 @@ 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. */ diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c index c855214..394daed 100644 --- a/gfs2/libgfs2/fs_geometry.c +++ b/gfs2/libgfs2/fs_geometry.c @@ -178,7 +178,7 @@ void rgblocks2bitblocks(unsigned int bsize, uint32_t *rgblocks, uint32_t *bitblo * 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; @@ -215,7 +215,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 a45144b..633901a 100644 --- a/gfs2/libgfs2/fs_ops.c +++ b/gfs2/libgfs2/fs_ops.c @@ -43,9 +43,9 @@ 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); free(ip); @@ -681,8 +681,10 @@ static int dirent_alloc(struct gfs2_inode *dip, struct gfs2_buffer_head *bh, new->de_rec_len = cpu_to_be16(cur_rec_len - GFS2_DIRENT_SIZE(cur_name_len)); new->de_name_len = cpu_to_be16(name_len); - dent->de_rec_len = cpu_to_be16(cur_rec_len - - be16_to_cpu(new->de_rec_len)); + + be16_to_cpu(new->de_rec_len); + dent->de_rec_len = cpu_to_be16(cur_rec_len - new->de_rec_len); + *dent_out = new; return 0; } @@ -714,14 +716,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"); @@ -741,7 +743,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; @@ -771,7 +773,7 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t index, uint64_t leaf 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)); lp = calloc(1, half_len * sizeof(uint64_t)); if (lp == NULL) { @@ -920,12 +922,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, +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; } @@ -952,13 +954,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, +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; @@ -966,11 +968,11 @@ static void 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); @@ -980,7 +982,7 @@ static void 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) { @@ -1071,7 +1073,8 @@ static void dir_make_exhash(struct gfs2_inode *dip) break; } while (gfs2_dirent_next(dip, bh, &dent) == 0); - dent->de_rec_len = cpu_to_be16(be16_to_cpu(dent->de_rec_len) + + be16_to_cpu(dent->de_rec_len); + dent->de_rec_len = cpu_to_be16(dent->de_rec_len + sizeof(struct gfs2_dinode) - sizeof(struct gfs2_leaf)); brelse(bh, updated); @@ -1092,7 +1095,7 @@ static void dir_make_exhash(struct gfs2_inode *dip) dip->i_di.di_depth = y; } -static void dir_l_add(struct gfs2_inode *dip, char *filename, int len, +static void dir_l_add(struct gfs2_inode *dip, const char *filename, int len, struct gfs2_inum *inum, unsigned int type) { struct gfs2_dirent *dent; @@ -1112,7 +1115,7 @@ static void dir_l_add(struct gfs2_inode *dip, char *filename, int len, dip->i_di.di_entries++; } -void dir_add(struct gfs2_inode *dip, char *filename, int len, +void dir_add(struct gfs2_inode *dip, const char *filename, int len, struct gfs2_inum *inum, unsigned int type) { if (dip->i_di.di_flags & GFS2_DIF_EXHASH) @@ -1183,7 +1186,7 @@ struct gfs2_buffer_head *init_dinode(struct gfs2_sbd *sdp, return bh; } -struct gfs2_inode *createi(struct gfs2_inode *dip, char *filename, +struct gfs2_inode *createi(struct gfs2_inode *dip, const char *filename, unsigned int mode, uint32_t flags) { struct gfs2_sbd *sdp = dip->i_sbd; @@ -1303,7 +1306,7 @@ static int linked_leaf_search(struct gfs2_inode *dip, const char *filename, 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; @@ -1314,9 +1317,9 @@ static int linked_leaf_search(struct gfs2_inode *dip, const char *filename, /* 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; @@ -1438,17 +1441,17 @@ static 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); diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c index c2ad8de..3375a6c 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; @@ -328,7 +329,7 @@ int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount) /* ------------------------------------------------------------------------ */ /* 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 e66d7d5..49dd2e2 100644 --- a/gfs2/libgfs2/gfs2_log.c +++ b/gfs2/libgfs2/gfs2_log.c @@ -27,7 +27,7 @@ void decrease_verbosity(void) _state.print_level--; } -static void print_msg(int priority, char *file, int line, const char *format, +static void print_msg(int priority, const char *file, int line, const char *format, va_list args) { switch (priority) { @@ -53,7 +53,7 @@ static void print_msg(int priority, char *file, int line, const char *format, } -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, ...) { diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index 5022f75..5eef1a6 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -74,7 +74,7 @@ static __inline__ __attribute__((noreturn)) void die(const char *fmt, ...) va_list ap; fprintf(stderr, "%s: ", __FILE__); va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + //vfprintf(stderr, fmt, ap); va_end(ap); exit(-1); } @@ -390,7 +390,7 @@ extern struct gfs2_buffer_head *__bget(struct buf_list *bl, uint64_t num, extern struct gfs2_buffer_head *__bread(struct buf_list *bl, uint64_t num, int line, const char *caller); extern struct gfs2_buffer_head *bhold(struct gfs2_buffer_head *bh); -extern void brelse(struct gfs2_buffer_head *bh, enum update_flags updated); +extern void brelse(struct gfs2_buffer_head *bh, enum update_flags is_updated); extern void __bsync(struct buf_list *bl, int line, const char *caller); extern void __bcommit(struct buf_list *bl, int line, const char *caller); @@ -454,14 +454,14 @@ extern struct gfs2_buffer_head *init_dinode(struct gfs2_sbd *sdp, struct gfs2_inum *inum, unsigned int mode, uint32_t flags, struct gfs2_inum *parent); -extern struct gfs2_inode *createi(struct gfs2_inode *dip, char *filename, +extern struct gfs2_inode *createi(struct gfs2_inode *dip, const char *filename, unsigned int mode, uint32_t flags); extern void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh, struct gfs2_dirent *prev, struct gfs2_dirent *cur); extern struct gfs2_inode *gfs2_load_inode(struct gfs2_sbd *sbp, uint64_t block); extern int gfs2_lookupi(struct gfs2_inode *dip, const char *filename, int len, struct gfs2_inode **ipp); -extern void dir_add(struct gfs2_inode *dip, char *filename, int len, +extern void dir_add(struct gfs2_inode *dip, const char *filename, int len, struct gfs2_inum *inum, unsigned int type); extern int gfs2_dirent_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh, const char *filename, int filename_len); @@ -620,7 +620,7 @@ do { print_log(1, MSG_CRITICAL, format); } while(0) extern void increase_verbosity(void); extern void decrease_verbosity(void); -extern void print_fsck_log(int iif, int priority, char *file, int line, +extern void print_fsck_log(int iif, int priority, const char *file, int line, const char *format, ...) __attribute__((format(printf,5,6))); extern char generic_interrupt(const char *caller, const char *where, @@ -643,9 +643,9 @@ extern void cleanup_metafs(struct gfs2_sbd *sdp); extern char *find_debugfs_mount(void); extern char *mp2fsname(char *mp); extern char *mp2fsname2(char *mp); -extern char *get_sysfs(char *fsname, char *filename); -extern int get_sysfs_uint(char *fsname, char *filename, unsigned int *val); -extern int set_sysfs(char *fsname, char *filename, char *val); +extern char *get_sysfs(const char *fsname, const char *filename); +extern int get_sysfs_uint(const char *fsname, const char *filename, unsigned int *val); +extern int set_sysfs(const char *fsname, const char *filename, const char *val); extern int is_fsname(char *name); /* recovery.c */ diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c index 726c582..02c911e 100644 --- a/gfs2/libgfs2/misc.c +++ b/gfs2/libgfs2/misc.c @@ -207,7 +207,7 @@ void cleanup_metafs(struct gfs2_sbd *sdp) rmdir(sdp->metafs_path); } -static char *__get_sysfs(char *fsname, char *filename) +static char *__get_sysfs(const char *fsname, const char *filename) { char path[PATH_MAX]; int fd, rv; @@ -229,7 +229,7 @@ static 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 *s; char *p; @@ -243,7 +243,7 @@ char *get_sysfs(char *fsname, char *filename) return sysfs_buf; } -int get_sysfs_uint(char *fsname, char *filename, unsigned int *val) +int get_sysfs_uint(const char *fsname, const char *filename, unsigned int *val) { char *s = __get_sysfs(fsname, filename); int ret; @@ -257,7 +257,7 @@ int get_sysfs_uint(char *fsname, char *filename, unsigned int *val) return 0; } -int set_sysfs(char *fsname, char *filename, char *val) +int set_sysfs(const char *fsname, const char *filename, const char *val) { char path[PATH_MAX]; int fd, rv, len; diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c index 15adb16..fc548d1 100644 --- a/gfs2/libgfs2/rgrp.c +++ b/gfs2/libgfs2/rgrp.c @@ -136,15 +136,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; @@ -152,7 +152,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/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c index b686bd7..95f5d17 100644 --- a/gfs2/mkfs/main_grow.c +++ b/gfs2/mkfs/main_grow.c @@ -56,7 +56,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; @@ -107,7 +107,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; @@ -116,7 +116,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; } /** @@ -128,7 +128,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; @@ -150,7 +150,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; @@ -179,7 +179,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 95e1fa5..b797b99 100644 --- a/gfs2/mkfs/main_jadd.c +++ b/gfs2/mkfs/main_jadd.c @@ -23,8 +23,8 @@ #define BUF_SIZE 4096 #define RANDOM(values) ((values) * (random() / (RAND_MAX + 1.0))) -void -make_jdata(int fd, char *value) +static void +make_jdata(int fd, const char *value) { int err; uint32_t val; @@ -41,8 +41,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; @@ -195,7 +195,7 @@ print_results(struct gfs2_sbd *sdp) } -int +static int create_new_inode(struct gfs2_sbd *sdp) { char name[PATH_MAX]; @@ -222,7 +222,7 @@ create_new_inode(struct gfs2_sbd *sdp) return fd; } -void +static void add_ir(struct gfs2_sbd *sdp) { int fd; @@ -253,7 +253,7 @@ add_ir(struct gfs2_sbd *sdp) new_name, error, strerror(errno)); } -void +static void add_sc(struct gfs2_sbd *sdp) { int fd; @@ -285,7 +285,7 @@ add_sc(struct gfs2_sbd *sdp) new_name, error, strerror(errno)); } -void +static void add_qc(struct gfs2_sbd *sdp) { int fd; @@ -351,7 +351,7 @@ add_qc(struct gfs2_sbd *sdp) new_name, error, strerror(errno)); } -void +static void gather_info(struct gfs2_sbd *sdp) { struct statfs statbuf; @@ -362,7 +362,7 @@ gather_info(struct gfs2_sbd *sdp) sdp->bsize = statbuf.f_bsize; } -void +static void find_current_journals(struct gfs2_sbd *sdp) { char jindex[PATH_MAX]; @@ -393,7 +393,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 fc53ae3..5e34f64 100644 --- a/gfs2/mkfs/main_mkfs.c +++ b/gfs2/mkfs/main_mkfs.c @@ -350,7 +350,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 1bf18d0..4ae8bbe 100644 --- a/gfs2/mount/mount.gfs2.c +++ b/gfs2/mount/mount.gfs2.c @@ -1,7 +1,7 @@ #include "util.h" -char *prog_name; -char *fsname; +const char *prog_name; +const char *fsname; int verbose, fake_mount = 0, no_mtab = 0; static sigset_t old_sigset; diff --git a/gfs2/mount/util.c b/gfs2/mount/util.c index ca48fe9..805e8a2 100644 --- a/gfs2/mount/util.c +++ b/gfs2/mount/util.c @@ -52,7 +52,7 @@ static int gfs_controld_fd; /* 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 */ @@ -258,7 +258,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; @@ -266,7 +266,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; @@ -275,7 +275,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; @@ -574,7 +574,7 @@ int lock_dlm_leave(struct mount_options *mo, struct gen_sb *sb, int mnterr) int lock_dlm_remount(struct mount_options *mo, struct gen_sb *sb) { struct gfsc_mount_args ma; - char *mode; + const char *mode; int fd, rv, result; memset(&ma, 0, sizeof(ma)); diff --git a/gfs2/quota/check.c b/gfs2/quota/check.c index 9223971..118758b 100644 --- a/gfs2/quota/check.c +++ b/gfs2/quota/check.c @@ -274,7 +274,7 @@ out: */ static void -print_list(char *str, osi_list_t *list) +print_list(const char *str, osi_list_t *list) { #if 0 osi_list_t *tmp; @@ -297,7 +297,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 bcd945d..27342f8 100644 --- a/gfs2/quota/gfs2_quota.h +++ b/gfs2/quota/gfs2_quota.h @@ -64,7 +64,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); void get_last_quota_id(int fd, uint32_t *max_id); int is_valid_quota_list(int fd); @@ -72,7 +72,7 @@ inline void read_quota_internal(int fd, unsigned int id, int id_type, struct gfs2_quota *q); inline void write_quota_internal(int fd, unsigned int id, int id_type, struct gfs2_quota *q); -void print_quota_list_warning(); +void print_quota_list_warning(void); /* check.c */ diff --git a/gfs2/quota/main.c b/gfs2/quota/main.c index 7b6ad78..5e2e487 100644 --- a/gfs2/quota/main.c +++ b/gfs2/quota/main.c @@ -50,7 +50,7 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...) */ static void -print_usage() +print_usage(void) { printf("Usage:\n"); printf("\n"); @@ -841,7 +841,7 @@ do_set(struct gfs2_sbd *sdp, commandline_t *comline) int fd; uint64_t offset; uint64_t new_value; - int error, adj_flag = 0;; + int error, adj_flag = 0; char quota_file[BUF_SIZE]; char id_str[16]; struct stat stat_buf; diff --git a/gfs2/tool/df.c b/gfs2/tool/df.c index 0baef04..4476137 100644 --- a/gfs2/tool/df.c +++ b/gfs2/tool/df.c @@ -40,17 +40,17 @@ static const char *anthropomorphize(unsigned long long inhuman_value) */ static void printit(unsigned long long block_size, const char *label, unsigned long long total, unsigned long long used, - unsigned long long free, unsigned int percentage) + unsigned long long freespace, unsigned int percentage) { switch (output_type) { case OUTPUT_BLOCKS: printf(" %-15s%-15llu%-15llu%-15llu%u%%\n", - label, total, used, free, percentage); + label, total, used, freespace, percentage); break; case OUTPUT_K: printf(" %-15s%-15llu%-15llu%-15llu%u%%\n", label, (total * block_size) / 1024, - (used * block_size) / 1024, (free * block_size) / 1024, + (used * block_size) / 1024, (freespace * block_size) / 1024, percentage); break; case OUTPUT_HUMAN: @@ -59,7 +59,7 @@ static void printit(unsigned long long block_size, const char *label, printf(" %-15s%-15s", label, anthropomorphize(total * block_size)); printf("%-15s", anthropomorphize(used * block_size)); - printf("%-15s%u%%\n", anthropomorphize(free * block_size), + printf("%-15s%u%%\n", anthropomorphize(freespace * block_size), percentage); break; } diff --git a/gfs2/tool/sb.c b/gfs2/tool/sb.c index d6296c8..9456704 100644 --- a/gfs2/tool/sb.c +++ b/gfs2/tool/sb.c @@ -34,7 +34,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;