diff options
Diffstat (limited to 'meta/recipes-devtools')
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 \ SECTION = "base" DEPENDS = "util-linux" -SRC_URI = "${SOURCEFORGE_MIRROR}/e2fsprogs/e2fsprogs-${PV}.tar.gz \ - file://mkdir.patch" +SRC_URI = "git://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git" +S = "${WORKDIR}/git" -inherit autotools gettext texinfo pkgconfig multilib_header +inherit autotools gettext texinfo pkgconfig multilib_header update-alternatives ptest + +BBCLASSEXTEND = "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 @@ -Upstream-Status: Pending - -Subject: e2fsprogs: fix cross compilation problem - -The checking of types in parse-types.sh doesn't make much sense in a -cross-compilation environment, because the generated binary is executed -on build machine. - -So even if asm_types.h has got correct statements for types, it's possible -that the generated binary will report an error. Because these types are for -the target machine. - -Signed-off-by: Chen Qi <Qi.Chen@windriver.com> ---- - config/parse-types.sh | 6 ++++-- - configure.in | 6 +++++- - 2 files changed, 9 insertions(+), 3 deletions(-) - -diff --git a/config/parse-types.sh b/config/parse-types.sh -index 5076f6c..24d2a99 100755 ---- a/config/parse-types.sh -+++ b/config/parse-types.sh -@@ -118,8 +118,10 @@ if ./asm_types - then - true - else -- echo "Problem detected with asm_types.h" -- echo "" > asm_types.h -+ if [ "${CROSS_COMPILE}" != "1" ]; then -+ echo "Problem detected with asm_types.h" -+ echo "" > asm_types.h -+ fi - fi - rm asm_types.c asm_types - -diff --git a/configure.in b/configure.in -index 68adf0d..ed1697b 100644 ---- a/configure.in -+++ b/configure.in -@@ -953,7 +953,11 @@ AC_SUBST(SIZEOF_LONG) - AC_SUBST(SIZEOF_LONG_LONG) - AC_SUBST(SIZEOF_OFF_T) - AC_C_BIGENDIAN --BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh -+if test $cross_compiling = no; then -+ BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh -+else -+ CROSS_COMPILE="1" BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh -+fi - ASM_TYPES_HEADER=./asm_types.h - AC_SUBST_FILE(ASM_TYPES_HEADER) - dnl --- -1.7.9.5 - 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 @@ -From 49d0fe2a14f2a23da2fe299643379b8c1d37df73 Mon Sep 17 00:00:00 2001 -From: Theodore Ts'o <tytso@mit.edu> -Date: Fri, 6 Feb 2015 12:46:39 -0500 -Subject: [PATCH] libext2fs: fix potential buffer overflow in closefs() - -Upstream-Status: Backport -CVE: CVE-2015-1572 - -The bug fix in f66e6ce4446: "libext2fs: avoid buffer overflow if -s_first_meta_bg is too big" had a typo in the fix for -ext2fs_closefs(). In practice most of the security exposure was from -the openfs path, since this meant if there was a carefully crafted -file system, buffer overrun would be triggered when the file system was -opened. - -However, if corrupted file system didn't trip over some corruption -check, and then the file system was modified via tune2fs or debugfs, -such that the superblock was marked dirty and then written out via the -closefs() path, it's possible that the buffer overrun could be -triggered when the file system is closed. - -Also clear up a signed vs unsigned warning while we're at it. - -Thanks to Nick Kralevich <nnk@google.com> for asking me to look at -compiler warning in the code in question, which led me to notice the -bug in f66e6ce4446. - -Addresses: CVE-2015-1572 - -Signed-off-by: Theodore Ts'o <tytso@mit.edu> ---- - lib/ext2fs/closefs.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c -index 1f99113..ab5b2fb 100644 ---- a/lib/ext2fs/closefs.c -+++ b/lib/ext2fs/closefs.c -@@ -287,7 +287,7 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags) - dgrp_t j; - #endif - char *group_ptr; -- int old_desc_blocks; -+ blk64_t old_desc_blocks; - struct ext2fs_numeric_progress_struct progress; - - EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); -@@ -346,7 +346,7 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags) - group_ptr = (char *) group_shadow; - if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) { - old_desc_blocks = fs->super->s_first_meta_bg; -- if (old_desc_blocks > fs->super->s_first_meta_bg) -+ if (old_desc_blocks > fs->desc_blocks) - old_desc_blocks = fs->desc_blocks; - } else - old_desc_blocks = fs->desc_blocks; --- -2.1.0 - 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 @@ -From c98fec004f077e566b9dfa20b25e3b86cb462a2e Mon Sep 17 00:00:00 2001 -From: Robert Yang <liezhi.yang@windriver.com> -Date: Tue, 24 Dec 2013 01:41:08 -0500 -Subject: [PATCH 01/11] mke2fs: add the ability to copy files from a given - directory - -We will add a -d option which will be used for adding the files from a -given directory to the filesystem, it is similiar to genext2fs, but -genext2fs doesn't fully support ext4. - -* We already have the basic operations in debugfs: - - Copy regular file - - Create directory - - Create symlink - - Create special file - - We will move these operations into create_inode.h and create_inode.c, - then let both mke2fs and debugfs use them. - -* What we need to do are: - - Copy the given directory recursively, this will be done by the - populate_fs() - - Set the owner, mode and other informations - - Handle the hard links - -TODO: - - The libext2fs can't create the socket file (S_IFSOCK), do we have a - plan to support it ? - -Upstream-Status: Backport - -Signed-off-by: Robert Yang <liezhi.yang@windriver.com> -Reviewed-by: Darren Hart <dvhart@linux.intel.com> ---- - misc/create_inode.c | 26 ++++++++++++++++++++++++++ - misc/create_inode.h | 17 +++++++++++++++++ - 2 files changed, 43 insertions(+) - create mode 100644 misc/create_inode.c - create mode 100644 misc/create_inode.h - -diff --git a/misc/create_inode.c b/misc/create_inode.c -new file mode 100644 -index 0000000..46aaa60 ---- /dev/null -+++ b/misc/create_inode.c -@@ -0,0 +1,26 @@ -+#include "create_inode.h" -+ -+/* Make a special file which is block, character and fifo */ -+errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st) -+{ -+} -+ -+/* Make a symlink name -> target */ -+errcode_t do_symlink_internal(ext2_ino_t cwd, const char *name, char *target) -+{ -+} -+ -+/* Make a directory in the fs */ -+errcode_t do_mkdir_internal(ext2_ino_t cwd, const char *name, struct stat *st) -+{ -+} -+ -+/* Copy the native file to the fs */ -+errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest) -+{ -+} -+ -+/* Copy files from source_dir to fs */ -+errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir) -+{ -+} -diff --git a/misc/create_inode.h b/misc/create_inode.h -new file mode 100644 -index 0000000..9fc97fa ---- /dev/null -+++ b/misc/create_inode.h -@@ -0,0 +1,17 @@ -+#include <sys/types.h> -+#include <sys/stat.h> -+#include <fcntl.h> -+#include "et/com_err.h" -+#include "e2p/e2p.h" -+#include "ext2fs/ext2fs.h" -+#include "nls-enable.h" -+ -+ext2_filsys current_fs; -+ext2_ino_t root; -+ -+/* For populating the filesystem */ -+extern errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir); -+extern errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st); -+extern errcode_t do_symlink_internal(ext2_ino_t cwd, const char *name, char *target); -+extern errcode_t do_mkdir_internal(ext2_ino_t cwd, const char *name, struct stat *st); -+extern errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest); --- -1.7.10.4 - 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 @@ -From 08dfbaf4e3f704232ff46d78c0758a6cfe3961c8 Mon Sep 17 00:00:00 2001 -From: Robert Yang <liezhi.yang@windriver.com> -Date: Mon, 23 Dec 2013 02:59:10 -0500 -Subject: [PATCH 02/11] misc/create_inode.c: copy files recursively - -Use opendir() and readdir() to read the native directory, then use -lstat() to identify the file type and call the corresponding function to -add the file to the filesystem, call the populate_fs() recursively if it -is a directory. - -NOTE: the libext2fs can't create the socket file. - -Upstream-Status: Backport - -Signed-off-by: Robert Yang <liezhi.yang@windriver.com> -Reviewed-by: Darren Hart <dvhart@linux.intel.com> ---- - misc/create_inode.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 97 insertions(+) - -diff --git a/misc/create_inode.c b/misc/create_inode.c -index 46aaa60..b68b910 100644 ---- a/misc/create_inode.c -+++ b/misc/create_inode.c -@@ -1,5 +1,13 @@ - #include "create_inode.h" - -+#if __STDC_VERSION__ < 199901L -+# if __GNUC__ >= 2 -+# define __func__ __FUNCTION__ -+# else -+# define __func__ "<unknown>" -+# endif -+#endif -+ - /* Make a special file which is block, character and fifo */ - errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st) - { -@@ -23,4 +31,93 @@ errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest) - /* Copy files from source_dir to fs */ - errcode_t populate_fs(ext2_ino_t parent_ino, const char *source_dir) - { -+ const char *name; -+ DIR *dh; -+ struct dirent *dent; -+ struct stat st; -+ char ln_target[PATH_MAX]; -+ ext2_ino_t ino; -+ errcode_t retval; -+ int read_cnt; -+ -+ root = EXT2_ROOT_INO; -+ -+ if (chdir(source_dir) < 0) { -+ com_err(__func__, errno, -+ _("while changing working directory to \"%s\""), source_dir); -+ return errno; -+ } -+ -+ if (!(dh = opendir("."))) { -+ com_err(__func__, errno, -+ _("while openning directory \"%s\""), source_dir); -+ return errno; -+ } -+ -+ while((dent = readdir(dh))) { -+ if((!strcmp(dent->d_name, ".")) || (!strcmp(dent->d_name, ".."))) -+ continue; -+ lstat(dent->d_name, &st); -+ name = dent->d_name; -+ -+ switch(st.st_mode & S_IFMT) { -+ case S_IFCHR: -+ case S_IFBLK: -+ case S_IFIFO: -+ if ((retval = do_mknod_internal(parent_ino, name, &st))) { -+ com_err(__func__, retval, -+ _("while creating special file \"%s\""), name); -+ return retval; -+ } -+ break; -+ case S_IFSOCK: -+ /* FIXME: there is no make socket function atm. */ -+ com_err(__func__, 0, -+ _("ignoring socket file \"%s\""), name); -+ continue; -+ case S_IFLNK: -+ if((read_cnt = readlink(name, ln_target, sizeof(ln_target))) == -1) { -+ com_err(__func__, errno, -+ _("while trying to readlink \"%s\""), name); -+ return errno; -+ } -+ ln_target[read_cnt] = '\0'; -+ if ((retval = do_symlink_internal(parent_ino, name, ln_target))) { -+ com_err(__func__, retval, -+ _("while writing symlink\"%s\""), name); -+ return retval; -+ } -+ break; -+ case S_IFREG: -+ if ((retval = do_write_internal(parent_ino, name, name))) { -+ com_err(__func__, retval, -+ _("while writing file \"%s\""), name); -+ return retval; -+ } -+ break; -+ case S_IFDIR: -+ if ((retval = do_mkdir_internal(parent_ino, name, &st))) { -+ com_err(__func__, retval, -+ _("while making dir \"%s\""), name); -+ return retval; -+ } -+ if ((retval = ext2fs_namei(current_fs, root, parent_ino, name, &ino))) { -+ com_err(name, retval, 0); -+ return retval; -+ } -+ /* Populate the dir recursively*/ -+ retval = populate_fs(ino, name); -+ if (retval) { -+ com_err(__func__, retval, _("while adding dir \"%s\""), name); -+ return retval; -+ } -+ chdir(".."); -+ break; -+ default: -+ com_err(__func__, 0, -+ _("ignoring entry \"%s\""), name); -+ } -+ } -+ closedir(dh); -+ return retval; - } --- -1.7.10.4 - 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 @@ -From ae7d33823bfc330e08b25c5fe4d25838ef7c77ce Mon Sep 17 00:00:00 2001 -From: Robert Yang <liezhi.yang@windriver.com> -Date: Mon, 23 Dec 2013 03:13:28 -0500 -Subject: [PATCH 03/11] misc/create_inode.c: create special file - -The do_mknod_internal() is used for creating special file which is -block, character and fifo, most of the code are from debugfs/debugfs.c, -the debugfs/debugfs.c will be modified to use this function. - -Upstream-Status: Backport - -Signed-off-by: Robert Yang <liezhi.yang@windriver.com> -Reviewed-by: Darren Hart <dvhart@linux.intel.com> ---- - misc/create_inode.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 72 insertions(+) - -diff --git a/misc/create_inode.c b/misc/create_inode.c -index b68b910..4da8aff 100644 ---- a/misc/create_inode.c -+++ b/misc/create_inode.c -@@ -11,6 +11,78 @@ - /* Make a special file which is block, character and fifo */ - errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st) - { -+ ext2_ino_t ino; -+ errcode_t retval; -+ struct ext2_inode inode; -+ unsigned long major, minor, mode; -+ int filetype; -+ -+ switch(st->st_mode & S_IFMT) { -+ case S_IFCHR: -+ mode = LINUX_S_IFCHR; -+ filetype = EXT2_FT_CHRDEV; -+ break; -+ case S_IFBLK: -+ mode = LINUX_S_IFBLK; -+ filetype = EXT2_FT_BLKDEV; -+ break; -+ case S_IFIFO: -+ mode = LINUX_S_IFIFO; -+ filetype = EXT2_FT_FIFO; -+ break; -+ } -+ -+ if (!(current_fs->flags & EXT2_FLAG_RW)) { -+ com_err(__func__, 0, "Filesystem opened read/only"); -+ return -1; -+ } -+ retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &ino); -+ if (retval) { -+ com_err(__func__, retval, 0); -+ return retval; -+ } -+ -+#ifdef DEBUGFS -+ printf("Allocated inode: %u\n", ino); -+#endif -+ retval = ext2fs_link(current_fs, cwd, name, ino, filetype); -+ if (retval == EXT2_ET_DIR_NO_SPACE) { -+ retval = ext2fs_expand_dir(current_fs, cwd); -+ if (retval) { -+ com_err(__func__, retval, "while expanding directory"); -+ return retval; -+ } -+ retval = ext2fs_link(current_fs, cwd, name, ino, filetype); -+ } -+ if (retval) { -+ com_err(name, retval, 0); -+ return -1; -+ } -+ if (ext2fs_test_inode_bitmap2(current_fs->inode_map, ino)) -+ com_err(__func__, 0, "Warning: inode already set"); -+ ext2fs_inode_alloc_stats2(current_fs, ino, +1, 0); -+ memset(&inode, 0, sizeof(inode)); -+ inode.i_mode = mode; -+ inode.i_atime = inode.i_ctime = inode.i_mtime = -+ current_fs->now ? current_fs->now : time(0); -+ -+ major = major(st->st_rdev); -+ minor = minor(st->st_rdev); -+ -+ if ((major < 256) && (minor < 256)) { -+ inode.i_block[0] = major * 256 + minor; -+ inode.i_block[1] = 0; -+ } else { -+ inode.i_block[0] = 0; -+ inode.i_block[1] = (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12); -+ } -+ inode.i_links_count = 1; -+ -+ retval = ext2fs_write_new_inode(current_fs, ino, &inode); -+ if (retval) -+ com_err(__func__, retval, "while creating inode %u", ino); -+ -+ return retval; - } - - /* Make a symlink name -> target */ --- -1.7.10.4 - 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 @@ -From 09d3049776882167f7249ee26265b4163d7222c1 Mon Sep 17 00:00:00 2001 -From: Robert Yang <liezhi.yang@windriver.com> -Date: Mon, 23 Dec 2013 03:19:55 -0500 -Subject: [PATCH 04/11] misc/create_inode.c: create symlink - -The do_symlink_internal() is used for creating symlinks, most of the -code are from debugfs/debugfs.c, the debugfs/debugfs.c will be modified -to use this function. - -Upstream-Status: Backport - -Signed-off-by: Robert Yang <liezhi.yang@windriver.com> -Reviewed-by: Darren Hart <dvhart@linux.intel.com> ---- - misc/create_inode.c | 32 ++++++++++++++++++++++++++++++++ - 1 file changed, 32 insertions(+) - -diff --git a/misc/create_inode.c b/misc/create_inode.c -index 4da8aff..f845103 100644 ---- a/misc/create_inode.c -+++ b/misc/create_inode.c -@@ -88,6 +88,38 @@ errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st) - /* Make a symlink name -> target */ - errcode_t do_symlink_internal(ext2_ino_t cwd, const char *name, char *target) - { -+ char *cp; -+ ext2_ino_t parent_ino; -+ errcode_t retval; -+ struct ext2_inode inode; -+ struct stat st; -+ -+ cp = strrchr(name, '/'); -+ if (cp) { -+ *cp = 0; -+ if ((retval = ext2fs_namei(current_fs, root, cwd, name, &parent_ino))){ -+ com_err(name, retval, 0); -+ return retval; -+ } -+ name = cp+1; -+ } else -+ parent_ino = cwd; -+ -+try_again: -+ retval = ext2fs_symlink(current_fs, parent_ino, 0, name, target); -+ if (retval == EXT2_ET_DIR_NO_SPACE) { -+ retval = ext2fs_expand_dir(current_fs, parent_ino); -+ if (retval) { -+ com_err("do_symlink_internal", retval, "while expanding directory"); -+ return retval; -+ } -+ goto try_again; -+ } -+ if (retval) { -+ com_err("ext2fs_symlink", retval, 0); -+ return retval; -+ } -+ - } - - /* Make a directory in the fs */ --- -1.7.10.4 - 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 @@ -From 2973c74afaa532f3f72639b463322b2523519c20 Mon Sep 17 00:00:00 2001 -From: Robert Yang <liezhi.yang@windriver.com> -Date: Mon, 23 Dec 2013 03:28:12 -0500 -Subject: [PATCH 05/11] misc/create_inode.c: copy regular file - -The do_write_internal() is used for copying file from native fs to -target, most of the code are from debugfs/debugfs.c, the -debugfs/debugfs.c will be modified to use this function. - -Upstream-Status: Backport - -Signed-off-by: Robert Yang <liezhi.yang@windriver.com> -Reviewed-by: Darren Hart <dvhart@linux.intel.com> ---- - misc/create_inode.c | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 183 insertions(+) - -diff --git a/misc/create_inode.c b/misc/create_inode.c -index f845103..98f4a93 100644 ---- a/misc/create_inode.c -+++ b/misc/create_inode.c -@@ -8,6 +8,16 @@ - # endif - #endif - -+/* 64KiB is the minimium blksize to best minimize system call overhead. */ -+#ifndef IO_BUFSIZE -+#define IO_BUFSIZE 64*1024 -+#endif -+ -+/* Block size for `st_blocks' */ -+#ifndef S_BLKSIZE -+#define S_BLKSIZE 512 -+#endif -+ - /* Make a special file which is block, character and fifo */ - errcode_t do_mknod_internal(ext2_ino_t cwd, const char *name, struct stat *st) - { -@@ -127,9 +137,182 @@ errcode_t do_mkdir_internal(ext2_ino_t cwd, const char *name, struct stat *st) - { - } - -+static errcode_t copy_file(int fd, ext2_ino_t newfile, int bufsize, int make_holes) -+{ -+ ext2_file_t e2_file; -+ errcode_t retval; -+ int got; -+ unsigned int written; -+ char *buf; -+ char *ptr; -+ char *zero_buf; -+ int cmp; -+ -+ retval = ext2fs_file_open(current_fs, newfile, -+ EXT2_FILE_WRITE, &e2_file); -+ if (retval) -+ return retval; -+ -+ retval = ext2fs_get_mem(bufsize, &buf); -+ if (retval) { -+ com_err("copy_file", retval, "can't allocate buffer\n"); -+ return retval; -+ } -+ -+ /* This is used for checking whether the whole block is zero */ -+ retval = ext2fs_get_memzero(bufsize, &zero_buf); -+ if (retval) { -+ com_err("copy_file", retval, "can't allocate buffer\n"); -+ ext2fs_free_mem(&buf); -+ return retval; -+ } -+ -+ while (1) { -+ got = read(fd, buf, bufsize); -+ if (got == 0) -+ break; -+ if (got < 0) { -+ retval = errno; -+ goto fail; -+ } -+ ptr = buf; -+ -+ /* Sparse copy */ -+ if (make_holes) { -+ /* Check whether all is zero */ -+ cmp = memcmp(ptr, zero_buf, got); -+ if (cmp == 0) { -+ /* The whole block is zero, make a hole */ -+ retval = ext2fs_file_lseek(e2_file, got, EXT2_SEEK_CUR, NULL); -+ if (retval) -+ goto fail; -+ got = 0; -+ } -+ } -+ -+ /* Normal copy */ -+ while (got > 0) { -+ retval = ext2fs_file_write(e2_file, ptr, -+ got, &written); -+ if (retval) -+ goto fail; -+ -+ got -= written; -+ ptr += written; -+ } -+ } -+ ext2fs_free_mem(&buf); -+ ext2fs_free_mem(&zero_buf); -+ retval = ext2fs_file_close(e2_file); -+ return retval; -+ -+fail: -+ ext2fs_free_mem(&buf); -+ ext2fs_free_mem(&zero_buf); -+ (void) ext2fs_file_close(e2_file); -+ return retval; -+} -+ - /* Copy the native file to the fs */ - errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest) - { -+ int fd; -+ struct stat statbuf; -+ ext2_ino_t newfile; -+ errcode_t retval; -+ struct ext2_inode inode; -+ int bufsize = IO_BUFSIZE; -+ int make_holes = 0; -+ -+ fd = open(src, O_RDONLY); -+ if (fd < 0) { -+ com_err(src, errno, 0); -+ return errno; -+ } -+ if (fstat(fd, &statbuf) < 0) { -+ com_err(src, errno, 0); -+ close(fd); -+ return errno; -+ } -+ -+ retval = ext2fs_namei(current_fs, root, cwd, dest, &newfile); -+ if (retval == 0) { -+ com_err(__func__, 0, "The file '%s' already exists\n", dest); -+ close(fd); -+ return retval; -+ } -+ -+ retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &newfile); -+ if (retval) { -+ com_err(__func__, retval, 0); -+ close(fd); -+ return retval; -+ } -+#ifdef DEBUGFS -+ printf("Allocated inode: %u\n", newfile); -+#endif -+ retval = ext2fs_link(current_fs, cwd, dest, newfile, -+ EXT2_FT_REG_FILE); -+ if (retval == EXT2_ET_DIR_NO_SPACE) { -+ retval = ext2fs_expand_dir(current_fs, cwd); -+ if (retval) { -+ com_err(__func__, retval, "while expanding directory"); -+ close(fd); -+ return retval; -+ } -+ retval = ext2fs_link(current_fs, cwd, dest, newfile, -+ EXT2_FT_REG_FILE); -+ } -+ if (retval) { -+ com_err(dest, retval, 0); -+ close(fd); -+ return retval; -+ } -+ if (ext2fs_test_inode_bitmap2(current_fs->inode_map, newfile)) -+ com_err(__func__, 0, "Warning: inode already set"); -+ ext2fs_inode_alloc_stats2(current_fs, newfile, +1, 0); -+ memset(&inode, 0, sizeof(inode)); -+ inode.i_mode = (statbuf.st_mode & ~LINUX_S_IFMT) | LINUX_S_IFREG; -+ inode.i_atime = inode.i_ctime = inode.i_mtime = -+ current_fs->now ? current_fs->now : time(0); -+ inode.i_links_count = 1; -+ inode.i_size = statbuf.st_size; -+ if (current_fs->super->s_feature_incompat & -+ EXT3_FEATURE_INCOMPAT_EXTENTS) { -+ int i; -+ struct ext3_extent_header *eh; -+ -+ eh = (struct ext3_extent_header *) &inode.i_block[0]; -+ eh->eh_depth = 0; -+ eh->eh_entries = 0; -+ eh->eh_magic = ext2fs_cpu_to_le16(EXT3_EXT_MAGIC); -+ i = (sizeof(inode.i_block) - sizeof(*eh)) / -+ sizeof(struct ext3_extent); -+ eh->eh_max = ext2fs_cpu_to_le16(i); -+ inode.i_flags |= EXT4_EXTENTS_FL; -+ } -+ -+ if ((retval = ext2fs_write_new_inode(current_fs, newfile, &inode))) { -+ com_err(__func__, retval, "while creating inode %u", newfile); -+ close(fd); -+ return retval; -+ } -+ if (LINUX_S_ISREG(inode.i_mode)) { -+ if (statbuf.st_blocks < statbuf.st_size / S_BLKSIZE) { -+ make_holes = 1; -+ /* -+ * Use I/O blocksize as buffer size when -+ * copying sparse files. -+ */ -+ bufsize = statbuf.st_blksize; -+ } -+ retval = copy_file(fd, newfile, bufsize, make_holes); -+ if (retval) -+ com_err("copy_file", retval, 0); -+ } -+ close(fd); -+ -+ return 0; - } - - /* Copy files from source_dir to fs */ --- -1.7.10.4 - 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 @@ -From c8d1c43be24489036137f8fdebcfccc208f7cc8b Mon Sep 17 00:00:00 2001 -From: Robert Yang <liezhi.yang@windriver.com> -Date: Mon, 23 Dec 2013 03:34:14 -0500 -Subject: [PATCH 06/11] misc/create_inode.c: create directory - -The do_mkdir_internal() is used for making dir on the target fs, most of -the code are from debugfs/debugfs.c, the debugfs/debugfs.c will be -modified to use this function. - -Upstream-Status: Backport - -Signed-off-by: Robert Yang <liezhi.yang@windriver.com> -Reviewed-by: Darren Hart <dvhart@linux.intel.com> ---- - misc/create_inode.c | 31 +++++++++++++++++++++++++++++++ - 1 file changed, 31 insertions(+) - -diff --git a/misc/create_inode.c b/misc/create_inode.c -index 98f4a93..6a8c92a 100644 ---- a/misc/create_inode.c -+++ b/misc/create_inode.c -@@ -135,6 +135,37 @@ try_again: - /* Make a directory in the fs */ - errcode_t do_mkdir_internal(ext2_ino_t cwd, const char *name, struct stat *st) - { -+ char *cp; -+ ext2_ino_t parent_ino, ino; -+ errcode_t retval; -+ struct ext2_inode inode; -+ -+ -+ cp = strrchr(name, '/'); -+ if (cp) { -+ *cp = 0; -+ if ((retval = ext2fs_namei(current_fs, root, cwd, name, &parent_ino))){ -+ com_err(name, retval, 0); -+ return retval; -+ } -+ name = cp+1; -+ } else -+ parent_ino = cwd; -+ -+try_again: -+ retval = ext2fs_mkdir(current_fs, parent_ino, 0, name); -+ if (retval == EXT2_ET_DIR_NO_SPACE) { -+ retval = ext2fs_expand_dir(current_fs, parent_ino); -+ if (retval) { -+ com_err(__func__, retval, "while expanding directory"); -+ return retval; -+ } -+ goto try_again; -+ } -+ |
