-/* Arguments for do_free_dentry(). */
-struct free_dentry_args {
- struct lookup_table *lookup_table;
- bool lt_decrement_refcnt;
-};
+/* Like free_dentry(), but assigns a new ADS entries owner if this dentry was
+ * the previous owner, and also deletes the dentry from its link_group_list */
+void put_dentry(struct dentry *dentry)
+{
+ if (dentry->ads_entries_status == ADS_ENTRIES_OWNER) {
+ struct dentry *new_owner;
+ list_for_each_entry(new_owner, &dentry->link_group_list,
+ link_group_list)
+ {
+ if (new_owner->ads_entries_status == ADS_ENTRIES_USER) {
+ new_owner->ads_entries_status = ADS_ENTRIES_OWNER;
+ break;
+ }
+ }
+ dentry->ads_entries_status = ADS_ENTRIES_USER;
+ }
+ struct list_head *next;
+ list_del(&dentry->link_group_list);
+ free_dentry(dentry);
+}
+
+
+/* clones a dentry.
+ *
+ * Beware:
+ * - memory for file names is not cloned
+ * - next, prev, and children pointers and not touched
+ * - stream entries are not cloned.
+ */
+struct dentry *clone_dentry(struct dentry *old)
+{
+ struct dentry *new = MALLOC(sizeof(struct dentry));
+ if (!new)
+ return NULL;
+ memcpy(new, old, sizeof(struct dentry));
+ new->file_name = NULL;
+ new->file_name_len = 0;
+ new->file_name_utf8 = NULL;
+ new->file_name_utf8_len = 0;
+ new->short_name = NULL;
+ new->short_name_len = 0;
+ return new;
+}