diff options
| author | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
|---|---|---|
| committer | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
| commit | 972dcfcdbfe75dcfeb777150c136576cf1a71e99 (patch) | |
| tree | 97a61cd7e293d7ae9d56ef7ed0f81253365bb026 /meta/recipes-devtools/e2fsprogs | |
| download | poky-972dcfcdbfe75dcfeb777150c136576cf1a71e99.tar.gz | |
initial commit for Enea Linux 5.0 arm
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'meta/recipes-devtools/e2fsprogs')
23 files changed, 2345 insertions, 0 deletions
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs.inc b/meta/recipes-devtools/e2fsprogs/e2fsprogs.inc new file mode 100644 index 0000000000..bcd9ba7590 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs.inc | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | SUMMARY = "Ext2 Filesystem Utilities" | ||
| 2 | DESCRIPTION = "The Ext2 Filesystem Utilities (e2fsprogs) contain all of the standard utilities for creating, \ | ||
| 3 | fixing, configuring , and debugging ext2 filesystems." | ||
| 4 | HOMEPAGE = "http://e2fsprogs.sourceforge.net/" | ||
| 5 | |||
| 6 | LICENSE = "GPLv2 & LGPLv2 & BSD & MIT" | ||
| 7 | LICENSE_e2fsprogs-e2fsck = "GPLv2" | ||
| 8 | LICENSE_e2fsprogs-mke2fs = "GPLv2" | ||
| 9 | LICENSE_e2fsprogs-fsck = "GPLv2" | ||
| 10 | LICENSE_e2fsprogs-tune2fs = "GPLv2" | ||
| 11 | LICENSE_e2fsprogs-badblocks = "GPLv2" | ||
| 12 | LIC_FILES_CHKSUM = "file://COPYING;md5=b48f21d765b875bd10400975d12c1ca2 \ | ||
| 13 | file://lib/ext2fs/ext2fs.h;beginline=1;endline=9;md5=596a8dedcb4e731c6b21c7a46fba6bef \ | ||
| 14 | file://lib/e2p/e2p.h;beginline=1;endline=7;md5=8a74ade8f9d65095d70ef2d4bf48e36a \ | ||
| 15 | file://lib/uuid/uuid.h.in;beginline=1;endline=32;md5=dbb8079e114a5f841934b99e59c8820a \ | ||
| 16 | file://lib/uuid/COPYING;md5=58dcd8452651fc8b07d1f65ce07ca8af \ | ||
| 17 | file://lib/et/et_name.c;beginline=1;endline=11;md5=ead236447dac7b980dbc5b4804d8c836 \ | ||
| 18 | file://lib/ss/ss.h;beginline=1;endline=20;md5=6e89ad47da6e75fecd2b5e0e81e1d4a6" | ||
| 19 | SECTION = "base" | ||
| 20 | DEPENDS = "util-linux" | ||
| 21 | |||
| 22 | SRC_URI = "${SOURCEFORGE_MIRROR}/e2fsprogs/e2fsprogs-${PV}.tar.gz \ | ||
| 23 | file://mkdir.patch" | ||
| 24 | |||
| 25 | inherit autotools gettext texinfo pkgconfig multilib_header | ||
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 new file mode 100644 index 0000000000..73043bedda --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-e2fsprogs-fix-cross-compilation-problem.patch | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Subject: e2fsprogs: fix cross compilation problem | ||
| 4 | |||
| 5 | The checking of types in parse-types.sh doesn't make much sense in a | ||
| 6 | cross-compilation environment, because the generated binary is executed | ||
| 7 | on build machine. | ||
| 8 | |||
| 9 | So even if asm_types.h has got correct statements for types, it's possible | ||
| 10 | that the generated binary will report an error. Because these types are for | ||
| 11 | the target machine. | ||
| 12 | |||
| 13 | Signed-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 | |||
| 19 | diff --git a/config/parse-types.sh b/config/parse-types.sh | ||
| 20 | index 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 | |||
| 36 | diff --git a/configure.in b/configure.in | ||
| 37 | index 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 | -- | ||
| 54 | 1.7.9.5 | ||
| 55 | |||
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 new file mode 100644 index 0000000000..9ea413ef57 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0001-mke2fs-add-the-ability-to-copy-files-from-a-given-di.patch | |||
| @@ -0,0 +1,98 @@ | |||
| 1 | From c98fec004f077e566b9dfa20b25e3b86cb462a2e Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Tue, 24 Dec 2013 01:41:08 -0500 | ||
| 4 | Subject: [PATCH 01/11] mke2fs: add the ability to copy files from a given | ||
| 5 | directory | ||
| 6 | |||
| 7 | We will add a -d option which will be used for adding the files from a | ||
| 8 | given directory to the filesystem, it is similiar to genext2fs, but | ||
| 9 | genext2fs 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 | |||
| 26 | TODO: | ||
| 27 | - The libext2fs can't create the socket file (S_IFSOCK), do we have a | ||
| 28 | plan to support it ? | ||
| 29 | |||
| 30 | Upstream-Status: Backport | ||
| 31 | |||
| 32 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 33 | Reviewed-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 | |||
| 41 | diff --git a/misc/create_inode.c b/misc/create_inode.c | ||
| 42 | new file mode 100644 | ||
| 43 | index 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 | +} | ||
| 73 | diff --git a/misc/create_inode.h b/misc/create_inode.h | ||
| 74 | new file mode 100644 | ||
| 75 | index 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 | -- | ||
| 97 | 1.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 new file mode 100644 index 0000000000..9bff644ea6 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0002-misc-create_inode.c-copy-files-recursively.patch | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | From 08dfbaf4e3f704232ff46d78c0758a6cfe3961c8 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Mon, 23 Dec 2013 02:59:10 -0500 | ||
| 4 | Subject: [PATCH 02/11] misc/create_inode.c: copy files recursively | ||
| 5 | |||
| 6 | Use opendir() and readdir() to read the native directory, then use | ||
| 7 | lstat() to identify the file type and call the corresponding function to | ||
| 8 | add the file to the filesystem, call the populate_fs() recursively if it | ||
| 9 | is a directory. | ||
| 10 | |||
| 11 | NOTE: the libext2fs can't create the socket file. | ||
| 12 | |||
| 13 | Upstream-Status: Backport | ||
| 14 | |||
| 15 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 16 | Reviewed-by: Darren Hart <dvhart@linux.intel.com> | ||
| 17 | --- | ||
| 18 | misc/create_inode.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 19 | 1 file changed, 97 insertions(+) | ||
| 20 | |||
| 21 | diff --git a/misc/create_inode.c b/misc/create_inode.c | ||
| 22 | index 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 | -- | ||
| 134 | 1.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 new file mode 100644 index 0000000000..3847b6e5ce --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0003-misc-create_inode.c-create-special-file.patch | |||
| @@ -0,0 +1,103 @@ | |||
| 1 | From ae7d33823bfc330e08b25c5fe4d25838ef7c77ce Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Mon, 23 Dec 2013 03:13:28 -0500 | ||
| 4 | Subject: [PATCH 03/11] misc/create_inode.c: create special file | ||
| 5 | |||
| 6 | The do_mknod_internal() is used for creating special file which is | ||
| 7 | block, character and fifo, most of the code are from debugfs/debugfs.c, | ||
| 8 | the debugfs/debugfs.c will be modified to use this function. | ||
| 9 | |||
| 10 | Upstream-Status: Backport | ||
| 11 | |||
| 12 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 13 | Reviewed-by: Darren Hart <dvhart@linux.intel.com> | ||
| 14 | --- | ||
| 15 | misc/create_inode.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 16 | 1 file changed, 72 insertions(+) | ||
| 17 | |||
| 18 | diff --git a/misc/create_inode.c b/misc/create_inode.c | ||
| 19 | index 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 | -- | ||
| 102 | 1.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 new file mode 100644 index 0000000000..83d198c75a --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0004-misc-create_inode.c-create-symlink.patch | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | From 09d3049776882167f7249ee26265b4163d7222c1 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Mon, 23 Dec 2013 03:19:55 -0500 | ||
| 4 | Subject: [PATCH 04/11] misc/create_inode.c: create symlink | ||
| 5 | |||
| 6 | The do_symlink_internal() is used for creating symlinks, most of the | ||
| 7 | code are from debugfs/debugfs.c, the debugfs/debugfs.c will be modified | ||
| 8 | to use this function. | ||
| 9 | |||
| 10 | Upstream-Status: Backport | ||
| 11 | |||
| 12 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 13 | Reviewed-by: Darren Hart <dvhart@linux.intel.com> | ||
| 14 | --- | ||
| 15 | misc/create_inode.c | 32 ++++++++++++++++++++++++++++++++ | ||
| 16 | 1 file changed, 32 insertions(+) | ||
| 17 | |||
| 18 | diff --git a/misc/create_inode.c b/misc/create_inode.c | ||
| 19 | index 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 | -- | ||
| 62 | 1.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 new file mode 100644 index 0000000000..7935cd84ff --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0005-misc-create_inode.c-copy-regular-file.patch | |||
| @@ -0,0 +1,224 @@ | |||
| 1 | From 2973c74afaa532f3f72639b463322b2523519c20 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Mon, 23 Dec 2013 03:28:12 -0500 | ||
| 4 | Subject: [PATCH 05/11] misc/create_inode.c: copy regular file | ||
| 5 | |||
| 6 | The do_write_internal() is used for copying file from native fs to | ||
| 7 | target, most of the code are from debugfs/debugfs.c, the | ||
| 8 | debugfs/debugfs.c will be modified to use this function. | ||
| 9 | |||
| 10 | Upstream-Status: Backport | ||
| 11 | |||
| 12 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 13 | Reviewed-by: Darren Hart <dvhart@linux.intel.com> | ||
| 14 | --- | ||
| 15 | misc/create_inode.c | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 16 | 1 file changed, 183 insertions(+) | ||
| 17 | |||
| 18 | diff --git a/misc/create_inode.c b/misc/create_inode.c | ||
| 19 | index 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 | -- | ||
| 223 | 1.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 new file mode 100644 index 0000000000..5c7ca9c37e --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0006-misc-create_inode.c-create-directory.patch | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | From c8d1c43be24489036137f8fdebcfccc208f7cc8b Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Mon, 23 Dec 2013 03:34:14 -0500 | ||
| 4 | Subject: [PATCH 06/11] misc/create_inode.c: create directory | ||
| 5 | |||
| 6 | The do_mkdir_internal() is used for making dir on the target fs, most of | ||
| 7 | the code are from debugfs/debugfs.c, the debugfs/debugfs.c will be | ||
| 8 | modified to use this function. | ||
| 9 | |||
| 10 | Upstream-Status: Backport | ||
| 11 | |||
| 12 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 13 | Reviewed-by: Darren Hart <dvhart@linux.intel.com> | ||
| 14 | --- | ||
| 15 | misc/create_inode.c | 31 +++++++++++++++++++++++++++++++ | ||
| 16 | 1 file changed, 31 insertions(+) | ||
| 17 | |||
| 18 | diff --git a/misc/create_inode.c b/misc/create_inode.c | ||
| 19 | index 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 | -- | ||
| 61 | 1.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 new file mode 100644 index 0000000000..f296393b4f --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0007-misc-create_inode.c-set-owner-mode-time-for-the-inod.patch | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | From 2b1f6e6b386703a5d7e60b7d8b72746f3d31a8bc Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Mon, 23 Dec 2013 03:39:56 -0500 | ||
| 4 | Subject: [PATCH 07/11] misc/create_inode.c: set owner/mode/time for the inode | ||
| 5 | |||
| 6 | Set the uid, gid, mode and time for inode. | ||
| 7 | |||
| 8 | Upstream-Status: Backport | ||
| 9 | |||
| 10 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 11 | Reviewed-by: Darren Hart <dvhart@linux.intel.com> | ||
| 12 | --- | ||
| 13 | misc/create_inode.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ | ||
| 14 | 1 file changed, 45 insertions(+) | ||
| 15 | |||
| 16 | diff --git a/misc/create_inode.c b/misc/create_inode.c | ||
| 17 | index 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 | -- | ||
| 80 | 1.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 new file mode 100644 index 0000000000..1f98673f35 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0008-mke2fs.c-add-an-option-d-root-directory.patch | |||
| @@ -0,0 +1,168 @@ | |||
| 1 | From df856929e42bd4f3bdc8d4f59ee82ae8b28532e6 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Tue, 24 Dec 2013 01:50:45 -0500 | ||
| 4 | Subject: [PATCH 08/11] mke2fs.c: add an option: -d root-directory | ||
| 5 | |||
| 6 | This option is used for adding the files from a given directory (the | ||
| 7 | root-directory) to the filesystem, it is similiar to genext2fs, but | ||
| 8 | genext2fs doesn't fully support ext4. | ||
| 9 | |||
| 10 | Upstream-Status: Backport | ||
| 11 | |||
| 12 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 13 | Reviewed-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 | |||
| 19 | diff --git a/misc/Makefile.in b/misc/Makefile.in | ||
| 20 | index 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 | ||
| 69 | diff --git a/misc/mke2fs.c b/misc/mke2fs.c | ||
| 70 | index 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 | -- | ||
| 167 | 1.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 new file mode 100644 index 0000000000..a330ee45a5 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0009-misc-create_inode.c-handle-hardlinks.patch | |||
| @@ -0,0 +1,210 @@ | |||
| 1 | From d83dc950b3ec1fbde33b23d42c5154091a74f4d9 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Mon, 23 Dec 2013 03:44:03 -0500 | ||
| 4 | Subject: [PATCH 09/11] misc/create_inode.c: handle hardlinks | ||
| 5 | |||
| 6 | Create the inode and save the native inode number when we meet the hard | ||
| 7 | link (st_nlink > 1) at the first time, use ext2fs_link() to link the | ||
| 8 | name to the target inode number when we meet the same native inode | ||
| 9 | number again. | ||
| 10 | |||
| 11 | This algorithm is referred from the genext2fs. | ||
| 12 | |||
| 13 | Upstream-Status: Backport | ||
| 14 | |||
| 15 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 16 | Reviewed-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 | |||
| 23 | diff --git a/misc/create_inode.c b/misc/create_inode.c | ||
| 24 | index 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; | ||
| 153 | diff --git a/misc/create_inode.h b/misc/create_inode.h | ||
| 154 | index 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); | ||
| 185 | diff --git a/misc/mke2fs.c b/misc/mke2fs.c | ||
| 186 | index 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 | -- | ||
| 209 | 1.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 new file mode 100644 index 0000000000..2a6ca8f9a3 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0010-debugfs-use-the-functions-in-misc-create_inode.c.patch | |||
| @@ -0,0 +1,496 @@ | |||
| 1 | From db89992fab2215f52dce4c595a39271b4ff3000b Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Mon, 23 Dec 2013 04:22:22 -0500 | ||
| 4 | Subject: [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 | |||
| 20 | Upstream-Status: Backport | ||
| 21 | |||
| 22 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 23 | Reviewed-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 | |||
| 30 | diff --git a/debugfs/Makefile.in b/debugfs/Makefile.in | ||
| 31 | index 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 \ | ||
| 79 | diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c | ||
| 80 | index 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 | |||
| 482 | diff --git a/debugfs/debugfs.h b/debugfs/debugfs.h | ||
| 483 | index 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 | -- | ||
| 495 | 1.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 new file mode 100644 index 0000000000..ddd2cb8b42 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0011-mke2fs.8.in-update-the-manual-for-the-d-option.patch | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | From 89fca439f1b58595f2f424598a27869f8c7bd815 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Mon, 23 Dec 2013 04:43:18 -0500 | ||
| 4 | Subject: [PATCH 11/11] mke2fs.8.in: update the manual for the -d option | ||
| 5 | |||
| 6 | Update the manual for the -d option | ||
| 7 | |||
| 8 | Upstream-Status: Backport | ||
| 9 | |||
| 10 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 11 | Reviewed-by: Darren Hart <dvhart@linux.intel.com> | ||
| 12 | --- | ||
| 13 | misc/mke2fs.8.in | 7 +++++++ | ||
| 14 | 1 file changed, 7 insertions(+) | ||
| 15 | |||
| 16 | diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in | ||
| 17 | index 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 | -- | ||
| 42 | 1.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 new file mode 100644 index 0000000000..2624f90e72 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/0012-Fix-musl-build-failures.patch | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | From c6ff7feb9038d6e8aaffe2e69b205ad5fa33df2f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Paul Barker <paul@paulbarker.me.uk> | ||
| 3 | Date: Mon, 18 Aug 2014 21:02:56 +0200 | ||
| 4 | Subject: [PATCH] Fix musl build failures | ||
| 5 | |||
| 6 | In lib/ext2fs/unix_io.c, __u64 should be used instead of __uint64_t. This type | ||
| 7 | is guaranteed by the e2fsprogs build system. | ||
| 8 | (795c02def3681a99cc792a5ebc162d06f8a1eeb7) | ||
| 9 | |||
| 10 | In misc/create_inode.c, <limits.h> is needed for the definition of PATH_MAX. | ||
| 11 | (bbccc6f3c6a106721fb6f1ef4df6bc32c7986235) | ||
| 12 | |||
| 13 | Both of these fixes have been made upstream with the git commit IDs given but | ||
| 14 | those are larger commits containing other changes not needed here. | ||
| 15 | |||
| 16 | Signed-off-by: Paul Barker <paul@paulbarker.me.uk> | ||
| 17 | |||
| 18 | Upstream-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 | |||
| 24 | diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c | ||
| 25 | index 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 | ||
| 42 | diff --git a/misc/create_inode.c b/misc/create_inode.c | ||
| 43 | index 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 | -- | ||
| 53 | 1.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 new file mode 100644 index 0000000000..4de67c9704 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/CVE-2015-0247.patch | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | From f66e6ce4446738c2c7f43d41988a3eb73347e2f5 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Theodore Ts'o <tytso@mit.edu> | ||
| 3 | Date: Sat, 9 Aug 2014 12:24:54 -0400 | ||
| 4 | Subject: libext2fs: avoid buffer overflow if s_first_meta_bg is too big | ||
| 5 | |||
| 6 | If s_first_meta_bg is greater than the of number block group | ||
| 7 | descriptor blocks, then reading or writing the block group descriptors | ||
| 8 | will end up overruning the memory buffer allocated for the | ||
| 9 | descriptors. Fix this by limiting first_meta_bg to no more than | ||
| 10 | fs->desc_blocks. This doesn't correct the bad s_first_meta_bg value, | ||
| 11 | but it avoids causing the e2fsprogs userspace programs from | ||
| 12 | potentially crashing. | ||
| 13 | |||
| 14 | Fixes CVE-2015-0247 | ||
| 15 | Upstream-Status: Backport | ||
| 16 | |||
| 17 | Signed-off-by: Theodore Ts'o <tytso@mit.edu> | ||
| 18 | Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com> | ||
| 19 | |||
| 20 | diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c | ||
| 21 | index 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, | ||
| 38 | diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c | ||
| 39 | index 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 | -- | ||
| 57 | cgit v0.10.2 | ||
| 58 | |||
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/acinclude.m4 b/meta/recipes-devtools/e2fsprogs/e2fsprogs/acinclude.m4 new file mode 100644 index 0000000000..c0bd7dbdee --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/acinclude.m4 | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | # Extracted from the package's shipped aclocal.m4. Custom macros should be in | ||
| 2 | # acinclude.m4 so running aclocal doesn't blow them away. | ||
| 3 | # | ||
| 4 | # Signed-off-by: Ross Burton <ross.burton@intel.com> | ||
| 5 | |||
| 6 | # from http://autoconf-archive.cryp.to/ax_tls.html | ||
| 7 | # | ||
| 8 | # This was licensed under the GPL with the following exception: | ||
| 9 | # | ||
| 10 | # As a special exception, the respective Autoconf Macro's copyright | ||
| 11 | # owner gives unlimited permission to copy, distribute and modify the | ||
| 12 | # configure scripts that are the output of Autoconf when processing | ||
| 13 | # the Macro. You need not follow the terms of the GNU General Public | ||
| 14 | # License when using or distributing such scripts, even though | ||
| 15 | # portions of the text of the Macro appear in them. The GNU General | ||
| 16 | # Public License (GPL) does govern all other use of the material that | ||
| 17 | # constitutes the Autoconf Macro. | ||
| 18 | # | ||
| 19 | # This special exception to the GPL applies to versions of the | ||
| 20 | # Autoconf Macro released by the Autoconf Macro Archive. When you make | ||
| 21 | # and distribute a modified version of the Autoconf Macro, you may | ||
| 22 | # extend this special exception to the GPL to apply to your modified | ||
| 23 | # version as well. | ||
| 24 | # | ||
| 25 | AC_DEFUN([AX_TLS], [ | ||
| 26 | AC_MSG_CHECKING(for thread local storage (TLS) class) | ||
| 27 | AC_CACHE_VAL(ac_cv_tls, [ | ||
| 28 | ax_tls_keywords="__thread __declspec(thread) none" | ||
| 29 | for ax_tls_keyword in $ax_tls_keywords; do | ||
| 30 | case $ax_tls_keyword in | ||
| 31 | none) ac_cv_tls=none ; break ;; | ||
| 32 | *) | ||
| 33 | AC_TRY_COMPILE( | ||
| 34 | [#include <stdlib.h> | ||
| 35 | static void | ||
| 36 | foo(void) { | ||
| 37 | static ] $ax_tls_keyword [ int bar; | ||
| 38 | exit(1); | ||
| 39 | }], | ||
| 40 | [], | ||
| 41 | [ac_cv_tls=$ax_tls_keyword ; break], | ||
| 42 | ac_cv_tls=none | ||
| 43 | ) | ||
| 44 | esac | ||
| 45 | done | ||
| 46 | ]) | ||
| 47 | |||
| 48 | if test "$ac_cv_tls" != "none"; then | ||
| 49 | dnl AC_DEFINE([TLS], [], [If the compiler supports a TLS storage class define it to that here]) | ||
| 50 | AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here]) | ||
| 51 | fi | ||
| 52 | AC_MSG_RESULT($ac_cv_tls) | ||
| 53 | ]) | ||
| 54 | |||
| 55 | # =========================================================================== | ||
| 56 | # http://www.nongnu.org/autoconf-archive/check_gnu_make.html | ||
| 57 | # =========================================================================== | ||
| 58 | # | ||
| 59 | # SYNOPSIS | ||
| 60 | # | ||
| 61 | # CHECK_GNU_MAKE() | ||
| 62 | # | ||
| 63 | # DESCRIPTION | ||
| 64 | # | ||
| 65 | # This macro searches for a GNU version of make. If a match is found, the | ||
| 66 | # makefile variable `ifGNUmake' is set to the empty string, otherwise it | ||
| 67 | # is set to "#". This is useful for including a special features in a | ||
| 68 | # Makefile, which cannot be handled by other versions of make. The | ||
| 69 | # variable _cv_gnu_make_command is set to the command to invoke GNU make | ||
| 70 | # if it exists, the empty string otherwise. | ||
| 71 | # | ||
| 72 | # Here is an example of its use: | ||
| 73 | # | ||
| 74 | # Makefile.in might contain: | ||
| 75 | # | ||
| 76 | # # A failsafe way of putting a dependency rule into a makefile | ||
| 77 | # $(DEPEND): | ||
| 78 | # $(CC) -MM $(srcdir)/*.c > $(DEPEND) | ||
| 79 | # | ||
| 80 | # @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND))) | ||
| 81 | # @ifGNUmake@ include $(DEPEND) | ||
| 82 | # @ifGNUmake@ endif | ||
| 83 | # | ||
| 84 | # Then configure.in would normally contain: | ||
| 85 | # | ||
| 86 | # CHECK_GNU_MAKE() | ||
| 87 | # AC_OUTPUT(Makefile) | ||
| 88 | # | ||
| 89 | # Then perhaps to cause gnu make to override any other make, we could do | ||
| 90 | # something like this (note that GNU make always looks for GNUmakefile | ||
| 91 | # first): | ||
| 92 | # | ||
| 93 | # if ! test x$_cv_gnu_make_command = x ; then | ||
| 94 | # mv Makefile GNUmakefile | ||
| 95 | # echo .DEFAULT: > Makefile ; | ||
| 96 | # echo \ $_cv_gnu_make_command \$@ >> Makefile; | ||
| 97 | # fi | ||
| 98 | # | ||
| 99 | # Then, if any (well almost any) other make is called, and GNU make also | ||
| 100 | # exists, then the other make wraps the GNU make. | ||
| 101 | # | ||
| 102 | # LICENSE | ||
| 103 | # | ||
| 104 | # Copyright (c) 2008 John Darrington <j.darrington@elvis.murdoch.edu.au> | ||
| 105 | # | ||
| 106 | # Copying and distribution of this file, with or without modification, are | ||
| 107 | # permitted in any medium without royalty provided the copyright notice | ||
| 108 | # and this notice are preserved. | ||
| 109 | # | ||
| 110 | # Note: Modified by Ted Ts'o to add @ifNotGNUMake@ | ||
| 111 | |||
| 112 | AC_DEFUN( | ||
| 113 | [CHECK_GNU_MAKE], [ AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command, | ||
| 114 | _cv_gnu_make_command='' ; | ||
| 115 | dnl Search all the common names for GNU make | ||
| 116 | for a in "$MAKE" make gmake gnumake ; do | ||
| 117 | if test -z "$a" ; then continue ; fi ; | ||
| 118 | if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then | ||
| 119 | _cv_gnu_make_command=$a ; | ||
| 120 | break; | ||
| 121 | fi | ||
| 122 | done ; | ||
| 123 | ) ; | ||
| 124 | dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise | ||
| 125 | if test "x$_cv_gnu_make_command" != "x" ; then | ||
| 126 | ifGNUmake='' ; | ||
| 127 | ifNotGNUmake='#' ; | ||
| 128 | else | ||
| 129 | ifGNUmake='#' ; | ||
| 130 | ifNotGNUmake='' ; | ||
| 131 | AC_MSG_RESULT("Not found"); | ||
| 132 | fi | ||
| 133 | AC_SUBST(ifGNUmake) | ||
| 134 | AC_SUBST(ifNotGNUmake) | ||
| 135 | ] ) | ||
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/cache_inode.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/cache_inode.patch new file mode 100644 index 0000000000..f9ef8e5f26 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/cache_inode.patch | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | The 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 | |||
| 8 | This adds in a rather hacky algorthim which starts where we finished | ||
| 9 | searching previously using a static variable rather than starting | ||
| 10 | from scratch if a hint isn't provided. | ||
| 11 | |||
| 12 | This was after noticing that mkfs.ext4 -F X -d Y was spending *lots* | ||
| 13 | of time in ext2fs_new_block2 called from ext2fs_bmap from ext2fs_file_write(). | ||
| 14 | |||
| 15 | Numbers wise, this took a core-image-sato-sdk mkfs time from over | ||
| 16 | 8 minutes to around 35 seconds. | ||
| 17 | |||
| 18 | Upstream-Status: Pending | ||
| 19 | |||
| 20 | RP 2015/02/20 | ||
| 21 | |||
| 22 | Index: 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/fix-icache.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/fix-icache.patch new file mode 100644 index 0000000000..03c0abc026 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/fix-icache.patch | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | inode.c: only update the icache for ext2_inode | ||
| 2 | |||
| 3 | We only read the cache when: | ||
| 4 | |||
| 5 | bufsize == sizeof(struct ext2_inode) | ||
| 6 | |||
| 7 | then we should only update the cache in the same condition, otherwise | ||
| 8 | there would be errors, for example: | ||
| 9 | |||
| 10 | cache[0]: cached ino 14 when bufsize = 128 by ext2fs_write_inode_full() | ||
| 11 | cache[1]: cached ino 14 when bufsize = 156 by ext2fs_read_inode_full() | ||
| 12 | |||
| 13 | Then update the cache: | ||
| 14 | cache[0]: cached ino 15 when bufsize = 156 by ext2fs_read_inode_full() | ||
| 15 | |||
| 16 | Then the ino 14 would hit the cache[1] when bufsize = 128 (but it was | ||
| 17 | cached by bufsize = 156), so there would be errors. | ||
| 18 | |||
| 19 | Upstream-Status: [Submitted] | ||
| 20 | |||
| 21 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 22 | --- | ||
| 23 | lib/ext2fs/inode.c | 20 ++++++++++++-------- | ||
| 24 | 1 file changed, 12 insertions(+), 8 deletions(-) | ||
| 25 | |||
| 26 | diff --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 | -- | ||
| 64 | 1.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 new file mode 100644 index 0000000000..9b467c338c --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/misc-mke2fs.c-return-error-when-failed-to-populate-fs.patch | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | From e4ffd6fe975888d306b5f700ba54af18b59f6759 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Thu, 20 Mar 2014 11:10:21 +0800 | ||
| 4 | Subject: [PATCH] misc/mke2fs.c: return error when failed to populate filesystem | ||
| 5 | |||
| 6 | We need return retval when "mke2fs -d" failed, otherwise the "$?" would | ||
| 7 | be 0 which is misleading. | ||
| 8 | |||
| 9 | Upstream-Status Submitted | ||
| 10 | |||
| 11 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 12 | --- | ||
| 13 | misc/mke2fs.c | 7 ++++--- | ||
| 14 | 1 file changed, 4 insertions(+), 3 deletions(-) | ||
| 15 | |||
| 16 | diff --git a/misc/mke2fs.c b/misc/mke2fs.c | ||
| 17 | index 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 | -- | ||
| 36 | 1.8.3.1 | ||
| 37 | |||
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/mkdir.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/mkdir.patch new file mode 100644 index 0000000000..aa7a2981b4 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/mkdir.patch | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | Upstream-Status: Inappropriate [configuration] | ||
| 2 | |||
| 3 | Signed-off-by: Mei Lei <lei.mei@intel.com> | ||
| 4 | |||
| 5 | Index: e2fsprogs-1.41.5/po/Makefile.in.in | ||
| 6 | =================================================================== | ||
| 7 | --- e2fsprogs-1.41.5.orig/po/Makefile.in.in 2009-02-14 13:49:08.000000000 +0000 | ||
| 8 | +++ e2fsprogs-1.41.5/po/Makefile.in.in 2009-08-19 17:52:31.000000000 +0100 | ||
| 9 | @@ -30,7 +30,7 @@ | ||
| 10 | INSTALL = @INSTALL@ | ||
| 11 | INSTALL_DATA = @INSTALL_DATA@ | ||
| 12 | MKINSTALLDIRS = @MKINSTALLDIRS@ | ||
| 13 | -mkinstalldirs = $(SHELL) $(MKINSTALLDIRS) | ||
| 14 | +mkinstalldirs = $(MKINSTALLDIRS) | ||
| 15 | |||
| 16 | GMSGFMT = @GMSGFMT@ | ||
| 17 | MSGFMT = @MSGFMT@ | ||
| 18 | Index: 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 | ||
| 24 | AC_SUBST(BUILD_CFLAGS) | ||
| 25 | AC_SUBST(BUILD_LDFLAGS) | ||
| 26 | +MKINSTALLDIRS="mkdir -p" | ||
| 27 | +AC_SUBST(MKINSTALLDIRS) | ||
| 28 | dnl | ||
| 29 | dnl Make our output files, being sure that we create the some miscellaneous | ||
| 30 | dnl directories | ||
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/quiet-debugfs.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/quiet-debugfs.patch new file mode 100644 index 0000000000..830e9d57a5 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/quiet-debugfs.patch | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | When executing a script don't echo every command, as we do this for entire | ||
| 2 | filesystems at rootfs time. | ||
| 3 | |||
| 4 | Upstream-Status: Inappropriate | ||
| 5 | Signed-off-by: Ross Burton <ross.burton@intel.com> | ||
| 6 | |||
| 7 | diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c | ||
| 8 | index 5590295..ac57292 100644 | ||
| 9 | --- a/debugfs/debugfs.c | ||
| 10 | +++ b/debugfs/debugfs.c | ||
| 11 | @@ -2378,7 +2378,7 @@ static int source_file(const char *cmd_file, int ss_idx) | ||
| 12 | cp = strchr(buf, '\r'); | ||
| 13 | if (cp) | ||
| 14 | *cp = 0; | ||
| 15 | - printf("debugfs: %s\n", buf); | ||
| 16 | + /*printf("debugfs: %s\n", buf);*/ | ||
| 17 | retval = ss_execute_line(ss_idx, buf); | ||
| 18 | if (retval) { | ||
| 19 | ss_perror(ss_idx, retval, buf); | ||
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/remove.ldconfig.call.patch b/meta/recipes-devtools/e2fsprogs/e2fsprogs/remove.ldconfig.call.patch new file mode 100644 index 0000000000..f3e6eb778f --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/remove.ldconfig.call.patch | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | From b139e03ac2f72e644e547c7ee9b1514383af4d97 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Andrei Dinu <andrei.adrianx.dinu@intel.com> | ||
| 3 | Date: Wed, 30 Jan 2013 15:22:04 +0200 | ||
| 4 | Subject: [PATCH] When /etc/ld.so.cache is writeable by user running bitbake | ||
| 5 | then it creates invalid cache (in my case libstdc++.so | ||
| 6 | cannot be found after building zlib(-native) and I have to | ||
| 7 | call touch */libstdc++.so && /sbin/ldconfig to fix it. | ||
| 8 | |||
| 9 | So remove ldconfig call from make install-libs | ||
| 10 | |||
| 11 | Patch authored by Martin Jansa. | ||
| 12 | |||
| 13 | Upstream-Status: Inappropriate [disable feature] | ||
| 14 | |||
| 15 | Signed-off-by: Scott Garman <scott.a.garman@intel.com> | ||
| 16 | Signed-off-by: Andrei Dinu <andrei.adrianx.dinu@intel.com> | ||
| 17 | --- | ||
| 18 | lib/Makefile.elf-lib | 3 --- | ||
| 19 | 1 file changed, 3 deletions(-) | ||
| 20 | |||
| 21 | diff --git a/lib/Makefile.elf-lib b/lib/Makefile.elf-lib | ||
| 22 | index 78479d3..4a4a5ac 100644 | ||
| 23 | --- a/lib/Makefile.elf-lib | ||
| 24 | +++ b/lib/Makefile.elf-lib | ||
| 25 | @@ -50,8 +50,6 @@ install-shlibs install:: $(ELF_LIB) installdirs-elf-lib $(DEP_INSTALL_SYMLINK) | ||
| 26 | $(E) " SYMLINK $(libdir)/$(ELF_IMAGE).so" | ||
| 27 | $(Q) $(INSTALL_SYMLINK) $(ELF_INSTALL_DIR)/$(ELF_SONAME) \ | ||
| 28 | $(libdir)/$(ELF_IMAGE).so $(DESTDIR) | ||
| 29 | - $(E) " LDCONFIG" | ||
| 30 | - $(Q) -$(LDCONFIG) | ||
| 31 | |||
| 32 | install-strip: install | ||
| 33 | $(E) " STRIP-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)" | ||
| 34 | @@ -67,7 +65,6 @@ uninstall-shlibs uninstall:: | ||
| 35 | $(RM) -f $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB) \ | ||
| 36 | $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_SONAME) \ | ||
| 37 | $(DESTDIR)$(libdir)/$(ELF_IMAGE).so | ||
| 38 | - -$(LDCONFIG) | ||
| 39 | |||
| 40 | clean:: | ||
| 41 | $(RM) -rf elfshared | ||
| 42 | -- | ||
| 43 | 1.7.9.5 | ||
| 44 | |||
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bb b/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bb new file mode 100644 index 0000000000..70ccdfd540 --- /dev/null +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bb | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | require e2fsprogs.inc | ||
| 2 | |||
| 3 | |||
| 4 | SRC_URI += "file://acinclude.m4 \ | ||
| 5 | file://remove.ldconfig.call.patch \ | ||
| 6 | file://fix-icache.patch \ | ||
| 7 | file://quiet-debugfs.patch \ | ||
| 8 | file://0001-mke2fs-add-the-ability-to-copy-files-from-a-given-di.patch \ | ||
| 9 | file://0002-misc-create_inode.c-copy-files-recursively.patch \ | ||
| 10 | file://0003-misc-create_inode.c-create-special-file.patch \ | ||
| 11 | file://0004-misc-create_inode.c-create-symlink.patch \ | ||
| 12 | file://0005-misc-create_inode.c-copy-regular-file.patch \ | ||
| 13 | file://0006-misc-create_inode.c-create-directory.patch \ | ||
| 14 | file://0007-misc-create_inode.c-set-owner-mode-time-for-the-inod.patch \ | ||
| 15 | file://0008-mke2fs.c-add-an-option-d-root-directory.patch \ | ||
| 16 | file://0009-misc-create_inode.c-handle-hardlinks.patch \ | ||
| 17 | file://0010-debugfs-use-the-functions-in-misc-create_inode.c.patch \ | ||
| 18 | file://0011-mke2fs.8.in-update-the-manual-for-the-d-option.patch \ | ||
| 19 | file://0012-Fix-musl-build-failures.patch \ | ||
| 20 | file://0001-e2fsprogs-fix-cross-compilation-problem.patch \ | ||
| 21 | file://misc-mke2fs.c-return-error-when-failed-to-populate-fs.patch \ | ||
| 22 | file://cache_inode.patch \ | ||
| 23 | file://CVE-2015-0247.patch \ | ||
| 24 | " | ||
| 25 | |||
| 26 | SRC_URI[md5sum] = "3f8e41e63b432ba114b33f58674563f7" | ||
| 27 | SRC_URI[sha256sum] = "2f92ac06e92fa00f2ada3ee67dad012d74d685537527ad1241d82f2d041f2802" | ||
| 28 | |||
| 29 | EXTRA_OECONF += "--libdir=${base_libdir} --sbindir=${base_sbindir} --enable-elf-shlibs --disable-libuuid --disable-uuidd --enable-verbose-makecmds" | ||
| 30 | EXTRA_OECONF_darwin = "--libdir=${base_libdir} --sbindir=${base_sbindir} --enable-bsd-shlibs" | ||
| 31 | |||
| 32 | do_configure_prepend () { | ||
| 33 | cp ${WORKDIR}/acinclude.m4 ${S}/ | ||
| 34 | } | ||
| 35 | |||
| 36 | do_install () { | ||
| 37 | oe_runmake 'DESTDIR=${D}' install | ||
| 38 | oe_runmake 'DESTDIR=${D}' install-libs | ||
| 39 | # We use blkid from util-linux now so remove from here | ||
| 40 | rm -f ${D}${base_libdir}/libblkid* | ||
| 41 | rm -rf ${D}${includedir}/blkid | ||
| 42 | rm -f ${D}${base_libdir}/pkgconfig/blkid.pc | ||
| 43 | rm -f ${D}${base_sbindir}/blkid | ||
| 44 | rm -f ${D}${base_sbindir}/fsck | ||
| 45 | rm -f ${D}${base_sbindir}/findfs | ||
| 46 | |||
| 47 | # e2initrd_helper and the pkgconfig files belong in libdir | ||
| 48 | if [ ! ${D}${libdir} -ef ${D}${base_libdir} ]; then | ||
| 49 | install -d ${D}${libdir} | ||
| 50 | mv ${D}${base_libdir}/e2initrd_helper ${D}${libdir} | ||
| 51 | mv ${D}${base_libdir}/pkgconfig ${D}${libdir} | ||
| 52 | fi | ||
| 53 | |||
| 54 | oe_multilib_header ext2fs/ext2_types.h | ||
| 55 | install -d ${D}${base_bindir} | ||
| 56 | mv ${D}${bindir}/chattr ${D}${base_bindir}/chattr.e2fsprogs | ||
| 57 | } | ||
| 58 | |||
| 59 | do_install_append_class-target() { | ||
| 60 | # Clean host path in compile_et, mk_cmds | ||
| 61 | sed -i -e "s,ET_DIR=\"${S}/lib/et\",ET_DIR=\"${datadir}/et\",g" ${D}${bindir}/compile_et | ||
| 62 | sed -i -e "s,SS_DIR=\"${S}/lib/ss\",SS_DIR=\"${datadir}/ss\",g" ${D}${bindir}/mk_cmds | ||
| 63 | } | ||
| 64 | |||
| 65 | RDEPENDS_e2fsprogs = "e2fsprogs-badblocks" | ||
| 66 | RRECOMMENDS_e2fsprogs = "e2fsprogs-mke2fs e2fsprogs-e2fsck" | ||
| 67 | |||
| 68 | PACKAGES =+ "e2fsprogs-e2fsck e2fsprogs-mke2fs e2fsprogs-tune2fs e2fsprogs-badblocks" | ||
| 69 | PACKAGES =+ "libcomerr libss libe2p libext2fs" | ||
| 70 | |||
| 71 | FILES_e2fsprogs-e2fsck = "${base_sbindir}/e2fsck ${base_sbindir}/fsck.ext*" | ||
| 72 | FILES_e2fsprogs-mke2fs = "${base_sbindir}/mke2fs ${base_sbindir}/mkfs.ext* ${sysconfdir}/mke2fs.conf" | ||
| 73 | FILES_e2fsprogs-tune2fs = "${base_sbindir}/tune2fs ${base_sbindir}/e2label" | ||
| 74 | FILES_e2fsprogs-badblocks = "${base_sbindir}/badblocks" | ||
| 75 | FILES_libcomerr = "${base_libdir}/libcom_err.so.*" | ||
| 76 | FILES_libss = "${base_libdir}/libss.so.*" | ||
| 77 | FILES_libe2p = "${base_libdir}/libe2p.so.*" | ||
| 78 | FILES_libext2fs = "${libdir}/e2initrd_helper ${base_libdir}/libext2fs.so.*" | ||
| 79 | FILES_${PN}-dev += "${datadir}/*/*.awk ${datadir}/*/*.sed ${base_libdir}/*.so" | ||
| 80 | |||
| 81 | BBCLASSEXTEND = "native" | ||
| 82 | |||
| 83 | inherit update-alternatives | ||
| 84 | |||
| 85 | ALTERNATIVE_${PN} = "chattr" | ||
| 86 | ALTERNATIVE_PRIORITY = "100" | ||
| 87 | ALTERNATIVE_LINK_NAME[chattr] = "${base_bindir}/chattr" | ||
| 88 | ALTERNATIVE_TARGET[chattr] = "${base_bindir}/chattr.e2fsprogs" | ||
