]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
ext2fs: always attempt to load nls table when loading the filesystem
authorGabriel Krisman Bertazi <krisman@collabora.com>
Sun, 28 Apr 2019 19:06:27 +0000 (15:06 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 28 Apr 2019 19:06:27 +0000 (15:06 -0400)
fs->encoding is exposed by the library, so we need to at least try to
load it when populating ext2_filsys.  Nevertheless, failing to do so
shouldn't be a fatal error, unless the user really needs that
information.  Thus, we ignore this failure during open/initialization
and let the user who needs it validate that field before trying to use
it.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/unix.c
lib/ext2fs/initialize.c
lib/ext2fs/openfs.c

index 5b3552ece6b1fcd7f59bb62a742a92914b65856b..7c24f2e31e4f81d8e68f3e41eac58c60cf6efad9 100644 (file)
@@ -55,7 +55,6 @@ extern int optind;
 #include "problem.h"
 #include "jfs_user.h"
 #include "../version.h"
-#include <ext2fs/nls.h>
 
 /* Command line options */
 static int cflag;              /* check disk */
@@ -1785,13 +1784,10 @@ print_unsupp_features:
                goto get_newer;
        }
 
-       if (ext2fs_has_feature_fname_encoding(sb)) {
-               fs->encoding = nls_load_table(sb->s_encoding);
-               if (!fs->encoding) {
-                       log_err(ctx, _("%s has unsupported encoding: %0x\n"),
-                               ctx->filesystem_name, sb->s_encoding);
-                       goto get_newer;
-               }
+       if (ext2fs_has_feature_fname_encoding(sb) && !fs->encoding) {
+               log_err(ctx, _("%s has unsupported encoding: %0x\n"),
+                       ctx->filesystem_name, sb->s_encoding);
+               goto get_newer;
        }
 
        /*
index 30b1ae0333406a739fffd3e67c8d89550aebee85..2d470a070bcc5c5b8b2940c0312b1c6b01fd4acf 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "ext2_fs.h"
 #include "ext2fs.h"
+#include "nls.h"
 
 #ifndef O_BINARY
 #define O_BINARY 0
@@ -190,6 +191,9 @@ errcode_t ext2fs_initialize(const char *name, int flags,
        assign_field(s_encoding);
        assign_field(s_encoding_flags);
 
+       if (ext2fs_has_feature_fname_encoding(param))
+               fs->encoding = nls_load_table(param->s_encoding);
+
        if (super->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
                retval = EXT2_ET_UNSUPP_FEATURE;
                goto cleanup;
index 85d73e2a429b3837ab3e3db07abbaffae0852d20..9ee6cd07f7f3ea50e6fb41cd597dfedcf1cc4209 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "ext2fs.h"
 #include "e2image.h"
+#include "nls.h"
 
 blk64_t ext2fs_descriptor_block_loc2(ext2_filsys fs, blk64_t group_block,
                                     dgrp_t i)
@@ -502,6 +503,9 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
                ext2fs_set_feature_shared_blocks(fs->super);
        }
 
+       if (ext2fs_has_feature_fname_encoding(fs->super))
+               fs->encoding = nls_load_table(fs->super->s_encoding);
+
        fs->flags &= ~EXT2_FLAG_NOFREE_ON_ERROR;
        *ret_fs = fs;