@@ -279,3 +279,29 @@ int eventfs_add_file(const char *name, umode_t mode,
list_add_tail(&ef->list, &ef_parent->ei->e_top_files);
return 0;
}
+
+/**
+ * eventfs_remove - remove eventfs dir or file from list
+ * @eventfs_file: a pointer to eventfs_file to be removed.
+ *
+ * This function recursively remove eventfs_file which
+ * contains info of file or dir.
+ */
+void eventfs_remove(struct eventfs_file *ef)
+{
+ struct eventfs_file *ef_child, *n;
+
+ if (!ef)
+ return;
+
+ if (ef->ei) {
+ /* search for nested folders or files */
+ list_for_each_entry_safe(ef_child, n, &ef->ei->e_top_files, list) {
+ eventfs_remove(ef_child);
+ }
+ kfree(ef->ei);
+ }
+ list_del(&ef->list);
+ kfree(ef->name);
+ kfree(ef);
+}
@@ -55,6 +55,8 @@ int eventfs_add_top_file(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops);
+void eventfs_remove(struct eventfs_file *ef);
+
struct dentry *tracefs_create_file(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops);