Wrapfs: dentry operations
authorErez Zadok <ezk@cs.sunysb.edu>
Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)
committerErez Zadok <ezk@cs.sunysb.edu>
Tue, 27 Dec 2016 03:52:47 +0000 (22:52 -0500)
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/wrapfs/dentry.c [new file with mode: 0644]

diff --git a/fs/wrapfs/dentry.c b/fs/wrapfs/dentry.c
new file mode 100644 (file)
index 0000000..ca8efa4
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1998-2010 Erez Zadok
+ * Copyright (c) 2009     Shrikar Archak
+ * Copyright (c) 2003-2010 Stony Brook University
+ * Copyright (c) 2003-2010 The Research Foundation of SUNY
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "wrapfs.h"
+
+/*
+ * returns: -ERRNO if error (returned to user)
+ *          0: tell VFS to invalidate dentry
+ *          1: dentry is valid
+ */
+static int wrapfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
+{
+       struct path lower_path, saved_path;
+       struct dentry *lower_dentry;
+       int err = 1;
+
+       wrapfs_get_lower_path(dentry, &lower_path);
+       lower_dentry = lower_path.dentry;
+       if (!lower_dentry->d_op || !lower_dentry->d_op->d_revalidate)
+               goto out;
+       pathcpy(&saved_path, &nd->path);
+       pathcpy(&nd->path, &lower_path);
+       err = lower_dentry->d_op->d_revalidate(lower_dentry, nd);
+       pathcpy(&nd->path, &saved_path);
+out:
+       wrapfs_put_lower_path(dentry, &lower_path);
+       return err;
+}
+
+static void wrapfs_d_release(struct dentry *dentry)
+{
+       /* release and reset the lower paths */
+       wrapfs_put_reset_lower_path(dentry);
+       free_dentry_private_data(dentry);
+       return;
+}
+
+const struct dentry_operations wrapfs_dops = {
+       .d_revalidate   = wrapfs_d_revalidate,
+       .d_release      = wrapfs_d_release,
+};