no, it is not. labs also seems to just round up the length
not adding the remainder of the unaligned va address. it
would be a one line fix in the kernel.
the manpage sais this:
Va and len specify the position of the segment in the
process's address space. Va is rounded down
ooh
that is my halt.
egattach(0,"shared",0,1024);
works fine!
my test
test1(void)
{
char *ap;
ap = segattach(0,"shared",0,1024);
print("%p\n",ap); // deffe000
}
term% cat /proc/917256/segment
Stack defff000 d0001
Text R 1000 60001
Data
on the other point, you are indeed correct. the manpage
or the kernel is wrong. will sort this out tomorrow.
--
cinap
it works, you just mistyped "shared" in the first call.
--
cinap
Hello cinap,
My experiment here.
void
main(int argc, char *argv[])
{ char *ap;
char buf[1];
ARGBEGIN{
default: usage();
}ARGEND
ap = segattach(0,"share",0,1024);
print("%p\n",ap); // error
/* compare */
the + 2MB is to keep some distance to the bss (heap).
the assumption might'v been that telnet will not
dynamically allocate more than 2MB from the time
when the segment is created.
a better solution would be to just pass 0 as va. the
kernel will then put the segment downwards from
the stack base a
Hello,
I think
vastart += 2*1024*1024;
is weird.
if we look /proc/$ip/segment in share(), we will have better solution.
but I am not convinced we should apply the solution.
because we seldom needs shared segment.
I haven’t had any trouble with telnetd.
I needed shared segment for specia
why? segattach() gets an explicit address here and
it should round va down and va+len up as neccesary
to make them page aligned. but the initial passed
range should be covered by the created segment
in any case.
do you have any trouble with telnet that is fixed
by your change?
--
cinap
Hello,
we have an example for segattach() in /sys/src/cmd/ip/telnetd.c
void*
share(ulong len)
{
uchar *vastart;
vastart = sbrk(0);
if(vastart == (void*)-1)
return 0;
vastart += 2*1024*1024;
if(segattach(0, "shared", vastart, len) == (void*