tune2fs: explain why an fsck is needed

Currently tune2fs just says without any explanation, "run fsck -f".
Add a short explanation that a freshly checked file system is required
to reduce user confusion.  (We could add even more details, but
hopefully this is enough.)

Addresses-Debian-Bug: #857336

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Theodore Ts'o 2017-08-23 10:57:25 -04:00
parent 9667504178
commit a120a5da24
5 changed files with 16 additions and 2 deletions

View File

@ -116,6 +116,8 @@ struct blk_move {
errcode_t ext2fs_run_ext3_journal(ext2_filsys *fs); errcode_t ext2fs_run_ext3_journal(ext2_filsys *fs);
static const char *fsck_explain = N_("\nThis operation requires a freshly checked filesystem.\n");
static const char *please_fsck = N_("Please run e2fsck -f on the filesystem.\n"); static const char *please_fsck = N_("Please run e2fsck -f on the filesystem.\n");
static const char *please_dir_fsck = static const char *please_dir_fsck =
N_("Please run e2fsck -fD on the filesystem.\n"); N_("Please run e2fsck -fD on the filesystem.\n");
@ -419,7 +421,8 @@ static void check_fsck_needed(ext2_filsys fs, const char *prompt)
if (!(fs->super->s_state & EXT2_VALID_FS) || if (!(fs->super->s_state & EXT2_VALID_FS) ||
(fs->super->s_state & EXT2_ERROR_FS) || (fs->super->s_state & EXT2_ERROR_FS) ||
(fs->super->s_lastcheck < fs->super->s_mtime)) { (fs->super->s_lastcheck < fs->super->s_mtime)) {
printf("\n%s\n", _(please_fsck)); puts(_(fsck_explain));
puts(_(please_fsck));
if (mount_flags & EXT2_MF_READONLY) if (mount_flags & EXT2_MF_READONLY)
printf("%s", _("(and reboot afterwards!)\n")); printf("%s", _("(and reboot afterwards!)\n"));
exit(1); exit(1);
@ -441,7 +444,8 @@ static void request_dir_fsck_afterwards(ext2_filsys fs)
return; return;
fsck_requested++; fsck_requested++;
fs->super->s_state &= ~EXT2_VALID_FS; fs->super->s_state &= ~EXT2_VALID_FS;
printf("\n%s\n", _(please_dir_fsck)); puts(_(fsck_explain));
puts(_(please_dir_fsck));
if (mount_flags & EXT2_MF_READONLY) if (mount_flags & EXT2_MF_READONLY)
printf("%s", _("(and reboot afterwards!)\n")); printf("%s", _("(and reboot afterwards!)\n"));
} }

View File

@ -11,6 +11,8 @@ Writing superblocks and filesystem accounting information: done
tune2fs -O metadata_csum test.img tune2fs -O metadata_csum test.img
This operation requires a freshly checked filesystem.
Please run e2fsck -f on the filesystem. Please run e2fsck -f on the filesystem.
Exit status is 1 Exit status is 1
@ -57,6 +59,8 @@ Exit status is 0
tune2fs -O metadata_csum test.img tune2fs -O metadata_csum test.img
Enabling checksums could take some time. Enabling checksums could take some time.
Proceed anyway (or wait 5 seconds) ? (y,N) Proceed anyway (or wait 5 seconds) ? (y,N)
This operation requires a freshly checked filesystem.
Please run e2fsck -fD on the filesystem. Please run e2fsck -fD on the filesystem.
Exit status is 0 Exit status is 0

View File

@ -18,6 +18,8 @@ Pass 5: Checking group summary information
Exit status is 0 Exit status is 0
tune2fs -O metadata_csum test.img tune2fs -O metadata_csum test.img
This operation requires a freshly checked filesystem.
Please run e2fsck -fD on the filesystem. Please run e2fsck -fD on the filesystem.
Exit status is 0 Exit status is 0

View File

@ -18,6 +18,8 @@ Pass 5: Checking group summary information
Exit status is 0 Exit status is 0
tune2fs -O metadata_csum test.img tune2fs -O metadata_csum test.img
This operation requires a freshly checked filesystem.
Please run e2fsck -fD on the filesystem. Please run e2fsck -fD on the filesystem.
Exit status is 0 Exit status is 0

View File

@ -19,6 +19,8 @@ Exit status is 0
tune2fs -I 256 -O metadata_csum test.img tune2fs -I 256 -O metadata_csum test.img
Setting inode size 256 Setting inode size 256
This operation requires a freshly checked filesystem.
Please run e2fsck -fD on the filesystem. Please run e2fsck -fD on the filesystem.
Exit status is 0 Exit status is 0