- return inode_get_tagged_item(inode, TAG_WIMLIB_UNIX_DATA,
- sizeof(struct wimlib_unix_data_disk));
+ u8 *p;
+ u32 old_len;
+
+ /* Remove any existing items with the same tag */
+ while ((p = inode_get_tagged_item(inode, tag, 0, &old_len)) != NULL) {
+ p -= sizeof(struct tagged_item_header);
+ old_len += sizeof(struct tagged_item_header);
+ old_len = ALIGN(old_len, 8);
+ memmove(p, p + old_len, (inode->i_extra->data +
+ inode->i_extra->size) - (p + old_len));
+ inode->i_extra->size -= old_len;
+ }
+
+ /* Add the new item */
+ p = inode_add_tagged_item(inode, tag, len);
+ if (!p)
+ return false;
+ memcpy(p, data, len);
+ return true;