Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1.  
  2.  
  3.  
  4. struct group_info init_groups = { .usage = ATOMIC_INIT(2) };
  5.  
  6. struct group_info *groups_alloc(int gidsetsize){
  7.  
  8. struct group_info *group_info;
  9.  
  10. int nblocks;
  11.  
  12. int i;
  13.  
  14.  
  15.  
  16. nblocks = (gidsetsize + NGROUPS_PER_BLOCK - 1) / NGROUPS_PER_BLOCK;
  17.  
  18. /* Make sure we always allocate at least one indirect block pointer */
  19.  
  20. nblocks = nblocks ? : 1;
  21.  
  22. group_info = kmalloc(sizeof(*group_info) + nblocks*sizeof(gid_t *), GFP_USER);
  23.  
  24. if (!group_info)
  25.  
  26. return NULL;
  27.  
  28. group_info->ngroups = gidsetsize;
  29.  
  30. group_info->nblocks = nblocks;
  31.  
  32. atomic_set(&group_info->usage, 1);
  33.  
  34.  
  35.  
  36. if (gidsetsize <= NGROUPS_SMALL)
  37.  
  38. group_info->blocks[0] = group_info->small_block;
  39.  
  40. else {
  41.  
  42. for (i = 0; i < nblocks; i++) {
  43.  
  44. gid_t *b;
  45.  
  46. b = (void *)__get_free_page(GFP_USER);
  47.  
  48. if (!b)
  49.  
  50. goto out_undo_partial_alloc;
  51.  
  52. group_info->blocks[i] = b;
  53.  
  54. }
  55.  
  56. }
  57.  
  58. return
  59. Ctrl+B Buy Bitcoin [Earn $10 Free] Ctrl+L Buy AltCoins Ctrl+P Buy More AltCoins Ctrl+E Visual eBay
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement