diff --git a/misc/Makefile.in b/misc/Makefile.in index 8dcae2ed..ccad78cd 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 0292a643..0c6d4f30 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 00000000..f964efd6 --- /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) +}