xfs
[Top] [All Lists]

[PATCH 1/4] xfs: add helper function to convert project id between user

To: xfs@xxxxxxxxxxx
Subject: [PATCH 1/4] xfs: add helper function to convert project id between user and kernel space
From: Gao feng <gaofeng@xxxxxxxxxxxxxx>
Date: Wed, 4 Sep 2013 14:38:34 +0800
Cc: dwight.engen@xxxxxxxxxx, david@xxxxxxxxxxxxx, bfoster@xxxxxxxxxx, ebiederm@xxxxxxxxxxxx, Gao feng <gaofeng@xxxxxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1378276717-9663-1-git-send-email-gaofeng@xxxxxxxxxxxxxx>
References: <1378276717-9663-1-git-send-email-gaofeng@xxxxxxxxxxxxxx>
Create two helper functions to convert project id between
user and kernel space.

Signed-off-by: Gao feng <gaofeng@xxxxxxxxxxxxxx>
---
 fs/xfs/xfs_linux.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
index f9bb590..cc9cc5b 100644
--- a/fs/xfs/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -215,6 +215,25 @@ static inline kgid_t xfs_gid_to_kgid(__uint32_t gid)
        return make_kgid(&init_user_ns, gid);
 }
 
+static inline int
+xfs_convert_to_kernel_projid(__uint32_t prid, prid_t *kprid)
+{
+       kprojid_t kprojid = make_kprojid(current_user_ns(), prid);
+       if (!projid_valid(kprojid))
+               return -1;
+
+       *kprid = from_kprojid(&init_user_ns, kprojid);
+       return 0;
+}
+
+static inline __uint32_t
+xfs_convert_to_user_projid(prid_t kprid)
+{
+       kprojid_t kprojid = make_kprojid(&init_user_ns, kprid);
+
+       return from_kprojid(current_user_ns(), kprojid);
+}
+
 /*
  * Various platform dependent calls that don't fit anywhere else
  */
-- 
1.8.3.1

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