From: Theodore Ts'o Date: Sat, 22 Sep 2012 21:07:46 +0000 (-0400) Subject: mke2fs: prohibit file system features not supported by the HURD X-Git-Tag: v1.43-WIP-2012-09-22~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48b35e238708c08e93b8b165014dc34257a05916;p=thirdparty%2Fe2fsprogs.git mke2fs: prohibit file system features not supported by the HURD There are certain file system features which can not be supported by the HURD, since they use fields in the inode which have been claimed by HURD-specific features (i.e., such as the author field). We will mask out those features so they are not enabled by accident, but if the user tries to explicitly specify them we will issue an error message. Signed-off-by: "Theodore Ts'o" --- diff --git a/misc/mke2fs.c b/misc/mke2fs.c index d4b396b2b..69cd9991c 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -655,6 +655,23 @@ static void show_stats(ext2_filsys fs) printf("\n\n"); } +/* + * Returns true if making a file system for the Hurd, else 0 + */ +static int for_hurd(const char *os) +{ + if (!os) { +#ifdef __GNU__ + return 1; +#else + return 0; +#endif + } + if (isdigit(*os)) + return (atoi(os) == EXT2_OS_HURD); + return (strcasecmp(os, "GNU") == 0 || strcasecmp(os, "hurd") == 0); +} + /* * Set the S_CREATOR_OS field. Return true if OS is known, * otherwise, 0. @@ -1027,15 +1044,11 @@ static char **parse_fs_type(const char *fs_type, const char *size_type; struct str_list list; unsigned long long meg; - int is_hurd = 0; + int is_hurd = for_hurd(creator_os); if (init_list(&list)) return 0; - if (creator_os && (!strcasecmp(creator_os, "GNU") || - !strcasecmp(creator_os, "hurd"))) - is_hurd = 1; - if (fs_type) ext_type = fs_type; else if (is_hurd) @@ -1705,10 +1718,40 @@ profile_error: tmp = get_string_from_profile(fs_types, "default_features", ""); } + /* Mask off features which aren't supported by the Hurd */ + if (for_hurd(creator_os)) { + fs_param.s_feature_incompat &= ~EXT2_FEATURE_INCOMPAT_FILETYPE; + fs_param.s_feature_ro_compat &= + ~(EXT4_FEATURE_RO_COMPAT_HUGE_FILE | + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM); + } edit_feature(fs_features ? fs_features : tmp, &fs_param.s_feature_compat); if (tmp) free(tmp); + /* + * If the user specified features incompatible with the Hurd, complain + */ + if (for_hurd(creator_os)) { + if (fs_param.s_feature_incompat & + EXT2_FEATURE_INCOMPAT_FILETYPE) { + fprintf(stderr, _("The HURD does not support the " + "filetype feature.\n")); + exit(1); + } + if (fs_param.s_feature_ro_compat & + EXT4_FEATURE_RO_COMPAT_HUGE_FILE) { + fprintf(stderr, _("The HURD does not support the " + "huge_file feature.\n")); + exit(1); + } + if (fs_param.s_feature_ro_compat & + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) { + fprintf(stderr, _("The HURD does not support the " + "metadata_csum feature.\n")); + exit(1); + } + } /* * We now need to do a sanity check of fs_blocks_count for