From: Theodore Ts'o Date: Wed, 4 Jul 2007 18:10:46 +0000 (-0400) Subject: Compile the default mke2fs.conf into mke2fs program X-Git-Tag: v1.40.1~13 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=d48bc60459f3552d2f229d8ec041b7eb36787541;p=tools%2Fe2fsprogs.git Compile the default mke2fs.conf into mke2fs program People are getting surprised by mke2fs creating filesystems with different defaults than earlier versions of mke2fs if mke2fs.conf is not present. Having gotten two complaints about ramdisks getting created by with 4k blocksizes which then blow up when the ramdisk is mounted with a "Magic mismatch, very weird" error message from the kernel, let's fix this by making sure mke2fs has a built-in version of mke2fs.conf file. People can still override the built-in version of mke2fs.conf by editing /etc/mke2fs.conf, but this maintains the previous behavior. Addresses-Sourceforge-Bug: #1745818 Signed-off-by: "Theodore Ts'o" --- diff --git a/misc/Makefile.in b/misc/Makefile.in index 8dcae2e..ccad78c 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in @@ -29,7 +29,7 @@ LPROGS= @E2INITRD_PROG@ TUNE2FS_OBJS= tune2fs.o util.o MKLPF_OBJS= mklost+found.o -MKE2FS_OBJS= mke2fs.o util.o profile.o prof_err.o +MKE2FS_OBJS= mke2fs.o util.o profile.o prof_err.o default_profile.o CHATTR_OBJS= chattr.o LSATTR_OBJS= lsattr.o UUIDGEN_OBJS= uuidgen.o @@ -74,6 +74,10 @@ prof_err.c prof_err.h: $(srcdir)/../e2fsck/prof_err.et @echo " COMPILE_ET prof_err.et" @$(COMPILE_ET) $(srcdir)/../e2fsck/prof_err.et +default_profile.c: $(srcdir)/mke2fs.conf $(srcdir)/profile-to-c.awk + @echo " PROFILE_TO_C mke2fs.conf" + $(AWK) -f $(srcdir)/profile-to-c.awk < $(srcdir)/mke2fs.conf \ + > default_profile.c profile.o: @echo " CC $<" @$(CC) -c $(ALL_CFLAGS) $(srcdir)/../e2fsck/profile.c -o $@ @@ -351,7 +355,8 @@ clean: $(RM) -f $(SPROGS) $(USPROGS) $(UPROGS) $(UMANPAGES) $(SMANPAGES) \ $(FMANPAGES) \ base_device base_device.out mke2fs.static filefrag \ - e2initrd_helper partinfo prof_err.[ch] \#* *.s *.o *.a *~ core + e2initrd_helper partinfo prof_err.[ch] default_profile.c \ + \#* *.s *.o *.a *~ core mostlyclean: clean distclean: clean diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 0292a64..0c6d4f3 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -900,6 +900,9 @@ static void edit_feature(const char *str, __u32 *compat_array) } } +extern const char *mke2fs_default_profile; +static const char *default_files[] = { "", 0 }; + static void PRS(int argc, char *argv[]) { int b, c; @@ -958,7 +961,11 @@ static void PRS(int argc, char *argv[]) if ((tmp = getenv("MKE2FS_CONFIG")) != NULL) config_fn[0] = tmp; profile_set_syntax_err_cb(syntax_err_report); - profile_init(config_fn, &profile); + retval = profile_init(config_fn, &profile); + if (retval == ENOENT) { + profile_init(default_files, &profile); + profile_set_default(profile, mke2fs_default_profile); + } setbuf(stdout, NULL); setbuf(stderr, NULL); diff --git a/misc/profile-to-c.awk b/misc/profile-to-c.awk new file mode 100644 index 0000000..f964efd --- /dev/null +++ b/misc/profile-to-c.awk @@ -0,0 +1,12 @@ +#!/bin/awk +BEGIN { + printf("const char *mke2fs_default_profile = \n"); +} + +{ + printf(" \"%s\\n\"\n", $0); +} + +END { + printf(";\n", str) +}