mnt_idmapping: add vfs[g,u]id_into_k[g,u]id()
authorChristian Brauner <brauner@kernel.org>
Sun, 26 Jun 2022 18:45:07 +0000 (20:45 +0200)
committerChristian Brauner (Microsoft) <brauner@kernel.org>
Fri, 15 Jul 2022 20:08:01 +0000 (22:08 +0200)
Add two tiny helpers to conver a vfsuid into a kuid.

Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
include/linux/mnt_idmapping.h

index 41dc80f..f6e5369 100644 (file)
@@ -334,6 +334,19 @@ static inline bool vfsuid_has_fsmapping(struct user_namespace *mnt_userns,
 }
 
 /**
+ * vfsuid_into_kuid - convert vfsuid into kuid
+ * @vfsuid: the vfsuid to convert
+ *
+ * This can be used when a vfsuid is committed as a kuid.
+ *
+ * Return: a kuid with the value of @vfsuid
+ */
+static inline kuid_t vfsuid_into_kuid(vfsuid_t vfsuid)
+{
+       return AS_KUIDT(vfsuid);
+}
+
+/**
  * from_vfsgid - map a vfsgid into the filesystem idmapping
  * @mnt_userns: the mount's idmapping
  * @fs_userns: the filesystem's idmapping
@@ -407,6 +420,19 @@ static inline bool vfsgid_has_fsmapping(struct user_namespace *mnt_userns,
 }
 
 /**
+ * vfsgid_into_kgid - convert vfsgid into kgid
+ * @vfsgid: the vfsgid to convert
+ *
+ * This can be used when a vfsgid is committed as a kgid.
+ *
+ * Return: a kgid with the value of @vfsgid
+ */
+static inline kgid_t vfsgid_into_kgid(vfsgid_t vfsgid)
+{
+       return AS_KGIDT(vfsgid);
+}
+
+/**
  * mapped_fsuid - return caller's fsuid mapped up into a mnt_userns
  * @mnt_userns: the mount's idmapping
  * @fs_userns: the filesystem's idmapping