PERFORCE change 124529 for review
Roman Divacky
rdivacky at FreeBSD.org
Thu Aug 2 12:29:40 PDT 2007
On Thu, Aug 02, 2007 at 01:56:34PM -0400, Jung-uk Kim wrote:
> On Thursday 02 August 2007 07:30 am, Roman Divacky wrote:
> > +
> > +/* XXX: fake one.. waiting for ssouhlal to commit his patch */
> > +int
> > +linux_sched_getaffinity(struct thread *td, struct
> > linux_sched_getaffinity_args *args) +{
> > + int error;
> > + cpumask_t i = ~0;
> > +
> > + if (args->len < sizeof(cpumask_t))
> > + return (EINVAL);
> > +
> > + error = copyout(&i, args->user_mask_ptr, sizeof(cpumask_t));
> > + return (error);
> > +}
>
> Er, shouldn't it be more like this?
>
> int
> linux_sched_getaffinity(struct thread *td,
> struct linux_sched_getaffinity_args *args)
> {
> uint8_t *mask;
> int error;
>
> if (args->cpusetsize < sizeof(cpumask_t))
> return (EINVAL);
>
> mask = malloc(args->cpusetsize, M_LINUX, M_WAITOK);
> memset(mask, 0xff, args->cpusetsize);
> error = copyout(mask, args->mask, args->cpusetsize);
> free(mask, M_LINUX);
>
> return (error);
> }
hm.. I looked at it and in my version the cpumask_t (linux one) is defined
to be bit array of configurable length. I dont know what is the default but
I think its quite safe to assume that its 128.
but still.. the prototype is:
asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len,
unsigned long __user *user_mask_ptr)
and the len is not used anywhere in the code to dynamically size it. I wonder
how to deal with that
More information about the p4-projects
mailing list