Re: [9fans] segattach in telnetd

2014-09-13 Thread cinap_lenrek
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

Re: [9fans] segattach in telnetd

2014-09-13 Thread arisawa
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

Re: [9fans] segattach in telnetd

2014-09-13 Thread cinap_lenrek
on the other point, you are indeed correct. the manpage or the kernel is wrong. will sort this out tomorrow. -- cinap

Re: [9fans] segattach in telnetd

2014-09-13 Thread cinap_lenrek
it works, you just mistyped "shared" in the first call. -- cinap

Re: [9fans] segattach in telnetd

2014-09-13 Thread arisawa
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 */

Re: [9fans] segattach in telnetd

2014-09-13 Thread cinap_lenrek
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

Re: [9fans] segattach in telnetd

2014-09-13 Thread arisawa
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

Re: [9fans] segattach in telnetd

2014-09-13 Thread cinap_lenrek
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

[9fans] segattach in telnetd

2014-09-13 Thread arisawa
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*