xfs
[Top] [All Lists]

[RFC PATCH 3/4] xfs: add a new method xfs_vn_tmpfile()

To: xfs@xxxxxxxxxxx
Subject: [RFC PATCH 3/4] xfs: add a new method xfs_vn_tmpfile()
From: Zhi Yong Wu <zwu.kernel@xxxxxxxxx>
Date: Mon, 25 Nov 2013 19:32:33 +0800
Cc: Zhi Yong Wu <wuzhy@xxxxxxxxxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1385379154-3802-1-git-send-email-zwu.kernel@xxxxxxxxx>
References: <1385379154-3802-1-git-send-email-zwu.kernel@xxxxxxxxx>
From: Zhi Yong Wu <wuzhy@xxxxxxxxxxxxxxxxxx>

Add a new O_TMPFILE method to VFS inteface.

http://oss.sgi.com/archives/xfs/2013-08/msg00336.html

Signed-off-by: Zhi Yong Wu <wuzhy@xxxxxxxxxxxxxxxxxx>
---
 fs/xfs/xfs_iops.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index eb55be5..5d2e781 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -39,6 +39,7 @@
 #include "xfs_da_btree.h"
 #include "xfs_dir2_priv.h"
 #include "xfs_dinode.h"
+#include "xfs_trans_space.h"
 
 #include <linux/capability.h>
 #include <linux/xattr.h>
@@ -1051,6 +1052,24 @@ xfs_vn_fiemap(
        return 0;
 }
 
+STATIC int
+xfs_vn_tmpfile(
+       struct inode    *dir,
+       struct dentry   *dentry,
+       umode_t         mode)
+{
+       struct xfs_inode *ip = NULL;
+       int             error;
+
+       error = xfs_create_tmpfile(XFS_I(dir)->i_mount, mode, 0, &ip);
+       if (error)
+               return -error;
+
+       d_instantiate(dentry, VFS_I(ip));
+
+       return -error;
+}
+
 static const struct inode_operations xfs_inode_operations = {
        .get_acl                = xfs_get_acl,
        .getattr                = xfs_vn_getattr,
@@ -1087,6 +1106,7 @@ static const struct inode_operations 
xfs_dir_inode_operations = {
        .removexattr            = generic_removexattr,
        .listxattr              = xfs_vn_listxattr,
        .update_time            = xfs_vn_update_time,
+       .tmpfile                = xfs_vn_tmpfile,
 };
 
 static const struct inode_operations xfs_dir_ci_inode_operations = {
@@ -1113,6 +1133,7 @@ static const struct inode_operations 
xfs_dir_ci_inode_operations = {
        .removexattr            = generic_removexattr,
        .listxattr              = xfs_vn_listxattr,
        .update_time            = xfs_vn_update_time,
+       .tmpfile                = xfs_vn_tmpfile,
 };
 
 static const struct inode_operations xfs_symlink_inode_operations = {
-- 
1.7.6.5

<Prev in Thread] Current Thread [Next in Thread>