shmget: add "shmflg" checks for SHM_HUGE*

This commit is contained in:
NAKAMURA Gou
2016-03-17 21:47:47 +09:00
parent d65135c040
commit 48167d3223
5 changed files with 39 additions and 5 deletions

View File

@ -3536,6 +3536,7 @@ int do_shmget(const key_t key, const size_t size, const int shmflg)
int error;
struct shmid_ds ads;
struct shmobj *obj;
int pgshift;
dkprintf("do_shmget(%#lx,%#lx,%#x)\n", key, size, shmflg);
@ -3610,6 +3611,11 @@ int do_shmget(const key_t key, const size_t size, const int shmflg)
return -ENOSPC;
}
pgshift = PAGE_SHIFT;
if (shmflg & SHM_HUGETLB) {
pgshift = (shmflg >> SHM_HUGE_SHIFT) & 0x3F;
}
memset(&ads, 0, sizeof(ads));
ads.shm_perm.key = key;
ads.shm_perm.uid = proc->euid;
@ -3629,6 +3635,7 @@ int do_shmget(const key_t key, const size_t size, const int shmflg)
}
obj->index = ++the_maxi;
obj->pgshift = pgshift;
list_add(&obj->chain, &kds_list);
++the_shm_info.used_ids;