public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* gfs2-utils: master - libgfs2: Remove die from fix_device_geometry
@ 2009-04-07 15:20 Andrew Price
0 siblings, 0 replies; only message in thread
From: Andrew Price @ 2009-04-07 15:20 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitdiff;h=33d84bd3b7c27e5c7ed09825ca16b2648e622673
Commit: 33d84bd3b7c27e5c7ed09825ca16b2648e622673
Parent: 71980c621f0cad351b18e3eb026e643b8eafadfe
Author: Andrew Price <andy@andrewprice.me.uk>
AuthorDate: Tue Apr 7 16:15:51 2009 +0100
Committer: Andrew Price <andy@andrewprice.me.uk>
CommitterDate: Tue Apr 7 16:15:51 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 783d216..1ae2968 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -348,7 +348,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 94c7d71..8218528 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -299,7 +299,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 ce3a6ae..2057d0d 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -530,7 +530,11 @@ void 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 */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-04-07 15:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-07 15:20 gfs2-utils: master - libgfs2: Remove die from fix_device_geometry Andrew Price
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).