Currently gfs2_edit complains that it doesn't know what 'master' means
when it can't find the master directory. This patch catches the case
where the master directory hasn't been found and reports the error more
clearly to the user. It also updates a terse 'out of space' error
message in blk_alloc_i to be more clear.

rhbz#742293

Signed-off-by: Andrew Price <anpr...@redhat.com>
---
 gfs2/edit/hexedit.c   |   10 +++++++---
 gfs2/libgfs2/fs_ops.c |    2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 4b992de..69d1940 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1700,10 +1700,14 @@ uint64_t check_keywords(const char *kword)
        else if (!strcmp(kword, "root") || !strcmp(kword, "rootdir"))
                blk = sbd.sd_sb.sb_root_dir.no_addr;
        else if (!strcmp(kword, "master")) {
-               if (!sbd.gfs1)
-                       blk = sbd.sd_sb.sb_master_dir.no_addr;
-               else
+               if (sbd.gfs1)
                        fprintf(stderr, "This is GFS1; there's no master 
directory.\n");
+               else if (!sbd.sd_sb.sb_master_dir.no_addr) {
+                       fprintf(stderr, "GFS2 master directory not found on 
%s\n",
+                                                                 
sbd.device_name);
+                       exit(-1);
+               } else
+                       blk = sbd.sd_sb.sb_master_dir.no_addr;
        }
        else if (!strcmp(kword, "jindex")) {
                if (sbd.gfs1)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index def6f80..a72394f 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -137,7 +137,7 @@ static uint64_t blk_alloc_i(struct gfs2_sbd *sdp, unsigned 
int type)
        }
 
        if (n == NULL) {
-               fprintf(stderr, "out of space\n");
+               fprintf(stderr, "Not enough space available on device\n");
                exit(1);
        }
 
-- 
1.7.7.6

Reply via email to