Signed-off-by: Philip Tricca <[email protected]> --- .../misc-xattr-create-xattr-block-node.patch | 126 +++++++++++++++++++++ .../e2fsprogs/e2fsprogs_1.42.9.bbappend | 1 + 2 files changed, 127 insertions(+) create mode 100644 recipes-devtools/e2fsprogs/e2fsprogs/misc-xattr-create-xattr-block-node.patch
diff --git a/recipes-devtools/e2fsprogs/e2fsprogs/misc-xattr-create-xattr-block-node.patch b/recipes-devtools/e2fsprogs/e2fsprogs/misc-xattr-create-xattr-block-node.patch new file mode 100644 index 0000000..cff47ed --- /dev/null +++ b/recipes-devtools/e2fsprogs/e2fsprogs/misc-xattr-create-xattr-block-node.patch @@ -0,0 +1,126 @@ +Add two new functions to manage a cache of xattr blocks as well as a new struct +to build a linked list of xattr blocks. + +xattr_add_block: Adds a block to the cache. This function is supplied with a +pointer to the head of a linked list of xattr blocks and an xattr block to add. +The purpose of this cache is to allow sharing of what would otherwise be +duplicate xattr blocks and so duplicates are not allowed in this cache. If an +identical block is already in the cache a pointer to this block will be +returned. + +xattr_rm_block: Removes a block from the cache. This function is supplied with +a pointer to the cache and a node that shall be removed from the cache. The +cache is searched for the node and the node is removed if found. + +Both functions are integrated into the 'set_inode_xattr'. Here the logic is +rearranged to cope with associating preexisting xattr blocks with inodes as +well as creating new blocks when necessary. + +Signed-off-by: Philip Tricca <[email protected]> + +Index: e2fsprogs-1.42.9/misc/xattr.c +=================================================================== +--- e2fsprogs-1.42.9.orig/misc/xattr.c ++++ e2fsprogs-1.42.9/misc/xattr.c +@@ -25,6 +25,19 @@ + #define XATTR_STDERR(fmt, args...) do {} while (0) + #endif + ++/* nodes for simple linked list to track xattr blocks, calling it a cache ++ * would be a stretch ... ++ */ ++typedef struct xattr_node xattr_node_t; ++ ++struct xattr_node { ++ struct ext2_ext_attr_header *header; ++ blk_t block; ++ struct xattr_node *next; ++}; ++ ++xattr_node_t *xattr_list_head = NULL; ++ + /* structure for mapping xattr name prefix data */ + typedef struct xattr_prefix { + int index; +@@ -48,6 +61,17 @@ xattr_prefix_t xattr_prefixes [] = { + { 0 }, + }; + ++/* free xattr node and the buffer holding the xattr block */ ++static void ++xattr_free_node (xattr_node_t *node) ++{ ++ if (node) { ++ if (node->header) ++ free (node->header); ++ free (node); ++ } ++} ++ + /* Free remaining resources after all files have been processed. */ + void + xattr_cleanup () +@@ -260,6 +284,28 @@ out: + return ret; + } + ++/* Add an xattr node to the list specified by head. This function will update ++ * head as necessary. It will return a pointer to the xattr_node_t added to the ++ * list. In the event that an identical xattr block is already on the list this ++ * function will return a pointer to the pre-existing node. ++ */ ++static xattr_node_t* ++xattr_add_block (xattr_node_t **head, xattr_node_t *node) ++{ ++ XATTR_STDERR ("Adding xattr to the the node list.\n"); ++ return node; ++} ++ ++/* Remove xattr node from list. Returns pointer to the node being removed. ++ * NOTE: We're not comparing the xattr blocks, just the nodes. ++ */ ++static xattr_node_t* ++xattr_rm_block (xattr_node_t **head, xattr_node_t *node) ++{ ++ XATTR_STDERR ("Removing xattr from the node list.\n"); ++ return node; ++} ++ + /* This is the entry point to the xattr module. This function copies the xattrs + * from the file at 'path' to the file system object at 'ino'. + * +@@ -274,16 +320,21 @@ set_inode_xattr (ext2_filsys fs, ext2_in + errcode_t ret = 0; + char *buf = NULL; + struct ext2_inode inode = { 0 }; +- blk_t block = 0; +- struct ext2_ext_attr_header *header = NULL; ++ xattr_node_t *node = NULL, *node_tmp = NULL; + uint32_t newcount = 0; + + XATTR_STDERR ("Copying xattrs from %s to inode 0x%x.\n", path, ino); ++ /* Create an xattr_node_t for it and add it to the cache if appropriate */ ++ if (!(node = calloc (1, sizeof (xattr_node_t)))) { ++ com_err (__func__, errno, "calloc"); ++ ret = errno; ++ goto out; ++ } + /* Populate the xattr block for the file at path */ +- if (ret = xattr_build_block (path, &header, fs->blocksize)) { ++ if (ret = xattr_build_block (path, &(node->header), fs->blocksize)) { + goto out; + } +- if (header == NULL) { ++ if (node->header == NULL) { + XATTR_STDERR ("set_inode_xattrs: no xattrs for %s\n", path); + goto out; + } +@@ -321,7 +372,6 @@ set_inode_xattr (ext2_filsys fs, ext2_in + if (ret = ext2fs_write_inode (fs, ino, &inode)) + com_err(__func__, ret, "ext2fs_write_inode: returned %d", ret); + out: +- if (header) +- free (header); ++ xattr_free_node (node); + return ret; + } diff --git a/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bbappend b/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bbappend index d2cefbf..241a9bf 100644 --- a/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bbappend +++ b/recipes-devtools/e2fsprogs/e2fsprogs_1.42.9.bbappend @@ -7,4 +7,5 @@ SRC_URI += " \ file://misc-create_inode.c-label-fs-objects.patch \ file://lib-ext2fs-ext2_ext_attr.h-add-xattr-index.patch \ file://misc-xattr-create-xattr-block.patch \ + file://misc-xattr-create-xattr-block-node.patch \ " -- 2.1.4 -- _______________________________________________ yocto mailing list [email protected] https://lists.yoctoproject.org/listinfo/yocto
