From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3211 invoked by alias); 27 Jan 2009 15:00:01 -0000 Received: (qmail 3174 invoked by alias); 27 Jan 2009 15:00:01 -0000 X-SWARE-Spam-Status: Yes, hits=5.4 required=5.0 tests=AWL,BAYES_50,J_CHICKENPOX_101,J_CHICKENPOX_22,J_CHICKENPOX_25,J_CHICKENPOX_35,J_CHICKENPOX_36,J_CHICKENPOX_41,J_CHICKENPOX_42,J_CHICKENPOX_43,J_CHICKENPOX_45,J_CHICKENPOX_46,J_CHICKENPOX_48,J_CHICKENPOX_52,J_CHICKENPOX_56,J_CHICKENPOX_63,J_CHICKENPOX_66,J_CHICKENPOX_73,J_CHICKENPOX_84,J_CHICKENPOX_93,KAM_MX,SPF_HELO_PASS X-Spam-Status: Yes, hits=5.4 required=5.0 tests=AWL,BAYES_50,J_CHICKENPOX_101,J_CHICKENPOX_22,J_CHICKENPOX_25,J_CHICKENPOX_35,J_CHICKENPOX_36,J_CHICKENPOX_41,J_CHICKENPOX_42,J_CHICKENPOX_43,J_CHICKENPOX_45,J_CHICKENPOX_46,J_CHICKENPOX_48,J_CHICKENPOX_52,J_CHICKENPOX_56,J_CHICKENPOX_63,J_CHICKENPOX_66,J_CHICKENPOX_73,J_CHICKENPOX_84,J_CHICKENPOX_93,KAM_MX,SPF_HELO_PASS X-Spam-Flag: YES X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on bastion.fedora.phx.redhat.com Subject: gfs2-utils: master - Replace deprecated do_seek, do_read, do_write functions To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: gfs2-utils.git X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 90beba33edce469c767f0278c3ba7ae0af54ea49 X-Git-Newrev: 36a1249c6b52d18bf52e93d155d12a983a0e9df6 From: Bob Peterson Message-Id: <20090127145933.2764CC024D@lists.fedorahosted.org> Date: Tue, 27 Jan 2009 15:00: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-q1/txt/msg00294.txt.bz2 Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitdiff;h=36a1249c6b52d18bf52e93d155d12a983a0e9df6 Commit: 36a1249c6b52d18bf52e93d155d12a983a0e9df6 Parent: 90beba33edce469c767f0278c3ba7ae0af54ea49 Author: Bob Peterson AuthorDate: Mon Jan 26 22:11:13 2009 -0600 Committer: Bob Peterson CommitterDate: Tue Jan 27 08:56:22 2009 -0600 Replace deprecated do_seek, do_read, do_write functions and fix a bunch of warning messages. --- gfs2/convert/gfs2_convert.c | 14 ++++-- gfs2/edit/hexedit.c | 78 ++++++++++++++++++++++++-------- gfs2/edit/savemeta.c | 101 +++++++++++++++++++++++++++++++++++------ gfs2/fsck/initialize.c | 9 ++-- gfs2/fsck/lost_n_found.c | 8 ++-- gfs2/fsck/main.c | 2 +- gfs2/fsck/metawalk.c | 100 +++++++++++++++++++++++++--------------- gfs2/fsck/pass1.c | 102 +++++++++++++++++++++++------------------ gfs2/fsck/pass1b.c | 80 +++++++++++++++++++------------- gfs2/fsck/pass1c.c | 43 ++++++++++------- gfs2/fsck/pass2.c | 94 +++++++++++++++++++++----------------- gfs2/fsck/pass4.c | 17 +++++--- gfs2/fsck/pass5.c | 8 ++- gfs2/fsck/rgrepair.c | 30 +++++++------ gfs2/libgfs2/buf.c | 106 ++++++++++++++++++++++++++++++++++--------- gfs2/libgfs2/fs_geometry.c | 3 +- gfs2/libgfs2/fs_ops.c | 12 +++-- gfs2/libgfs2/libgfs2.h | 73 ++++++++++------------------- gfs2/libgfs2/misc.c | 4 +- gfs2/libgfs2/ondisk.c | 2 +- gfs2/libgfs2/structures.c | 18 +++++--- gfs2/mkfs/main_jadd.c | 60 +++++++++++++++++++++--- gfs2/mount/util.c | 16 ++++++- gfs2/mount/util.h | 7 --- gfs2/quota/main.c | 14 +++++- gfs2/tool/df.c | 20 +++++++- gfs2/tool/sb.c | 27 +++++++++-- 27 files changed, 694 insertions(+), 354 deletions(-) diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c index 634764a..5e396a5 100644 --- a/gfs2/convert/gfs2_convert.c +++ b/gfs2/convert/gfs2_convert.c @@ -532,8 +532,10 @@ int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_buffer_head *dibh, b = blk->lblock; /* Calculate the metapath in GFS2 terms */ memset(&mp2, 0, sizeof(mp2)); - for (h = gfs2_height; h--;) - mp2.mp_list[h] = do_div(b, gfs2_inptrs); + for (h = gfs2_height; h--;) { + mp2.mp_list[h] = b % gfs2_inptrs; + b /= gfs2_inptrs; + } for (h = gfs2_height - 1; h >= 0; h--) { if (h) { /* find/reuse a bh from the old metadata. */ @@ -830,7 +832,8 @@ int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp, if (inum.no_formal_ino) { /* if not a sentinel (placeholder) */ error = fetch_inum(sbp, inum.no_addr, &inum); if (error) { - log_crit("Error retrieving inode %" PRIx64 "\n", inum.no_addr); + log_crit("Error retrieving inode 0x%llx\n", + (unsigned long long)inum.no_addr); break; } /* fix the dirent's inode number from the fetched inum. */ @@ -1330,8 +1333,9 @@ int journ_space_to_rg(struct gfs2_sbd *sdp) (rgd->ri.ri_addr > rgdhigh->ri.ri_addr))) rgdhigh = rgd; } /* for each rg */ - log_info("Addr %" PRIx64 " comes after rg at addr %" PRIx64 "\n", - jndx->ji_addr, rgdhigh->ri.ri_addr); + log_info("Addr 0x%llx comes after rg at addr 0x%llx\n", + (unsigned long long)jndx->ji_addr, + (unsigned long long)rgdhigh->ri.ri_addr); if (!rgdhigh) { /* if we somehow didn't find one. */ log_crit("Error: No suitable rg found for journal.\n"); return -1; diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index 9b1fcc4..7f6b7d9 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -887,7 +887,7 @@ void gfs_jindex_in(struct gfs_jindex *jindex, char *buf) /* ------------------------------------------------------------------------ */ void gfs_jindex_print(struct gfs_jindex *ji) { - pv(ji, ji_addr, "%llu", "0x%llx"); + pv((unsigned long long)ji, ji_addr, "%llu", "0x%llx"); pv(ji, ji_nsegment, "%u", "0x%x"); pv(ji, ji_pad, "%u", "0x%x"); } @@ -1265,10 +1265,20 @@ int display_indirect(struct iinfo *ind, int indblocks, int level, uint64_t start // FIXME: handle failed malloc tmpbuf = malloc(sbd.bsize); if (tmpbuf) { - do_lseek(sbd.device_fd, - ind->ii[pndx].block * sbd.bsize); - do_read(sbd.device_fd, tmpbuf, - sbd.bsize); /* read in the desired block */ + lseek(sbd.device_fd, + ind->ii[pndx].block * sbd.bsize, + SEEK_SET); + /* read in the desired block */ + if (read(sbd.device_fd, tmpbuf, sbd.bsize) != + sbd.bsize) { + fprintf(stderr, "bad read: %s from %s:" + "%d: block %lld (0x%llx)\n", + strerror(errno), + __FUNCTION__, __LINE__, + (unsigned long long)ind->ii[pndx].block, + (unsigned long long)ind->ii[pndx].block); + exit(-1); + } memset(more_indir, 0, sizeof(struct iinfo)); if (S_ISDIR(di.di_mode)) { do_leaf_extended(tmpbuf, more_indir); @@ -1444,8 +1454,12 @@ void read_superblock(int fd) { sbd1 = (struct gfs_sb *)&sbd.sd_sb; ioctl(fd, BLKFLSBUF, 0); - do_lseek(fd, 0x10 * 4096); - do_read(fd, buf, sbd.bsize); /* read in the desired block */ + lseek(fd, 0x10 * 4096, SEEK_SET); + if (read(fd, buf, sbd.bsize) != sbd.bsize) { + fprintf(stderr, "bad read: %s from %s:%d: superblock\n", + strerror(errno), __FUNCTION__, __LINE__); + exit(-1); + } memset(&sbd, 0, sizeof(struct gfs2_sbd)); sbd.device_fd = fd; sbd.bsize = GFS2_DEFAULT_BSIZE; @@ -1486,8 +1500,17 @@ void read_superblock(int fd) void read_master_dir(void) { ioctl(sbd.device_fd, BLKFLSBUF, 0); - do_lseek(sbd.device_fd, sbd.sd_sb.sb_master_dir.no_addr * sbd.bsize); - do_read(sbd.device_fd, buf, sbd.bsize); /* read in the desired block */ + lseek(sbd.device_fd, sbd.sd_sb.sb_master_dir.no_addr * sbd.bsize, + SEEK_SET); + if (read(sbd.device_fd, buf, sbd.bsize) != sbd.bsize) { + fprintf(stderr, "read error: %s from %s:%d: " + "master dir block %lld (0x%llx)\n", + strerror(errno), __FUNCTION__, + __LINE__, + (unsigned long long)sbd.sd_sb.sb_master_dir.no_addr, + (unsigned long long)sbd.sd_sb.sb_master_dir.no_addr); + exit(-1); + } gfs2_dinode_in(&di, buf); /* parse disk inode into structure */ do_dinode_extended(&di, buf); /* get extended data, if any */ memcpy(&masterdir, &indirect[0], sizeof(struct indirect_info)); @@ -1514,8 +1537,16 @@ int display(int identify_only) if (block_in_mem != blk) { /* If we changed blocks from the last read */ dev_offset = blk * sbd.bsize; ioctl(sbd.device_fd, BLKFLSBUF, 0); - do_lseek(sbd.device_fd, dev_offset); - do_read(sbd.device_fd, buf, sbd.bsize); /* read desired block */ + lseek(sbd.device_fd, dev_offset, SEEK_SET); + if (read(sbd.device_fd, buf, sbd.bsize) != sbd.bsize) { + fprintf(stderr, "read error: %s from %s:%d: " + "offset %lld (0x%llx)\n", + strerror(errno), __FUNCTION__, + __LINE__, + (unsigned long long)dev_offset, + (unsigned long long)dev_offset); + exit(-1); + } block_in_mem = blk; /* remember which block is in memory */ } line = 1; @@ -1850,8 +1881,17 @@ void hex_edit(int *exitch) ch += (estring[i+1] - 'A' + 0x0a); buf[offset + hexoffset] = ch; } - do_lseek(sbd.device_fd, dev_offset); - do_write(sbd.device_fd, buf, sbd.bsize); + lseek(sbd.device_fd, dev_offset, SEEK_SET); + if (write(sbd.device_fd, buf, sbd.bsize) != + sbd.bsize) { + fprintf(stderr, "write error: %s from %s:%d: " + "offset %lld (0x%llx)\n", + strerror(errno), + __FUNCTION__, __LINE__, + (unsigned long long)dev_offset, + (unsigned long long)dev_offset); + exit(-1); + } fsync(sbd.device_fd); } } @@ -2232,10 +2272,10 @@ void gfs_log_header_print(struct gfs_log_header *lh) gfs2_meta_header_print(&lh->lh_header); pv(lh, lh_flags, "%u", "0x%.8X"); pv(lh, lh_pad, "%u", "%x"); - pv(lh, lh_first, "%llu", "%llx"); - pv(lh, lh_sequence, "%llu", "%llx"); - pv(lh, lh_tail, "%llu", "%llx"); - pv(lh, lh_last_dump, "%llu", "%llx"); + pv((unsigned long long)lh, lh_first, "%llu", "%llx"); + pv((unsigned long long)lh, lh_sequence, "%llu", "%llx"); + pv((unsigned long long)lh, lh_tail, "%llu", "%llx"); + pv((unsigned long long)lh, lh_last_dump, "%llu", "%llx"); } /* ------------------------------------------------------------------------ */ @@ -2295,8 +2335,8 @@ int fsck_readi(struct gfs2_inode *ip, void *buf, uint64_t offset, if (!size) return 0; if (isdir) { - lblock = offset; - o = do_div(lblock, sdp->sd_jbsize); + o = offset % sdp->sd_jbsize; + lblock = offset / sdp->sd_jbsize; } else { lblock = offset >> sdp->sd_sb.sb_bsize_shift; o = offset & (sdp->bsize - 1); diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 4932a9e..2e4eda8 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -188,8 +188,21 @@ int save_block(int fd, int out_fd, uint64_t blk) return 0; } memset(savedata, 0, sizeof(struct saved_metablock)); - do_lseek(fd, blk * sbd.bsize); - do_read(fd, savedata->buf, sbd.bsize); /* read in the block */ + if (lseek(fd, blk * sbd.bsize, SEEK_SET) != blk * sbd.bsize) { + fprintf(stderr, "bad seek: %s from %s:%d: " + "block %lld (0x%llx)\n", strerror(errno), + __FUNCTION__, __LINE__, + (unsigned long long)blk, (unsigned long long)blk); + exit(-1); + } + /* read in the block */ + if (read(fd, savedata->buf, sbd.bsize) != sbd.bsize) { + fprintf(stderr, "bad read: %s from %s:%d: " + "block %lld (0x%llx)\n", strerror(errno), + __FUNCTION__, __LINE__, + (unsigned long long)blk, (unsigned long long)blk); + exit(-1); + } /* If this isn't metadata and isn't a system file, we don't want it. Note that we're checking "block" here rather than blk. That's @@ -206,11 +219,34 @@ int save_block(int fd, int out_fd, uint64_t blk) p--; } savedata->blk = cpu_to_be64(blk); - do_write(out_fd, &savedata->blk, sizeof(savedata->blk)); + if (write(out_fd, &savedata->blk, sizeof(savedata->blk)) != + sizeof(savedata->blk)) { + fprintf(stderr, "write error: %s from %s:%d: " + "block %lld (0x%llx)\n", strerror(errno), + __FUNCTION__, __LINE__, + (unsigned long long)savedata->blk, + (unsigned long long)savedata->blk); + exit(-1); + } outsz = blklen - trailing0; savedata->siglen = cpu_to_be16(outsz); - do_write(out_fd, &savedata->siglen, sizeof(savedata->siglen)); - do_write(out_fd, savedata->buf, outsz); + if (write(out_fd, &savedata->siglen, sizeof(savedata->siglen)) != + sizeof(savedata->siglen)) { + fprintf(stderr, "write error: %s from %s:%d: " + "block %lld (0x%llx)\n", strerror(errno), + __FUNCTION__, __LINE__, + (unsigned long long)savedata->blk, + (unsigned long long)savedata->blk); + exit(-1); + } + if (write(out_fd, savedata->buf, outsz) != outsz) { + fprintf(stderr, "write error: %s from %s:%d: " + "block %lld (0x%llx)\n", strerror(errno), + __FUNCTION__, __LINE__, + (unsigned long long)savedata->blk, + (unsigned long long)savedata->blk); + exit(-1); + } total_out += sizeof(savedata->blk) + sizeof(savedata->siglen) + outsz; blks_saved++; return blktype; @@ -434,7 +470,7 @@ void savemeta(char *out_fn, int saveoption) if (!savedata) die("Can't allocate memory for the operation.\n"); - do_lseek(sbd.device_fd, 0); + lseek(sbd.device_fd, 0, SEEK_SET); blks_saved = total_out = last_reported_block = 0; if (!gfs1) sbd.bsize = BUFSIZE; @@ -543,8 +579,10 @@ void savemeta(char *out_fn, int saveoption) slow = gfs2_rgrp_read(&sbd, rgd); if (slow) continue; - log_debug("RG at %"PRIu64" is %u long\n", - rgd->ri.ri_addr, rgd->ri.ri_length); + log_debug("RG at %lld (0x%llx) is %u long\n", + (unsigned long long)rgd->ri.ri_addr, + (unsigned long long)rgd->ri.ri_addr, + rgd->ri.ri_length); for (i = 0; i < rgd->ri.ri_length; i++) { if(gfs2_block_set(&sbd, blocklist, rgd->ri.ri_addr + i, @@ -604,8 +642,8 @@ int restore_data(int fd, int in_fd, int printblocksonly) 0x00, 0x00, 0x00, 0x01}; if (!printblocksonly) - do_lseek(fd, 0); - do_lseek(in_fd, 0); + lseek(fd, 0, SEEK_SET); + lseek(in_fd, 0, SEEK_SET); rs = read(in_fd, buf, sizeof(buf)); if (rs != sizeof(buf)) { fprintf(stderr, "Error: File is too small.\n"); @@ -620,7 +658,13 @@ int restore_data(int fd, int in_fd, int printblocksonly) } if (pos == sizeof(buf) - sizeof(uint64_t) - sizeof(uint16_t)) pos = 0; - do_lseek(in_fd, pos); + if (lseek(in_fd, pos, SEEK_SET) != pos) { + fprintf(stderr, "bad seek: %s from %s:%d: " + "offset %lld (0x%llx)\n", strerror(errno), + __FUNCTION__, __LINE__, (unsigned long long)pos, + (unsigned long long)pos); + exit(-1); + } blks_saved = total_out = 0; last_fs_block = 0; while (TRUE) { @@ -648,7 +692,16 @@ int restore_data(int fd, int in_fd, int printblocksonly) savedata->siglen = be16_to_cpu(buf16); if (savedata->siglen > 0 && savedata->siglen <= sizeof(savedata->buf)) { - do_read(in_fd, savedata->buf, savedata->siglen); + if (read(in_fd, savedata->buf, savedata->siglen) != + savedata->siglen) { + fprintf(stderr, "read error: %s from %s:%d: " + "block %lld (0x%llx)\n", + strerror(errno), __FUNCTION__, + __LINE__, + (unsigned long long)savedata->blk, + (unsigned long long)savedata->blk); + exit(-1); + } if (first) { gfs2_sb_in(&sbd.sd_sb, savedata->buf); sbd1 = (struct gfs_sb *)&sbd.sd_sb; @@ -688,8 +741,28 @@ int restore_data(int fd, int in_fd, int printblocksonly) "device; quitting.\n"); break; } - do_lseek(fd, savedata->blk * sbd.bsize); - do_write(fd, savedata->buf, sbd.bsize); + if (lseek(fd, savedata->blk * sbd.bsize, + SEEK_SET) != + savedata->blk * sbd.bsize) { + fprintf(stderr, "bad seek: %s from %s:" + "%d: block %lld (0x%llx)\n", + strerror(errno), __FUNCTION__, + __LINE__, (unsigned long long) + savedata->blk, + (unsigned long long) + savedata->blk); + exit(-1); + } + if (write(fd, savedata->buf, sbd.bsize) != + sbd.bsize) { + fprintf(stderr, "write error: %s from " + "%s:%d: block %lld (0x%llx)\n", + strerror(errno), + __FUNCTION__, __LINE__, + (unsigned long long)savedata->blk, + (unsigned long long)savedata->blk); + exit(-1); + } writes++; } blks_saved++; diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index e3d3f6c..67806f9 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -84,8 +84,8 @@ static void empty_super_block(struct gfs2_sbd *sdp) struct rgrp_list *rgd; rgd = osi_list_entry(sdp->rglist.next, struct rgrp_list, list); - log_debug("Deleting rgd for 0x%p: rgd=0x%p bits=0x%p\n", - rgd->ri.ri_addr, rgd, rgd->bits); + log_debug("Deleting rgd for 0x%llx: rgd=0x%p bits=0x%p\n", + (unsigned long long)rgd->ri.ri_addr, rgd, rgd->bits); osi_list_del(&rgd->list); if(rgd->bits) free(rgd->bits); @@ -146,8 +146,9 @@ static int set_block_ranges(struct gfs2_sbd *sdp) last_fs_block = rmax; if (last_fs_block > 0xffffffff && sizeof(unsigned long) <= 4) { log_crit("This file system is too big for this computer to handle.\n"); - log_crit("Last fs block = 0x%llx, but sizeof(unsigned long) is %d bytes.\n", - last_fs_block, sizeof(unsigned long)); + log_crit("Last fs block = 0x%llx, but sizeof(unsigned long) is %lu bytes.\n", + (unsigned long long)last_fs_block, + sizeof(unsigned long)); goto fail; } diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c index 72c5bbe..4310770 100644 --- a/gfs2/fsck/lost_n_found.c +++ b/gfs2/fsck/lost_n_found.c @@ -59,8 +59,8 @@ int add_inode_to_lf(struct gfs2_inode *ip){ } switch(ip->i_di.di_mode & S_IFMT){ case S_IFDIR: - log_info("Adding .. entry pointing to lost+found for %"PRIu64"\n", - ip->i_di.di_num.no_addr); + log_info("Adding .. entry pointing to lost+found for %llu\n", + (unsigned long long)ip->i_di.di_num.no_addr); sprintf(tmp_name, ".."); filename_len = strlen(tmp_name); /* no trailing NULL */ if(!(filename = malloc((sizeof(char) * filename_len) + 1))) { @@ -140,7 +140,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){ increment_link(ip->i_sbd, lf_dip->i_di.di_num.no_addr); free(filename); - log_notice("Added inode #%"PRIu64" to lost+found dir\n", - ip->i_di.di_num.no_addr); + log_notice("Added inode #%llu to lost+found dir\n", + (unsigned long long)ip->i_di.di_num.no_addr); return 0; } diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index 17c9772..203dfa7 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -129,7 +129,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, - void builder(struct gfs2_sbd *sbp), + int builder(struct gfs2_sbd *sbp), enum gfs2_mark_block mark) { uint64_t iblock = 0; diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index 278c8dd..a1b9184 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -172,12 +172,14 @@ int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh, if (de.de_rec_len < sizeof(struct gfs2_dirent) + de.de_name_len || !de.de_name_len) { - log_err("Directory block %" PRIu64 "(0x%" - PRIx64 "), entry %d of directory %" - PRIu64 "(0x%" PRIx64 ") is corrupt.\n", - bh->b_blocknr, bh->b_blocknr, (*count) + 1, - ip->i_di.di_num.no_addr, - ip->i_di.di_num.no_addr); + log_err("Directory block %llu (0x%llx" + "), entry %d of directory %llu" + "(0x%llx) is corrupt.\n", + (unsigned long long)bh->b_blocknr, + (unsigned long long)bh->b_blocknr, + (*count) + 1, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); if (query(&opts, "Attempt to repair it? (y/n) ")) { if (dirent_repair(ip, bh, &de, dent, type, first)) @@ -198,10 +200,13 @@ int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh, first = 0; } else { /* FIXME: Do something about this */ - log_err("Directory entry with inode number of zero in leaf %" - PRIu64 "(0x%" PRIx64 ") of directory %" PRIu64 - " (0x%" PRIx64 ")!\n", bh->b_blocknr, bh->b_blocknr, - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); + log_err("Directory entry with inode number of " + "zero in leaf %llu (0x%llx) of " + "directory %llu (0x%llx)!\n", + (unsigned long long)bh->b_blocknr, + (unsigned long long)bh->b_blocknr, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); return 1; } } else { @@ -255,10 +260,12 @@ void warn_and_patch(struct gfs2_inode *ip, uint64_t *leaf_no, const char *msg) { if (*bad_leaf != *leaf_no) { - log_err("Directory Inode %" PRIu64 "(0x%" - PRIx64 ") points to leaf %" PRIu64 "(0x%" - PRIx64 ") %s.\n", ip->i_di.di_num.no_addr, - ip->i_di.di_num.no_addr, *leaf_no, *leaf_no, msg); + log_err("Directory Inode %llu (0x%llx) points to leaf %llu" + " (0x%llx) %s.\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)*leaf_no, + (unsigned long long)*leaf_no, msg); } if (*leaf_no == *bad_leaf || query(&opts, "Attempt to patch around it? (y/n) ")) { @@ -302,15 +309,16 @@ int check_leaf(struct gfs2_inode *ip, enum update_flags *update, continue; } else { if(ref_count != exp_count){ - log_err("Dir #%" PRIu64 " (0x%" - PRIx64 ") has an incorrect " - "number of pointers to leaf #%" - PRIu64 " (0x%" PRIx64 - ")\n\tFound: %u, Expected: %u\n", + log_err("Dir #%llu (0x%llx) has an incorrect " + "number of pointers to leaf #%llu " + " (0x%llx)\n\tFound: %u, Expected: " + "%u\n", (unsigned long long) ip->i_di.di_num.no_addr, + (unsigned long long) ip->i_di.di_num.no_addr, - old_leaf, old_leaf, ref_count, - exp_count); + (unsigned long long)old_leaf, + (unsigned long long)old_leaf, + ref_count, exp_count); if (query(&opts, "Attempt to fix it? (y/n) ")) { int factor = 0, divisor = ref_count; @@ -335,11 +343,13 @@ int check_leaf(struct gfs2_inode *ip, enum update_flags *update, do { /* Make sure the block number is in range. */ if(gfs2_check_range(ip->i_sbd, leaf_no)){ - log_err("Leaf block #%" PRIu64 " (0x%" - PRIx64 ") is out of range for " - "directory #%" PRIu64 " (0x%" - PRIx64 ").\n", leaf_no, leaf_no, + log_err("Leaf block #%llu (0x%llx) is out " + "of range for directory #%llu (0x%llx" + ").\n", (unsigned long long)leaf_no, + (unsigned long long)leaf_no, + (unsigned long long) ip->i_di.di_num.no_addr, + (unsigned long long) ip->i_di.di_num.no_addr); warn_and_patch(ip, &leaf_no, &bad_leaf, old_leaf, index, @@ -383,10 +393,15 @@ int check_leaf(struct gfs2_inode *ip, enum update_flags *update, /* Make sure it's really a leaf. */ if (leaf.lf_header.mh_type != GFS2_METATYPE_LF) { - log_err("Inode %" PRIu64 " (0x%" - PRIx64 ") points to bad leaf " - PRIu64 " (0x%" PRIx64 ").\n", - ip->i_di.di_num.no_addr, leaf_no); + log_err("Inode %llu (0x%llx" + ") points to bad leaf %llu" + " (0x%llx).\n", + (unsigned long long) + ip->i_di.di_num.no_addr, + (unsigned long long) + ip->i_di.di_num.no_addr, + (unsigned long long)leaf_no, + (unsigned long long)leaf_no); brelse(lbh, *update); break; } @@ -420,11 +435,18 @@ int check_leaf(struct gfs2_inode *ip, enum update_flags *update, lbh = bread(&sbp->buf_list, leaf_no); gfs2_leaf_in(&leaf, lbh->b_data); - log_err("Leaf %"PRIu64" (0x%" PRIx64 - ") entry count in directory %" PRIu64 - " doesn't match number of entries found - is %u, found %u\n", - leaf_no, leaf_no, ip->i_di.di_num.no_addr, - leaf.lf_entries, count); + log_err("Leaf %llu (0x%llx) entry " + "count in directory %llu" + " (0x%llx) doesn't match " + "number of entries found " + "- is %u, found %u\n", + (unsigned long long)leaf_no, + (unsigned long long)leaf_no, + (unsigned long long) + ip->i_di.di_num.no_addr, + (unsigned long long) + ip->i_di.di_num.no_addr, + leaf.lf_entries, count); if(query(&opts, "Update leaf entry count? (y/n) ")) { leaf.lf_entries = count; gfs2_leaf_out(&leaf, lbh->b_data); @@ -650,8 +672,9 @@ int check_inode_eattr(struct gfs2_inode *ip, enum update_flags *want_updated, return 0; } - log_debug("Extended attributes exist for inode #%" PRIu64 " (0x%" PRIx64 - ").\n", ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); + log_debug("Extended attributes exist for inode #%llu (0x%llx).\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); if(ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT){ if((error = check_indirect_eattr(ip, ip->i_di.di_eattr, @@ -782,8 +805,9 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass) /* We don't need to record directory blocks - they will be * recorded later...i think... */ if (S_ISDIR(ip->i_di.di_mode)) - log_debug("Directory with height > 0 at %"PRIu64"\n", - ip->i_di.di_num.no_addr); + log_debug("Directory with height > 0 at %llu (0x%llx)\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); /* check data blocks */ list = &metalist[height - 1]; diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c index 9d6d90d..e199fb4 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -174,8 +174,9 @@ static int clear_eas(struct gfs2_inode *ip, struct block_count *bc, struct gfs2_sbd *sdp = ip->i_sbd; *want_updated = not_updated; - log_err("Inode #%" PRIu64 " (0x%" PRIx64 "): %s", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, emsg); + log_err("Inode #%llu (0x%llx): %s", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, emsg); if (block) log_err(" at block #%" PRIu64 " (0x%" PRIx64 ")", block, block); @@ -246,11 +247,12 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect, return 1; } if(q.block_type != gfs2_block_free) { /* Duplicate? */ - log_err("Inode #%" PRIu64 " (0x%" PRIx64 - "): Duplicate EA indirect block found at #%" PRIu64 - " (0x%" PRIx64 ").\n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, - indirect, indirect); + log_err("Inode #%llu (0x%llx): Duplicate EA indirect " + "block found at #%llu (0x%llx).\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)indirect, + (unsigned long long)indirect); gfs2_block_set(sdp, bl, indirect, gfs2_dup_block); bc->ea_count++; ret = 1; @@ -267,9 +269,9 @@ static int finish_eattr_indir(struct gfs2_inode *ip, int indir_ok, enum update_flags *want_updated, void *private) { if (indir_ok) { - log_debug("Marking inode #%" PRIu64 " (0x%" - PRIx64 ") with eattr block\n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); + log_debug("Marking inode #%llu (0x%llx) with eattr block\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); /* Mark the inode as having an eattr in the block map so pass1c can check it. */ gfs2_block_mark(ip->i_sbd, bl, ip->i_di.di_num.no_addr, @@ -307,11 +309,12 @@ static int check_extended_leaf_eattr(struct gfs2_inode *ip, uint64_t *data_ptr, int ret = 0; if(gfs2_check_range(sdp, el_blk)){ - log_err("Inode #%" PRIu64 " (0x%" PRIx64 "): EA extended " - "leaf block #%" PRIu64 " (0x%" PRIx64 - ") is out of range.\n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, - el_blk, el_blk); + log_err("Inode #%llu (0x%llx): EA extended " + "leaf block #%llu (0x%llx) is out of range.\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)el_blk, + (unsigned long long)el_blk); gfs2_block_set(sdp, bl, ip->i_di.di_eattr, gfs2_bad_block); return 1; } @@ -373,10 +376,11 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block, gfs2_block_set(sdp, bl, parent, gfs2_eattr_block); } if(gfs2_check_range(sdp, block)){ - log_warn("Inode #%" PRIu64 " (0x%" PRIx64 "): EA leaf block " - "#%" PRIu64 " (0x%" PRIx64 ") is out of range.\n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, - block, block); + log_warn("Inode #%llu (0x%llx): EA leaf block #%llu (0x%llx" + ") is out of range.\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)block, (unsigned long long)block); gfs2_block_set(sdp, bl, ip->i_di.di_eattr, gfs2_bad_block); ret = 1; } @@ -570,10 +574,11 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh, ip = fsck_inode_get(sdp, bh); if (ip->i_di.di_num.no_addr != block) { - log_err("Inode #%" PRIu64 " (0x%" PRIx64 - "): Bad inode address found: %" PRIu64 " (0x%" PRIx64 ")\n", - block, block, ip->i_di.di_num.no_addr, - ip->i_di.di_num.no_addr); + log_err("Inode #%llu (0x%llx): Bad inode address found: %llu " + "(0x%llx)\n", (unsigned long long)block, + (unsigned long long)block, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); if(query(&opts, "Fix address in inode at block #%" PRIu64 " (0x%" PRIx64 ")? (y/n) ", block, block)) { ip->i_di.di_num.no_addr = ip->i_di.di_num.no_formal_ino = block; @@ -692,10 +697,12 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh, /* FIXME: fix height and depth here - wasn't implemented in * old fsck either, so no biggy... */ if (ip->i_di.di_height < compute_height(sdp, ip->i_di.di_size)){ - log_warn("Dinode #%" PRIu64 " (0x%" PRIx64 ") has bad height " - "Found %u, Expected >= %u\n", ip->i_di.di_num.no_addr, - ip->i_di.di_num.no_addr, ip->i_di.di_height, - compute_height(sdp, ip->i_di.di_size)); + log_warn("Dinode #%llu (0x%llx) has bad height " + "Found %u, Expected >= %u\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + ip->i_di.di_height, + compute_height(sdp, ip->i_di.di_size)); /* once implemented, remove continue statement */ log_warn("Marking inode invalid\n"); if(gfs2_block_set(sdp, bl, block, gfs2_meta_inval)) { @@ -711,11 +718,12 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh, if (S_ISDIR(ip->i_di.di_mode) && (ip->i_di.di_flags & GFS2_DIF_EXHASH)) { if (((1 << ip->i_di.di_depth) * sizeof(uint64_t)) != ip->i_di.di_size){ - log_warn("Directory dinode #%" PRIu64 " (0x%" PRIx64 - ") has bad depth. Found %u, Expected %u\n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, - ip->i_di.di_depth, - (1 >> (ip->i_di.di_size/sizeof(uint64_t)))); + log_warn("Directory dinode #%llu (0x%llx" + ") has bad depth. Found %u, Expected %u\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + ip->i_di.di_depth, + (1 >> (ip->i_di.di_size/sizeof(uint64_t)))); /* once implemented, remove continue statement */ log_warn("Marking inode invalid\n"); if(gfs2_block_set(sdp, bl, block, gfs2_meta_inval)) { @@ -737,8 +745,9 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh, return 0; } if(error > 0) { - log_warn("Marking inode #%" PRIu64 " (0x%" PRIx64 ") invalid\n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); + log_warn("Marking inode #%llu (0x%llx) invalid\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); /* FIXME: Must set all leaves invalid as well */ check_metatree(ip, &invalidate_metatree); gfs2_block_set(sdp, bl, ip->i_di.di_num.no_addr, @@ -752,20 +761,23 @@ int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh, if (ip->i_di.di_blocks != (1 + bc.indir_count + bc.data_count + bc.ea_count)) { - log_err("Inode #%" PRIu64 " (0x%" PRIx64 "): Ondisk block count (%" - PRIu64 ") does not match what fsck found (%" PRIu64 ")\n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, - ip->i_di.di_blocks, - 1 + bc.indir_count + bc.data_count + bc.ea_count); + log_err("Inode #%llu (0x%llx): Ondisk block count (%llu" + ") does not match what fsck found (%llu)\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_blocks, + (unsigned long long)1 + bc.indir_count + + bc.data_count + bc.ea_count); if(query(&opts, "Fix ondisk block count? (y/n) ")) { ip->i_di.di_blocks = 1 + bc.indir_count + bc.data_count + bc.ea_count; gfs2_dinode_out(&ip->i_di, ip->i_bh->b_data); f = updated; } else - log_err("Bad block count for #%" PRIu64 " (0x%" PRIx64 - ") not fixed\n", ip->i_di.di_num.no_addr, - ip->i_di.di_num.no_addr); + log_err("Bad block count for #%llu (0x%llx" + ") not fixed\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); } fsck_inode_put(ip, f); @@ -857,8 +869,10 @@ int pass1(struct gfs2_sbd *sbp) stack; return -1; } - log_debug("RG at %" PRIu64 " (0x%" PRIx64 ") is %u long\n", - rgd->ri.ri_addr, rgd->ri.ri_addr, rgd->ri.ri_length); + log_debug("RG at %llu (0x%llx) is %u long\n", + (unsigned long long)rgd->ri.ri_addr, + (unsigned long long)rgd->ri.ri_addr, + rgd->ri.ri_length); for (i = 0; i < rgd->ri.ri_length; i++) { if(gfs2_block_set(sbp, bl, rgd->ri.ri_addr + i, gfs2_meta_other)){ diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c index 1b0dde0..dcb8dbe 100644 --- a/gfs2/fsck/pass1b.c +++ b/gfs2/fsck/pass1b.c @@ -138,11 +138,16 @@ static int find_dentry(struct gfs2_inode *ip, struct gfs2_dirent *de, if(id->block_no == de->de_inum.no_addr) { id->name = strdup(filename); id->parent = ip->i_di.di_num.no_addr; - log_debug("Duplicate block %" PRIu64 " (0x%" PRIx64 - ") is in file or directory %" PRIu64 - " (0x%" PRIx64 ") named %s\n", id->block_no, - id->block_no, ip->i_di.di_num.no_addr, - ip->i_di.di_num.no_addr, filename); + log_debug("Duplicate block %llu (0x%llx" + ") is in file or directory %llu" + " (0x%llx) named %s\n", + (unsigned long long)id->block_no, + (unsigned long long)id->block_no, + (unsigned long long) + ip->i_di.di_num.no_addr, + (unsigned long long) + ip->i_di.di_num.no_addr, + filename); /* If there are duplicates of * duplicates, I guess we'll miss them * here */ @@ -165,10 +170,11 @@ static int clear_dup_metalist(struct gfs2_inode *ip, uint64_t block, if(dh->ref_count == 1) return 1; if(block == dh->b->block_no) { - log_err("Found dup in inode \"%s\" (block #%"PRIu64 - ") with block #%"PRIu64"\n", - dh->id->name ? dh->id->name : "unknown name", - ip->i_di.di_num.no_addr, block); + log_err("Found dup in inode \"%s\" (block #%llu" + ") with block #%llu\n", + dh->id->name ? dh->id->name : "unknown name", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)block); log_err("Inode %s is in directory %"PRIu64" (0x%" PRIx64 ")\n", dh->id->name ? dh->id->name : "", dh->id->parent, dh->id->parent); @@ -189,11 +195,13 @@ static int clear_dup_data(struct gfs2_inode *ip, uint64_t block, void *private) return 1; } if(block == dh->b->block_no) { - log_err("Found dup in inode \"%s\" for block #%" PRIu64 - " (0x%" PRIx64 ") at block #%" PRIu64 " (0x%" PRIx64 ")\n", - dh->id->name ? dh->id->name : "unknown name", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, block, - block); + log_err("Found dup in inode \"%s\" for block #%llu" + " (0x%llx) at block #%llu (0x%llx)\n", + dh->id->name ? dh->id->name : "unknown name", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)block, + (unsigned long long)block); log_err("Inode %s is in directory %"PRIu64" (0x%" PRIx64 ")\n", dh->id->name ? dh->id->name : "", dh->id->parent, dh->id->parent); @@ -219,11 +227,13 @@ static int clear_dup_eattr_indir(struct gfs2_inode *ip, uint64_t block, if(dh->ref_count == 1) return 1; if(block == dh->b->block_no) { - log_err("Found dup in inode \"%s\" with address #%" PRIu64 - " (0x%" PRIx64 ") with block #%" PRIu64 " (0x%" PRIx64 ")\n", - dh->id->name ? dh->id->name : "unknown name", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, block, - block); + log_err("Found dup in inode \"%s\" with address #%llu" + " (0x%llx) with block #%llu (0x%llx)\n", + dh->id->name ? dh->id->name : "unknown name", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)block, + (unsigned long long)block); log_err("Inode %s is in directory %" PRIu64 " (0x%" PRIx64 ")\n", dh->id->name ? dh->id->name : "", dh->id->parent, dh->id->parent); @@ -244,11 +254,13 @@ static int clear_dup_eattr_leaf(struct gfs2_inode *ip, uint64_t block, if(dh->ref_count == 1) return 1; if(block == dh->b->block_no) { - log_err("Found dup in inode \"%s\" with address #%" PRIu64 - " (0x%" PRIx64 ") with block #%" PRIu64 " (0x%" PRIx64 ")\n", - dh->id->name ? dh->id->name : "unknown name", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, block, - block); + log_err("Found dup in inode \"%s\" with address #%llu" + " (0x%llx) with block #%llu (0x%llx)\n", + dh->id->name ? dh->id->name : "unknown name", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)block, + (unsigned long long)block); log_err("Inode %s is in directory %" PRIu64 " (0x%" PRIx64 ")\n", dh->id->name ? dh->id->name : "", dh->id->parent, dh->id->parent); @@ -316,11 +328,12 @@ static int clear_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_data_ptr, if(dh->ref_count == 1) return 1; if(block == dh->b->block_no) { - log_err("Found dup in inode \"%s\" with address #%" PRIu64 - " (0x%" PRIx64 ") with block #%" PRIu64 " (0x%" PRIx64 ")\n", - dh->id->name ? dh->id->name : "unknown name", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, block, - block); + log_err("Found dup in inode \"%s\" with address #%llu" + " (0x%llx) with block #%llu (0x%llx)\n", + dh->id->name ? dh->id->name : "unknown name", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)block, (unsigned long long)block); log_err("Inode %s is in directory %" PRIu64 " (0x%" PRIx64 ")\n", dh->id->name ? dh->id->name : "", dh->id->parent, dh->id->parent); @@ -413,10 +426,11 @@ int handle_dup_blk(struct gfs2_sbd *sbp, struct blocks *b) dh.ref_inode_count++; dh.ref_count += id->dup_count; } - log_notice("Block %" PRIu64 " (0x%" PRIx64 ") has %d inodes referencing it" - " for a total of %d duplicate references\n", - b->block_no, b->block_no, dh.ref_inode_count, - dh.ref_inode_count, dh.ref_count); + log_notice("Block %llu (0x%llx) has %d inodes referencing it" + " for a total of %d duplicate references\n", + (unsigned long long)b->block_no, + (unsigned long long)b->block_no, + dh.ref_inode_count, dh.ref_count); osi_list_foreach(tmp, &b->ref_inode_list) { id = osi_list_entry(tmp, struct inode_with_dups, list); diff --git a/gfs2/fsck/pass1c.c b/gfs2/fsck/pass1c.c index aaeac15..62f4d7d 100644 --- a/gfs2/fsck/pass1c.c +++ b/gfs2/fsck/pass1c.c @@ -37,11 +37,13 @@ int check_eattr_indir(struct gfs2_inode *ip, uint64_t block, *update = not_updated; if(gfs2_check_range(sbp, block)) { - log_err("Extended attributes indirect block #%"PRIu64 - " (0x%" PRIx64 ") for inode #%" PRIu64 - " (0x%" PRIx64 ") out of range...removing\n", - block, block, ip->i_di.di_num.no_addr, - ip->i_di.di_num.no_addr); + log_err("Extended attributes indirect block #%llu" + " (0x%llx) for inode #%llu" + " (0x%llx) out of range...removing\n", + (unsigned long long)block, + (unsigned long long)block, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); ip->i_di.di_eattr = 0; *update = (opts.no ? not_updated : updated); return 1; @@ -51,11 +53,13 @@ int check_eattr_indir(struct gfs2_inode *ip, uint64_t block, return -1; } else if(q.block_type != gfs2_indir_blk) { - log_err("Extended attributes indirect block #%"PRIu64 - " (0x%" PRIx64 ") for inode #%" PRIu64 - " (0x%" PRIx64 ") invalid...removing\n", - block, block, ip->i_di.di_num.no_addr, - ip->i_di.di_num.no_addr); + log_err("Extended attributes indirect block #%llu" + " (0x%llx) for inode #%llu" + " (0x%llx) invalid...removing\n", + (unsigned long long)block, + (unsigned long long)block, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); ip->i_di.di_eattr = 0; *update = (opts.no ? not_updated : updated); return 1; @@ -76,9 +80,10 @@ int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block, *update = not_updated; if(gfs2_check_range(sbp, block)) { - log_err("Extended attributes block for inode #%" PRIu64 - " (0x%" PRIx64 ") out of range...removing\n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); + log_err("Extended attributes block for inode #%llu" + " (0x%llx) out of range...removing\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); ip->i_di.di_eattr = 0; *update = (opts.no ? not_updated : updated); return 1; @@ -88,9 +93,10 @@ int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block, return -1; } else if(q.block_type != gfs2_meta_eattr) { - log_err("Extended attributes block for inode #%"PRIu64 - " (0x%" PRIx64 ") invalid...removing\n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); + log_err("Extended attributes block for inode #%llu" + " (0x%llx) invalid...removing\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); ip->i_di.di_eattr = 0; *update = (opts.no ? not_updated : updated); return 1; @@ -249,8 +255,9 @@ int pass1c(struct gfs2_sbd *sbp) gfs2_block_clear(sbp, bl, block_no, gfs2_eattr_block); ip = fsck_inode_get(sbp, bh); - log_debug("Found eattr at %"PRIu64" (0x%" PRIx64 ")\n", - ip->i_di.di_eattr, ip->i_di.di_eattr); + log_debug("Found eattr at %llu (0x%llx)\n", + (unsigned long long)ip->i_di.di_eattr, + (unsigned long long)ip->i_di.di_eattr); /* FIXME: Handle walking the eattr here */ error = check_inode_eattr(ip, &want_updated, &pass1c_fxns); diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c index 3d29f88..791c07d 100644 --- a/gfs2/fsck/pass2.c +++ b/gfs2/fsck/pass2.c @@ -268,11 +268,13 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent, q.block_type != gfs2_inode_lnk && q.block_type != gfs2_inode_blk && q.block_type != gfs2_inode_chr && q.block_type != gfs2_inode_fifo && q.block_type != gfs2_inode_sock) { - log_err("Directory entry '%s' at block %" PRIu64 " (0x%" PRIx64 - ") in dir inode %" PRIu64 " (0x%" PRIx64 + log_err("Directory entry '%s' at block %llu (0x%llx" + ") in dir inode %llu (0x%llx" ") has an invalid block type: %d.\n", tmp_name, - de->de_inum.no_addr, de->de_inum.no_addr, - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, + (unsigned long long)de->de_inum.no_addr, + (unsigned long long)de->de_inum.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, q.block_type); if(query(&opts, "Clear directory entry to non-inode block? (y/n) ")) { @@ -297,11 +299,12 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent, return -1; } if(error > 0) { - log_warn("Type '%s' in dir entry (%s, %" PRIu64 "/0x%" PRIx64 ") " - "conflicts with type '%s' in dinode. (Dir entry is stale.)\n", - de_type_string(de->de_type), tmp_name, - de->de_inum.no_addr, de->de_inum.no_addr, - block_type_string(&q)); + log_warn("Type '%s' in dir entry (%s, %llu/0x%llx) conflicts" + " with type '%s' in dinode. (Dir entry is stale.)\n", + de_type_string(de->de_type), tmp_name, + (unsigned long long)de->de_inum.no_addr, + (unsigned long long)de->de_inum.no_addr, + block_type_string(&q)); if(query(&opts, "Clear stale directory entry? (y/n) ")) { entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr); check_inode_eattr(entry_ip, update, &clear_eattrs); @@ -322,9 +325,10 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent, log_debug("Found . dentry\n"); if(ds->dotdir) { - log_err("Already found '.' entry in directory %" PRIu64 " (0x%" - PRIx64 ")\n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); + log_err("Already found '.' entry in directory %llu" + " (0x%llx)\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); if(query(&opts, "Clear duplicate '.' entry? (y/n) ")) { entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr); @@ -352,12 +356,16 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent, /* check that '.' refers to this inode */ if(de->de_inum.no_addr != ip->i_di.di_num.no_addr) { - log_err("'.' entry's value incorrect in directory %" PRIu64 - " (0x%" PRIx64 "). Points to %"PRIu64 - " (0x%" PRIx64 ") when it should point to %" PRIu64 - " (0x%" PRIx64 ").\n", - de->de_inum.no_addr, de->de_inum.no_addr, - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); + log_err("'.' entry's value incorrect in directory %llu" + " (0x%llx). Points to %llu" + " (0x%llx) when it should point to %llu" + " (0x%llx).\n", + (unsigned long long)de->de_inum.no_addr, + (unsigned long long)de->de_inum.no_addr, + (unsigned long long)de->de_inum.no_addr, + (unsigned long long)de->de_inum.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); if(query(&opts, "Remove '.' reference? (y/n) ")) { entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr); check_inode_eattr(entry_ip, update, @@ -389,9 +397,10 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent, if(!strcmp("..", tmp_name)) { log_debug("Found .. dentry\n"); if(ds->dotdotdir) { - log_err("Already found '..' entry in directory %" PRIu64 " (0x%" - PRIx64 ")\n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); + log_err("Already found '..' entry in directory %llu" + "(0x%llx)\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); if(query(&opts, "Clear duplicate '..' entry? (y/n) ")) { entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr); @@ -415,10 +424,10 @@ int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent, } if(q.block_type != gfs2_inode_dir) { - log_err("Found '..' entry in directory %" PRIu64 " (0x%" - PRIx64 ") pointing to" - " something that's not a directory", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); + log_err("Found '..' entry in directory %llu (0x%llx) " + "pointing to something that's not a directory", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); if(query(&opts, "Clear bad '..' directory entry? (y/n) ")) { entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr); check_inode_eattr(entry_ip, update, @@ -513,7 +522,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, - void builder(struct gfs2_sbd *sbp)) + int builder(struct gfs2_sbd *sbp)) { uint64_t iblock = 0; struct dir_status ds = {0}; @@ -578,23 +587,25 @@ int check_system_dir(struct gfs2_inode *sysinode, const char *dirname, update = 1; } if(sysinode->i_di.di_entries != ds.entry_count) { - log_err("%s inode %" PRIu64 " (0x%" PRIx64 + log_err("%s inode %llu (0x%llx" "): Entries is %d - should be %d\n", dirname, - sysinode->i_di.di_num.no_addr, - sysinode->i_di.di_num.no_addr, + (unsigned long long)sysinode->i_di.di_num.no_addr, + (unsigned long long)sysinode->i_di.di_num.no_addr, sysinode->i_di.di_entries, ds.entry_count); - if(query(&opts, "Fix entries for %s inode %" PRIu64 " (0x%" - PRIx64 ")? (y/n) ", dirname, - sysinode->i_di.di_num.no_addr, - sysinode->i_di.di_num.no_addr)) { + if(query(&opts, "Fix entries for %s inode %llu (0x%llx" + ")? (y/n) ", dirname, + (unsigned long long)sysinode->i_di.di_num.no_addr, + (unsigned long long)sysinode->i_di.di_num.no_addr)) { sysinode->i_di.di_entries = ds.entry_count; log_warn("Entries updated\n"); update = 1; } else { - log_err("Entries for inode %" PRIu64 " (0x%" PRIx64 - ") left out of sync\n", - sysinode->i_di.di_num.no_addr, - sysinode->i_di.di_num.no_addr); + log_err("Entries for inode %llu (0x%llx" + ") left out of sync\n", + (unsigned long long) + sysinode->i_di.di_num.no_addr, + (unsigned long long) + sysinode->i_di.di_num.no_addr); } } @@ -756,10 +767,11 @@ int pass2(struct gfs2_sbd *sbp) bh = bread(&sbp->buf_list, i); ip = fsck_inode_get(sbp, bh); if(ip->i_di.di_entries != ds.entry_count) { - log_err("Entries is %d - should be %d for inode block %" PRIu64 - " (0x%" PRIx64 ")\n", - ip->i_di.di_entries, ds.entry_count, - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); + log_err("Entries is %d - should be %d for inode " + "block %llu (0x%llx)\n", + ip->i_di.di_entries, ds.entry_count, + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); ip->i_di.di_entries = ds.entry_count; fsck_inode_put(ip, updated); /* does a gfs2_dinode_out, brelse */ } diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c index 3ec380d..aa1a222 100644 --- a/gfs2/fsck/pass4.c +++ b/gfs2/fsck/pass4.c @@ -12,15 +12,17 @@ int fix_inode_count(struct gfs2_sbd *sbp, struct inode_info *ii, struct gfs2_inode *ip) { - log_info("Fixing inode count for %" PRIu64 " (0x%" PRIx64 ") \n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); + log_info("Fixing inode count for %llu (0x%llx) \n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); if(ip->i_di.di_nlink == ii->counted_links) return 0; ip->i_di.di_nlink = ii->counted_links; - log_debug("Changing inode %" PRIu64 " (0x%" PRIx64 ") to have %u links\n", - ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, - ii->counted_links); + log_debug("Changing inode %llu (0x%llx) to have %u links\n", + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr, + ii->counted_links); return 0; } @@ -52,7 +54,10 @@ int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) { return -1; } if(q.bad_block) { - log_err("Unlinked inode contains bad blocks\n", ii->inode); + log_err("Unlinked inode %llu (0x%llx) contains" + "bad blocks\n", + (unsigned long long)ii->inode, + (unsigned long long)ii->inode); if(query(&opts, "Clear unlinked inode with bad blocks? (y/n) ")) { gfs2_block_set(sbp, bl, ii->inode, diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c index 2a2cf4e..61600de 100644 --- a/gfs2/fsck/pass5.c +++ b/gfs2/fsck/pass5.c @@ -137,9 +137,11 @@ enum update_flags update_rgrp(struct gfs2_sbd *sbp, struct rgrp_list *rgp, /* actually adjust counters and write out to disk */ if(rgp->rg.rg_free != count[0]) { - log_err("RG #%" PRIu64 " (0x%" PRIx64 - ") free count inconsistent: is %u should be %u\n", - rgp->ri.ri_addr, rgp->ri.ri_addr, rgp->rg.rg_free, count[0]); + log_err("RG #%llu (0x%llx) free count inconsistent: " + "is %u should be %u\n", + (unsigned long long)rgp->ri.ri_addr, + (unsigned long long)rgp->ri.ri_addr, + rgp->rg.rg_free, count[0]); rgp->rg.rg_free = count[0]; update = 1; } diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c index 9298b10..4d0e420 100644 --- a/gfs2/fsck/rgrepair.c +++ b/gfs2/fsck/rgrepair.c @@ -136,9 +136,10 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list, uint64_t rgdist; rgdist = blk - block_of_last_rg; - log_debug("dist 0x%" PRIx64 " = 0x% " PRIx64 - " - 0x%" PRIx64, rgdist, - blk, block_of_last_rg); + log_debug("dist 0x%llx = 0x%llx - 0x%llx", + (unsigned long long)rgdist, + (unsigned long long)blk, + (unsigned long long)block_of_last_rg); /* ----------------------------------------- */ /* We found an RG. Check to see if we need */ /* to set the first_rg_dist based on whether */ @@ -249,8 +250,9 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list, } /* for subsequent bitmaps */ gfs2_compute_bitstructs(sdp, calc_rgd); - log_debug("Memory allocated for rg at 0x%p, bh:\n", - calc_rgd->ri.ri_addr, calc_rgd->bh); + log_debug("Memory allocated for rg at 0x%llx, bh: %p\n", + (unsigned long long)calc_rgd->ri.ri_addr, + calc_rgd->bh); if (!calc_rgd->bh) { log_crit("Can't allocate memory for bitmap repair.\n"); return -1; @@ -311,9 +313,10 @@ int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, osi_list_t *ret_list, for (tmp = ret_list, rgi = 0; tmp != ret_list; tmp = tmp->next, rgi++) { calc_rgd = osi_list_entry(tmp, struct rgrp_list, list); - log_debug("%d: 0x%" PRIx64 " / %x / 0x%" - PRIx64 " / 0x%x / 0x%x\n", rgi + 1, - calc_rgd->ri.ri_addr, calc_rgd->ri.ri_length, + log_debug("%d: 0x%llx / %x / 0x%llx" + " / 0x%x / 0x%x\n", rgi + 1, + (unsigned long long)calc_rgd->ri.ri_addr, + calc_rgd->ri.ri_length, calc_rgd->ri.ri_data0, calc_rgd->ri.ri_data, calc_rgd->ri.ri_bitbytes); } @@ -446,8 +449,8 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count) gfs2_rgrp_free(&sdp->rglist, not_updated); return -1; } - log_warn("L%d: number of rgs expected = %d.\n", trust_lvl + 1, - sdp->rgrps); + log_warn("L%d: number of rgs expected = %lld.\n", trust_lvl + 1, + (unsigned long long)sdp->rgrps); if (calc_rg_count != sdp->rgrps) { log_warn("L%d: They don't match; either (1) the fs was extended, (2) an odd\n", trust_lvl + 1); log_warn("L%d: rg size was used, or (3) we have a corrupt rg index.\n", trust_lvl + 1); @@ -499,12 +502,11 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count) expected = osi_list_entry(exp, struct rgrp_list, list); actual = osi_list_entry(act, struct rgrp_list, list); - ri_compare(rg, actual->ri, expected->ri, ri_addr, PRIx64); + ri_compare(rg, actual->ri, expected->ri, ri_addr, "llx"); ri_compare(rg, actual->ri, expected->ri, ri_length, PRIx32); - ri_compare(rg, actual->ri, expected->ri, ri_data0, PRIx64); + ri_compare(rg, actual->ri, expected->ri, ri_data0, "llx"); ri_compare(rg, actual->ri, expected->ri, ri_data, PRIx32); - ri_compare(rg, actual->ri, expected->ri, ri_bitbytes, - PRIx32); + ri_compare(rg, actual->ri, expected->ri, ri_bitbytes, PRIx32); /* If we modified the index, write it back to disk. */ if (rindex_modified) { if (query(&opts, "Fix the index? (y/n)")) { diff --git a/gfs2/libgfs2/buf.c b/gfs2/libgfs2/buf.c index d20a7bd..6939c25 100644 --- a/gfs2/libgfs2/buf.c +++ b/gfs2/libgfs2/buf.c @@ -19,7 +19,7 @@ blkno2head(struct buf_list *bl, uint64_t blkno) (gfs2_disk_hash((char *)&blkno, sizeof(uint64_t)) & BUF_HASH_MASK); } -static void write_buffer(struct buf_list *bl, struct gfs2_buffer_head *bh) +static int write_buffer(struct buf_list *bl, struct gfs2_buffer_head *bh) { struct gfs2_sbd *sdp = bl->sbp; @@ -27,11 +27,18 @@ static void write_buffer(struct buf_list *bl, struct gfs2_buffer_head *bh) osi_list_del(&bh->b_hash); bl->num_bufs--; if (bh->b_changed) { - do_lseek(sdp->device_fd, bh->b_blocknr * sdp->bsize); - do_write(sdp->device_fd, bh->b_data, sdp->bsize); + if (lseek(sdp->device_fd, bh->b_blocknr * sdp->bsize, + SEEK_SET) != bh->b_blocknr * sdp->bsize) { + return -1; + } + if (write(sdp->device_fd, bh->b_data, sdp->bsize) != + sdp->bsize) { + return -1; + } sdp->writes++; } free(bh); + return 0; } void init_buf_list(struct gfs2_sbd *sdp, struct buf_list *bl, uint32_t limit) @@ -47,7 +54,7 @@ void init_buf_list(struct gfs2_sbd *sdp, struct buf_list *bl, uint32_t limit) osi_list_init(&bl->buf_hash[i]); } -static void add_buffer(struct buf_list *bl, struct gfs2_buffer_head *bh) +static int add_buffer(struct buf_list *bl, struct gfs2_buffer_head *bh) { osi_list_t *head = blkno2head(bl, bh->b_blocknr); @@ -64,7 +71,8 @@ static void add_buffer(struct buf_list *bl, struct gfs2_buffer_head *bh) bh = osi_list_entry(tmp, struct gfs2_buffer_head, b_list); if (!bh->b_count) { - write_buffer(bl, bh); + if (write_buffer(bl, bh)) + return -1; found++; if (found >= 10) break; @@ -72,6 +80,7 @@ static void add_buffer(struct buf_list *bl, struct gfs2_buffer_head *bh) } bl->spills++; } + return 0; } struct gfs2_buffer_head *bfind(struct buf_list *bl, uint64_t num) @@ -95,8 +104,9 @@ struct gfs2_buffer_head *bfind(struct buf_list *bl, uint64_t num) return NULL; } -struct gfs2_buffer_head *bget_generic(struct buf_list *bl, uint64_t num, - int find_existing, int read_disk) +struct gfs2_buffer_head *__bget_generic(struct buf_list *bl, uint64_t num, + int find_existing, int read_disk, + int line, const char *caller) { struct gfs2_buffer_head *bh; struct gfs2_sbd *sdp = bl->sbp; @@ -114,23 +124,44 @@ struct gfs2_buffer_head *bget_generic(struct buf_list *bl, uint64_t num, bh->b_blocknr = num; bh->b_data = (char *)bh + sizeof(struct gfs2_buffer_head); if (read_disk) { - do_lseek(sdp->device_fd, num * sdp->bsize); - do_read(sdp->device_fd, bh->b_data, sdp->bsize); + if (lseek(sdp->device_fd, num * sdp->bsize, SEEK_SET) != + num * sdp->bsize) { + fprintf(stderr, "bad seek: %s from %s:%d: block " + "%llu (0x%llx)\n", strerror(errno), + caller, line, (unsigned long long)num, + (unsigned long long)num); + exit(-1); + } + if (read(sdp->device_fd, bh->b_data, sdp->bsize) < 0) { + fprintf(stderr, "bad read: %s from %s:%d: block " + "%llu (0x%llx)\n", strerror(errno), + caller, line, (unsigned long long)num, + (unsigned long long)num); + exit(-1); + } + } + if (add_buffer(bl, bh)) { + fprintf(stderr, "bad write: %s from %s:%d: block " + "%llu (0x%llx)\n", strerror(errno), + caller, line, (unsigned long long)num, + (unsigned long long)num); + exit(-1); } - add_buffer(bl, bh); bh->b_changed = FALSE; return bh; } -struct gfs2_buffer_head *bget(struct buf_list *bl, uint64_t num) +struct gfs2_buffer_head *__bget(struct buf_list *bl, uint64_t num, int line, + const char *caller) { - return bget_generic(bl, num, TRUE, FALSE); + return __bget_generic(bl, num, TRUE, FALSE, line, caller); } -struct gfs2_buffer_head *bread(struct buf_list *bl, uint64_t num) +struct gfs2_buffer_head *__bread(struct buf_list *bl, uint64_t num, int line, + const char *caller) { - return bget_generic(bl, num, TRUE, TRUE); + return __bget_generic(bl, num, TRUE, TRUE, line, caller); } struct gfs2_buffer_head *bhold(struct gfs2_buffer_head *bh) @@ -155,7 +186,7 @@ void brelse(struct gfs2_buffer_head *bh, enum update_flags updated) bh->b_count--; } -void bsync(struct buf_list *bl) +void __bsync(struct buf_list *bl, int line, const char *caller) { struct gfs2_buffer_head *bh; @@ -167,12 +198,19 @@ void bsync(struct buf_list *bl) " (0x%" PRIx64")\n", bh->b_blocknr, bh->b_blocknr); exit(-1); } - write_buffer(bl, bh); + if (write_buffer(bl, bh)) { + fprintf(stderr, "bad write: %s from %s:%d: block " + "%lld (0x%llx)\n", strerror(errno), + caller, line, + (unsigned long long)bh->b_blocknr, + (unsigned long long)bh->b_blocknr); + exit(-1); + } } } /* commit buffers to disk but do not discard */ -void bcommit(struct buf_list *bl) +void __bcommit(struct buf_list *bl, int line, const char *caller) { osi_list_t *tmp, *x; struct gfs2_buffer_head *bh; @@ -180,11 +218,35 @@ void bcommit(struct buf_list *bl) osi_list_foreach_safe(tmp, &bl->list, x) { bh = osi_list_entry(tmp, struct gfs2_buffer_head, b_list); - if (!bh->b_count) /* if not reserved for later */ - write_buffer(bl, bh);/* write the data & free memory */ - else if (bh->b_changed) { /* if buffer has changed */ - do_lseek(sdp->device_fd, bh->b_blocknr * sdp->bsize); - do_write(sdp->device_fd, bh->b_data, sdp->bsize); + if (!bh->b_count) { /* if not reserved for later */ + if (write_buffer(bl, bh)) { /* write & free */ + fprintf(stderr, "bad write: %s from %s:%d: " + "block %lld (0x%llx)\n", + strerror(errno), caller, line, + (unsigned long long)bh->b_blocknr, + (unsigned long long)bh->b_blocknr); + exit(-1); + } + } else if (bh->b_changed) { /* if buffer has changed */ + if (lseek(sdp->device_fd, + bh->b_blocknr * sdp->bsize, SEEK_SET) != + bh->b_blocknr * sdp->bsize) { + fprintf(stderr, "bad seek: %s from %s:%d: " + "block %lld (0x%llx)\n", + strerror(errno), caller, line, + (unsigned long long)bh->b_blocknr, + (unsigned long long)bh->b_blocknr); + exit(-1); + } + if (write(sdp->device_fd, bh->b_data, sdp->bsize) != + sdp->bsize) { + fprintf(stderr, "bad write: %s from %s:%d: " + "block %lld (0x%llx)\n", + strerror(errno), caller, line, + (unsigned long long)bh->b_blocknr, + (unsigned long long)bh->b_blocknr); + exit(-1); + } bh->b_changed = FALSE; /* no longer changed */ } } diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c index 5bbb5f0..2d9b8a7 100644 --- a/gfs2/libgfs2/fs_geometry.c +++ b/gfs2/libgfs2/fs_geometry.c @@ -129,7 +129,8 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, int rgsize_specified) for (tmp = head->next; tmp != head; tmp = tmp->next) { rl = osi_list_entry(tmp, struct rgrp_list, list); log_info("rg_o = %llu, rg_l = %llu\n", - rl->start, rl->length); + (unsigned long long)rl->start, + (unsigned long long)rl->length); } } } diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c index e7aef67..e070f47 100644 --- a/gfs2/libgfs2/fs_ops.c +++ b/gfs2/libgfs2/fs_ops.c @@ -292,8 +292,10 @@ struct metapath *find_metapath(struct gfs2_inode *ip, uint64_t block) fprintf(stderr, "Out of memory in %s\n", __FUNCTION__); exit(-1); } - for (i = ip->i_di.di_height; i--;) - mp->mp_list[i] = do_div(b, sdp->sd_inptrs); + for (i = ip->i_di.di_height; i--;) { + mp->mp_list[i] = b % sdp->sd_inptrs; + b /= sdp->sd_inptrs; + } return mp; } @@ -454,7 +456,8 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf, if (isdir) { lblock = offset; - o = do_div(lblock, sdp->sd_jbsize); + o = lblock % sdp->sd_jbsize; + lblock /= sdp->sd_jbsize; } else { lblock = offset >> sdp->sd_sb.sb_bsize_shift; o = offset & (sdp->bsize - 1); @@ -526,7 +529,8 @@ int gfs2_writei(struct gfs2_inode *ip, void *buf, if (isdir) { lblock = offset; - o = do_div(lblock, sdp->sd_jbsize); + o = lblock % sdp->sd_jbsize; + lblock /= sdp->sd_jbsize; } else { lblock = offset >> sdp->sd_sb.sb_bsize_shift; o = offset & (sdp->bsize - 1); diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index c627f19..db24bb9 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -79,43 +79,8 @@ static __inline__ __attribute__((noreturn)) void die(const char *fmt, ...) exit(-1); } -extern __inline__ __attribute__((deprecated)) void do_lseek(int fd, off_t off) -{ - if (lseek(fd, off, SEEK_SET) != off) { - fprintf(stderr, "bad seek: %s on line %d of file %s\n", - strerror(errno),__LINE__, __FILE__); - exit(-1); - } -} - -extern __inline__ __attribute__((deprecated)) void do_read(int fd, void *buf, size_t len) -{ - if (read(fd, buf, len) < 0) { - fprintf(stderr, "bad read: %s on line %d of file %s\n", - strerror(errno), __LINE__, __FILE__); - exit(-1); - } -} - -extern __inline__ __attribute__((deprecated)) void do_write(int fd, const void *buf, size_t len) -{ - if (write(fd, buf, len) != len) { - fprintf(stderr, "bad write: %s on line %d of file %s\n", - strerror(errno), __LINE__, __FILE__); - exit(-1); - } -} - #define DIV_RU(x, y) (((x) + (y) - 1) / (y)) -static __inline__ __attribute__((deprecated)) uint64_t do_div_i(uint64_t *num, unsigned int den) -{ - unsigned int m = *num % den; - *num /= den; - return m; -} -#define do_div(n, d) do_div_i(&(n), (d)) - struct device { uint64_t start; uint64_t length; @@ -412,14 +377,26 @@ extern void *gfs2_block_list_destroy(struct gfs2_sbd *sdp, /* buf.c */ extern void init_buf_list(struct gfs2_sbd *sdp, struct buf_list *bl, uint32_t limit); extern struct gfs2_buffer_head *bfind(struct buf_list *bl, uint64_t num); -extern struct gfs2_buffer_head *bget_generic(struct buf_list *bl, uint64_t num, - int find_existing, int read_disk); -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); +extern struct gfs2_buffer_head *__bget_generic(struct buf_list *bl, + uint64_t num, int find_existing, + int read_disk, int line, + const char *caller); +extern struct gfs2_buffer_head *__bget(struct buf_list *bl, uint64_t num, + int line, const char *caller); +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 bsync(struct buf_list *bl); -extern void bcommit(struct buf_list *bl); +extern void __bsync(struct buf_list *bl, int line, const char *caller); +extern void __bcommit(struct buf_list *bl, int line, const char *caller); + +#define bget_generic(bl, num, find, read) __bget_generic(bl, num, find, read, \ + __LINE__, \ + __FUNCTION__) +#define bget(bl, num) __bget(bl, num, __LINE__, __FUNCTION__) +#define bread(bl, num) __bread(bl, num, __LINE__, __FUNCTION__) +#define bsync(bl) do { __bsync(bl, __LINE__, __FUNCTION__); } while(0) +#define bcommit(bl) do { __bcommit(bl, __LINE__, __FUNCTION__); } while(0) /* device_geometry.c */ extern int device_geometry(struct gfs2_sbd *sdp); @@ -687,16 +664,16 @@ extern void gfs2_rgrp_relse(struct rgrp_list *rgd, enum update_flags updated); extern void gfs2_rgrp_free(osi_list_t *rglist, enum update_flags updated); /* structures.c */ -extern void build_master(struct gfs2_sbd *sdp); +extern int build_master(struct gfs2_sbd *sdp); extern void build_sb(struct gfs2_sbd *sdp); extern int build_jindex(struct gfs2_sbd *sdp); -extern void build_per_node(struct gfs2_sbd *sdp); -extern void build_inum(struct gfs2_sbd *sdp); -extern void build_statfs(struct gfs2_sbd *sdp); +extern int build_per_node(struct gfs2_sbd *sdp); +extern int build_inum(struct gfs2_sbd *sdp); +extern int build_statfs(struct gfs2_sbd *sdp); extern int build_rindex(struct gfs2_sbd *sdp); extern int build_quota(struct gfs2_sbd *sdp); -extern void build_root(struct gfs2_sbd *sdp); -extern int do_init(struct gfs2_sbd *sdp); +extern int build_root(struct gfs2_sbd *sdp); +extern int do_init(struct gfs2_sbd *sdp); extern int gfs2_check_meta(struct gfs2_buffer_head *bh, int type); extern int gfs2_next_rg_meta(struct rgrp_list *rgd, uint64_t *block, int first); extern int gfs2_next_rg_metatype(struct gfs2_sbd *sdp, struct rgrp_list *rgd, @@ -712,7 +689,7 @@ extern int write_sb(struct gfs2_sbd *sdp); /* ondisk.c */ extern uint32_t gfs2_disk_hash(const char *data, int len); extern void print_it(const char *label, const char *fmt, const char *fmt2, ...) - __attribute__((format(printf,3,4))); + __attribute__((format(printf,2,4))); /* Translation functions */ diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c index a59ea21..72b9eef 100644 --- a/gfs2/libgfs2/misc.c +++ b/gfs2/libgfs2/misc.c @@ -34,8 +34,8 @@ uint32_t compute_heightsize(struct gfs2_sbd *sdp, uint64_t *heightsize, uint32_t m; space = heightsize[x - 1] * inptrs; - d = space; - m = do_div(d, inptrs); + m = space % inptrs; + d = space / inptrs; if (d != heightsize[x - 1] || m) break; diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c index 46d0bad..7599a66 100644 --- a/gfs2/libgfs2/ondisk.c +++ b/gfs2/libgfs2/ondisk.c @@ -81,7 +81,7 @@ void gfs2_meta_header_out(struct gfs2_meta_header *mh, char *buf) void gfs2_meta_header_print(struct gfs2_meta_header *mh) { - pv(mh, mh_magic, "0x%.8X", NULL); + pv(mh, mh_magic, "0x%08X", NULL); pv(mh, mh_type, "%u", "0x%x"); pv(mh, mh_format, "%u", "0x%x"); } diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c index dbe35ab..4d77b2c 100644 --- a/gfs2/libgfs2/structures.c +++ b/gfs2/libgfs2/structures.c @@ -12,7 +12,7 @@ #include "libgfs2.h" -void build_master(struct gfs2_sbd *sdp) +int build_master(struct gfs2_sbd *sdp) { struct gfs2_inum inum; uint64_t bn; @@ -30,6 +30,7 @@ void build_master(struct gfs2_sbd *sdp) printf("\nMaster dir:\n"); gfs2_dinode_print(&sdp->master_dir->i_di); } + return 0; } void build_sb(struct gfs2_sbd *sdp) @@ -159,7 +160,7 @@ int build_jindex(struct gfs2_sbd *sdp) return 0; } -static void build_inum_range(struct gfs2_inode *per_node, unsigned int j) +static int build_inum_range(struct gfs2_inode *per_node, unsigned int j) { struct gfs2_sbd *sdp = per_node->i_sbd; char name[256]; @@ -176,6 +177,7 @@ static void build_inum_range(struct gfs2_inode *per_node, unsigned int j) } inode_put(ip, updated); + return 0; } static void build_statfs_change(struct gfs2_inode *per_node, unsigned int j) @@ -234,7 +236,7 @@ static int build_quota_change(struct gfs2_inode *per_node, unsigned int j) return 0; } -void build_per_node(struct gfs2_sbd *sdp) +int build_per_node(struct gfs2_sbd *sdp) { struct gfs2_inode *per_node; unsigned int j; @@ -254,9 +256,10 @@ void build_per_node(struct gfs2_sbd *sdp) } inode_put(per_node, updated); + return 0; } -void build_inum(struct gfs2_sbd *sdp) +int build_inum(struct gfs2_sbd *sdp) { struct gfs2_inode *ip; @@ -269,9 +272,10 @@ void build_inum(struct gfs2_sbd *sdp) } sdp->md.inum = ip; + return 0; } -void build_statfs(struct gfs2_sbd *sdp) +int build_statfs(struct gfs2_sbd *sdp) { struct gfs2_inode *ip; @@ -284,6 +288,7 @@ void build_statfs(struct gfs2_sbd *sdp) } sdp->md.statfs = ip; + return 0; } int build_rindex(struct gfs2_sbd *sdp) @@ -351,7 +356,7 @@ int build_quota(struct gfs2_sbd *sdp) return 0; } -void build_root(struct gfs2_sbd *sdp) +int build_root(struct gfs2_sbd *sdp) { struct gfs2_inum inum; uint64_t bn; @@ -368,6 +373,7 @@ void build_root(struct gfs2_sbd *sdp) printf("\nRoot directory:\n"); gfs2_dinode_print(&sdp->md.rooti->i_di); } + return 0; } int do_init(struct gfs2_sbd *sdp) diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c index 2975d7e..f48dcd5 100644 --- a/gfs2/mkfs/main_jadd.c +++ b/gfs2/mkfs/main_jadd.c @@ -235,7 +235,13 @@ add_ir(struct gfs2_sbd *sdp) struct gfs2_inum_range ir; make_jdata(fd, "set"); memset(&ir, 0, sizeof(struct gfs2_inum_range)); - do_write(fd, (void*)&ir, sizeof(struct gfs2_inum_range)); + if (write(fd, (void*)&ir, sizeof(struct gfs2_inum_range)) != + sizeof(struct gfs2_inum_range)) { + fprintf(stderr, "write error: %s from %s:%d: " + "offset 0\n", strerror(errno), + __FUNCTION__, __LINE__); + exit(-1); + } } close(fd); @@ -261,7 +267,13 @@ add_sc(struct gfs2_sbd *sdp) make_jdata(fd, "set"); memset(&sc, 0, sizeof(struct gfs2_statfs_change)); - do_write(fd, (void*)&sc, sizeof(struct gfs2_statfs_change)); + if (write(fd, (void*)&sc, sizeof(struct gfs2_statfs_change)) != + sizeof(struct gfs2_statfs_change)) { + fprintf(stderr, "write error: %s from %s:%d: " + "offset 0\n", strerror(errno), + __FUNCTION__, __LINE__); + exit(-1); + } } close(fd); @@ -293,10 +305,18 @@ add_qc(struct gfs2_sbd *sdp) memset(buf, 0, sdp->bsize); for (x=0; xbsize); + if (write(fd, buf, sdp->bsize) != sdp->bsize) { + fprintf(stderr, "write error: %s from %s:%d: " + "block %lld (0x%llx)\n", + strerror(errno), + __FUNCTION__, __LINE__, + (unsigned long long)x, + (unsigned long long)x); + exit(-1); + } } - do_lseek(fd, 0); + lseek(fd, 0, SEEK_SET); memset(&mh, 0, sizeof(struct gfs2_meta_header)); mh.mh_magic = GFS2_MAGIC; @@ -305,7 +325,15 @@ add_qc(struct gfs2_sbd *sdp) gfs2_meta_header_out(&mh, buf); for (x=0; xbsize); + if (write(fd, buf, sdp->bsize) != sdp->bsize) { + fprintf(stderr, "write error: %s from %s:%d: " + "block %lld (0x%llx)\n", + strerror(errno), + __FUNCTION__, __LINE__, + (unsigned long long)x, + (unsigned long long)x); + exit(-1); + } } error = fsync(fd); @@ -385,10 +413,18 @@ add_j(struct gfs2_sbd *sdp) make_jdata(fd, "clear"); memset(buf, 0, sdp->bsize); for (x=0; xbsize); + if (write(fd, buf, sdp->bsize) != sdp->bsize) { + fprintf(stderr, "write error: %s from %s:%d: " + "block %lld (0x%llx)\n", + strerror(errno), + __FUNCTION__, __LINE__, + (unsigned long long)x, + (unsigned long long)x); + exit(-1); + } } - do_lseek(fd, 0); + lseek(fd, 0, SEEK_SET); memset(&lh, 0, sizeof(struct gfs2_log_header)); lh.lh_header.mh_magic = GFS2_MAGIC; @@ -405,7 +441,15 @@ add_j(struct gfs2_sbd *sdp) hash = gfs2_disk_hash(buf, sizeof(struct gfs2_log_header)); ((struct gfs2_log_header *)buf)->lh_hash = cpu_to_be32(hash); - do_write(fd, buf, sdp->bsize); + if (write(fd, buf, sdp->bsize) != sdp->bsize) { + fprintf(stderr, "write error: %s from %s:%d: " + "block %lld (0x%llx)\n", + strerror(errno), + __FUNCTION__, __LINE__, + (unsigned long long)x, + (unsigned long long)x); + exit(-1); + } if (++seq == blocks) seq = 0; diff --git a/gfs2/mount/util.c b/gfs2/mount/util.c index 782e5e8..d65d710 100644 --- a/gfs2/mount/util.c +++ b/gfs2/mount/util.c @@ -259,7 +259,13 @@ int get_sb(char *device, struct gen_sb *sb_out) char buf[GFS2_BASIC_BLOCK]; struct gfs2_sb sb; - do_lseek(fd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK); + if (lseek(fd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK, SEEK_SET) != + GFS2_SB_ADDR * GFS2_BASIC_BLOCK) { + fprintf(stderr, "bad seek: %s from %s:%d: " + "superblock\n", + strerror(errno), __FUNCTION__, __LINE__); + exit(-1); + } do_read(fd, buf, GFS2_BASIC_BLOCK); gfs2_sb_in(&sb, buf); @@ -283,7 +289,13 @@ int get_sb(char *device, struct gen_sb *sb_out) char buf[GFS_BASIC_BLOCK]; struct gfs_sb sb; - do_lseek(fd, GFS_SB_ADDR * GFS_BASIC_BLOCK); + if (lseek(fd, GFS_SB_ADDR * GFS_BASIC_BLOCK, SEEK_SET) != + GFS_SB_ADDR * GFS_BASIC_BLOCK) { + fprintf(stderr, "bad seek: %s from %s:%d: " + "superblock\n", + strerror(errno), __FUNCTION__, __LINE__); + exit(-1); + } do_read(fd, buf, GFS2_BASIC_BLOCK); gfs_sb_in(&sb, buf); diff --git a/gfs2/mount/util.h b/gfs2/mount/util.h index 2d40d82..fe0f83d 100644 --- a/gfs2/mount/util.h +++ b/gfs2/mount/util.h @@ -39,13 +39,6 @@ do { \ printf("%s: " fmt "\n", prog_name, ##args); \ } while (0) -#define do_lseek(fd, off) \ -do { \ - if (lseek((fd), (off), SEEK_SET) != (off)) \ - die("bad seek: %s on line %d of file %s\n", \ - strerror(errno),__LINE__, __FILE__); \ -} while (0) - #define do_read(fd, buff, len) \ do { \ if (read((fd), (buff), (len)) != (len)) \ diff --git a/gfs2/quota/main.c b/gfs2/quota/main.c index 773c250..66822fc 100644 --- a/gfs2/quota/main.c +++ b/gfs2/quota/main.c @@ -291,8 +291,18 @@ read_superblock(struct gfs2_sb *sb, struct gfs2_sbd *sdp) die("Could not open the block device %s: %s\n", sdp->device_name, strerror(errno)); } - do_lseek(fd, 0x10 * 4096); - do_read(fd, buf, PATH_MAX); + if (lseek(fd, 0x10 * 4096, SEEK_SET) != 0x10 * 4096) { + fprintf(stderr, "bad seek: %s from %s:%d: " + "superblock\n", + strerror(errno), __FUNCTION__, __LINE__); + + exit(-1); + } + if (read(fd, buf, PATH_MAX) != PATH_MAX) { + fprintf(stderr, "bad read: %s from %s:%d: superblock\n", + strerror(errno), __FUNCTION__, __LINE__); + exit(-1); + } gfs2_sb_in(sb, buf); close(fd); diff --git a/gfs2/tool/df.c b/gfs2/tool/df.c index cd3bfaa..8e5800e 100644 --- a/gfs2/tool/df.c +++ b/gfs2/tool/df.c @@ -102,8 +102,17 @@ do_df_one(char *path) init_buf_list(&sbd, &sbd.buf_list, 128 << 20); init_buf_list(&sbd, &sbd.nvbuf_list, 0xffffffff); - do_lseek(sbd.device_fd, 0x10 * sbd.bsize); - do_read(sbd.device_fd, buf, sbd.bsize); /* read in the superblock */ + if (lseek(sbd.device_fd, 0x10 * sbd.bsize, SEEK_SET) != + 0x10 * sbd.bsize) { + fprintf(stderr, "bad seek: %s from %s:%d: superblock\n", + strerror(errno), __FUNCTION__, __LINE__); + exit(-1); + } + if (read(sbd.device_fd, buf, sbd.bsize) != sbd.bsize) { + fprintf(stderr, "bad read: %s from %s:%d: superblock\n", + strerror(errno), __FUNCTION__, __LINE__); + exit(-1); + } compute_constants(&sbd); gfs2_sb_in(&sbd.sd_sb, buf); /* parse it out into the sb structure */ @@ -152,7 +161,12 @@ do_df_one(char *path) sprintf(statfs_fn, "%s/statfs", sbd.metafs_path); statfs_fd = open(statfs_fn, O_RDONLY); - do_read(statfs_fd, buf, sizeof(struct gfs2_statfs_change)); + if (read(statfs_fd, buf, sizeof(struct gfs2_statfs_change)) != + sizeof(struct gfs2_statfs_change)) { + fprintf(stderr, "bad read: %s from %s:%d: superblock\n", + strerror(errno), __FUNCTION__, __LINE__); + exit(-1); + } gfs2_statfs_change_in(&sc, (char *)&buf); close(statfs_fd); diff --git a/gfs2/tool/sb.c b/gfs2/tool/sb.c index 21bfe2e..a668b8e 100644 --- a/gfs2/tool/sb.c +++ b/gfs2/tool/sb.c @@ -77,8 +77,17 @@ do_sb(int argc, char **argv) printf("\n"); } - do_lseek(fd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK); - do_read(fd, buf, GFS2_BASIC_BLOCK); + if (lseek(fd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK, SEEK_SET) != + GFS2_SB_ADDR * GFS2_BASIC_BLOCK) { + fprintf(stderr, "bad seek: %s from %s:%d: superblock\n", + strerror(errno), __FUNCTION__, __LINE__); + exit(-1); + } + if (read(fd, buf, GFS2_BASIC_BLOCK) != GFS2_BASIC_BLOCK) { + fprintf(stderr, "bad read: %s from %s:%d: superblock\n", + strerror(errno), __FUNCTION__, __LINE__); + exit(-1); + } gfs2_sb_in(&sb, (char*) buf); @@ -135,8 +144,18 @@ do_sb(int argc, char **argv) if (newval) { gfs2_sb_out(&sb,(char*) buf); - do_lseek(fd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK); - do_write(fd, buf, GFS2_BASIC_BLOCK); + if (lseek(fd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK, SEEK_SET) != + GFS2_SB_ADDR * GFS2_BASIC_BLOCK) { + fprintf(stderr, "bad seek: %s from %s:%d: superblock\n", + strerror(errno), __FUNCTION__, __LINE__); + exit(-1); + } + if (write(fd, buf, GFS2_BASIC_BLOCK) != GFS2_BASIC_BLOCK) { + fprintf(stderr, "write error: %s from %s:%d: " + "superblock\n", strerror(errno), + __FUNCTION__, __LINE__); + exit(-1); + } fsync(fd);