Requires a tweak to gfs2_edit to allow journal dinode fields to be
modified by keyword.

Signed-off-by: Andrew Price <anpr...@redhat.com>
---
 gfs2/edit/hexedit.c | 5 +++--
 tests/fsck.at       | 9 +++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 5cdea684..f015828c 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -2486,8 +2486,9 @@ static void process_parameters(int argc, char *argv[], 
int pass)
                }
                if (termlines || strchr(argv[i],'/')) /* if print or slash */
                        continue;
-                       
-               if (!strncmp(argv[i], "journal", 7) && isdigit(argv[i][7])) {
+
+               if (!strncmp(argv[i], "journal", 7) && isdigit(argv[i][7]) &&
+                   strcmp(argv[i+1], "field")) {
                        int blk = 0;
 
                        if (i < argc - 1 && isdigit(argv[i + 1][0])) {
diff --git a/tests/fsck.at b/tests/fsck.at
index 0dfeac33..39a04d04 100644
--- a/tests/fsck.at
+++ b/tests/fsck.at
@@ -45,3 +45,12 @@ AT_SETUP([Fix bad rindex entry #1])
 AT_KEYWORDS(fsck.gfs2 fsck)
 GFS_NUKERG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [-i 1])
 AT_CLEANUP
+
+AT_SETUP([Rebuild bad journal])
+AT_KEYWORDS(fsck.gfs2 fsck)
+GFS_TGT_REGEN
+AT_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([gfs2_edit -p journal0 field di_header.mh_magic 0 $GFS_TGT], 0, 
[ignore], [ignore])
+AT_CHECK([fsck.gfs2 -y $GFS_TGT], 1, [ignore], [ignore])
+AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore])
+AT_CLEANUP
-- 
2.14.3

Reply via email to