From: Robert Yang <liezhi.yang@windriver.com>
To: <tytso@mit.edu>, <dvhart@linux.intel.com>
Cc: <linux-ext4@vger.kernel.org>
Subject: [PATCH V4 08/11] mke2fs.c: add an option: -d root-directory
Date: Sat, 1 Mar 2014 03:06:12 -0500 [thread overview]
Message-ID: <1393661175-459-9-git-send-email-liezhi.yang@windriver.com> (raw)
In-Reply-To: <1393661175-459-1-git-send-email-liezhi.yang@windriver.com>
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 <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
---
misc/Makefile.in | 13 +++++++++----
misc/mke2fs.c | 31 ++++++++++++++++++++++---------
2 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/misc/Makefile.in b/misc/Makefile.in
index 29b6aab..fbd09a5 100644
--- a/misc/Makefile.in
+++ b/misc/Makefile.in
@@ -43,7 +43,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 \
- mk_hugefiles.o
+ mk_hugefiles.o create_inode.o
CHATTR_OBJS= chattr.o
LSATTR_OBJS= lsattr.o
UUIDGEN_OBJS= uuidgen.o
@@ -61,7 +61,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
@@ -83,7 +84,7 @@ SRCS= $(srcdir)/tune2fs.c $(srcdir)/mklost+found.c $(srcdir)/mke2fs.c $(srcdir)/
$(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)
@@ -646,7 +647,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 \
$(srcdir)/mke2fs.h
@@ -737,3 +738,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 facbe4c..b76b07e 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -22,7 +22,6 @@
#include <stdio.h>
#include <string.h>
#include <strings.h>
-#include <fcntl.h>
#include <ctype.h>
#include <time.h>
#ifdef __linux__
@@ -45,25 +44,20 @@ extern int optind;
#include <errno.h>
#endif
#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <libgen.h>
#include <limits.h>
#include <blkid/blkid.h>
#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 "mke2fs.h"
+#include "create_inode.h"
#define STRIDE_LENGTH 8
@@ -111,6 +105,7 @@ static char *mount_dir;
char *journal_device;
static int sync_kludge; /* Set using the MKE2FS_SYNC env. option */
char **fs_types;
+const char *root_dir; /* Copy files from the specified directory */
static profile_t profile;
@@ -122,7 +117,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[,...]] "
@@ -1526,7 +1522,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);
@@ -1714,6 +1710,9 @@ profile_error:
case 'U':
fs_uuid = optarg;
break;
+ case 'd':
+ root_dir = optarg;
+ break;
case 'v':
verbose = 1;
break;
@@ -2967,6 +2966,20 @@ no_journal:
retval = mk_hugefiles(fs);
if (retval)
com_err(program_name, retval, "while creating huge files");
+ /* 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 file system"));
+ else if (!quiet)
+ printf("%s", _("done\n"));
+ }
if (!quiet)
printf("%s", _("Writing superblocks and "
--
1.7.10.4
next prev parent reply other threads:[~2014-03-01 8:06 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-01 8:06 [PATCH V4 00/11] 2fsprogs/mke2fs: add an option: -d root-directory Robert Yang
2014-03-01 8:06 ` [PATCH V4 01/11] mke2fs: add the ability to copy files from a given directory Robert Yang
2014-03-01 8:06 ` [PATCH V4 02/11] misc/create_inode.c: copy files recursively Robert Yang
2014-03-01 8:06 ` [PATCH V4 03/11] misc/create_inode.c: create special file Robert Yang
2014-03-01 8:06 ` [PATCH V4 04/11] misc/create_inode.c: create symlink Robert Yang
2014-03-01 8:06 ` [PATCH V4 05/11] misc/create_inode.c: copy regular file Robert Yang
2014-03-06 19:06 ` Darrick J. Wong
2014-03-06 19:47 ` Theodore Ts'o
2014-03-06 20:14 ` Darrick J. Wong
2014-03-06 22:57 ` Theodore Ts'o
2014-03-07 1:24 ` Robert Yang
2014-03-07 2:56 ` Darrick J. Wong
2014-03-07 3:22 ` Robert Yang
2014-03-07 2:38 ` Darrick J. Wong
2014-03-01 8:06 ` [PATCH V4 06/11] misc/create_inode.c: create directory Robert Yang
2014-03-01 8:06 ` [PATCH V4 07/11] misc/create_inode.c: set owner/mode/time for the inode Robert Yang
2014-03-01 8:06 ` Robert Yang [this message]
2014-03-01 8:06 ` [PATCH V4 09/11] misc/create_inode.c: handle hardlinks Robert Yang
2014-03-01 8:06 ` [PATCH V4 10/11] debugfs: use the functions in misc/create_inode.c Robert Yang
2014-03-01 8:06 ` [PATCH V4 11/11] mke2fs.8.in: update the manual for the -d option Robert Yang
2014-03-06 8:21 ` [PATCH V4 00/11] 2fsprogs/mke2fs: add an option: -d root-directory Darren Hart
2014-03-06 9:39 ` Robert Yang
2014-03-06 16:30 ` Theodore Ts'o
2014-03-07 2:51 ` Robert Yang
2014-03-07 2:59 ` Darrick J. Wong
2014-03-07 3:24 ` Robert Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1393661175-459-9-git-send-email-liezhi.yang@windriver.com \
--to=liezhi.yang@windriver.com \
--cc=dvhart@linux.intel.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).