summaryrefslogtreecommitdiffstats
path: root/module/spl
diff options
context:
space:
mode:
authorChunwei Chen <[email protected]>2016-10-18 17:30:41 -0700
committerBrian Behlendorf <[email protected]>2016-10-20 09:33:28 -0700
commitae7eda1dde8aebc298a013254dcd90f7fa42171a (patch)
tree56167dff16e601f6255616467f310ca23fc74b02 /module/spl
parent87063d7dc392cb710c70dba49021d6e4ec8961a9 (diff)
Linux 4.9 compat: group_info changes
In Linux 4.9, torvalds/linux@81243ea, group_info changed from 2d array via ->blocks to 1d array via ->gid. We change the spl cred functions accordingly. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Chunwei Chen <[email protected]> Closes #581
Diffstat (limited to 'module/spl')
-rw-r--r--module/spl/spl-cred.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/module/spl/spl-cred.c b/module/spl/spl-cred.c
index d046f9513..1d486c1f0 100644
--- a/module/spl/spl-cred.c
+++ b/module/spl/spl-cred.c
@@ -85,7 +85,9 @@ crgetngroups(const cred_t *cr)
gi = cr->group_info;
rc = gi->ngroups;
+#ifndef HAVE_GROUP_INFO_GID
/*
+ * For Linux <= 4.8,
* crgetgroups will only returns gi->blocks[0], which contains only
* the first NGROUPS_PER_BLOCK groups.
*/
@@ -93,12 +95,16 @@ crgetngroups(const cred_t *cr)
WARN_ON_ONCE(1);
rc = NGROUPS_PER_BLOCK;
}
+#endif
return rc;
}
/*
* Return an array of supplemental gids. The returned address is safe
* to use as long as the caller has taken a reference with crhold().
+ *
+ * Linux 4.9 API change, group_info changed from 2d array via ->blocks to 1d
+ * array via ->gid.
*/
gid_t *
crgetgroups(const cred_t *cr)
@@ -107,8 +113,12 @@ crgetgroups(const cred_t *cr)
gid_t *gids = NULL;
gi = cr->group_info;
+#ifdef HAVE_GROUP_INFO_GID
+ gids = KGIDP_TO_SGIDP(gi->gid);
+#else
if (gi->nblocks > 0)
gids = KGIDP_TO_SGIDP(gi->blocks[0]);
+#endif
return gids;
}