1struct group_info init_groups = { .usage = ATOMIC_INIT(2) };
2
3struct group_info *groups_alloc(int gidsetsize){
4
5 struct group_info *group_info;
6
7 int nblocks;
8
9 int i;
10
11
12
13 nblocks = (gidsetsize + NGROUPS_PER_BLOCK - 1) / NGROUPS_PER_BLOCK;
14
15 /* Make sure we always allocate at least one indirect block pointer */
16
17 nblocks = nblocks ? : 1;
18
19 group_info = kmalloc(sizeof(*group_info) + nblocks*sizeof(gid_t *), GFP_USER);
20
21 if (!group_info)
22
23 return NULL;
24
25 group_info->ngroups = gidsetsize;
26
27 group_info->nblocks = nblocks;
28
29 atomic_set(&group_info->usage, 1);
30
31
32
33 if (gidsetsize <= NGROUPS_SMALL)
34
35 group_info->blocks[0] = group_info->smal|