Subject: Re: Fixing Linux emulated brk()
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-kern
Date: 03/15/2001 00:05:12
In article <1eqa468.1aaa74i1saf6rdM@[10.0.12.137]>,
Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr> wrote:

>I need some information about this ctob(vm->vm_dsize). What is it for?
>As I understood vm->vm_daddr is the current break value, why do we add
>something to it?

daddr is the base, dsize is the size in pages, ctob() converts it
to bytes; [or atop() er.., we should really have one macro I suppose,
chs?]. We round it because this is how we define the break point.
Even if we did not, obreak does that for us. As you can see we are
a bit screwed, because we don't store the actual size value anywhere,
only in units of pages. A horrible kludge would be to store the
actual value somewhere else in struct proc [p_emuldata], and return
it so that we behave like linux. I don't see another solution that
does not involve changes to the non-compat code. It is ~trivial to
do. So add a vm_dsize to linux_emuldata and go from there.
If anyone else can see another way to do it, feel free to yell.

As an aside, the way brk is done in linux seems broken to me. I
always remembered brk aligning to a page boundary. That way you
don't have to call it 4 times to set the break point.

christos