From patchwork Fri Dec 27 09:09:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Yang X-Patchwork-Id: 305435 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 5C62B2C0090 for ; Fri, 27 Dec 2013 20:09:32 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754335Ab3L0JJ3 (ORCPT ); Fri, 27 Dec 2013 04:09:29 -0500 Received: from mail.windriver.com ([147.11.1.11]:55138 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754299Ab3L0JJY (ORCPT ); Fri, 27 Dec 2013 04:09:24 -0500 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail.windriver.com (8.14.5/8.14.5) with ESMTP id rBR99LWV006131 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Fri, 27 Dec 2013 01:09:22 -0800 (PST) Received: from pek-hostel-vm02.wrs.com (128.224.153.172) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.2.347.0; Fri, 27 Dec 2013 01:09:21 -0800 From: Robert Yang To: , CC: Subject: [PATCH V3 08/11] mke2fs.c: add an option: -d root-directory Date: Fri, 27 Dec 2013 04:09:02 -0500 Message-ID: <1388135345-2006-9-git-send-email-liezhi.yang@windriver.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1388135345-2006-1-git-send-email-liezhi.yang@windriver.com> References: <1388135345-2006-1-git-send-email-liezhi.yang@windriver.com> MIME-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This option is used for adding the files from a given directory (the root-directory) to the filesystem, it is similiar to genext2fs, but genext2fs doesn't fully support ext4. Signed-off-by: Robert Yang Reviewed-by: Darren Hart --- misc/Makefile.in | 13 +++++++++---- misc/mke2fs.c | 32 +++++++++++++++++++++++--------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/misc/Makefile.in b/misc/Makefile.in index 553c361..15860dd 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in @@ -42,7 +42,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 default_profile.o +MKE2FS_OBJS= mke2fs.o util.o profile.o prof_err.o default_profile.o create_inode.o CHATTR_OBJS= chattr.o LSATTR_OBJS= lsattr.o UUIDGEN_OBJS= uuidgen.o @@ -60,7 +60,8 @@ E2FREEFRAG_OBJS= e2freefrag.o PROFILED_TUNE2FS_OBJS= profiled/tune2fs.o profiled/util.o PROFILED_MKLPF_OBJS= profiled/mklost+found.o PROFILED_MKE2FS_OBJS= profiled/mke2fs.o profiled/util.o profiled/profile.o \ - profiled/prof_err.o profiled/default_profile.o + profiled/prof_err.o profiled/default_profile.o \ + profiled/create_inode.o PROFILED_CHATTR_OBJS= profiled/chattr.o PROFILED_LSATTR_OBJS= profiled/lsattr.o PROFILED_UUIDGEN_OBJS= profiled/uuidgen.o @@ -82,7 +83,7 @@ SRCS= $(srcdir)/tune2fs.c $(srcdir)/mklost+found.c $(srcdir)/mke2fs.c \ $(srcdir)/uuidgen.c $(srcdir)/blkid.c $(srcdir)/logsave.c \ $(srcdir)/filefrag.c $(srcdir)/base_device.c \ $(srcdir)/ismounted.c $(srcdir)/../e2fsck/profile.c \ - $(srcdir)/e2undo.c $(srcdir)/e2freefrag.c + $(srcdir)/e2undo.c $(srcdir)/e2freefrag.c $(srcdir)/create_inode.c LIBS= $(LIBEXT2FS) $(LIBCOM_ERR) DEPLIBS= $(LIBEXT2FS) $(DEPLIBCOM_ERR) @@ -630,7 +631,7 @@ mke2fs.o: $(srcdir)/mke2fs.c $(top_builddir)/lib/config.h \ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \ $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/lib/ext2fs/ext2fs.h \ $(srcdir)/util.h profile.h prof_err.h $(top_srcdir)/version.h \ - $(srcdir)/nls-enable.h $(top_srcdir)/lib/quota/mkquota.h \ + $(srcdir)/nls-enable.h $(top_srcdir)/lib/quota/mkquota.h $(srcdir)/create_inode.h\ $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \ $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h chattr.o: $(srcdir)/chattr.c $(top_builddir)/lib/config.h \ @@ -710,3 +711,7 @@ e2freefrag.o: $(srcdir)/e2freefrag.c $(top_builddir)/lib/config.h \ $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \ $(srcdir)/e2freefrag.h +create_inode.o: $(srcdir)/create_inode.h $(srcdir)/create_inode.c \ + $(top_builddir)/lib/config.h $(top_srcdir)/lib/ext2fs/ext2fs.h \ + $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/e2p/e2p.h \ + $(srcdir)/nls-enable.h diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 64d5a46..5a908d1 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #ifdef __linux__ @@ -44,24 +43,19 @@ extern int optind; #include #endif #include -#include -#include #include #include #include #include "ext2fs/ext2_fs.h" #include "ext2fs/ext2fsP.h" -#include "et/com_err.h" #include "uuid/uuid.h" -#include "e2p/e2p.h" -#include "ext2fs/ext2fs.h" #include "util.h" #include "profile.h" #include "prof_err.h" #include "../version.h" -#include "nls-enable.h" #include "quota/mkquota.h" +#include "create_inode.h" #define STRIDE_LENGTH 8 @@ -105,6 +99,7 @@ static char *mount_dir; char *journal_device; static int sync_kludge; /* Set using the MKE2FS_SYNC env. option */ static char **fs_types; +const char *root_dir; /* Copy files from the specified directory */ static profile_t profile; @@ -116,7 +111,8 @@ static void usage(void) fprintf(stderr, _("Usage: %s [-c|-l filename] [-b block-size] " "[-C cluster-size]\n\t[-i bytes-per-inode] [-I inode-size] " "[-J journal-options]\n" - "\t[-G flex-group-size] [-N number-of-inodes]\n" + "\t[-G flex-group-size] [-N number-of-inodes] " + "[-d root-directory]\n" "\t[-m reserved-blocks-percentage] [-o creator-os]\n" "\t[-g blocks-per-group] [-L volume-label] " "[-M last-mounted-directory]\n\t[-O feature[,...]] " @@ -1434,7 +1430,7 @@ profile_error: } while ((c = getopt (argc, argv, - "b:cg:i:jl:m:no:qr:s:t:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:V")) != EOF) { + "b:cg:i:jl:m:no:qr:s:t:d:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:V")) != EOF) { switch (c) { case 'b': blocksize = parse_num_blocks2(optarg, -1); @@ -1622,6 +1618,9 @@ profile_error: case 'U': fs_uuid = optarg; break; + case 'd': + root_dir = optarg; + break; case 'v': verbose = 1; break; @@ -2829,6 +2828,21 @@ no_journal: EXT4_FEATURE_RO_COMPAT_QUOTA)) create_quota_inodes(fs); + /* Copy files from the specified directory */ + if (root_dir) { + if (!quiet) + printf("%s", _("Copying files into the device: ")); + + current_fs = fs; + root = EXT2_ROOT_INO; + retval = populate_fs(root, root_dir); + if (retval) + fprintf(stderr, "%s", + _("\nError while populating %s"), root_dir); + else if (!quiet) + printf("%s", _("done\n")); + } + if (!quiet) printf("%s", _("Writing superblocks and " "filesystem accounting information: "));