public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: Andrew Price <andyp@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: cluster: STABLE3 - libgfs2: Remove die from fix_device_geometry Date: Tue, 14 Apr 2009 10:14:00 -0000 [thread overview] Message-ID: <20090414101418.84825120365@lists.fedorahosted.org> (raw) Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=ad295e1cc89bc14ab8d41105f4570b99f931eb8d Commit: ad295e1cc89bc14ab8d41105f4570b99f931eb8d Parent: e625d0e4bb26cb03b05df5272e1a6c1c75cee999 Author: Andrew Price <andy@andrewprice.me.uk> AuthorDate: Tue Apr 14 11:12:31 2009 +0100 Committer: Andrew Price <andy@andrewprice.me.uk> CommitterDate: Tue Apr 14 11:12:31 2009 +0100 libgfs2: Remove die from fix_device_geometry This patch removes the die call from fix_device_geometry and adds error reporting. All callers are updated to provide the same behaviour as before. Signed-off-by: Andrew Price <andy@andrewprice.me.uk> --- gfs2/edit/hexedit.c | 6 +++++- gfs2/edit/savemeta.c | 6 +++++- gfs2/fsck/rgrepair.c | 7 ++++++- gfs2/libgfs2/device_geometry.c | 10 ++++++---- gfs2/libgfs2/libgfs2.h | 2 +- gfs2/mkfs/main_grow.c | 7 ++++++- gfs2/mkfs/main_mkfs.c | 6 +++++- 7 files changed, 34 insertions(+), 10 deletions(-) diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index ac21ebd..8a5f3bb 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -1752,7 +1752,11 @@ void read_superblock(int fd) } block = 0x10 * (GFS2_DEFAULT_BSIZE / sbd.bsize); device_geometry(&sbd); - fix_device_geometry(&sbd); + if (fix_device_geometry(&sbd)) { + fprintf(stderr, "Device is too small (%"PRIu64" bytes)\n", + sbd.device.length << GFS2_BASIC_BLOCK_SHIFT); + exit(-1); + } if(gfs1) { sbd.sd_inptrs = (sbd.bsize - sizeof(struct gfs_indirect)) / sizeof(uint64_t); diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 7c2ba04..2f70a24 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -477,7 +477,11 @@ void savemeta(char *out_fn, int saveoption) fprintf(stderr, "Geometery error\n"); exit(-1); } - fix_device_geometry(&sbd); + if (fix_device_geometry(&sbd)) { + fprintf(stderr, "Device is too small (%"PRIu64" bytes)\n", + sbd.device.length << GFS2_BASIC_BLOCK_SHIFT); + exit(-1); + } osi_list_init(&sbd.rglist); init_buf_list(&sbd, &sbd.buf_list, 128 << 20); init_buf_list(&sbd, &sbd.nvbuf_list, 0xffffffff); diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c index 4ddd740..948d041 100644 --- a/gfs2/fsck/rgrepair.c +++ b/gfs2/fsck/rgrepair.c @@ -346,7 +346,12 @@ int gfs2_rindex_calculate(struct gfs2_sbd *sdp, osi_list_t *ret_list, fprintf(stderr, "Geometry error\n"); exit(-1); } - fix_device_geometry(sdp); + if (fix_device_geometry(sdp)) { + fprintf(stderr, "Device is too small (%"PRIu64" bytes)\n", + sdp->device.length << GFS2_BASIC_BLOCK_SHIFT); + exit(-1); + } + /* Compute the default resource group layout as mkfs would have done */ compute_rgrp_layout(sdp, FALSE); build_rgrps(sdp, FALSE); /* FALSE = calc but don't write to disk. */ diff --git a/gfs2/libgfs2/device_geometry.c b/gfs2/libgfs2/device_geometry.c index f37defa..b2d5861 100644 --- a/gfs2/libgfs2/device_geometry.c +++ b/gfs2/libgfs2/device_geometry.c @@ -43,7 +43,7 @@ int device_geometry(struct gfs2_sbd *sdp) * */ -void fix_device_geometry(struct gfs2_sbd *sdp) +int fix_device_geometry(struct gfs2_sbd *sdp) { struct device *device = &sdp->device; unsigned int bbsize = sdp->bsize >> GFS2_BASIC_BLOCK_SHIFT; @@ -61,9 +61,10 @@ void fix_device_geometry(struct gfs2_sbd *sdp) start = device->start; length = device->length; - if (length < 1 << (20 - GFS2_BASIC_BLOCK_SHIFT)) - die("device is way too small (%"PRIu64" bytes)\n", - length << GFS2_BASIC_BLOCK_SHIFT); + if (length < 1 << (20 - GFS2_BASIC_BLOCK_SHIFT)) { + errno = ENOSPC; + return -1; + } remainder = start % bbsize; if (remainder) { @@ -85,4 +86,5 @@ void fix_device_geometry(struct gfs2_sbd *sdp) device->start, device->length, device->rgf_flags); printf("\nDevice Size: %"PRIu64"\n", sdp->device_size); } + return 0; } diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index 0742f9e..633aff3 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -398,7 +398,7 @@ extern void __bcommit(struct buf_list *bl, int line, const char *caller); /* device_geometry.c */ extern int device_geometry(struct gfs2_sbd *sdp); -extern void fix_device_geometry(struct gfs2_sbd *sdp); +extern int fix_device_geometry(struct gfs2_sbd *sdp); /* fs_bits.c */ #define BFITNOENT (0xFFFFFFFF) diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c index 3593629..b686bd7 100644 --- a/gfs2/mkfs/main_grow.c +++ b/gfs2/mkfs/main_grow.c @@ -297,7 +297,12 @@ main_grow(int argc, char *argv[]) if(read_sb(sdp) < 0) die("gfs: Error reading superblock.\n"); - fix_device_geometry(sdp); + if (fix_device_geometry(sdp)) { + fprintf(stderr, "Device is too small (%"PRIu64" bytes)\n", + sdp->device.length << GFS2_BASIC_BLOCK_SHIFT); + exit(-1); + } + if (mount_gfs2_meta(sdp)) { fprintf(stderr, "Error mounting GFS2 metafs: %s\n", strerror(errno)); diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c index c1b6795..fc53ae3 100644 --- a/gfs2/mkfs/main_mkfs.c +++ b/gfs2/mkfs/main_mkfs.c @@ -533,7 +533,11 @@ main_mkfs(int argc, char *argv[]) } sdp->device.length = sdp->orig_fssize; } - fix_device_geometry(sdp); + if (fix_device_geometry(sdp)) { + fprintf(stderr, "Device is too small (%"PRIu64" bytes)\n", + sdp->device.length << GFS2_BASIC_BLOCK_SHIFT); + exit(-1); + } /* Compute the resource group layouts */
reply other threads:[~2009-04-14 10:14 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20090414101418.84825120365@lists.fedorahosted.org \ --to=andyp@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).