1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-21 15:45:02 +00:00

Current linux_fooaffinity() emulation fails, as the FreeBSD affinity

syscalls expect the bitmap size in the range from 32 to 128. Old glibc
always assumed size 1024, while newer glibc searches for approriate
size, starting from 1024 and going up.

For now, use FreeBSD size of cpuset_t for bitmap size parameter and
return EINVAL if length of user space bitmap less than our size of
cpuset_t.

Submitted by:	dchagin
MFC after:	1 week
	[This requires MFC of the actual linux affinity syscalls]
This commit is contained in:
Konstantin Belousov 2008-10-04 19:23:30 +00:00
parent 55fd3bafdb
commit 68da8b22d2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=183612

View File

@ -1828,15 +1828,17 @@ linux_sched_getaffinity(struct thread *td,
printf(ARGS(sched_getaffinity, "%d, %d, *"), args->pid,
args->len);
#endif
if (args->len < sizeof(cpuset_t))
return (EINVAL);
cga.level = CPU_LEVEL_WHICH;
cga.which = CPU_WHICH_PID;
cga.id = args->pid;
cga.cpusetsize = sizeof(cpumask_t);
cga.cpusetsize = sizeof(cpuset_t);
cga.mask = (cpuset_t *) args->user_mask_ptr;
if ((error = cpuset_getaffinity(td, &cga)) == 0)
td->td_retval[0] = sizeof(cpumask_t);
td->td_retval[0] = sizeof(cpuset_t);
return (error);
}
@ -1855,10 +1857,13 @@ linux_sched_setaffinity(struct thread *td,
printf(ARGS(sched_setaffinity, "%d, %d, *"), args->pid,
args->len);
#endif
if (args->len < sizeof(cpuset_t))
return (EINVAL);
csa.level = CPU_LEVEL_WHICH;
csa.which = CPU_WHICH_PID;
csa.id = args->pid;
csa.cpusetsize = args->len;
csa.cpusetsize = sizeof(cpuset_t);
csa.mask = (cpuset_t *) args->user_mask_ptr;
return (cpuset_setaffinity(td, &csa));