mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
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 <behlendorf1@llnl.gov> Signed-off-by: Chunwei Chen <david.chen@osnexus.com> Closes #581
This commit is contained in:
committed by
Brian Behlendorf
parent
87063d7dc3
commit
ae7eda1dde
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -166,6 +166,7 @@ splat_cred_test2(struct file *file, void *arg)
|
||||
return 0;
|
||||
} /* splat_cred_test2() */
|
||||
|
||||
#define SPLAT_NGROUPS 32
|
||||
/*
|
||||
* Verify the groupmember() works correctly by constructing an interesting
|
||||
* CRED() and checking that the expected gids are part of it.
|
||||
@@ -188,7 +189,7 @@ splat_cred_test3(struct file *file, void *arg)
|
||||
* 1:(NGROUPS_MAX-1). Gid 0 is explicitly avoided so we can reliably
|
||||
* test for its absence in the test cases.
|
||||
*/
|
||||
gi = groups_alloc(NGROUPS_SMALL);
|
||||
gi = groups_alloc(SPLAT_NGROUPS);
|
||||
if (gi == NULL) {
|
||||
splat_vprint(file, SPLAT_CRED_TEST3_NAME, "Failed create "
|
||||
"group_info for known gids: %d\n", -ENOMEM);
|
||||
@@ -196,7 +197,7 @@ splat_cred_test3(struct file *file, void *arg)
|
||||
goto show_groups;
|
||||
}
|
||||
|
||||
for (i = 0, tmp_gid = known_gid; i < NGROUPS_SMALL; i++) {
|
||||
for (i = 0, tmp_gid = known_gid; i < SPLAT_NGROUPS; i++) {
|
||||
splat_vprint(file, SPLAT_CRED_TEST3_NAME, "Adding gid %d "
|
||||
"to current CRED() (%d/%d)\n", tmp_gid, i, gi->ngroups);
|
||||
#ifdef HAVE_KUIDGID_T
|
||||
|
||||
Reference in New Issue
Block a user