Whamcloud - gitweb
Teach ext2fs_open2() to honor the EXT2_FLAG_SUPER_ONLY flag
[tools/e2fsprogs.git] / lib / ext2fs / openfs.c
index 9ee6cd0..ec2d6cb 100644 (file)
 
 #include "ext2_fs.h"
 
-
 #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)
@@ -395,6 +393,8 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
        }
        fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count,
                                          EXT2_DESC_PER_BLOCK(fs->super));
+       if (flags & EXT2_FLAG_SUPER_ONLY)
+               goto skip_read_bg;
        retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
                                &fs->group_desc);
        if (retval)
@@ -481,7 +481,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
                if (fs->flags & EXT2_FLAG_RW)
                        ext2fs_mark_super_dirty(fs);
        }
-
+skip_read_bg:
        if (ext2fs_has_feature_mmp(fs->super) &&
            !(flags & EXT2_FLAG_SKIP_MMP) &&
            (flags & (EXT2_FLAG_RW | EXT2_FLAG_EXCLUSIVE))) {
@@ -503,8 +503,8 @@ 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);
+       if (ext2fs_has_feature_casefold(fs->super))
+               fs->encoding = ext2fs_load_nls_table(fs->super->s_encoding);
 
        fs->flags &= ~EXT2_FLAG_NOFREE_ON_ERROR;
        *ret_fs = fs;