diff options
7 files changed, 112 insertions, 134 deletions
diff --git a/patches/mtd-utils-1.5.2/0001-make-ubifs-optional.patch b/patches/mtd-utils-1.5.2/0001-make-ubifs-optional.patch index 7da2ef498..5e3582e4c 100644 --- a/patches/mtd-utils-1.5.2/0001-make-ubifs-optional.patch +++ b/patches/mtd-utils-1.5.2/0001-make-ubifs-optional.patch @@ -8,7 +8,7 @@ Signed-off-by: Bernhard Walle <bernhard@bwalle.de> 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile -index eade23467074..8d1506df37f9 100644 +index 3ce8587b22a1..5cc0125c5243 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,9 @@ UBI_BINS = \ diff --git a/patches/mtd-utils-1.5.2/0002-Make-liblzo-optional-for-ubifs-tools.patch b/patches/mtd-utils-1.5.2/0002-Make-liblzo-optional-for-ubifs-tools.patch index 1317c3e55..e3b630578 100644 --- a/patches/mtd-utils-1.5.2/0002-Make-liblzo-optional-for-ubifs-tools.patch +++ b/patches/mtd-utils-1.5.2/0002-Make-liblzo-optional-for-ubifs-tools.patch @@ -11,7 +11,7 @@ Signed-off-by: Bernhard Walle <bernhard@bwalle.de> 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile -index 8d1506df37f9..228dc9cc6ea2 100644 +index 5cc0125c5243..9cfd9700a570 100644 --- a/Makefile +++ b/Makefile @@ -107,7 +107,7 @@ $(call _mkdep,lib/,libmtd.a) @@ -24,7 +24,7 @@ index 8d1506df37f9..228dc9cc6ea2 100644 # diff --git a/mkfs.ubifs/compr.c b/mkfs.ubifs/compr.c -index 4152b6af8832..244d4507b5ce 100644 +index 34b2f6001b6b..549b4de13932 100644 --- a/mkfs.ubifs/compr.c +++ b/mkfs.ubifs/compr.c @@ -24,7 +24,11 @@ @@ -39,7 +39,7 @@ index 4152b6af8832..244d4507b5ce 100644 #include <linux/types.h> #define crc32 __zlib_crc32 -@@ -86,6 +90,8 @@ static int zlib_deflate(void *in_buf, size_t in_len, void *out_buf, +@@ -85,6 +89,8 @@ static int zlib_deflate(void *in_buf, size_t in_len, void *out_buf, return 0; } @@ -48,7 +48,7 @@ index 4152b6af8832..244d4507b5ce 100644 static int lzo_compress(void *in_buf, size_t in_len, void *out_buf, size_t *out_len) { -@@ -103,6 +109,17 @@ static int lzo_compress(void *in_buf, size_t in_len, void *out_buf, +@@ -102,6 +108,17 @@ static int lzo_compress(void *in_buf, size_t in_len, void *out_buf, return 0; } diff --git a/patches/mtd-utils-1.5.2/0003-mkfs.ubifs-change-add_directory-argument-to-existing.patch b/patches/mtd-utils-1.5.2/0003-mkfs.ubifs-change-add_directory-argument-to-existing.patch index a423ea509..acff3b642 100644 --- a/patches/mtd-utils-1.5.2/0003-mkfs.ubifs-change-add_directory-argument-to-existing.patch +++ b/patches/mtd-utils-1.5.2/0003-mkfs.ubifs-change-add_directory-argument-to-existing.patch @@ -6,16 +6,17 @@ A 'non_existing' argument which is only used with !non_existing is just too confusing. Change this to positive logic. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> +Reviewed-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- mkfs.ubifs/mkfs.ubifs.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c -index 200c8a5007e4..fbcaf1ffbed6 100644 +index ca17e2bca3ac..1b816ae483e0 100644 --- a/mkfs.ubifs/mkfs.ubifs.c +++ b/mkfs.ubifs/mkfs.ubifs.c -@@ -1396,12 +1396,12 @@ static int add_non_dir(const char *path_name, ino_t *inum, unsigned int nlink, +@@ -1395,12 +1395,12 @@ static int add_non_dir(const char *path_name, ino_t *inum, unsigned int nlink, * @dir_name: directory path name * @dir_inum: UBIFS inode number of directory * @st: directory inode statistics @@ -32,7 +33,7 @@ index 200c8a5007e4..fbcaf1ffbed6 100644 { struct dirent *entry; DIR *dir = NULL; -@@ -1417,7 +1417,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, +@@ -1416,7 +1416,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, unsigned long long dir_creat_sqnum = ++c->max_sqnum; dbg_msg(2, "%s", dir_name); @@ -41,7 +42,7 @@ index 200c8a5007e4..fbcaf1ffbed6 100644 dir = opendir(dir_name); if (dir == NULL) return sys_err_msg("cannot open directory '%s'", -@@ -1435,7 +1435,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, +@@ -1434,7 +1434,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, * Before adding the directory itself, we have to iterate over all the * entries the device table adds to this directory and create them. */ @@ -50,7 +51,7 @@ index 200c8a5007e4..fbcaf1ffbed6 100644 struct stat dent_st; errno = 0; -@@ -1493,7 +1493,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, +@@ -1492,7 +1492,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, inum = ++c->highest_inum; if (S_ISDIR(dent_st.st_mode)) { @@ -59,7 +60,7 @@ index 200c8a5007e4..fbcaf1ffbed6 100644 if (err) goto out_free; nlink += 1; -@@ -1545,7 +1545,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, +@@ -1544,7 +1544,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, inum = ++c->highest_inum; if (S_ISDIR(nh_elt->mode)) { @@ -68,7 +69,7 @@ index 200c8a5007e4..fbcaf1ffbed6 100644 if (err) goto out_free; nlink += 1; -@@ -1571,14 +1571,14 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, +@@ -1570,14 +1570,14 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, goto out_free; free(name); @@ -85,7 +86,7 @@ index 200c8a5007e4..fbcaf1ffbed6 100644 closedir(dir); return -1; } -@@ -1625,7 +1625,7 @@ static int write_data(void) +@@ -1624,7 +1624,7 @@ static int write_data(void) } head_flags = 0; diff --git a/patches/mtd-utils-1.5.2/0004-mkfs.ubifs-use-xmalloc-xzalloc-for-allocating-memory.patch b/patches/mtd-utils-1.5.2/0004-mkfs.ubifs-use-xmalloc-xzalloc-for-allocating-memory.patch index cc9234bfc..4fc8e70ce 100644 --- a/patches/mtd-utils-1.5.2/0004-mkfs.ubifs-use-xmalloc-xzalloc-for-allocating-memory.patch +++ b/patches/mtd-utils-1.5.2/0004-mkfs.ubifs-use-xmalloc-xzalloc-for-allocating-memory.patch @@ -3,16 +3,17 @@ Date: Fri, 28 Nov 2014 11:11:26 +0100 Subject: [PATCH] mkfs.ubifs: use xmalloc/xzalloc for allocating memory Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> +Reviewed-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- mkfs.ubifs/mkfs.ubifs.c | 64 +++++++++++-------------------------------------- 1 file changed, 14 insertions(+), 50 deletions(-) diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c -index fbcaf1ffbed6..cb7b643ce73c 100644 +index 1b816ae483e0..049219b52cc5 100644 --- a/mkfs.ubifs/mkfs.ubifs.c +++ b/mkfs.ubifs/mkfs.ubifs.c -@@ -260,13 +260,8 @@ static int is_contained(const char *file, const char *dir) +@@ -259,13 +259,8 @@ static int is_contained(const char *file, const char *dir) file_base = dirname(copy); /* Turn the paths into the canonical form */ @@ -28,7 +29,7 @@ index fbcaf1ffbed6..cb7b643ce73c 100644 if (!realpath(file_base, real_file)) { perror("Could not canonicalize file path"); -@@ -501,9 +496,7 @@ static int get_options(int argc, char**argv) +@@ -500,9 +495,7 @@ static int get_options(int argc, char**argv) case 'r': case 'd': root_len = strlen(optarg); @@ -39,7 +40,7 @@ index fbcaf1ffbed6..cb7b643ce73c 100644 /* * The further code expects '/' at the end of the root -@@ -911,9 +904,7 @@ static int add_to_index(union ubifs_key *key, char *name, int lnum, int offs, +@@ -910,9 +903,7 @@ static int add_to_index(union ubifs_key *key, char *name, int lnum, int offs, struct idx_entry *e; dbg_msg(3, "LEB %d offs %d len %d", lnum, offs, len); @@ -50,7 +51,7 @@ index fbcaf1ffbed6..cb7b643ce73c 100644 e->next = NULL; e->prev = idx_list_last; e->key = *key; -@@ -1194,9 +1185,7 @@ static struct inum_mapping *lookup_inum_mapping(dev_t dev, ino_t inum) +@@ -1193,9 +1184,7 @@ static struct inum_mapping *lookup_inum_mapping(dev_t dev, ino_t inum) return im; im = im->next; } @@ -61,7 +62,7 @@ index fbcaf1ffbed6..cb7b643ce73c 100644 im->next = hash_table[k]; im->prev = NULL; im->dev = dev; -@@ -1356,9 +1345,7 @@ static int add_non_dir(const char *path_name, ino_t *inum, unsigned int nlink, +@@ -1355,9 +1344,7 @@ static int add_non_dir(const char *path_name, ino_t *inum, unsigned int nlink, /* New entry */ im->use_inum = *inum; im->use_nlink = 1; @@ -72,7 +73,7 @@ index fbcaf1ffbed6..cb7b643ce73c 100644 strcpy(im->path_name, path_name); } else { /* Existing entry */ -@@ -1708,21 +1695,14 @@ static int write_index(void) +@@ -1707,21 +1694,14 @@ static int write_index(void) head_flags = LPROPS_INDEX; /* Allocate index node */ idx_sz = ubifs_idx_node_sz(c, c->fanout); @@ -96,7 +97,7 @@ index fbcaf1ffbed6..cb7b643ce73c 100644 idx_ptr[0] = idx_list_first; for (i = 1; i < idx_cnt; i++) idx_ptr[i] = idx_ptr[i - 1]->next; -@@ -2165,13 +2145,8 @@ static int init(void) +@@ -2164,13 +2144,8 @@ static int init(void) c->lpt_first = UBIFS_LOG_LNUM + c->log_lebs; c->lpt_last = c->lpt_first + c->lpt_lebs - 1; @@ -112,7 +113,7 @@ index fbcaf1ffbed6..cb7b643ce73c 100644 /* Initialize LPT's own lprops */ for (i = 0; i < c->lpt_lebs; i++) { -@@ -2183,23 +2158,12 @@ static int init(void) +@@ -2182,23 +2157,12 @@ static int init(void) c->dark_wm = ALIGN(UBIFS_MAX_NODE_SZ, c->min_io_size); dbg_msg(1, "dead_wm %d dark_wm %d", c->dead_wm, c->dark_wm); diff --git a/patches/mtd-utils-1.5.2/0005-mkfs.ubifs-simplify-make_path-with-xasprintf.patch b/patches/mtd-utils-1.5.2/0005-mkfs.ubifs-simplify-make_path-with-xasprintf.patch index 8c68c84a7..c47a7e023 100644 --- a/patches/mtd-utils-1.5.2/0005-mkfs.ubifs-simplify-make_path-with-xasprintf.patch +++ b/patches/mtd-utils-1.5.2/0005-mkfs.ubifs-simplify-make_path-with-xasprintf.patch @@ -3,16 +3,17 @@ Date: Fri, 28 Nov 2014 11:15:18 +0100 Subject: [PATCH] mkfs.ubifs: simplify make_path with xasprintf Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> +Reviewed-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- mkfs.ubifs/mkfs.ubifs.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c -index cb7b643ce73c..c1e72bbddf9d 100644 +index 049219b52cc5..a99c61382304 100644 --- a/mkfs.ubifs/mkfs.ubifs.c +++ b/mkfs.ubifs/mkfs.ubifs.c -@@ -228,13 +228,9 @@ static char *make_path(const char *dir, const char *name) +@@ -227,13 +227,9 @@ static char *make_path(const char *dir, const char *name) { char *s; diff --git a/patches/mtd-utils-1.5.2/0006-mkfs.ubifs-Add-extended-attribute-support.patch b/patches/mtd-utils-1.5.2/0006-mkfs.ubifs-Add-extended-attribute-support.patch index 9f86f4a8a..77e161334 100644 --- a/patches/mtd-utils-1.5.2/0006-mkfs.ubifs-Add-extended-attribute-support.patch +++ b/patches/mtd-utils-1.5.2/0006-mkfs.ubifs-Add-extended-attribute-support.patch @@ -10,9 +10,9 @@ Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- mkfs.ubifs/key.h | 18 +++++ - mkfs.ubifs/mkfs.ubifs.c | 201 +++++++++++++++++++++++++++++++++++++++++------- + mkfs.ubifs/mkfs.ubifs.c | 205 +++++++++++++++++++++++++++++++++++++++++------- mkfs.ubifs/ubifs.h | 9 +++ - 3 files changed, 201 insertions(+), 27 deletions(-) + 3 files changed, 205 insertions(+), 27 deletions(-) diff --git a/mkfs.ubifs/key.h b/mkfs.ubifs/key.h index d3a02d4ff1a6..39379fd48178 100644 @@ -44,24 +44,38 @@ index d3a02d4ff1a6..39379fd48178 100644 * @c: UBIFS file-system description object * @key: key to initialize diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c -index c1e72bbddf9d..667dce7f2986 100644 +index a99c61382304..30cd10c25819 100644 --- a/mkfs.ubifs/mkfs.ubifs.c +++ b/mkfs.ubifs/mkfs.ubifs.c -@@ -26,6 +26,8 @@ +@@ -25,6 +25,10 @@ #include "mkfs.ubifs.h" #include <crc32.h> #include "common.h" +#include <sys/types.h> ++#ifndef WITHOUT_XATTR +#include <attr/xattr.h> ++#endif /* Size (prime number) of hash table for link counting */ #define HASH_TABLE_SIZE 10099 -@@ -981,20 +983,168 @@ static int add_node(union ubifs_key *key, char *name, void *node, int len) +@@ -980,20 +984,170 @@ static int add_node(union ubifs_key *key, char *name, void *node, int len) return 0; } -+int add_xattr(struct stat *st, ino_t inum, const void *data, unsigned int data_len, -+ struct qstr *nm) ++#ifdef WITHOUT_XATTR ++static inline int inode_add_xattr(struct ubifs_ino_node *host_ino, ++ const char *path_name, struct stat *st, ino_t inum) ++{ ++ (void)host_ino; ++ (void)path_name; ++ (void)st; ++ (void)inum; ++ ++ return 0; ++} ++#else ++static int add_xattr(struct stat *st, ino_t inum, const void *data, ++ unsigned int data_len, struct qstr *nm) +{ + struct ubifs_ino_node *ino; + struct ubifs_dent_node *xent; @@ -131,21 +145,20 @@ index c1e72bbddf9d..667dce7f2986 100644 +} + +static int inode_add_xattr(struct ubifs_ino_node *host_ino, -+ const char *path_name, struct stat *st, ino_t inum) ++ const char *path_name, struct stat *st, ino_t inum) +{ + int ret; + struct qstr nm; + void *buf = NULL; + ssize_t len; + ssize_t pos = 0; -+ void *attrval = NULL; + -+ len = listxattr(path_name, NULL, 0); ++ len = llistxattr(path_name, NULL, 0); + if (len < 0) { + if (errno == ENOENT) + return 0; + -+ sys_err_msg("flistxattr failed on %s", path_name); ++ sys_err_msg("llistxattr failed on %s", path_name); + + return len; + } @@ -155,29 +168,23 @@ index c1e72bbddf9d..667dce7f2986 100644 + + buf = xmalloc(len); + -+ len = listxattr(path_name, buf, len); ++ len = llistxattr(path_name, buf, len); + if (len < 0) { -+ sys_err_msg("flistxattr failed on %s", path_name); ++ sys_err_msg("llistxattr failed on %s", path_name); + goto out_free; + } + + while (pos < len) { ++ char attrbuf[1024] = { }; + char *name; + ssize_t attrsize; + + name = buf + pos; + pos += strlen(name) + 1; + -+ attrsize = getxattr(path_name, name, NULL, 0); ++ attrsize = lgetxattr(path_name, name, attrbuf, sizeof(attrbuf) - 1); + if (attrsize < 0) { -+ sys_err_msg("getxattr failed on %s", path_name); -+ goto out_free; -+ } -+ -+ attrval = xmalloc(attrsize); -+ attrsize = getxattr(path_name, name, attrval, attrsize); -+ if (attrsize < 0) { -+ sys_err_msg("getxattr failed on %s", path_name); ++ sys_err_msg("lgetxattr failed on %s", path_name); + goto out_free; + } + @@ -189,12 +196,9 @@ index c1e72bbddf9d..667dce7f2986 100644 + host_ino->xattr_size += CALC_XATTR_BYTES(attrsize); + host_ino->xattr_names += nm.len; + -+ ret = add_xattr(st, inum, attrval, attrsize, &nm); ++ ret = add_xattr(st, inum, attrbuf, attrsize, &nm); + if (ret < 0) + goto out_free; -+ -+ free(attrval); -+ attrval = NULL; + } + +noxattr: @@ -203,10 +207,10 @@ index c1e72bbddf9d..667dce7f2986 100644 + +out_free: + free(buf); -+ free(attrval); + + return -1; +} ++#endif + /** - * add_inode_with_data - write an inode. @@ -229,7 +233,7 @@ index c1e72bbddf9d..667dce7f2986 100644 if (c->default_compr != UBIFS_COMPR_NONE) use_flags |= UBIFS_COMPR_FL; -@@ -1038,18 +1188,13 @@ static int add_inode_with_data(struct stat *st, ino_t inum, void *data, +@@ -1037,18 +1191,13 @@ static int add_inode_with_data(struct stat *st, ino_t inum, void *data, len = UBIFS_INO_NODE_SZ + data_len; @@ -254,7 +258,7 @@ index c1e72bbddf9d..667dce7f2986 100644 } /** -@@ -1065,8 +1210,8 @@ static int add_inode(struct stat *st, ino_t inum, int flags) +@@ -1064,8 +1213,8 @@ static int add_inode(struct stat *st, ino_t inum, int flags) * is being created does not exist at the host file system, but is defined by * the device table. */ @@ -265,7 +269,7 @@ index c1e72bbddf9d..667dce7f2986 100644 { int fd, flags = 0; -@@ -1081,7 +1226,7 @@ static int add_dir_inode(DIR *dir, ino_t inum, loff_t size, unsigned int nlink, +@@ -1080,7 +1229,7 @@ static int add_dir_inode(DIR *dir, ino_t inum, loff_t size, unsigned int nlink, flags = 0; } @@ -274,7 +278,7 @@ index c1e72bbddf9d..667dce7f2986 100644 } /** -@@ -1090,12 +1235,12 @@ static int add_dir_inode(DIR *dir, ino_t inum, loff_t size, unsigned int nlink, +@@ -1089,12 +1238,12 @@ static int add_dir_inode(DIR *dir, ino_t inum, loff_t size, unsigned int nlink, * @inum: target inode number * @flags: source inode flags */ @@ -289,7 +293,7 @@ index c1e72bbddf9d..667dce7f2986 100644 } /** -@@ -1118,7 +1263,7 @@ static int add_symlink_inode(const char *path_name, struct stat *st, ino_t inum, +@@ -1117,7 +1266,7 @@ static int add_symlink_inode(const char *path_name, struct stat *st, ino_t inum, if (len > UBIFS_MAX_INO_DATA) return err_msg("symlink too long for %s", path_name); @@ -298,7 +302,7 @@ index c1e72bbddf9d..667dce7f2986 100644 } /** -@@ -1276,12 +1421,14 @@ static int add_file(const char *path_name, struct stat *st, ino_t inum, +@@ -1275,12 +1424,14 @@ static int add_file(const char *path_name, struct stat *st, ino_t inum, return err; } } while (ret != 0); @@ -314,7 +318,7 @@ index c1e72bbddf9d..667dce7f2986 100644 } /** -@@ -1361,15 +1508,15 @@ static int add_non_dir(const char *path_name, ino_t *inum, unsigned int nlink, +@@ -1360,15 +1511,15 @@ static int add_non_dir(const char *path_name, ino_t *inum, unsigned int nlink, if (S_ISREG(st->st_mode)) return add_file(path_name, st, *inum, flags); if (S_ISCHR(st->st_mode)) @@ -334,7 +338,7 @@ index c1e72bbddf9d..667dce7f2986 100644 return err_msg("file '%s' has unknown inode type", path_name); } -@@ -1549,7 +1696,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, +@@ -1548,7 +1699,7 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, creat_sqnum = dir_creat_sqnum; diff --git a/patches/mtd-utils-1.5.2/0007-mkfs.ubifs-Optionally-create-extended-attribute-with.patch b/patches/mtd-utils-1.5.2/0007-mkfs.ubifs-Optionally-create-extended-attribute-with.patch index 4de70724c..c9e725e90 100644 --- a/patches/mtd-utils-1.5.2/0007-mkfs.ubifs-Optionally-create-extended-attribute-with.patch +++ b/patches/mtd-utils-1.5.2/0007-mkfs.ubifs-Optionally-create-extended-attribute-with.patch @@ -33,14 +33,14 @@ UBIFS image, both evmctl and mkfs.ubifs must be run twice: Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- - mkfs.ubifs/mkfs.ubifs.c | 77 +++++++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 68 insertions(+), 9 deletions(-) + mkfs.ubifs/mkfs.ubifs.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c -index 667dce7f2986..4ab24a240087 100644 +index 30cd10c25819..58200dea9732 100644 --- a/mkfs.ubifs/mkfs.ubifs.c +++ b/mkfs.ubifs/mkfs.ubifs.c -@@ -114,6 +114,7 @@ static char *output; +@@ -115,6 +115,7 @@ static char *output; static int out_fd; static int out_ubi; static int squash_owner; @@ -48,7 +48,7 @@ index 667dce7f2986..4ab24a240087 100644 /* The 'head' (position) which nodes are written */ static int head_lnum; -@@ -136,7 +137,7 @@ static struct inum_mapping **hash_table; +@@ -137,7 +138,7 @@ static struct inum_mapping **hash_table; /* Inode creation sequence number */ static unsigned long long creat_sqnum; @@ -57,7 +57,7 @@ index 667dce7f2986..4ab24a240087 100644 static const struct option longopts[] = { {"root", 1, NULL, 'r'}, -@@ -160,6 +161,7 @@ static const struct option longopts[] = { +@@ -161,6 +162,7 @@ static const struct option longopts[] = { {"log-lebs", 1, NULL, 'l'}, {"orph-lebs", 1, NULL, 'p'}, {"squash-uids" , 0, NULL, 'U'}, @@ -65,7 +65,7 @@ index 667dce7f2986..4ab24a240087 100644 {NULL, 0, NULL, 0} }; -@@ -200,6 +202,9 @@ static const char *helptext = +@@ -201,6 +203,9 @@ static const char *helptext = "-V, --version display version information\n" "-g, --debug=LEVEL display debug information (0 - none, 1 - statistics,\n" " 2 - files, 3 - more details)\n" @@ -75,10 +75,36 @@ index 667dce7f2986..4ab24a240087 100644 "-h, --help display this help text\n\n" "Note, SIZE is specified in bytes, but it may also be specified in Kilobytes,\n" "Megabytes, and Gigabytes if a KiB, MiB, or GiB suffix is used.\n\n" -@@ -221,6 +226,25 @@ static const char *helptext = - "flag may make the first mount very slow, because the \"free space fixup\" procedure\n" - "takes time. This feature is supported by the Linux kernel starting from version 3.0.\n"; +@@ -616,6 +621,10 @@ static int get_options(int argc, char**argv) + case 'U': + squash_owner = 1; + break; ++ case 'a': ++ do_create_inum_attr = 1; ++ break; ++ + } + } +@@ -985,6 +994,14 @@ static int add_node(union ubifs_key *key, char *name, void *node, int len) + } + + #ifdef WITHOUT_XATTR ++static inline int create_inum_attr(ino_t inum, const char *name) ++{ ++ (void)inum; ++ (void)name; ++ ++ return 0; ++} ++ + static inline int inode_add_xattr(struct ubifs_ino_node *host_ino, + const char *path_name, struct stat *st, ino_t inum) + { +@@ -996,6 +1013,26 @@ static inline int inode_add_xattr(struct ubifs_ino_node *host_ino, + return 0; + } + #else +static int create_inum_attr(ino_t inum, const char *name) +{ + char *str; @@ -98,90 +124,35 @@ index 667dce7f2986..4ab24a240087 100644 + return ret; +} + - /** - * make_path - make a path name from a directory and a name. - * @dir: directory path name -@@ -615,6 +639,10 @@ static int get_options(int argc, char**argv) - case 'U': - squash_owner = 1; - break; -+ case 'a': -+ do_create_inum_attr = 1; -+ break; + - } - } - -@@ -1063,12 +1091,12 @@ static int inode_add_xattr(struct ubifs_ino_node *host_ino, - ssize_t pos = 0; - void *attrval = NULL; - -- len = listxattr(path_name, NULL, 0); -+ len = llistxattr(path_name, NULL, 0); - if (len < 0) { - if (errno == ENOENT) - return 0; - -- sys_err_msg("flistxattr failed on %s", path_name); -+ sys_err_msg("llistxattr failed on %s", path_name); - - return len; - } -@@ -1078,9 +1106,9 @@ static int inode_add_xattr(struct ubifs_ino_node *host_ino, - - buf = xmalloc(len); - -- len = listxattr(path_name, buf, len); -+ len = llistxattr(path_name, buf, len); - if (len < 0) { -- sys_err_msg("flistxattr failed on %s", path_name); -+ sys_err_msg("llistxattr failed on %s", path_name); - goto out_free; - } - -@@ -1091,19 +1119,37 @@ static int inode_add_xattr(struct ubifs_ino_node *host_ino, - name = buf + pos; - pos += strlen(name) + 1; - -- attrsize = getxattr(path_name, name, NULL, 0); -+ attrsize = lgetxattr(path_name, name, NULL, 0); - if (attrsize < 0) { -- sys_err_msg("getxattr failed on %s", path_name); -+ sys_err_msg("lgetxattr failed on %s", path_name); - goto out_free; - } - - attrval = xmalloc(attrsize); -- attrsize = getxattr(path_name, name, attrval, attrsize); -+ attrsize = lgetxattr(path_name, name, attrval, attrsize); - if (attrsize < 0) { -- sys_err_msg("getxattr failed on %s", path_name); -+ sys_err_msg("lgetxattr failed on %s", path_name); + static int add_xattr(struct stat *st, ino_t inum, const void *data, + unsigned int data_len, struct qstr *nm) + { +@@ -1110,6 +1147,23 @@ static int inode_add_xattr(struct ubifs_ino_node *host_ino, goto out_free; } + if (!strcmp(name, "user.image-inode-number")) { + ino_t inum_from_xattr; + -+ inum_from_xattr = strtoull(attrval, NULL, 10); ++ inum_from_xattr = strtoull(attrbuf, NULL, 10); + if (inum != inum_from_xattr) { + errno = EINVAL; -+ sys_err_msg("calculated inum (%llu) doesn't match inum from xattr (%llu) on %s", ++ sys_err_msg("calculated inum (%llu) doesn't match inum from xattr (%llu) size (%zd) on %s", + (unsigned long long)inum, + (unsigned long long)inum_from_xattr, ++ attrsize, + path_name); + goto out_free; + } + -+ free(attrval); -+ attrval = NULL; + continue; + } + nm.name = name; nm.len = strlen(name); -@@ -1634,6 +1680,10 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, +@@ -1637,6 +1691,10 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, goto out_free; } @@ -192,7 +163,7 @@ index 667dce7f2986..4ab24a240087 100644 err = add_dent_node(dir_inum, entry->d_name, inum, type); if (err) goto out_free; -@@ -1686,6 +1736,10 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, +@@ -1689,6 +1747,10 @@ static int add_directory(const char *dir_name, ino_t dir_inum, struct stat *st, goto out_free; } @@ -203,7 +174,7 @@ index 667dce7f2986..4ab24a240087 100644 err = add_dent_node(dir_inum, nh_elt->name, inum, type); if (err) goto out_free; -@@ -1755,6 +1809,11 @@ static int write_data(void) +@@ -1758,6 +1820,11 @@ static int write_data(void) } head_flags = 0; |