summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/e2fsprogs
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2016-01-13 17:37:28 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-18 11:47:03 +0000
commit8c3276ecea38d4d67c22e6db49060b2d4b457278 (patch)
treea08abeadef1a30dff799b50755a33a4faf8ab33c /meta/recipes-devtools/e2fsprogs
parentb248e55c0c39a4d45adc0690f2eefb332ab233f5 (diff)
downloadpoky-8c3276ecea38d4d67c22e6db49060b2d4b457278.tar.gz
e2fsprogs: 1.42.9 -> 1.43 (master)
Upgrade to 1.43 (master) to make "mke2fs -d" support xattr, so that the layer which requires xattr such as meta-selinux can populate images easily. * Remove the following patches since they are alredy in the source. 0001-e2fsprogs-fix-cross-compilation-problem.patch 0001-libext2fs-fix-potential-buffer-overflow-in-closefs.patch 0001-mke2fs-add-the-ability-to-copy-files-from-a-given-di.patch 0002-misc-create_inode.c-copy-files-recursively.patch 0003-misc-create_inode.c-create-special-file.patch 0004-misc-create_inode.c-create-symlink.patch 0005-misc-create_inode.c-copy-regular-file.patch 0006-misc-create_inode.c-create-directory.patch 0007-misc-create_inode.c-set-owner-mode-time-for-the-inod.patch 0008-mke2fs.c-add-an-option-d-root-directory.patch 0009-misc-create_inode.c-handle-hardlinks.patch 0010-debugfs-use-the-functions-in-misc-create_inode.c.patch 0011-mke2fs.8.in-update-the-manual-for-the-d-option.patch 0012-Fix-musl-build-failures.patch CVE-2015-0247.patch copy-in-create-hardlinks-with-the-correct-directory-.patch fix-icache.patch misc-mke2fs.c-return-error-when-failed-to-populate-fs.patch * Remove cache_inode.patch since it is not needed any more * Updated mkdir.patch and ptest.patch * Add --enable-libblkid to EXTRA_OECONF since libblkid is not created by default. * Time of core-image-sato-sdk do_rootfs: - Before upgrade real 3m18.508s user 7m42.088s sys 1m1.984s - After upgrade real 3m21.552s user 7m38.496s sys 1m0.644s The are nearly the same * The "fsck -f" shows the image is OK, and also can boot. [YOCTO #8622] (From OE-Core rev: a1f235ad736d322bb50eb4a4293b6b2f4e5200aa) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/e2fsprogs')
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs.inc8
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-e2fsprogs-fix-cross-compilation-problem.patch55
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-libext2fs-fix-potential-buffer-overflow-in-closefs.patch59
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-mke2fs-add-the-ability-to-copy-files-from-a-given-di.patch98
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0002-misc-create_inode.c-copy-files-recursively.patch135
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0003-misc-create_inode.c-create-special-file.patch103
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0004-misc-create_inode.c-create-symlink.patch63
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0005-misc-create_inode.c-copy-regular-file.patch224
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0006-misc-create_inode.c-create-directory.patch62
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0007-misc-create_inode.c-set-owner-mode-time-for-the-inod.patch81
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0008-mke2fs.c-add-an-option-d-root-directory.patch168
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0009-misc-create_inode.c-handle-hardlinks.patch210
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0010-debugfs-use-the-functions-in-misc-create_inode.c.patch496
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0011-mke2fs.8.in-update-the-manual-for-the-d-option.patch43
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/0012-Fix-musl-build-failures.patch54
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/CVE-2015-0247.patch58
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/cache_inode.patch52
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/copy-in-create-hardlinks-with-the-correct-directory-.patch81
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/fix-icache.patch65
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/misc-mke2fs.c-return-error-when-failed-to-populate-fs.patch37
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/mkdir.patch32
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs/ptest.patch35
-rw-r--r--meta/recipes-devtools/e2fsprogs/e2fsprogs_git.bb (renamed from meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bb)44
23 files changed, 43 insertions, 2220 deletions
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs.inc b/meta/recipes-devtools/e2fsprogs/e2fsprogs.inc
index bcd9ba7590..09e4ea5bb6 100644
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs.inc
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs.inc
@@ -19,7 +19,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=b48f21d765b875bd10400975d12c1ca2 \
19SECTION = "base" 19SECTION = "base"
20DEPENDS = "util-linux" 20DEPENDS = "util-linux"
21 21
22SRC_URI = "${SOURCEFORGE_MIRROR}/e2fsprogs/e2fsprogs-${PV}.tar.gz \ 22SRC_URI = "git://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git"
23 file://mkdir.patch" 23S = "${WORKDIR}/git"
24 24
25inherit autotools gettext texinfo pkgconfig multilib_header 25inherit autotools gettext texinfo pkgconfig multilib_header update-alternatives ptest
26
27BBCLASSEXTEND = "native nativesdk"
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-e2fsprogs-fix-cross-compilation-problem.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-e2fsprogs-fix-cross-compilation-problem.patch
deleted file mode 100644
index 73043bedda..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-e2fsprogs-fix-cross-compilation-problem.patch
+++ /dev/null
@@ -1,55 +0,0 @@
1Upstream-Status: Pending
2
3Subject: e2fsprogs: fix cross compilation problem
4
5The checking of types in parse-types.sh doesn't make much sense in a
6cross-compilation environment, because the generated binary is executed
7on build machine.
8
9So even if asm_types.h has got correct statements for types, it's possible
10that the generated binary will report an error. Because these types are for
11the target machine.
12
13Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
14---
15 config/parse-types.sh | 6 ++++--
16 configure.in | 6 +++++-
17 2 files changed, 9 insertions(+), 3 deletions(-)
18
19diff --git a/config/parse-types.sh b/config/parse-types.sh
20index 5076f6c..24d2a99 100755
21--- a/config/parse-types.sh
22+++ b/config/parse-types.sh
23@@ -118,8 +118,10 @@ if ./asm_types
24 then
25 true
26 else
27- echo "Problem detected with asm_types.h"
28- echo "" > asm_types.h
29+ if [ "${CROSS_COMPILE}" != "1" ]; then
30+ echo "Problem detected with asm_types.h"
31+ echo "" > asm_types.h
32+ fi
33 fi
34 rm asm_types.c asm_types
35
36diff --git a/configure.in b/configure.in
37index 68adf0d..ed1697b 100644
38--- a/configure.in
39+++ b/configure.in
40@@ -953,7 +953,11 @@ AC_SUBST(SIZEOF_LONG)
41 AC_SUBST(SIZEOF_LONG_LONG)
42 AC_SUBST(SIZEOF_OFF_T)
43 AC_C_BIGENDIAN
44-BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
45+if test $cross_compiling = no; then
46+ BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
47+else
48+ CROSS_COMPILE="1" BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
49+fi
50 ASM_TYPES_HEADER=./asm_types.h
51 AC_SUBST_FILE(ASM_TYPES_HEADER)
52 dnl
53--
541.7.9.5
55
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-libext2fs-fix-potential-buffer-overflow-in-closefs.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-libext2fs-fix-potential-buffer-overflow-in-closefs.patch
deleted file mode 100644
index b904e46bda..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-libext2fs-fix-potential-buffer-overflow-in-closefs.patch
+++ /dev/null
@@ -1,59 +0,0 @@
1From 49d0fe2a14f2a23da2fe299643379b8c1d37df73 Mon Sep 17 00:00:00 2001
2From: Theodore Ts'o <tytso@mit.edu>
3Date: Fri, 6 Feb 2015 12:46:39 -0500
4Subject: [PATCH] libext2fs: fix potential buffer overflow in closefs()
5
6Upstream-Status: Backport
7CVE: CVE-2015-1572
8
9The bug fix in f66e6ce4446: "libext2fs: avoid buffer overflow if
10s_first_meta_bg is too big" had a typo in the fix for
11ext2fs_closefs(). In practice most of the security exposure was from
12the openfs path, since this meant if there was a carefully crafted
13file system, buffer overrun would be triggered when the file system was
14opened.
15
16However, if corrupted file system didn't trip over some corruption
17check, and then the file system was modified via tune2fs or debugfs,
18such that the superblock was marked dirty and then written out via the
19closefs() path, it's possible that the buffer overrun could be
20triggered when the file system is closed.
21
22Also clear up a signed vs unsigned warning while we're at it.
23
24Thanks to Nick Kralevich <nnk@google.com> for asking me to look at
25compiler warning in the code in question, which led me to notice the
26bug in f66e6ce4446.
27
28Addresses: CVE-2015-1572
29
30Signed-off-by: Theodore Ts'o <tytso@mit.edu>
31---
32 lib/ext2fs/closefs.c | 4 ++--
33 1 file changed, 2 insertions(+), 2 deletions(-)
34
35diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
36index 1f99113..ab5b2fb 100644
37--- a/lib/ext2fs/closefs.c
38+++ b/lib/ext2fs/closefs.c
39@@ -287,7 +287,7 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)
40 dgrp_t j;
41 #endif
42 char *group_ptr;
43- int old_desc_blocks;
44+ blk64_t old_desc_blocks;
45 struct ext2fs_numeric_progress_struct progress;
46
47 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
48@@ -346,7 +346,7 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)
49 group_ptr = (char *) group_shadow;
50 if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) {
51 old_desc_blocks = fs->super->s_first_meta_bg;
52- if (old_desc_blocks > fs->super->s_first_meta_bg)
53+ if (old_desc_blocks > fs->desc_blocks)
54 old_desc_blocks = fs->desc_blocks;
55 } else
56 old_desc_blocks = fs->desc_blocks;
57--
582.1.0
59
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-mke2fs-add-the-ability-to-copy-files-from-a-given-di.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-mke2fs-add-the-ability-to-copy-files-from-a-given-di.patch
deleted file mode 100644
index 9ea413ef57..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-mke2fs-add-the-ability-to-copy-files-from-a-given-di.patch
+++ /dev/null
@@ -1,98 +0,0 @@
1From c98fec004f077e566b9dfa20b25e3b86cb462a2e Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Tue, 24 Dec 2013 01:41:08 -0500
4Subject: [PATCH 01/11] mke2fs: add the ability to copy files from a given
5 directory
6
7We will add a -d option which will be used for adding the files from a
8given directory to the filesystem, it is similiar to genext2fs, but
9genext2fs doesn't fully support ext4.
10
11* We already have the basic operations in debugfs:
12 - Copy regular file
13 - Create directory
14 - Create symlink
15 - Create special file
16
17 We will move these operations into create_inode.h and create_inode.c,
18 then let both mke2fs and debugfs use them.
19
20* What we need to do are:
21 - Copy the given directory recursively, this will be done by the
22 populate_fs()
23 - Set the owner, mode and other informations
24 - Handle the hard links
25
26TODO:
27 - The libext2fs can't create the socket file (S_IFSOCK), do we have a
28 plan to support it ?
29
30Upstream-Status: Backport
31
32Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
33Reviewed-by: Darren Hart <dvhart@linux.intel.com>
34---
35 misc/create_inode.c | 26 ++++++++++++++++++++++++++
36 misc/create_inode.h | 17 +++++++++++++++++
37 2 files changed, 43 insertions(+)
38 create mode 100644 misc/create_inode.c
39 create mode 100644 misc/create_inode.h
40
41diff --git a/misc/create_inode.c b/misc/create_inode.c
42new file mode 100644
43index 0000000..46aaa60
44--- /dev/null
45+++ b/misc/create_inode.c
46@@ -0,0 +1,26 @@
47+#include "create_inode.h"
48+
49+/* Make a special file which is block, character and fifo */
50+errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st)
51+{
52+}
53+
54+/* Make a symlink name -> target */
55+errcode_t do_symlink_internal(ext2_ino_t cwd, const char *name, char *target)
56+{
57+}
58+
59+/* Make a directory in the fs */
60+errcode_t do_mkdir_internal(ext2_ino_t cwd, const char *name, struct stat *st)
61+{
62+}
63+
64+/* Copy the native file to the fs */
65+errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest)
66+{
67+}
68+
69+/* Copy files from source_dir to fs */
70+errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir)
71+{
72+}
73diff --git a/misc/create_inode.h b/misc/create_inode.h
74new file mode 100644
75index 0000000..9fc97fa
76--- /dev/null
77+++ b/misc/create_inode.h
78@@ -0,0 +1,17 @@
79+#include <sys/types.h>
80+#include <sys/stat.h>
81+#include <fcntl.h>
82+#include "et/com_err.h"
83+#include "e2p/e2p.h"
84+#include "ext2fs/ext2fs.h"
85+#include "nls-enable.h"
86+
87+ext2_filsys current_fs;
88+ext2_ino_t root;
89+
90+/* For populating the filesystem */
91+extern errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir);
92+extern errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st);
93+extern errcode_t do_symlink_internal(ext2_ino_t cwd, const char *name, char *target);
94+extern errcode_t do_mkdir_internal(ext2_ino_t cwd, const char *name, struct stat *st);
95+extern errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest);
96--
971.7.10.4
98
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0002-misc-create_inode.c-copy-files-recursively.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0002-misc-create_inode.c-copy-files-recursively.patch
deleted file mode 100644
index 9bff644ea6..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0002-misc-create_inode.c-copy-files-recursively.patch
+++ /dev/null
@@ -1,135 +0,0 @@
1From 08dfbaf4e3f704232ff46d78c0758a6cfe3961c8 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Mon, 23 Dec 2013 02:59:10 -0500
4Subject: [PATCH 02/11] misc/create_inode.c: copy files recursively
5
6Use opendir() and readdir() to read the native directory, then use
7lstat() to identify the file type and call the corresponding function to
8add the file to the filesystem, call the populate_fs() recursively if it
9is a directory.
10
11NOTE: the libext2fs can't create the socket file.
12
13Upstream-Status: Backport
14
15Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
16Reviewed-by: Darren Hart <dvhart@linux.intel.com>
17---
18 misc/create_inode.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++
19 1 file changed, 97 insertions(+)
20
21diff --git a/misc/create_inode.c b/misc/create_inode.c
22index 46aaa60..b68b910 100644
23--- a/misc/create_inode.c
24+++ b/misc/create_inode.c
25@@ -1,5 +1,13 @@
26 #include "create_inode.h"
27
28+#if __STDC_VERSION__ < 199901L
29+# if __GNUC__ >= 2
30+# define __func__ __FUNCTION__
31+# else
32+# define __func__ "<unknown>"
33+# endif
34+#endif
35+
36 /* Make a special file which is block, character and fifo */
37 errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st)
38 {
39@@ -23,4 +31,93 @@ errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest)
40 /* Copy files from source_dir to fs */
41 errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir)
42 {
43+ const char *name;
44+ DIR *dh;
45+ struct dirent *dent;
46+ struct stat st;
47+ char ln_target[PATH_MAX];
48+ ext2_ino_t ino;
49+ errcode_t retval;
50+ int read_cnt;
51+
52+ root = EXT2_ROOT_INO;
53+
54+ if (chdir(source_dir) < 0) {
55+ com_err(__func__, errno,
56+ _("while changing working directory to \"%s\""), source_dir);
57+ return errno;
58+ }
59+
60+ if (!(dh = opendir("."))) {
61+ com_err(__func__, errno,
62+ _("while openning directory \"%s\""), source_dir);
63+ return errno;
64+ }
65+
66+ while((dent = readdir(dh))) {
67+ if((!strcmp(dent->d_name, ".")) || (!strcmp(dent->d_name, "..")))
68+ continue;
69+ lstat(dent->d_name, &st);
70+ name = dent->d_name;
71+
72+ switch(st.st_mode & S_IFMT) {
73+ case S_IFCHR:
74+ case S_IFBLK:
75+ case S_IFIFO:
76+ if ((retval = do_mknod_internal(parent_ino, name, &st))) {
77+ com_err(__func__, retval,
78+ _("while creating special file \"%s\""), name);
79+ return retval;
80+ }
81+ break;
82+ case S_IFSOCK:
83+ /* FIXME: there is no make socket function atm. */
84+ com_err(__func__, 0,
85+ _("ignoring socket file \"%s\""), name);
86+ continue;
87+ case S_IFLNK:
88+ if((read_cnt = readlink(name, ln_target, sizeof(ln_target))) == -1) {
89+ com_err(__func__, errno,
90+ _("while trying to readlink \"%s\""), name);
91+ return errno;
92+ }
93+ ln_target[read_cnt] = '\0';
94+ if ((retval = do_symlink_internal(parent_ino, name, ln_target))) {
95+ com_err(__func__, retval,
96+ _("while writing symlink\"%s\""), name);
97+ return retval;
98+ }
99+ break;
100+ case S_IFREG:
101+ if ((retval = do_write_internal(parent_ino, name, name))) {
102+ com_err(__func__, retval,
103+ _("while writing file \"%s\""), name);
104+ return retval;
105+ }
106+ break;
107+ case S_IFDIR:
108+ if ((retval = do_mkdir_internal(parent_ino, name, &st))) {
109+ com_err(__func__, retval,
110+ _("while making dir \"%s\""), name);
111+ return retval;
112+ }
113+ if ((retval = ext2fs_namei(current_fs, root, parent_ino, name, &ino))) {
114+ com_err(name, retval, 0);
115+ return retval;
116+ }
117+ /* Populate the dir recursively*/
118+ retval = populate_fs(ino, name);
119+ if (retval) {
120+ com_err(__func__, retval, _("while adding dir \"%s\""), name);
121+ return retval;
122+ }
123+ chdir("..");
124+ break;
125+ default:
126+ com_err(__func__, 0,
127+ _("ignoring entry \"%s\""), name);
128+ }
129+ }
130+ closedir(dh);
131+ return retval;
132 }
133--
1341.7.10.4
135
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0003-misc-create_inode.c-create-special-file.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0003-misc-create_inode.c-create-special-file.patch
deleted file mode 100644
index 3847b6e5ce..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0003-misc-create_inode.c-create-special-file.patch
+++ /dev/null
@@ -1,103 +0,0 @@
1From ae7d33823bfc330e08b25c5fe4d25838ef7c77ce Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Mon, 23 Dec 2013 03:13:28 -0500
4Subject: [PATCH 03/11] misc/create_inode.c: create special file
5
6The do_mknod_internal() is used for creating special file which is
7block, character and fifo, most of the code are from debugfs/debugfs.c,
8the debugfs/debugfs.c will be modified to use this function.
9
10Upstream-Status: Backport
11
12Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
13Reviewed-by: Darren Hart <dvhart@linux.intel.com>
14---
15 misc/create_inode.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++
16 1 file changed, 72 insertions(+)
17
18diff --git a/misc/create_inode.c b/misc/create_inode.c
19index b68b910..4da8aff 100644
20--- a/misc/create_inode.c
21+++ b/misc/create_inode.c
22@@ -11,6 +11,78 @@
23 /* Make a special file which is block, character and fifo */
24 errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st)
25 {
26+ ext2_ino_t ino;
27+ errcode_t retval;
28+ struct ext2_inode inode;
29+ unsigned long major, minor, mode;
30+ int filetype;
31+
32+ switch(st->st_mode & S_IFMT) {
33+ case S_IFCHR:
34+ mode = LINUX_S_IFCHR;
35+ filetype = EXT2_FT_CHRDEV;
36+ break;
37+ case S_IFBLK:
38+ mode = LINUX_S_IFBLK;
39+ filetype = EXT2_FT_BLKDEV;
40+ break;
41+ case S_IFIFO:
42+ mode = LINUX_S_IFIFO;
43+ filetype = EXT2_FT_FIFO;
44+ break;
45+ }
46+
47+ if (!(current_fs->flags & EXT2_FLAG_RW)) {
48+ com_err(__func__, 0, "Filesystem opened read/only");
49+ return -1;
50+ }
51+ retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &ino);
52+ if (retval) {
53+ com_err(__func__, retval, 0);
54+ return retval;
55+ }
56+
57+#ifdef DEBUGFS
58+ printf("Allocated inode: %u\n", ino);
59+#endif
60+ retval = ext2fs_link(current_fs, cwd, name, ino, filetype);
61+ if (retval == EXT2_ET_DIR_NO_SPACE) {
62+ retval = ext2fs_expand_dir(current_fs, cwd);
63+ if (retval) {
64+ com_err(__func__, retval, "while expanding directory");
65+ return retval;
66+ }
67+ retval = ext2fs_link(current_fs, cwd, name, ino, filetype);
68+ }
69+ if (retval) {
70+ com_err(name, retval, 0);
71+ return -1;
72+ }
73+ if (ext2fs_test_inode_bitmap2(current_fs->inode_map, ino))
74+ com_err(__func__, 0, "Warning: inode already set");
75+ ext2fs_inode_alloc_stats2(current_fs, ino, +1, 0);
76+ memset(&inode, 0, sizeof(inode));
77+ inode.i_mode = mode;
78+ inode.i_atime = inode.i_ctime = inode.i_mtime =
79+ current_fs->now ? current_fs->now : time(0);
80+
81+ major = major(st->st_rdev);
82+ minor = minor(st->st_rdev);
83+
84+ if ((major < 256) && (minor < 256)) {
85+ inode.i_block[0] = major * 256 + minor;
86+ inode.i_block[1] = 0;
87+ } else {
88+ inode.i_block[0] = 0;
89+ inode.i_block[1] = (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);
90+ }
91+ inode.i_links_count = 1;
92+
93+ retval = ext2fs_write_new_inode(current_fs, ino, &inode);
94+ if (retval)
95+ com_err(__func__, retval, "while creating inode %u", ino);
96+
97+ return retval;
98 }
99
100 /* Make a symlink name -> target */
101--
1021.7.10.4
103
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0004-misc-create_inode.c-create-symlink.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0004-misc-create_inode.c-create-symlink.patch
deleted file mode 100644
index 83d198c75a..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0004-misc-create_inode.c-create-symlink.patch
+++ /dev/null
@@ -1,63 +0,0 @@
1From 09d3049776882167f7249ee26265b4163d7222c1 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Mon, 23 Dec 2013 03:19:55 -0500
4Subject: [PATCH 04/11] misc/create_inode.c: create symlink
5
6The do_symlink_internal() is used for creating symlinks, most of the
7code are from debugfs/debugfs.c, the debugfs/debugfs.c will be modified
8to use this function.
9
10Upstream-Status: Backport
11
12Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
13Reviewed-by: Darren Hart <dvhart@linux.intel.com>
14---
15 misc/create_inode.c | 32 ++++++++++++++++++++++++++++++++
16 1 file changed, 32 insertions(+)
17
18diff --git a/misc/create_inode.c b/misc/create_inode.c
19index 4da8aff..f845103 100644
20--- a/misc/create_inode.c
21+++ b/misc/create_inode.c
22@@ -88,6 +88,38 @@ errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st)
23 /* Make a symlink name -> target */
24 errcode_t do_symlink_internal(ext2_ino_t cwd, const char *name, char *target)
25 {
26+ char *cp;
27+ ext2_ino_t parent_ino;
28+ errcode_t retval;
29+ struct ext2_inode inode;
30+ struct stat st;
31+
32+ cp = strrchr(name, '/');
33+ if (cp) {
34+ *cp = 0;
35+ if ((retval = ext2fs_namei(current_fs, root, cwd, name, &parent_ino))){
36+ com_err(name, retval, 0);
37+ return retval;
38+ }
39+ name = cp+1;
40+ } else
41+ parent_ino = cwd;
42+
43+try_again:
44+ retval = ext2fs_symlink(current_fs, parent_ino, 0, name, target);
45+ if (retval == EXT2_ET_DIR_NO_SPACE) {
46+ retval = ext2fs_expand_dir(current_fs, parent_ino);
47+ if (retval) {
48+ com_err("do_symlink_internal", retval, "while expanding directory");
49+ return retval;
50+ }
51+ goto try_again;
52+ }
53+ if (retval) {
54+ com_err("ext2fs_symlink", retval, 0);
55+ return retval;
56+ }
57+
58 }
59
60 /* Make a directory in the fs */
61--
621.7.10.4
63
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0005-misc-create_inode.c-copy-regular-file.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0005-misc-create_inode.c-copy-regular-file.patch
deleted file mode 100644
index 7935cd84ff..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0005-misc-create_inode.c-copy-regular-file.patch
+++ /dev/null
@@ -1,224 +0,0 @@
1From 2973c74afaa532f3f72639b463322b2523519c20 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Mon, 23 Dec 2013 03:28:12 -0500
4Subject: [PATCH 05/11] misc/create_inode.c: copy regular file
5
6The do_write_internal() is used for copying file from native fs to
7target, most of the code are from debugfs/debugfs.c, the
8debugfs/debugfs.c will be modified to use this function.
9
10Upstream-Status: Backport
11
12Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
13Reviewed-by: Darren Hart <dvhart@linux.intel.com>
14---
15 misc/create_inode.c | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++
16 1 file changed, 183 insertions(+)
17
18diff --git a/misc/create_inode.c b/misc/create_inode.c
19index f845103..98f4a93 100644
20--- a/misc/create_inode.c
21+++ b/misc/create_inode.c
22@@ -8,6 +8,16 @@
23 # endif
24 #endif
25
26+/* 64KiB is the minimium blksize to best minimize system call overhead. */
27+#ifndef IO_BUFSIZE
28+#define IO_BUFSIZE 64*1024
29+#endif
30+
31+/* Block size for `st_blocks' */
32+#ifndef S_BLKSIZE
33+#define S_BLKSIZE 512
34+#endif
35+
36 /* Make a special file which is block, character and fifo */
37 errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st)
38 {
39@@ -127,9 +137,182 @@ errcode_t do_mkdir_internal(ext2_ino_t cwd, const char *name, struct stat *st)
40 {
41 }
42
43+static errcode_t copy_file(int fd, ext2_ino_t newfile, int bufsize, int make_holes)
44+{
45+ ext2_file_t e2_file;
46+ errcode_t retval;
47+ int got;
48+ unsigned int written;
49+ char *buf;
50+ char *ptr;
51+ char *zero_buf;
52+ int cmp;
53+
54+ retval = ext2fs_file_open(current_fs, newfile,
55+ EXT2_FILE_WRITE, &e2_file);
56+ if (retval)
57+ return retval;
58+
59+ retval = ext2fs_get_mem(bufsize, &buf);
60+ if (retval) {
61+ com_err("copy_file", retval, "can't allocate buffer\n");
62+ return retval;
63+ }
64+
65+ /* This is used for checking whether the whole block is zero */
66+ retval = ext2fs_get_memzero(bufsize, &zero_buf);
67+ if (retval) {
68+ com_err("copy_file", retval, "can't allocate buffer\n");
69+ ext2fs_free_mem(&buf);
70+ return retval;
71+ }
72+
73+ while (1) {
74+ got = read(fd, buf, bufsize);
75+ if (got == 0)
76+ break;
77+ if (got < 0) {
78+ retval = errno;
79+ goto fail;
80+ }
81+ ptr = buf;
82+
83+ /* Sparse copy */
84+ if (make_holes) {
85+ /* Check whether all is zero */
86+ cmp = memcmp(ptr, zero_buf, got);
87+ if (cmp == 0) {
88+ /* The whole block is zero, make a hole */
89+ retval = ext2fs_file_lseek(e2_file, got, EXT2_SEEK_CUR, NULL);
90+ if (retval)
91+ goto fail;
92+ got = 0;
93+ }
94+ }
95+
96+ /* Normal copy */
97+ while (got > 0) {
98+ retval = ext2fs_file_write(e2_file, ptr,
99+ got, &written);
100+ if (retval)
101+ goto fail;
102+
103+ got -= written;
104+ ptr += written;
105+ }
106+ }
107+ ext2fs_free_mem(&buf);
108+ ext2fs_free_mem(&zero_buf);
109+ retval = ext2fs_file_close(e2_file);
110+ return retval;
111+
112+fail:
113+ ext2fs_free_mem(&buf);
114+ ext2fs_free_mem(&zero_buf);
115+ (void) ext2fs_file_close(e2_file);
116+ return retval;
117+}
118+
119 /* Copy the native file to the fs */
120 errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest)
121 {
122+ int fd;
123+ struct stat statbuf;
124+ ext2_ino_t newfile;
125+ errcode_t retval;
126+ struct ext2_inode inode;
127+ int bufsize = IO_BUFSIZE;
128+ int make_holes = 0;
129+
130+ fd = open(src, O_RDONLY);
131+ if (fd < 0) {
132+ com_err(src, errno, 0);
133+ return errno;
134+ }
135+ if (fstat(fd, &statbuf) < 0) {
136+ com_err(src, errno, 0);
137+ close(fd);
138+ return errno;
139+ }
140+
141+ retval = ext2fs_namei(current_fs, root, cwd, dest, &newfile);
142+ if (retval == 0) {
143+ com_err(__func__, 0, "The file '%s' already exists\n", dest);
144+ close(fd);
145+ return retval;
146+ }
147+
148+ retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &newfile);
149+ if (retval) {
150+ com_err(__func__, retval, 0);
151+ close(fd);
152+ return retval;
153+ }
154+#ifdef DEBUGFS
155+ printf("Allocated inode: %u\n", newfile);
156+#endif
157+ retval = ext2fs_link(current_fs, cwd, dest, newfile,
158+ EXT2_FT_REG_FILE);
159+ if (retval == EXT2_ET_DIR_NO_SPACE) {
160+ retval = ext2fs_expand_dir(current_fs, cwd);
161+ if (retval) {
162+ com_err(__func__, retval, "while expanding directory");
163+ close(fd);
164+ return retval;
165+ }
166+ retval = ext2fs_link(current_fs, cwd, dest, newfile,
167+ EXT2_FT_REG_FILE);
168+ }
169+ if (retval) {
170+ com_err(dest, retval, 0);
171+ close(fd);
172+ return retval;
173+ }
174+ if (ext2fs_test_inode_bitmap2(current_fs->inode_map, newfile))
175+ com_err(__func__, 0, "Warning: inode already set");
176+ ext2fs_inode_alloc_stats2(current_fs, newfile, +1, 0);
177+ memset(&inode, 0, sizeof(inode));
178+ inode.i_mode = (statbuf.st_mode & ~LINUX_S_IFMT) | LINUX_S_IFREG;
179+ inode.i_atime = inode.i_ctime = inode.i_mtime =
180+ current_fs->now ? current_fs->now : time(0);
181+ inode.i_links_count = 1;
182+ inode.i_size = statbuf.st_size;
183+ if (current_fs->super->s_feature_incompat &
184+ EXT3_FEATURE_INCOMPAT_EXTENTS) {
185+ int i;
186+ struct ext3_extent_header *eh;
187+
188+ eh = (struct ext3_extent_header *) &inode.i_block[0];
189+ eh->eh_depth = 0;
190+ eh->eh_entries = 0;
191+ eh->eh_magic = ext2fs_cpu_to_le16(EXT3_EXT_MAGIC);
192+ i = (sizeof(inode.i_block) - sizeof(*eh)) /
193+ sizeof(struct ext3_extent);
194+ eh->eh_max = ext2fs_cpu_to_le16(i);
195+ inode.i_flags |= EXT4_EXTENTS_FL;
196+ }
197+
198+ if ((retval = ext2fs_write_new_inode(current_fs, newfile, &inode))) {
199+ com_err(__func__, retval, "while creating inode %u", newfile);
200+ close(fd);
201+ return retval;
202+ }
203+ if (LINUX_S_ISREG(inode.i_mode)) {
204+ if (statbuf.st_blocks < statbuf.st_size / S_BLKSIZE) {
205+ make_holes = 1;
206+ /*
207+ * Use I/O blocksize as buffer size when
208+ * copying sparse files.
209+ */
210+ bufsize = statbuf.st_blksize;
211+ }
212+ retval = copy_file(fd, newfile, bufsize, make_holes);
213+ if (retval)
214+ com_err("copy_file", retval, 0);
215+ }
216+ close(fd);
217+
218+ return 0;
219 }
220
221 /* Copy files from source_dir to fs */
222--
2231.7.10.4
224
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0006-misc-create_inode.c-create-directory.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0006-misc-create_inode.c-create-directory.patch
deleted file mode 100644
index 5c7ca9c37e..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0006-misc-create_inode.c-create-directory.patch
+++ /dev/null
@@ -1,62 +0,0 @@
1From c8d1c43be24489036137f8fdebcfccc208f7cc8b Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Mon, 23 Dec 2013 03:34:14 -0500
4Subject: [PATCH 06/11] misc/create_inode.c: create directory
5
6The do_mkdir_internal() is used for making dir on the target fs, most of
7the code are from debugfs/debugfs.c, the debugfs/debugfs.c will be
8modified to use this function.
9
10Upstream-Status: Backport
11
12Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
13Reviewed-by: Darren Hart <dvhart@linux.intel.com>
14---
15 misc/create_inode.c | 31 +++++++++++++++++++++++++++++++
16 1 file changed, 31 insertions(+)
17
18diff --git a/misc/create_inode.c b/misc/create_inode.c
19index 98f4a93..6a8c92a 100644
20--- a/misc/create_inode.c
21+++ b/misc/create_inode.c
22@@ -135,6 +135,37 @@ try_again:
23 /* Make a directory in the fs */
24 errcode_t do_mkdir_internal(ext2_ino_t cwd, const char *name, struct stat *st)
25 {
26+ char *cp;
27+ ext2_ino_t parent_ino, ino;
28+ errcode_t retval;
29+ struct ext2_inode inode;
30+
31+
32+ cp = strrchr(name, '/');
33+ if (cp) {
34+ *cp = 0;
35+ if ((retval = ext2fs_namei(current_fs, root, cwd, name, &parent_ino))){
36+ com_err(name, retval, 0);
37+ return retval;
38+ }
39+ name = cp+1;
40+ } else
41+ parent_ino = cwd;
42+
43+try_again:
44+ retval = ext2fs_mkdir(current_fs, parent_ino, 0, name);
45+ if (retval == EXT2_ET_DIR_NO_SPACE) {
46+ retval = ext2fs_expand_dir(current_fs, parent_ino);
47+ if (retval) {
48+ com_err(__func__, retval, "while expanding directory");
49+ return retval;
50+ }
51+ goto try_again;
52+ }
53+ if (retval) {
54+ com_err("ext2fs_mkdir", retval, 0);
55+ return retval;
56+ }
57 }
58
59 static errcode_t copy_file(int fd, ext2_ino_t newfile, int bufsize, int make_holes)
60--
611.7.10.4
62
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0007-misc-create_inode.c-set-owner-mode-time-for-the-inod.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0007-misc-create_inode.c-set-owner-mode-time-for-the-inod.patch
deleted file mode 100644
index f296393b4f..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0007-misc-create_inode.c-set-owner-mode-time-for-the-inod.patch
+++ /dev/null
@@ -1,81 +0,0 @@
1From 2b1f6e6b386703a5d7e60b7d8b72746f3d31a8bc Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Mon, 23 Dec 2013 03:39:56 -0500
4Subject: [PATCH 07/11] misc/create_inode.c: set owner/mode/time for the inode
5
6Set the uid, gid, mode and time for inode.
7
8Upstream-Status: Backport
9
10Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
11Reviewed-by: Darren Hart <dvhart@linux.intel.com>
12---
13 misc/create_inode.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
14 1 file changed, 45 insertions(+)
15
16diff --git a/misc/create_inode.c b/misc/create_inode.c
17index 6a8c92a..aad7354 100644
18--- a/misc/create_inode.c
19+++ b/misc/create_inode.c
20@@ -18,6 +18,40 @@
21 #define S_BLKSIZE 512
22 #endif
23
24+/* Fill the uid, gid, mode and time for the inode */
25+static void fill_inode(struct ext2_inode *inode, struct stat *st)
26+{
27+ if (st != NULL) {
28+ inode->i_uid = st->st_uid;
29+ inode->i_gid = st->st_gid;
30+ inode->i_mode |= st->st_mode;
31+ inode->i_atime = st->st_atime;
32+ inode->i_mtime = st->st_mtime;
33+ inode->i_ctime = st->st_ctime;
34+ }
35+}
36+
37+/* Set the uid, gid, mode and time for the inode */
38+errcode_t set_inode_extra(ext2_ino_t cwd, ext2_ino_t ino, struct stat *st)
39+{
40+ errcode_t retval;
41+ struct ext2_inode inode;
42+
43+ retval = ext2fs_read_inode(current_fs, ino, &inode);
44+ if (retval) {
45+ com_err(__func__, retval, "while reading inode %u", ino);
46+ return retval;
47+ }
48+
49+ fill_inode(&inode, st);
50+
51+ retval = ext2fs_write_inode(current_fs, ino, &inode);
52+ if (retval) {
53+ com_err(__func__, retval, "while writing inode %u", ino);
54+ return retval;
55+ }
56+}
57+
58 /* Make a special file which is block, character and fifo */
59 errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st)
60 {
61@@ -435,6 +469,17 @@ errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir)
62 com_err(__func__, 0,
63 _("ignoring entry \"%s\""), name);
64 }
65+
66+ if ((retval = ext2fs_namei(current_fs, root, parent_ino, name, &ino))){
67+ com_err(name, retval, 0);
68+ return retval;
69+ }
70+
71+ if ((retval = set_inode_extra(parent_ino, ino, &st))) {
72+ com_err(__func__, retval,
73+ _("while setting inode for \"%s\""), name);
74+ return retval;
75+ }
76 }
77 closedir(dh);
78 return retval;
79--
801.7.10.4
81
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0008-mke2fs.c-add-an-option-d-root-directory.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0008-mke2fs.c-add-an-option-d-root-directory.patch
deleted file mode 100644
index 1f98673f35..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0008-mke2fs.c-add-an-option-d-root-directory.patch
+++ /dev/null
@@ -1,168 +0,0 @@
1From df856929e42bd4f3bdc8d4f59ee82ae8b28532e6 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Tue, 24 Dec 2013 01:50:45 -0500
4Subject: [PATCH 08/11] mke2fs.c: add an option: -d root-directory
5
6This option is used for adding the files from a given directory (the
7root-directory) to the filesystem, it is similiar to genext2fs, but
8genext2fs doesn't fully support ext4.
9
10Upstream-Status: Backport
11
12Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
13Reviewed-by: Darren Hart <dvhart@linux.intel.com>
14---
15 misc/Makefile.in | 14 ++++++++++----
16 misc/mke2fs.c | 32 +++++++++++++++++++++++---------
17 2 files changed, 33 insertions(+), 13 deletions(-)
18
19diff --git a/misc/Makefile.in b/misc/Makefile.in
20index 553c361..8253723 100644
21--- a/misc/Makefile.in
22+++ b/misc/Makefile.in
23@@ -42,7 +42,8 @@ LPROGS= @E2INITRD_PROG@
24
25 TUNE2FS_OBJS= tune2fs.o util.o
26 MKLPF_OBJS= mklost+found.o
27-MKE2FS_OBJS= mke2fs.o util.o profile.o prof_err.o default_profile.o
28+MKE2FS_OBJS= mke2fs.o util.o profile.o prof_err.o default_profile.o \
29+ create_inode.o
30 CHATTR_OBJS= chattr.o
31 LSATTR_OBJS= lsattr.o
32 UUIDGEN_OBJS= uuidgen.o
33@@ -60,7 +61,8 @@ E2FREEFRAG_OBJS= e2freefrag.o
34 PROFILED_TUNE2FS_OBJS= profiled/tune2fs.o profiled/util.o
35 PROFILED_MKLPF_OBJS= profiled/mklost+found.o
36 PROFILED_MKE2FS_OBJS= profiled/mke2fs.o profiled/util.o profiled/profile.o \
37- profiled/prof_err.o profiled/default_profile.o
38+ profiled/prof_err.o profiled/default_profile.o \
39+ profiled/create_inode.o
40 PROFILED_CHATTR_OBJS= profiled/chattr.o
41 PROFILED_LSATTR_OBJS= profiled/lsattr.o
42 PROFILED_UUIDGEN_OBJS= profiled/uuidgen.o
43@@ -82,7 +84,7 @@ SRCS= $(srcdir)/tune2fs.c $(srcdir)/mklost+found.c $(srcdir)/mke2fs.c \
44 $(srcdir)/uuidgen.c $(srcdir)/blkid.c $(srcdir)/logsave.c \
45 $(srcdir)/filefrag.c $(srcdir)/base_device.c \
46 $(srcdir)/ismounted.c $(srcdir)/../e2fsck/profile.c \
47- $(srcdir)/e2undo.c $(srcdir)/e2freefrag.c
48+ $(srcdir)/e2undo.c $(srcdir)/e2freefrag.c $(srcdir)/create_inode.c
49
50 LIBS= $(LIBEXT2FS) $(LIBCOM_ERR)
51 DEPLIBS= $(LIBEXT2FS) $(DEPLIBCOM_ERR)
52@@ -630,7 +632,7 @@ mke2fs.o: $(srcdir)/mke2fs.c $(top_builddir)/lib/config.h \
53 $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
54 $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
55 $(srcdir)/util.h profile.h prof_err.h $(top_srcdir)/version.h \
56- $(srcdir)/nls-enable.h $(top_srcdir)/lib/quota/mkquota.h \
57+ $(srcdir)/nls-enable.h $(top_srcdir)/lib/quota/mkquota.h $(srcdir)/create_inode.h\
58 $(top_srcdir)/lib/quota/quotaio.h $(top_srcdir)/lib/quota/dqblk_v2.h \
59 $(top_srcdir)/lib/quota/quotaio_tree.h $(top_srcdir)/lib/../e2fsck/dict.h
60 chattr.o: $(srcdir)/chattr.c $(top_builddir)/lib/config.h \
61@@ -710,3 +712,7 @@ e2freefrag.o: $(srcdir)/e2freefrag.c $(top_builddir)/lib/config.h \
62 $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
63 $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
64 $(srcdir)/e2freefrag.h
65+create_inode.o: $(srcdir)/create_inode.h $(srcdir)/create_inode.c \
66+ $(top_builddir)/lib/config.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
67+ $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/e2p/e2p.h \
68+ $(srcdir)/nls-enable.h
69diff --git a/misc/mke2fs.c b/misc/mke2fs.c
70index 2e8ba60..578b62d 100644
71--- a/misc/mke2fs.c
72+++ b/misc/mke2fs.c
73@@ -22,7 +22,6 @@
74 #include <stdio.h>
75 #include <string.h>
76 #include <strings.h>
77-#include <fcntl.h>
78 #include <ctype.h>
79 #include <time.h>
80 #ifdef __linux__
81@@ -44,24 +43,19 @@ extern int optind;
82 #include <errno.h>
83 #endif
84 #include <sys/ioctl.h>
85-#include <sys/types.h>
86-#include <sys/stat.h>
87 #include <libgen.h>
88 #include <limits.h>
89 #include <blkid/blkid.h>
90
91 #include "ext2fs/ext2_fs.h"
92 #include "ext2fs/ext2fsP.h"
93-#include "et/com_err.h"
94 #include "uuid/uuid.h"
95-#include "e2p/e2p.h"
96-#include "ext2fs/ext2fs.h"
97 #include "util.h"
98 #include "profile.h"
99 #include "prof_err.h"
100 #include "../version.h"
101-#include "nls-enable.h"
102 #include "quota/mkquota.h"
103+#include "create_inode.h"
104
105 #define STRIDE_LENGTH 8
106
107@@ -105,6 +99,7 @@ static char *mount_dir;
108 char *journal_device;
109 static int sync_kludge; /* Set using the MKE2FS_SYNC env. option */
110 static char **fs_types;
111+const char *root_dir; /* Copy files from the specified directory */
112
113 static profile_t profile;
114
115@@ -116,7 +111,8 @@ static void usage(void)
116 fprintf(stderr, _("Usage: %s [-c|-l filename] [-b block-size] "
117 "[-C cluster-size]\n\t[-i bytes-per-inode] [-I inode-size] "
118 "[-J journal-options]\n"
119- "\t[-G flex-group-size] [-N number-of-inodes]\n"
120+ "\t[-G flex-group-size] [-N number-of-inodes] "
121+ "[-d root-directory]\n"
122 "\t[-m reserved-blocks-percentage] [-o creator-os]\n"
123 "\t[-g blocks-per-group] [-L volume-label] "
124 "[-M last-mounted-directory]\n\t[-O feature[,...]] "
125@@ -1394,7 +1390,7 @@ profile_error:
126 }
127
128 while ((c = getopt (argc, argv,
129- "b:cg:i:jl:m:no:qr:s:t:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:V")) != EOF) {
130+ "b:cg:i:jl:m:no:qr:s:t:d:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:V")) != EOF) {
131 switch (c) {
132 case 'b':
133 blocksize = parse_num_blocks2(optarg, -1);
134@@ -1582,6 +1578,9 @@ profile_error:
135 case 'U':
136 fs_uuid = optarg;
137 break;
138+ case 'd':
139+ root_dir = optarg;
140+ break;
141 case 'v':
142 verbose = 1;
143 break;
144@@ -2726,6 +2725,21 @@ no_journal:
145 EXT4_FEATURE_RO_COMPAT_QUOTA))
146 create_quota_inodes(fs);
147
148+ /* Copy files from the specified directory */
149+ if (root_dir) {
150+ if (!quiet)
151+ printf("%s", _("Copying files into the device: "));
152+
153+ current_fs = fs;
154+ root = EXT2_ROOT_INO;
155+ retval = populate_fs(root, root_dir);
156+ if (retval)
157+ fprintf(stderr, "%s",
158+ _("\nError while populating file system"));
159+ else if (!quiet)
160+ printf("%s", _("done\n"));
161+ }
162+
163 if (!quiet)
164 printf("%s", _("Writing superblocks and "
165 "filesystem accounting information: "));
166--
1671.7.10.4
168
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0009-misc-create_inode.c-handle-hardlinks.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0009-misc-create_inode.c-handle-hardlinks.patch
deleted file mode 100644
index a330ee45a5..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0009-misc-create_inode.c-handle-hardlinks.patch
+++ /dev/null
@@ -1,210 +0,0 @@
1From d83dc950b3ec1fbde33b23d42c5154091a74f4d9 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Mon, 23 Dec 2013 03:44:03 -0500
4Subject: [PATCH 09/11] misc/create_inode.c: handle hardlinks
5
6Create the inode and save the native inode number when we meet the hard
7link (st_nlink > 1) at the first time, use ext2fs_link() to link the
8name to the target inode number when we meet the same native inode
9number again.
10
11This algorithm is referred from the genext2fs.
12
13Upstream-Status: Backport
14
15Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
16Reviewed-by: Darren Hart <dvhart@linux.intel.com>
17---
18 misc/create_inode.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++
19 misc/create_inode.h | 18 +++++++++++
20 misc/mke2fs.c | 12 +++++++
21 3 files changed, 118 insertions(+)
22
23diff --git a/misc/create_inode.c b/misc/create_inode.c
24index aad7354..763504d 100644
25--- a/misc/create_inode.c
26+++ b/misc/create_inode.c
27@@ -18,6 +18,44 @@
28 #define S_BLKSIZE 512
29 #endif
30
31+/* For saving the hard links */
32+int hdlink_cnt = HDLINK_CNT;
33+
34+/* Link an inode number to a directory */
35+static errcode_t add_link(ext2_ino_t parent_ino, ext2_ino_t ino, const char *name)
36+{
37+ struct ext2_inode inode;
38+ errcode_t retval;
39+
40+ retval = ext2fs_read_inode(current_fs, ino, &inode);
41+ if (retval) {
42+ com_err(__func__, retval, "while reading inode %u", ino);
43+ return retval;
44+ }
45+
46+ retval = ext2fs_link(current_fs, parent_ino, name, ino, inode.i_flags);
47+ if (retval == EXT2_ET_DIR_NO_SPACE) {
48+ retval = ext2fs_expand_dir(current_fs, parent_ino);
49+ if (retval) {
50+ com_err(__func__, retval, "while expanding directory");
51+ return retval;
52+ }
53+ retval = ext2fs_link(current_fs, parent_ino, name, ino, inode.i_flags);
54+ }
55+ if (retval) {
56+ com_err(__func__, retval, "while linking %s", name);
57+ return retval;
58+ }
59+
60+ inode.i_links_count++;
61+
62+ retval = ext2fs_write_inode(current_fs, ino, &inode);
63+ if (retval)
64+ com_err(__func__, retval, "while writing inode %u", ino);
65+
66+ return retval;
67+}
68+
69 /* Fill the uid, gid, mode and time for the inode */
70 static void fill_inode(struct ext2_inode *inode, struct stat *st)
71 {
72@@ -278,6 +316,17 @@ fail:
73 return retval;
74 }
75
76+int is_hardlink(ext2_ino_t ino)
77+{
78+ int i;
79+
80+ for(i = 0; i < hdlinks.count; i++) {
81+ if(hdlinks.hdl[i].src_ino == ino)
82+ return i;
83+ }
84+ return -1;
85+}
86+
87 /* Copy the native file to the fs */
88 errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest)
89 {
90@@ -388,9 +437,11 @@ errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir)
91 struct dirent *dent;
92 struct stat st;
93 char ln_target[PATH_MAX];
94+ unsigned int save_inode;
95 ext2_ino_t ino;
96 errcode_t retval;
97 int read_cnt;
98+ int hdlink;
99
100 root = EXT2_ROOT_INO;
101
102@@ -412,6 +463,22 @@ errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir)
103 lstat(dent->d_name, &st);
104 name = dent->d_name;
105
106+ /* Check for hardlinks */
107+ save_inode = 0;
108+ if (!S_ISDIR(st.st_mode) && !S_ISLNK(st.st_mode) && st.st_nlink > 1) {
109+ hdlink = is_hardlink(st.st_ino);
110+ if (hdlink >= 0) {
111+ retval = add_link(parent_ino,
112+ hdlinks.hdl[hdlink].dst_ino, name);
113+ if (retval) {
114+ com_err(__func__, retval, "while linking %s", name);
115+ return retval;
116+ }
117+ continue;
118+ } else
119+ save_inode = 1;
120+ }
121+
122 switch(st.st_mode & S_IFMT) {
123 case S_IFCHR:
124 case S_IFBLK:
125@@ -480,6 +547,27 @@ errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir)
126 _("while setting inode for \"%s\""), name);
127 return retval;
128 }
129+
130+ /* Save the hardlink ino */
131+ if (save_inode) {
132+ /*
133+ * Check whether need more memory, and we don't need
134+ * free() since the lifespan will be over after the fs
135+ * populated.
136+ */
137+ if (hdlinks.count == hdlink_cnt) {
138+ if ((hdlinks.hdl = realloc (hdlinks.hdl,
139+ (hdlink_cnt + HDLINK_CNT) *
140+ sizeof (struct hdlink_s))) == NULL) {
141+ com_err(name, errno, "Not enough memory");
142+ return errno;
143+ }
144+ hdlink_cnt += HDLINK_CNT;
145+ }
146+ hdlinks.hdl[hdlinks.count].src_ino = st.st_ino;
147+ hdlinks.hdl[hdlinks.count].dst_ino = ino;
148+ hdlinks.count++;
149+ }
150 }
151 closedir(dh);
152 return retval;
153diff --git a/misc/create_inode.h b/misc/create_inode.h
154index 9fc97fa..2b6d429 100644
155--- a/misc/create_inode.h
156+++ b/misc/create_inode.h
157@@ -6,9 +6,27 @@
158 #include "ext2fs/ext2fs.h"
159 #include "nls-enable.h"
160
161+struct hdlink_s
162+{
163+ ext2_ino_t src_ino;
164+ ext2_ino_t dst_ino;
165+};
166+
167+struct hdlinks_s
168+{
169+ int count;
170+ struct hdlink_s *hdl;
171+};
172+
173+struct hdlinks_s hdlinks;
174+
175 ext2_filsys current_fs;
176 ext2_ino_t root;
177
178+/* For saving the hard links */
179+#define HDLINK_CNT 4
180+extern int hdlink_cnt;
181+
182 /* For populating the filesystem */
183 extern errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir);
184 extern errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st);
185diff --git a/misc/mke2fs.c b/misc/mke2fs.c
186index 578b62d..a63f0b7 100644
187--- a/misc/mke2fs.c
188+++ b/misc/mke2fs.c
189@@ -2730,6 +2730,18 @@ no_journal:
190 if (!quiet)
191 printf("%s", _("Copying files into the device: "));
192
193+ /*
194+ * Allocate memory for the hardlinks, we don't need free()
195+ * since the lifespan will be over after the fs populated.
196+ */
197+ if ((hdlinks.hdl = (struct hdlink_s *)
198+ malloc(hdlink_cnt * sizeof(struct hdlink_s))) == NULL) {
199+ fprintf(stderr, "%s", _("\nNot enough memory\n"));
200+ retval = ext2fs_close(fs);
201+ return retval;
202+ }
203+
204+ hdlinks.count = 0;
205 current_fs = fs;
206 root = EXT2_ROOT_INO;
207 retval = populate_fs(root, root_dir);
208--
2091.7.10.4
210
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0010-debugfs-use-the-functions-in-misc-create_inode.c.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0010-debugfs-use-the-functions-in-misc-create_inode.c.patch
deleted file mode 100644
index 2a6ca8f9a3..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0010-debugfs-use-the-functions-in-misc-create_inode.c.patch
+++ /dev/null
@@ -1,496 +0,0 @@
1From db89992fab2215f52dce4c595a39271b4ff3000b Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Mon, 23 Dec 2013 04:22:22 -0500
4Subject: [PATCH 10/11] debugfs: use the functions in misc/create_inode.c
5
6* Use the functions in misc/create_inode.c, and remove the duplicated
7 code.
8
9* The CREATE_INODE_DEPS in the debugfs/Makefile.in is used for recording
10 create_inode.o's depends which is from misc/Makefile.in, we have to
11 recompile create_inode.o because we need it to print more messages when
12 it is used by debugfs, just like we recompile e2freefrag.o, but it seems
13 that the e2freefrag.o's depends in debugfs/Makefile.in is incorrect, it
14 would not rebuild when its depends (e.g.: lib/config.h) is changed,
15 which would cause unexpected errors. Make duplicated code in
16 debugfs/Makefile.in and misc/Makefile.in is not a good idea, maybe we'd
17 better define CREATE_INODE_DEPS in the top Makefile, I'd like to send
18 another patch and fix the e2freefrag if you are fine with it.
19
20Upstream-Status: Backport
21
22Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
23Reviewed-by: Darren Hart <dvhart@linux.intel.com>
24---
25 debugfs/Makefile.in | 17 ++-
26 debugfs/debugfs.c | 305 +++------------------------------------------------
27 debugfs/debugfs.h | 1 +
28 3 files changed, 31 insertions(+), 292 deletions(-)
29
30diff --git a/debugfs/Makefile.in b/debugfs/Makefile.in
31index bf037e0..f51b78e 100644
32--- a/debugfs/Makefile.in
33+++ b/debugfs/Makefile.in
34@@ -18,7 +18,7 @@ MK_CMDS= _SS_DIR_OVERRIDE=../lib/ss ../lib/ss/mk_cmds
35
36 DEBUG_OBJS= debug_cmds.o debugfs.o util.o ncheck.o icheck.o ls.o \
37 lsdel.o dump.o set_fields.o logdump.o htree.o unused.o e2freefrag.o \
38- filefrag.o extent_cmds.o extent_inode.o zap.o
39+ filefrag.o extent_cmds.o extent_inode.o zap.o create_inode.o
40
41 RO_DEBUG_OBJS= ro_debug_cmds.o ro_debugfs.o util.o ncheck.o icheck.o ls.o \
42 lsdel.o logdump.o htree.o e2freefrag.o filefrag.o extent_cmds.o \
43@@ -28,7 +28,13 @@ SRCS= debug_cmds.c $(srcdir)/debugfs.c $(srcdir)/util.c $(srcdir)/ls.c \
44 $(srcdir)/ncheck.c $(srcdir)/icheck.c $(srcdir)/lsdel.c \
45 $(srcdir)/dump.c $(srcdir)/set_fields.c ${srcdir}/logdump.c \
46 $(srcdir)/htree.c $(srcdir)/unused.c ${srcdir}/../misc/e2freefrag.c \
47- $(srcdir)/filefrag.c $(srcdir)/extent_inode.c $(srcdir)/zap.c
48+ $(srcdir)/filefrag.c $(srcdir)/extent_inode.c $(srcdir)/zap.c \
49+ $(srcdir)/../misc/create_inode.c
50+
51+CREATE_INODE_DEPS= $(srcdir)/../misc/create_inode.h \
52+ $(srcdir)/../misc/create_inode.c $(top_builddir)/lib/config.h \
53+ $(srcdir)/../lib/ext2fs/ext2fs.h $(srcdir)/../lib/et/com_err.h \
54+ $(srcdir)/../lib/e2p/e2p.h $(srcdir)/../misc/nls-enable.h
55
56 LIBS= $(LIBEXT2FS) $(LIBE2P) $(LIBSS) $(LIBCOM_ERR) $(LIBBLKID) \
57 $(LIBUUID)
58@@ -81,6 +87,11 @@ e2freefrag.o: $(srcdir)/../misc/e2freefrag.c
59 $(E) " CC $@"
60 $(Q) $(CC) -c $(ALL_CFLAGS) -I$(srcdir) $< -DDEBUGFS -o $@
61
62+create_inode.o: $(CREATE_INODE_DEPS)
63+ $(E) " CC $@"
64+ $(Q) $(CC) -c $(ALL_CFLAGS) -I$(srcdir) \
65+ $(srcdir)/../misc/create_inode.c -DDEBUGFS -o $@
66+
67 debugfs.8: $(DEP_SUBSTITUTE) $(srcdir)/debugfs.8.in
68 $(E) " SUBST $@"
69 $(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/debugfs.8.in debugfs.8
70@@ -142,7 +153,7 @@ debugfs.o: $(srcdir)/debugfs.c $(top_srcdir)/lib/et/com_err.h \
71 $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
72 $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/version.h $(srcdir)/jfs_user.h \
73 $(top_srcdir)/lib/ext2fs/kernel-jbd.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
74- $(top_srcdir)/lib/ext2fs/kernel-list.h
75+ $(top_srcdir)/lib/ext2fs/kernel-list.h $(top_srcdir)/misc/util.h
76 util.o: $(srcdir)/util.c $(srcdir)/debugfs.h \
77 $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
78 $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
79diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
80index 9c215f7..62e9f44 100644
81--- a/debugfs/debugfs.c
82+++ b/debugfs/debugfs.c
83@@ -25,8 +25,6 @@ extern char *optarg;
84 #include <errno.h>
85 #endif
86 #include <fcntl.h>
87-#include <sys/types.h>
88-#include <sys/stat.h>
89
90 #include "debugfs.h"
91 #include "uuid/uuid.h"
92@@ -41,22 +39,11 @@ extern char *optarg;
93 #define BUFSIZ 8192
94 #endif
95
96-/* 64KiB is the minimium blksize to best minimize system call overhead. */
97-#ifndef IO_BUFSIZE
98-#define IO_BUFSIZE 64*1024
99-#endif
100-
101-/* Block size for `st_blocks' */
102-#ifndef S_BLKSIZE
103-#define S_BLKSIZE 512
104-#endif
105-
106 ss_request_table *extra_cmds;
107 const char *debug_prog_name;
108 int sci_idx;
109
110-ext2_filsys current_fs = NULL;
111-ext2_ino_t root, cwd;
112+ext2_ino_t cwd;
113
114 static void open_filesystem(char *device, int open_flags, blk64_t superblock,
115 blk64_t blocksize, int catastrophic,
116@@ -1576,189 +1563,24 @@ void do_find_free_inode(int argc, char *argv[])
117 }
118
119 #ifndef READ_ONLY
120-static errcode_t copy_file(int fd, ext2_ino_t newfile, int bufsize, int make_holes)
121-{
122- ext2_file_t e2_file;
123- errcode_t retval;
124- int got;
125- unsigned int written;
126- char *buf;
127- char *ptr;
128- char *zero_buf;
129- int cmp;
130-
131- retval = ext2fs_file_open(current_fs, newfile,
132- EXT2_FILE_WRITE, &e2_file);
133- if (retval)
134- return retval;
135-
136- retval = ext2fs_get_mem(bufsize, &buf);
137- if (retval) {
138- com_err("copy_file", retval, "can't allocate buffer\n");
139- return retval;
140- }
141-
142- /* This is used for checking whether the whole block is zero */
143- retval = ext2fs_get_memzero(bufsize, &zero_buf);
144- if (retval) {
145- com_err("copy_file", retval, "can't allocate buffer\n");
146- ext2fs_free_mem(&buf);
147- return retval;
148- }
149-
150- while (1) {
151- got = read(fd, buf, bufsize);
152- if (got == 0)
153- break;
154- if (got < 0) {
155- retval = errno;
156- goto fail;
157- }
158- ptr = buf;
159-
160- /* Sparse copy */
161- if (make_holes) {
162- /* Check whether all is zero */
163- cmp = memcmp(ptr, zero_buf, got);
164- if (cmp == 0) {
165- /* The whole block is zero, make a hole */
166- retval = ext2fs_file_lseek(e2_file, got, EXT2_SEEK_CUR, NULL);
167- if (retval)
168- goto fail;
169- got = 0;
170- }
171- }
172-
173- /* Normal copy */
174- while (got > 0) {
175- retval = ext2fs_file_write(e2_file, ptr,
176- got, &written);
177- if (retval)
178- goto fail;
179-
180- got -= written;
181- ptr += written;
182- }
183- }
184- ext2fs_free_mem(&buf);
185- ext2fs_free_mem(&zero_buf);
186- retval = ext2fs_file_close(e2_file);
187- return retval;
188-
189-fail:
190- ext2fs_free_mem(&buf);
191- ext2fs_free_mem(&zero_buf);
192- (void) ext2fs_file_close(e2_file);
193- return retval;
194-}
195-
196-
197 void do_write(int argc, char *argv[])
198 {
199- int fd;
200- struct stat statbuf;
201- ext2_ino_t newfile;
202 errcode_t retval;
203- struct ext2_inode inode;
204- int bufsize = IO_BUFSIZE;
205- int make_holes = 0;
206
207 if (common_args_process(argc, argv, 3, 3, "write",
208 "<native file> <new file>", CHECK_FS_RW))
209 return;
210
211- fd = open(argv[1], O_RDONLY);
212- if (fd < 0) {
213- com_err(argv[1], errno, 0);
214- return;
215- }
216- if (fstat(fd, &statbuf) < 0) {
217- com_err(argv[1], errno, 0);
218- close(fd);
219- return;
220- }
221-
222- retval = ext2fs_namei(current_fs, root, cwd, argv[2], &newfile);
223- if (retval == 0) {
224- com_err(argv[0], 0, "The file '%s' already exists\n", argv[2]);
225- close(fd);
226- return;
227- }
228-
229- retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &newfile);
230- if (retval) {
231+ if ((retval = do_write_internal(cwd, argv[1], argv[2])))
232 com_err(argv[0], retval, 0);
233- close(fd);
234- return;
235- }
236- printf("Allocated inode: %u\n", newfile);
237- retval = ext2fs_link(current_fs, cwd, argv[2], newfile,
238- EXT2_FT_REG_FILE);
239- if (retval == EXT2_ET_DIR_NO_SPACE) {
240- retval = ext2fs_expand_dir(current_fs, cwd);
241- if (retval) {
242- com_err(argv[0], retval, "while expanding directory");
243- close(fd);
244- return;
245- }
246- retval = ext2fs_link(current_fs, cwd, argv[2], newfile,
247- EXT2_FT_REG_FILE);
248- }
249- if (retval) {
250- com_err(argv[2], retval, 0);
251- close(fd);
252- return;
253- }
254- if (ext2fs_test_inode_bitmap2(current_fs->inode_map,newfile))
255- com_err(argv[0], 0, "Warning: inode already set");
256- ext2fs_inode_alloc_stats2(current_fs, newfile, +1, 0);
257- memset(&inode, 0, sizeof(inode));
258- inode.i_mode = (statbuf.st_mode & ~LINUX_S_IFMT) | LINUX_S_IFREG;
259- inode.i_atime = inode.i_ctime = inode.i_mtime =
260- current_fs->now ? current_fs->now : time(0);
261- inode.i_links_count = 1;
262- inode.i_size = statbuf.st_size;
263- if (current_fs->super->s_feature_incompat &
264- EXT3_FEATURE_INCOMPAT_EXTENTS) {
265- int i;
266- struct ext3_extent_header *eh;
267-
268- eh = (struct ext3_extent_header *) &inode.i_block[0];
269- eh->eh_depth = 0;
270- eh->eh_entries = 0;
271- eh->eh_magic = ext2fs_cpu_to_le16(EXT3_EXT_MAGIC);
272- i = (sizeof(inode.i_block) - sizeof(*eh)) /
273- sizeof(struct ext3_extent);
274- eh->eh_max = ext2fs_cpu_to_le16(i);
275- inode.i_flags |= EXT4_EXTENTS_FL;
276- }
277- if (debugfs_write_new_inode(newfile, &inode, argv[0])) {
278- close(fd);
279- return;
280- }
281- if (LINUX_S_ISREG(inode.i_mode)) {
282- if (statbuf.st_blocks < statbuf.st_size / S_BLKSIZE) {
283- make_holes = 1;
284- /*
285- * Use I/O blocksize as buffer size when
286- * copying sparse files.
287- */
288- bufsize = statbuf.st_blksize;
289- }
290- retval = copy_file(fd, newfile, bufsize, make_holes);
291- if (retval)
292- com_err("copy_file", retval, 0);
293- }
294- close(fd);
295 }
296
297 void do_mknod(int argc, char *argv[])
298 {
299 unsigned long mode, major, minor;
300- ext2_ino_t newfile;
301 errcode_t retval;
302- struct ext2_inode inode;
303 int filetype, nr;
304+ struct stat st;
305
306 if (check_fs_open(argv[0]))
307 return;
308@@ -1767,115 +1589,50 @@ void do_mknod(int argc, char *argv[])
309 com_err(argv[0], 0, "Usage: mknod <name> [p| [c|b] <major> <minor>]");
310 return;
311 }
312+
313 mode = minor = major = 0;
314 switch (argv[2][0]) {
315 case 'p':
316- mode = LINUX_S_IFIFO;
317- filetype = EXT2_FT_FIFO;
318+ st.st_mode = S_IFIFO;
319 nr = 3;
320 break;
321 case 'c':
322- mode = LINUX_S_IFCHR;
323- filetype = EXT2_FT_CHRDEV;
324+ st.st_mode = S_IFCHR;
325 nr = 5;
326 break;
327 case 'b':
328- mode = LINUX_S_IFBLK;
329- filetype = EXT2_FT_BLKDEV;
330+ st.st_mode = S_IFBLK;
331 nr = 5;
332 break;
333 default:
334- filetype = 0;
335 nr = 0;
336 }
337+
338 if (nr == 5) {
339 major = strtoul(argv[3], argv+3, 0);
340 minor = strtoul(argv[4], argv+4, 0);
341 if (major > 65535 || minor > 65535 || argv[3][0] || argv[4][0])
342 nr = 0;
343 }
344+
345 if (argc != nr)
346 goto usage;
347- if (check_fs_read_write(argv[0]))
348- return;
349- retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &newfile);
350- if (retval) {
351+
352+ st.st_rdev = makedev(major, minor);
353+ if ((retval = do_mknod_internal(cwd, argv[1], &st)))
354 com_err(argv[0], retval, 0);
355- return;
356- }
357- printf("Allocated inode: %u\n", newfile);
358- retval = ext2fs_link(current_fs, cwd, argv[1], newfile, filetype);
359- if (retval == EXT2_ET_DIR_NO_SPACE) {
360- retval = ext2fs_expand_dir(current_fs, cwd);
361- if (retval) {
362- com_err(argv[0], retval, "while expanding directory");
363- return;
364- }
365- retval = ext2fs_link(current_fs, cwd, argv[1], newfile,
366- filetype);
367- }
368- if (retval) {
369- com_err(argv[1], retval, 0);
370- return;
371- }
372- if (ext2fs_test_inode_bitmap2(current_fs->inode_map,newfile))
373- com_err(argv[0], 0, "Warning: inode already set");
374- ext2fs_inode_alloc_stats2(current_fs, newfile, +1, 0);
375- memset(&inode, 0, sizeof(inode));
376- inode.i_mode = mode;
377- inode.i_atime = inode.i_ctime = inode.i_mtime =
378- current_fs->now ? current_fs->now : time(0);
379- if ((major < 256) && (minor < 256)) {
380- inode.i_block[0] = major*256+minor;
381- inode.i_block[1] = 0;
382- } else {
383- inode.i_block[0] = 0;
384- inode.i_block[1] = (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);
385- }
386- inode.i_links_count = 1;
387- if (debugfs_write_new_inode(newfile, &inode, argv[0]))
388- return;
389 }
390
391 void do_mkdir(int argc, char *argv[])
392 {
393- char *cp;
394- ext2_ino_t parent;
395- char *name;
396 errcode_t retval;
397
398 if (common_args_process(argc, argv, 2, 2, "mkdir",
399 "<filename>", CHECK_FS_RW))
400 return;
401
402- cp = strrchr(argv[1], '/');
403- if (cp) {
404- *cp = 0;
405- parent = string_to_inode(argv[1]);
406- if (!parent) {
407- com_err(argv[1], ENOENT, 0);
408- return;
409- }
410- name = cp+1;
411- } else {
412- parent = cwd;
413- name = argv[1];
414- }
415-
416-try_again:
417- retval = ext2fs_mkdir(current_fs, parent, 0, name);
418- if (retval == EXT2_ET_DIR_NO_SPACE) {
419- retval = ext2fs_expand_dir(current_fs, parent);
420- if (retval) {
421- com_err(argv[0], retval, "while expanding directory");
422- return;
423- }
424- goto try_again;
425- }
426- if (retval) {
427- com_err("ext2fs_mkdir", retval, 0);
428- return;
429- }
430+ if ((retval = do_mkdir_internal(cwd, argv[1], NULL)))
431+ com_err(argv[0], retval, 0);
432
433 }
434
435@@ -2270,44 +2027,14 @@ void do_punch(int argc, char *argv[])
436
437 void do_symlink(int argc, char *argv[])
438 {
439- char *cp;
440- ext2_ino_t parent;
441- char *name, *target;
442 errcode_t retval;
443
444 if (common_args_process(argc, argv, 3, 3, "symlink",
445 "<filename> <target>", CHECK_FS_RW))
446 return;
447
448- cp = strrchr(argv[1], '/');
449- if (cp) {
450- *cp = 0;
451- parent = string_to_inode(argv[1]);
452- if (!parent) {
453- com_err(argv[1], ENOENT, 0);
454- return;
455- }
456- name = cp+1;
457- } else {
458- parent = cwd;
459- name = argv[1];
460- }
461- target = argv[2];
462-
463-try_again:
464- retval = ext2fs_symlink(current_fs, parent, 0, name, target);
465- if (retval == EXT2_ET_DIR_NO_SPACE) {
466- retval = ext2fs_expand_dir(current_fs, parent);
467- if (retval) {
468- com_err(argv[0], retval, "while expanding directory");
469- return;
470- }
471- goto try_again;
472- }
473- if (retval) {
474- com_err("ext2fs_symlink", retval, 0);
475- return;
476- }
477+ if ((retval = do_symlink_internal(cwd, argv[1], argv[2])))
478+ com_err(argv[0], retval, 0);
479
480 }
481
482diff --git a/debugfs/debugfs.h b/debugfs/debugfs.h
483index 6b4f6ef..2d464c1 100644
484--- a/debugfs/debugfs.h
485+++ b/debugfs/debugfs.h
486@@ -5,6 +5,7 @@
487 #include "ss/ss.h"
488 #include "ext2fs/ext2_fs.h"
489 #include "ext2fs/ext2fs.h"
490+#include "../misc/create_inode.h"
491
492 #ifdef __STDC__
493 #define NOARGS void
494--
4951.7.10.4
496
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0011-mke2fs.8.in-update-the-manual-for-the-d-option.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0011-mke2fs.8.in-update-the-manual-for-the-d-option.patch
deleted file mode 100644
index ddd2cb8b42..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0011-mke2fs.8.in-update-the-manual-for-the-d-option.patch
+++ /dev/null
@@ -1,43 +0,0 @@
1From 89fca439f1b58595f2f424598a27869f8c7bd815 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Mon, 23 Dec 2013 04:43:18 -0500
4Subject: [PATCH 11/11] mke2fs.8.in: update the manual for the -d option
5
6Update the manual for the -d option
7
8Upstream-Status: Backport
9
10Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
11Reviewed-by: Darren Hart <dvhart@linux.intel.com>
12---
13 misc/mke2fs.8.in | 7 +++++++
14 1 file changed, 7 insertions(+)
15
16diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
17index fea50da..b1ca486 100644
18--- a/misc/mke2fs.8.in
19+++ b/misc/mke2fs.8.in
20@@ -52,6 +52,10 @@ mke2fs \- create an ext2/ext3/ext4 filesystem
21 .I number-of-inodes
22 ]
23 [
24+.B \-d
25+.I root-directory
26+]
27+[
28 .B \-n
29 ]
30 [
31@@ -502,6 +506,9 @@ the
32 ratio). This allows the user to specify the number
33 of desired inodes directly.
34 .TP
35+.BI \-d " root-directory"
36+Add the files from the root-directory to the filesystem.
37+.TP
38 .BI \-o " creator-os"
39 Overrides the default value of the "creator operating system" field of the
40 filesystem. The creator field is set by default to the name of the OS the
41--
421.7.10.4
43
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0012-Fix-musl-build-failures.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0012-Fix-musl-build-failures.patch
deleted file mode 100644
index 0b8008dfc9..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/0012-Fix-musl-build-failures.patch
+++ /dev/null
@@ -1,54 +0,0 @@
1From c6ff7feb9038d6e8aaffe2e69b205ad5fa33df2f Mon Sep 17 00:00:00 2001
2From: Paul Barker <paul@paulbarker.me.uk>
3Date: Mon, 18 Aug 2014 21:02:56 +0200
4Subject: [PATCH] Fix musl build failures
5
6In lib/ext2fs/unix_io.c, __u64 should be used instead of __uint64_t. This type
7is guaranteed by the e2fsprogs build system.
8(795c02def3681a99cc792a5ebc162d06f8a1eeb7)
9
10In misc/create_inode.c, <limits.h> is needed for the definition of PATH_MAX.
11(bbccc6f3c6a106721fb6f1ef4df6bc32c7986235)
12
13Both of these fixes have been made upstream with the git commit IDs given but
14those are larger commits containing other changes not needed here.
15
16Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
17
18Upstream-Status: Backport
19---
20 lib/ext2fs/unix_io.c | 6 +++---
21 misc/create_inode.c | 1 +
22 2 files changed, 4 insertions(+), 3 deletions(-)
23
24diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
25index 19be630..0cc0f52 100644
26--- a/lib/ext2fs/unix_io.c
27+++ b/lib/ext2fs/unix_io.c
28@@ -931,10 +931,10 @@ static errcode_t unix_discard(io_channel channel, unsigned long long block,
29
30 if (channel->flags & CHANNEL_FLAGS_BLOCK_DEVICE) {
31 #ifdef BLKDISCARD
32- __uint64_t range[2];
33+ __u64 range[2];
34
35- range[0] = (__uint64_t)(block) * channel->block_size;
36- range[1] = (__uint64_t)(count) * channel->block_size;
37+ range[0] = (__u64)(block) * channel->block_size;
38+ range[1] = (__u64)(count) * channel->block_size;
39
40 ret = ioctl(data->dev, BLKDISCARD, &range);
41 #else
42diff --git a/misc/create_inode.c b/misc/create_inode.c
43index 6d8de04..fcec5aa 100644
44--- a/misc/create_inode.c
45+++ b/misc/create_inode.c
46@@ -1,4 +1,5 @@
47 #include "create_inode.h"
48+#include <limits.h>
49
50 #if __STDC_VERSION__ < 199901L
51 # if __GNUC__ >= 2
52--
531.9.1
54
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/CVE-2015-0247.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/CVE-2015-0247.patch
deleted file mode 100644
index 5b6346b150..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/CVE-2015-0247.patch
+++ /dev/null
@@ -1,58 +0,0 @@
1From f66e6ce4446738c2c7f43d41988a3eb73347e2f5 Mon Sep 17 00:00:00 2001
2From: Theodore Ts'o <tytso@mit.edu>
3Date: Sat, 9 Aug 2014 12:24:54 -0400
4Subject: libext2fs: avoid buffer overflow if s_first_meta_bg is too big
5
6If s_first_meta_bg is greater than the of number block group
7descriptor blocks, then reading or writing the block group descriptors
8will end up overruning the memory buffer allocated for the
9descriptors. Fix this by limiting first_meta_bg to no more than
10fs->desc_blocks. This doesn't correct the bad s_first_meta_bg value,
11but it avoids causing the e2fsprogs userspace programs from
12potentially crashing.
13
14Upstream-Status: Backport
15CVE: CVE-2015-0247
16
17Signed-off-by: Theodore Ts'o <tytso@mit.edu>
18Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com>
19
20diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
21index 4599eef..1f99113 100644
22--- a/lib/ext2fs/closefs.c
23+++ b/lib/ext2fs/closefs.c
24@@ -344,9 +344,11 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags)
25 * superblocks and group descriptors.
26 */
27 group_ptr = (char *) group_shadow;
28- if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
29+ if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) {
30 old_desc_blocks = fs->super->s_first_meta_bg;
31- else
32+ if (old_desc_blocks > fs->super->s_first_meta_bg)
33+ old_desc_blocks = fs->desc_blocks;
34+ } else
35 old_desc_blocks = fs->desc_blocks;
36
37 ext2fs_numeric_progress_init(fs, &progress, NULL,
38diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
39index a1a3517..ba501e6 100644
40--- a/lib/ext2fs/openfs.c
41+++ b/lib/ext2fs/openfs.c
42@@ -378,9 +378,11 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
43 #ifdef WORDS_BIGENDIAN
44 groups_per_block = EXT2_DESC_PER_BLOCK(fs->super);
45 #endif
46- if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
47+ if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) {
48 first_meta_bg = fs->super->s_first_meta_bg;
49- else
50+ if (first_meta_bg > fs->desc_blocks)
51+ first_meta_bg = fs->desc_blocks;
52+ } else
53 first_meta_bg = fs->desc_blocks;
54 if (first_meta_bg) {
55 retval = io_channel_read_blk(fs->io, group_block +
56--
57cgit v0.10.2
58
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/cache_inode.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/cache_inode.patch
deleted file mode 100644
index f9ef8e5f26..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/cache_inode.patch
+++ /dev/null
@@ -1,52 +0,0 @@
1The comment to this function says:
2
3"""
4 * Stupid algorithm --- we now just search forward starting from the
5 * goal. Should put in a smarter one someday....
6"""
7
8This adds in a rather hacky algorthim which starts where we finished
9searching previously using a static variable rather than starting
10from scratch if a hint isn't provided.
11
12This was after noticing that mkfs.ext4 -F X -d Y was spending *lots*
13of time in ext2fs_new_block2 called from ext2fs_bmap from ext2fs_file_write().
14
15Numbers wise, this took a core-image-sato-sdk mkfs time from over
168 minutes to around 35 seconds.
17
18Upstream-Status: Pending
19
20RP 2015/02/20
21
22Index: e2fsprogs-1.42.9/lib/ext2fs/alloc.c
23===================================================================
24--- e2fsprogs-1.42.9.orig/lib/ext2fs/alloc.c
25+++ e2fsprogs-1.42.9/lib/ext2fs/alloc.c
26@@ -160,6 +160,8 @@ errcode_t ext2fs_new_inode(ext2_filsys f
27 return 0;
28 }
29
30+static blk64_t last_goal = 0;
31+
32 /*
33 * Stupid algorithm --- we now just search forward starting from the
34 * goal. Should put in a smarter one someday....
35@@ -170,6 +172,9 @@ errcode_t ext2fs_new_block2(ext2_filsys
36 blk64_t i;
37 int c_ratio;
38
39+ if (!goal)
40+ goal = last_goal;
41+
42 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
43
44 if (!map)
45@@ -194,6 +199,7 @@ errcode_t ext2fs_new_block2(ext2_filsys
46
47 if (!ext2fs_fast_test_block_bitmap2(map, i)) {
48 *ret = i;
49+ last_goal = i;
50 return 0;
51 }
52 i = (i + c_ratio) & ~(c_ratio - 1);
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/copy-in-create-hardlinks-with-the-correct-directory-.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/copy-in-create-hardlinks-with-the-correct-directory-.patch
deleted file mode 100644
index f549693570..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/copy-in-create-hardlinks-with-the-correct-directory-.patch
+++ /dev/null
@@ -1,81 +0,0 @@
1From 2dcf8e92bc39e05b3c799f53fe911c024aee4375 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Fri, 23 Oct 2015 03:21:05 -0700
4Subject: [PATCH] copy-in: create hardlinks with the correct directory
5 filetype
6
7When we're creating hard links via ext2fs_link, the (misnamed?) flags
8argument specifies the filetype for the directory entry. This is
9*derived* from i_mode, so provide a translator. Otherwise, fsck will
10complain about unset file types.
11
12Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
13Signed-off-by: Theodore Ts'o <tytso@mit.edu>
14
15Upstream-Status: Backport
16
17Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
18---
19 misc/create_inode.c | 33 +++++++++++++++++++++++++++++++--
20 1 file changed, 31 insertions(+), 2 deletions(-)
21
22diff --git a/misc/create_inode.c b/misc/create_inode.c
23index fcec5aa..b8565da 100644
24--- a/misc/create_inode.c
25+++ b/misc/create_inode.c
26@@ -22,6 +22,33 @@
27 /* For saving the hard links */
28 int hdlink_cnt = HDLINK_CNT;
29
30+static int ext2_file_type(unsigned int mode)
31+{
32+ if (LINUX_S_ISREG(mode))
33+ return EXT2_FT_REG_FILE;
34+
35+ if (LINUX_S_ISDIR(mode))
36+ return EXT2_FT_DIR;
37+
38+ if (LINUX_S_ISCHR(mode))
39+ return EXT2_FT_CHRDEV;
40+
41+ if (LINUX_S_ISBLK(mode))
42+ return EXT2_FT_BLKDEV;
43+
44+ if (LINUX_S_ISLNK(mode))
45+ return EXT2_FT_SYMLINK;
46+
47+ if (LINUX_S_ISFIFO(mode))
48+ return EXT2_FT_FIFO;
49+
50+ if (LINUX_S_ISSOCK(mode))
51+ return EXT2_FT_SOCK;
52+
53+ return 0;
54+}
55+
56+
57 /* Link an inode number to a directory */
58 static errcode_t add_link(ext2_ino_t parent_ino, ext2_ino_t ino, const char *name)
59 {
60@@ -34,14 +61,16 @@ static errcode_t add_link(ext2_ino_t parent_ino, ext2_ino_t ino, const char *nam
61 return retval;
62 }
63
64- retval = ext2fs_link(current_fs, parent_ino, name, ino, inode.i_flags);
65+ retval = ext2fs_link(current_fs, parent_ino, name, ino,
66+ ext2_file_type(inode.i_mode));
67 if (retval == EXT2_ET_DIR_NO_SPACE) {
68 retval = ext2fs_expand_dir(current_fs, parent_ino);
69 if (retval) {
70 com_err(__func__, retval, "while expanding directory");
71 return retval;
72 }
73- retval = ext2fs_link(current_fs, parent_ino, name, ino, inode.i_flags);
74+ retval = ext2fs_link(current_fs, parent_ino, name, ino,
75+ ext2_file_type(inode.i_mode));
76 }
77 if (retval) {
78 com_err(__func__, retval, "while linking %s", name);
79--
801.7.9.5
81
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/fix-icache.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/fix-icache.patch
deleted file mode 100644
index d38cc4d3f4..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/fix-icache.patch
+++ /dev/null
@@ -1,65 +0,0 @@
1inode.c: only update the icache for ext2_inode
2
3We only read the cache when:
4
5bufsize == sizeof(struct ext2_inode)
6
7then we should only update the cache in the same condition, otherwise
8there would be errors, for example:
9
10cache[0]: cached ino 14 when bufsize = 128 by ext2fs_write_inode_full()
11cache[1]: cached ino 14 when bufsize = 156 by ext2fs_read_inode_full()
12
13Then update the cache:
14cache[0]: cached ino 15 when bufsize = 156 by ext2fs_read_inode_full()
15
16Then the ino 14 would hit the cache[1] when bufsize = 128 (but it was
17cached by bufsize = 156), so there would be errors.
18
19Upstream-Status: Submitted
20
21Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
22---
23 lib/ext2fs/inode.c | 20 ++++++++++++--------
24 1 file changed, 12 insertions(+), 8 deletions(-)
25
26diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
27--- a/lib/ext2fs/inode.c
28+++ b/lib/ext2fs/inode.c
29@@ -612,10 +612,12 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
30 #endif
31
32 /* Update the inode cache */
33- fs->icache->cache_last = (fs->icache->cache_last + 1) %
34- fs->icache->cache_size;
35- fs->icache->cache[fs->icache->cache_last].ino = ino;
36- fs->icache->cache[fs->icache->cache_last].inode = *inode;
37+ if (bufsize == sizeof(struct ext2_inode)) {
38+ fs->icache->cache_last = (fs->icache->cache_last + 1) %
39+ fs->icache->cache_size;
40+ fs->icache->cache[fs->icache->cache_last].ino = ino;
41+ fs->icache->cache[fs->icache->cache_last].inode = *inode;
42+ }
43
44 return 0;
45 }
46@@ -648,10 +650,12 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
47
48 /* Check to see if the inode cache needs to be updated */
49 if (fs->icache) {
50- for (i=0; i < fs->icache->cache_size; i++) {
51- if (fs->icache->cache[i].ino == ino) {
52- fs->icache->cache[i].inode = *inode;
53- break;
54+ if (bufsize == sizeof(struct ext2_inode)) {
55+ for (i=0; i < fs->icache->cache_size; i++) {
56+ if (fs->icache->cache[i].ino == ino) {
57+ fs->icache->cache[i].inode = *inode;
58+ break;
59+ }
60 }
61 }
62 } else {
63--
641.8.1.2
65
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/misc-mke2fs.c-return-error-when-failed-to-populate-fs.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/misc-mke2fs.c-return-error-when-failed-to-populate-fs.patch
deleted file mode 100644
index cba0ce0047..0000000000
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/misc-mke2fs.c-return-error-when-failed-to-populate-fs.patch
+++ /dev/null
@@ -1,37 +0,0 @@
1From e4ffd6fe975888d306b5f700ba54af18b59f6759 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Thu, 20 Mar 2014 11:10:21 +0800
4Subject: [PATCH] misc/mke2fs.c: return error when failed to populate filesystem
5
6We need return retval when "mke2fs -d" failed, otherwise the "$?" would
7be 0 which is misleading.
8
9Upstream-Status: Submitted
10
11Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
12---
13 misc/mke2fs.c | 7 ++++---
14 1 file changed, 4 insertions(+), 3 deletions(-)
15
16diff --git a/misc/mke2fs.c b/misc/mke2fs.c
17index a63f0b7..846190e 100644
18--- a/misc/mke2fs.c
19+++ b/misc/mke2fs.c
20@@ -2745,10 +2745,11 @@ no_journal:
21 current_fs = fs;
22 root = EXT2_ROOT_INO;
23 retval = populate_fs(root, root_dir);
24- if (retval)
25+ if (retval) {
26 fprintf(stderr, "%s",
27- _("\nError while populating file system"));
28- else if (!quiet)
29+ _("\nError while populating file system\n"));
30+ return retval;
31+ } else if (!quiet)
32 printf("%s", _("done\n"));
33 }
34
35--
361.8.3.1
37
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/mkdir.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/mkdir.patch
index aa7a2981b4..2a3aeff613 100644
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/mkdir.patch
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/mkdir.patch
@@ -2,29 +2,17 @@ Upstream-Status: Inappropriate [configuration]
2 2
3Signed-off-by: Mei Lei <lei.mei@intel.com> 3Signed-off-by: Mei Lei <lei.mei@intel.com>
4 4
5Index: e2fsprogs-1.41.5/po/Makefile.in.in 5diff --git a/configure.ac b/configure.ac
6=================================================================== 6index c1fe224..f5ac628 100644
7--- e2fsprogs-1.41.5.orig/po/Makefile.in.in 2009-02-14 13:49:08.000000000 +0000 7--- a/configure.ac
8+++ e2fsprogs-1.41.5/po/Makefile.in.in 2009-08-19 17:52:31.000000000 +0100 8+++ b/configure.ac
9@@ -30,7 +30,7 @@ 9@@ -1374,7 +1374,8 @@ if test -n "$WITH_DIET_LIBC" ; then
10 INSTALL = @INSTALL@ 10 INCLUDES="$INCLUDES -D_REENTRANT"
11 INSTALL_DATA = @INSTALL_DATA@
12 MKINSTALLDIRS = @MKINSTALLDIRS@
13-mkinstalldirs = $(SHELL) $(MKINSTALLDIRS)
14+mkinstalldirs = $(MKINSTALLDIRS)
15
16 GMSGFMT = @GMSGFMT@
17 MSGFMT = @MSGFMT@
18Index: e2fsprogs-1.41.5/configure.in
19===================================================================
20--- e2fsprogs-1.41.5.orig/configure.in 2009-08-19 17:53:50.000000000 +0100
21+++ e2fsprogs-1.41.5/configure.in 2009-08-19 17:48:38.000000000 +0100
22@@ -970,6 +970,8 @@
23 fi 11 fi
24 AC_SUBST(BUILD_CFLAGS) 12 AC_SUBST(INCLUDES)
25 AC_SUBST(BUILD_LDFLAGS) 13-AM_MKINSTALLDIRS
26+MKINSTALLDIRS="mkdir -p" 14+MKINSTALLDIRS="mkdir -p"
27+AC_SUBST(MKINSTALLDIRS) 15+AC_SUBST(MKINSTALLDIRS)
28 dnl 16 dnl
29 dnl Make our output files, being sure that we create the some miscellaneous 17 dnl Build CFLAGS
30 dnl directories 18 dnl
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/ptest.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/ptest.patch
index b8a53e9133..ef1ce5872a 100644
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/ptest.patch
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/ptest.patch
@@ -1,17 +1,17 @@
1Index: e2fsprogs-1.42.9/tests/Makefile.in 1diff --git a/tests/Makefile.in b/tests/Makefile.in
2=================================================================== 2index 60cf655..ce220f1 100644
3--- e2fsprogs-1.42.9.orig/tests/Makefile.in 3--- a/tests/Makefile.in
4+++ e2fsprogs-1.42.9/tests/Makefile.in 4+++ b/tests/Makefile.in
5@@ -18,7 +18,7 @@ test_one: $(srcdir)/test_one.in Makefile 5@@ -18,7 +18,7 @@ test_one: $(srcdir)/test_one.in Makefile mke2fs.conf
6 @echo "#!/bin/sh" > test_one 6 @echo "#!/bin/sh" > test_one
7 @HTREE_CMT@ @echo "HTREE=y" >> test_one 7 @echo "HTREE=y" >> test_one
8 @QUOTA_CMT@ @echo "QUOTA=y" >> test_one 8 @echo "QUOTA=y" >> test_one
9- @echo "SRCDIR=@srcdir@" >> test_one 9- @echo "SRCDIR=@srcdir@" >> test_one
10+ @echo "SRCDIR=/usr/lib/e2fsprogs/ptest/test" >> test_one 10+ @echo "SRCDIR=/usr/lib/e2fsprogs/ptest/test" >> test_one
11 @echo "DIFF_OPTS=@UNI_DIFF_OPTS@" >> test_one 11 @echo "DIFF_OPTS=@UNI_DIFF_OPTS@" >> test_one
12 @cat $(srcdir)/test_one.in >> test_one 12 @cat $(srcdir)/test_one.in >> test_one
13 @chmod +x test_one 13 @chmod +x test_one
14@@ -26,7 +26,7 @@ test_one: $(srcdir)/test_one.in Makefile 14@@ -26,7 +26,7 @@ test_one: $(srcdir)/test_one.in Makefile mke2fs.conf
15 test_script: test_one test_script.in Makefile mke2fs.conf 15 test_script: test_one test_script.in Makefile mke2fs.conf
16 @echo "Creating test_script..." 16 @echo "Creating test_script..."
17 @echo "#!/bin/sh" > test_script 17 @echo "#!/bin/sh" > test_script
@@ -20,11 +20,11 @@ Index: e2fsprogs-1.42.9/tests/Makefile.in
20 @cat $(srcdir)/test_script.in >> test_script 20 @cat $(srcdir)/test_script.in >> test_script
21 @chmod +x test_script 21 @chmod +x test_script
22 22
23Index: e2fsprogs-1.42.9/tests/test_config 23diff --git a/tests/test_config b/tests/test_config
24=================================================================== 24index 7f39157..c815a44 100644
25--- e2fsprogs-1.42.9.orig/tests/test_config 25--- a/tests/test_config
26+++ e2fsprogs-1.42.9/tests/test_config 26+++ b/tests/test_config
27@@ -3,23 +3,23 @@ 27@@ -3,24 +3,24 @@
28 # 28 #
29 29
30 unset LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME PAGER 30 unset LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME PAGER
@@ -54,13 +54,14 @@ Index: e2fsprogs-1.42.9/tests/test_config
54+RESIZE2FS_EXE="/sbin/resize2fs" 54+RESIZE2FS_EXE="/sbin/resize2fs"
55 RESIZE2FS="$USE_VALGRIND $RESIZE2FS_EXE" 55 RESIZE2FS="$USE_VALGRIND $RESIZE2FS_EXE"
56-E2UNDO_EXE="../misc/e2undo" 56-E2UNDO_EXE="../misc/e2undo"
57+E2UNDO_EXE="/sbin/e2undo"
58 E2UNDO="$USE_VALGRIND $E2UNDO_EXE"
57-TEST_REL=../tests/progs/test_rel 59-TEST_REL=../tests/progs/test_rel
58-TEST_ICOUNT=../tests/progs/test_icount 60-TEST_ICOUNT=../tests/progs/test_icount
59-CRCSUM=../tests/progs/crcsum 61-CRCSUM=../tests/progs/crcsum
60+E2UNDO_EXE="/sbin/e2undo"
61+TEST_REL=./progs/test_rel 62+TEST_REL=./progs/test_rel
62+TEST_ICOUNT=./progs/test_icount 63+TEST_ICOUNT=./progs/test_icount
63+CRCSUM=./progs/crcsum 64+CRCSUM=./progs/crcsum
64 LD_LIBRARY_PATH=../lib:../lib/ext2fs:../lib/e2p:../lib/et:../lib/ss 65 CLEAN_OUTPUT="sed -f $cmd_dir/filter.sed"
65 DYLD_LIBRARY_PATH=../lib:../lib/ext2fs:../lib/e2p:../lib/et:../lib/ss 66 LD_LIBRARY_PATH=../lib:../lib/ext2fs:../lib/e2p:../lib/et:../lib/ss:${LD_LIBRARY_PATH}
66 export LD_LIBRARY_PATH 67 DYLD_LIBRARY_PATH=../lib:../lib/ext2fs:../lib/e2p:../lib/et:../lib/ss:${DYLD_LIBRARY_PATH}
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bb b/meta/recipes-devtools/e2fsprogs/e2fsprogs_git.bb
index ce7d2e8628..0aab8ae3f6 100644
--- a/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bb
+++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs_git.bb
@@ -1,35 +1,20 @@
1require e2fsprogs.inc 1require e2fsprogs.inc
2 2
3RECIPE_NO_UPDATE_REASON = "Updating backported patches to 1.42.13 is too much pain. Let's wait until 1.43 is released."
4
5SRC_URI += "file://acinclude.m4 \ 3SRC_URI += "file://acinclude.m4 \
6 file://remove.ldconfig.call.patch \ 4 file://remove.ldconfig.call.patch \
7 file://fix-icache.patch \
8 file://quiet-debugfs.patch \ 5 file://quiet-debugfs.patch \
9 file://0001-mke2fs-add-the-ability-to-copy-files-from-a-given-di.patch \ 6 file://run-ptest \
10 file://0002-misc-create_inode.c-copy-files-recursively.patch \ 7 file://ptest.patch \
11 file://0003-misc-create_inode.c-create-special-file.patch \ 8 file://mkdir.patch \
12 file://0004-misc-create_inode.c-create-symlink.patch \
13 file://0005-misc-create_inode.c-copy-regular-file.patch \
14 file://0006-misc-create_inode.c-create-directory.patch \
15 file://0007-misc-create_inode.c-set-owner-mode-time-for-the-inod.patch \
16 file://0008-mke2fs.c-add-an-option-d-root-directory.patch \
17 file://0009-misc-create_inode.c-handle-hardlinks.patch \
18 file://0010-debugfs-use-the-functions-in-misc-create_inode.c.patch \
19 file://0011-mke2fs.8.in-update-the-manual-for-the-d-option.patch \
20 file://0012-Fix-musl-build-failures.patch \
21 file://0001-e2fsprogs-fix-cross-compilation-problem.patch \
22 file://misc-mke2fs.c-return-error-when-failed-to-populate-fs.patch \
23 file://cache_inode.patch \
24 file://CVE-2015-0247.patch \
25 file://0001-libext2fs-fix-potential-buffer-overflow-in-closefs.patch \
26 file://copy-in-create-hardlinks-with-the-correct-directory-.patch \
27" 9"
28 10
29SRC_URI[md5sum] = "3f8e41e63b432ba114b33f58674563f7" 11SRCREV = "0f26747167cc9d82df849b0aad387bf824f04544"
30SRC_URI[sha256sum] = "2f92ac06e92fa00f2ada3ee67dad012d74d685537527ad1241d82f2d041f2802" 12PV = "1.42+1.43-git${SRCPV}"
13
14EXTRA_OECONF += "--libdir=${base_libdir} --sbindir=${base_sbindir} \
15 --enable-elf-shlibs --disable-libuuid --disable-uuidd \
16 --enable-libblkid --enable-verbose-makecmds"
31 17
32EXTRA_OECONF += "--libdir=${base_libdir} --sbindir=${base_sbindir} --enable-elf-shlibs --disable-libuuid --disable-uuidd --enable-verbose-makecmds"
33EXTRA_OECONF_darwin = "--libdir=${base_libdir} --sbindir=${base_sbindir} --enable-bsd-shlibs" 18EXTRA_OECONF_darwin = "--libdir=${base_libdir} --sbindir=${base_sbindir} --enable-bsd-shlibs"
34 19
35do_configure_prepend () { 20do_configure_prepend () {
@@ -84,10 +69,6 @@ FILES_libe2p = "${base_libdir}/libe2p.so.*"
84FILES_libext2fs = "${libdir}/e2initrd_helper ${base_libdir}/libext2fs.so.*" 69FILES_libext2fs = "${libdir}/e2initrd_helper ${base_libdir}/libext2fs.so.*"
85FILES_${PN}-dev += "${datadir}/*/*.awk ${datadir}/*/*.sed ${base_libdir}/*.so" 70FILES_${PN}-dev += "${datadir}/*/*.awk ${datadir}/*/*.sed ${base_libdir}/*.so"
86 71
87BBCLASSEXTEND = "native nativesdk"
88
89inherit update-alternatives
90
91ALTERNATIVE_${PN} = "chattr" 72ALTERNATIVE_${PN} = "chattr"
92ALTERNATIVE_PRIORITY = "100" 73ALTERNATIVE_PRIORITY = "100"
93ALTERNATIVE_LINK_NAME[chattr] = "${base_bindir}/chattr" 74ALTERNATIVE_LINK_NAME[chattr] = "${base_bindir}/chattr"
@@ -99,12 +80,7 @@ ALTERNATIVE_LINK_NAME[blkid.8] = "${mandir}/man8/blkid.8"
99ALTERNATIVE_LINK_NAME[findfs.8] = "${mandir}/man8/findfs.8" 80ALTERNATIVE_LINK_NAME[findfs.8] = "${mandir}/man8/findfs.8"
100ALTERNATIVE_LINK_NAME[fsck.8] = "${mandir}/man8/fsck.8" 81ALTERNATIVE_LINK_NAME[fsck.8] = "${mandir}/man8/fsck.8"
101 82
102inherit ptest 83RDEPENDS_${PN}-ptest += "${PN} ${PN}-tune2fs coreutils procps bash"
103SRC_URI += "file://run-ptest"
104SRC_URI += "file://ptest.patch"
105
106RDEPENDS_${PN}-ptest += "${PN} ${PN}-tune2fs coreutils procps"
107#RDEPENDS_${PN}-ptest += "expect"
108 84
109do_compile_ptest() { 85do_compile_ptest() {
110 oe_runmake -C ${B}/tests 86 oe_runmake -C ${B}/tests