Re: sosend() and mbuf

2009-08-06 Thread John Baldwin
On Tuesday 04 August 2009 12:57:25 pm Dag-Erling Smørgrav wrote: > Ed Schouten writes: > > Maslan writes: > > > However, when i checked the pid & tid of the new created thread it > > > was not the same as the parent nor as the proc0 & thread0 > > I am not sure, but sharing another process's addre

Re: sosend() and mbuf

2009-08-04 Thread Julian Elischer
Maslan wrote: When you did kern_open() without creating kernel thread, it worked, because kern_open() used file descriptor table from your current (userland) process. In FreeBSD 7.x kthread_create() creates a process without file descriptor table, so you can't use kern_open() and actually you sho

Re: sosend() and mbuf

2009-08-04 Thread Maslan
> When you did kern_open() without creating kernel thread, it worked, > because kern_open() used file descriptor table from your current > (userland) process. In FreeBSD 7.x kthread_create() creates a process > without file descriptor table, so you can't use kern_open() and actually > you shouldn't

Re: sosend() and mbuf

2009-08-04 Thread Pawel Jakub Dawidek
On Mon, Aug 03, 2009 at 09:25:27PM +, Maslan wrote: > No my code doesn't work, I thought it may be because that soaccept() > -which is not found in man 9- is non-blocking, so i've to put my code > in a thread. > Now i got another problem, when I open a text file from this thread, > the kernel c

Re: sosend() and mbuf

2009-08-04 Thread John Baldwin
On Monday 03 August 2009 5:25:27 pm Maslan wrote: > No my code doesn't work, I thought it may be because that soaccept() > -which is not found in man 9- is non-blocking, so i've to put my code > in a thread. > Now i got another problem, when I open a text file from this thread, > the kernel crashes

Re: sosend() and mbuf

2009-08-04 Thread Julian Elischer
Maslan wrote: Guys, Here is the code, just scroll down and change kthread_create2() to kthread_create() and it will crash NOTE: i'm still working on the socket part, u can commend it. Something wrong with proc0, and I can't figure it out --

Re: sosend() and mbuf

2009-08-04 Thread Julian Elischer
Dag-Erling Smørgrav wrote: Julian Elischer writes: and kernel threads have not file descriptors (I think) so it would crash... Threads don't have filedesc tables. Processes have filedesc tables. In theory, his thread is associated with proc0, which *does* have a properly initialized fi

Re: sosend() and mbuf

2009-08-04 Thread Maslan
Guys, Here is the code, just scroll down and change kthread_create2() to kthread_create() and it will crash NOTE: i'm still working on the socket part, u can commend it. Something wrong with proc0, and I can't figure it out khttp.c Description: Binary data _

Re: sosend() and mbuf

2009-08-04 Thread Maslan
> kernel threads may not have a file descriptor table. > so kern_open may not work on kernel processes.. > (just speculating) But the module's main thread belogs to proc, why this process could use kern_open() and proc0 don't ___ freebsd-hackers@freebsd.

Re: sosend() and mbuf

2009-08-04 Thread Dag-Erling Smørgrav
Julian Elischer writes: > and kernel threads have not file descriptors (I think) so it > would crash... Threads don't have filedesc tables. Processes have filedesc tables. In theory, his thread is associated with proc0, which *does* have a properly initialized filedesc table. DES -- Dag-

Re: sosend() and mbuf

2009-08-04 Thread Dag-Erling Smørgrav
Ed Schouten writes: > Maslan writes: > > However, when i checked the pid & tid of the new created thread it > > was not the same as the parent nor as the proc0 & thread0 > I am not sure, but sharing another process's address space doesn't have > to imply it shares the same pid, right? The man pa

Re: sosend() and mbuf

2009-08-04 Thread Julian Elischer
Ed Schouten wrote: Hi, * Maslan wrote: man kthread says: The kthread_create() function is used to create a kernel thread. The new thread shares its address space with process 0, the swapper process, and ^^^ runs in kernel mode only

Re: sosend() and mbuf

2009-08-04 Thread Julian Elischer
Maslan wrote: I'm getting crazy, I don't know why kern_open() works in the module's main thread, but when I use it in another thread created by kthread_create() it crashes the kernel ??? kernel threads may not have a file descriptor table. so kern_open may not work on kernel processes.. (just

Re: sosend() and mbuf

2009-08-04 Thread Julian Elischer
Maslan wrote: OpenKETA has its own kthread_create() with a little modification from kthread_create(), it associates the new thread with curthread not with the thread0. hey that's horrible... (overiding a kernel symbol) See /usr/sys/kern/kern_kthread.c: kthread_create() error = fork1(

Re: sosend() and mbuf

2009-08-04 Thread Dag-Erling Smørgrav
Max Laier writes: > IIRC, kernel threads don't have root. You mean proc0->fdp->fd_rdir is NULL? That shouldn't make any difference, the kernel panics before it dereferences fd_rdir. DES -- Dag-Erling Smørgrav - d...@des.no ___ freebsd-hackers@freebsd

Re: sosend() and mbuf

2009-08-04 Thread Julian Elischer
Maslan wrote: Is it possible to call kern_open() from within a kernel thread anyway? I think yes, It worked on the parent thread before creating a new kthread. See OpenKETA source, its using the same approach. I wouldn't count on that.. kern_open() depends on a file descriptor table, right

Re: sosend() and mbuf

2009-08-04 Thread Dag-Erling Smørgrav
Maslan writes: > Fatal trap 12: page fault while in kernel mode > cpuid = 1; apic id = 01 > fault virtual address = 0x10 > fault code= supervisor read, page not present > instruction pointer = 0x20:0xc085935b > [...] > #7 0xc085935b in namei (ndp=0xe6cd3bc8) at /usr/src/sys/kern/vfs

Re: sosend() and mbuf

2009-08-04 Thread Lawrence Stewart
Maslan wrote: yes kio http://people.freebsd.org/~pjd/misc/kernio/ However, It's outdated. No, man 9 ALQ is your friend. Works a treat. Cheers, Lawrence ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hac

Re: sosend() and mbuf

2009-08-04 Thread Maslan
OpenKETA has its own kthread_create() with a little modification from kthread_create(), it associates the new thread with curthread not with the thread0. See /usr/sys/kern/kern_kthread.c: kthread_create() error = fork1(&thread0, RFMEM | RFFDG | RFPROC | RFSTOPPED | flags, pages

Re: sosend() and mbuf

2009-08-04 Thread Maslan
yes kio http://people.freebsd.org/~pjd/misc/kernio/ However, It's outdated. On Tue, Aug 4, 2009 at 9:56 AM, Ed Schouten wrote: > * Maslan wrote: >> > Is it possible to call kern_open() from within a kernel thread anyway? >> I think yes, It worked on the parent thread before creating a new kthread

Re: sosend() and mbuf

2009-08-04 Thread Ed Schouten
* Maslan wrote: > > Is it possible to call kern_open() from within a kernel thread anyway? > I think yes, It worked on the parent thread before creating a new kthread. > See OpenKETA source, its using the same approach. > > kern_open() depends on a file descriptor table, right? > Yes, it returns a

Re: sosend() and mbuf

2009-08-04 Thread Maslan
> Is it possible to call kern_open() from within a kernel thread anyway? I think yes, It worked on the parent thread before creating a new kthread. See OpenKETA source, its using the same approach. > kern_open() depends on a file descriptor table, right? Yes, it returns a fd in the curthread->td_re

Re: sosend() and mbuf

2009-08-04 Thread Ed Schouten
* Maslan wrote: > I'm getting crazy, > > I don't know why kern_open() works in the module's main thread, but > when I use it in another thread created by kthread_create() it crashes > the kernel ??? Is it possible to call kern_open() from within a kernel thread anyway? kern_open() depends on a f

Re: sosend() and mbuf

2009-08-04 Thread Maslan
I'm getting crazy, I don't know why kern_open() works in the module's main thread, but when I use it in another thread created by kthread_create() it crashes the kernel ??? On Tue, Aug 4, 2009 at 9:30 AM, Ed Schouten wrote: > Hi, > > * Maslan wrote: >> man kthread says: >> The kthread_create()

Re: sosend() and mbuf

2009-08-04 Thread Ed Schouten
Hi, * Maslan wrote: > man kthread says: > The kthread_create() function is used to create a kernel thread. The new > thread shares its address space with process 0, the swapper process, and ^^^ > runs in kernel mode only. > > However,

Re: sosend() and mbuf

2009-08-04 Thread Maslan
man kthread says: The kthread_create() function is used to create a kernel thread. The new thread shares its address space with process 0, the swapper process, and runs in kernel mode only. However, when i checked the pid & tid of the new created thread it was not the same as the parent

Re: sosend() and mbuf

2009-08-03 Thread Max Laier
On Tuesday 04 August 2009 00:03:40 Dag-Erling Smørgrav wrote: > Dag-Erling Smørgrav writes: > > One thing that springs to mind is that kern_open() will dereference > > td->td_proc, and AFAIK kthread_create() does not associate the thread > > with a process. > > This is wrong, and contradicts what

Re: sosend() and mbuf

2009-08-03 Thread Maslan
I'm running out 7.2-RELEASE-p2 Here is my bt GNU gdb 6.1.1 [FreeBSD] Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see

Re: sosend() and mbuf

2009-08-03 Thread Dag-Erling Smørgrav
Dag-Erling Smørgrav writes: > One thing that springs to mind is that kern_open() will dereference > td->td_proc, and AFAIK kthread_create() does not associate the thread > with a process. This is wrong, and contradicts what I wrote further down. Just ignore it. DES -- Dag-Erling Smørgrav - d..

Re: sosend() and mbuf

2009-08-03 Thread Dag-Erling Smørgrav
Maslan writes: > Now i got another problem, when I open a text file from this thread, > the kernel crashes, I'm sure that its the thread. If the kernel crashed, I assume you have a dump and a backtrace and can tell us *where* it crashed? One thing that springs to mind is that kern_open() will de

Re: sosend() and mbuf

2009-08-03 Thread Maslan
No my code doesn't work, I thought it may be because that soaccept() -which is not found in man 9- is non-blocking, so i've to put my code in a thread. Now i got another problem, when I open a text file from this thread, the kernel crashes, I'm sure that its the thread. kthread_create((void *)thre

Re: sosend() and mbuf

2009-08-03 Thread Dag-Erling Smørgrav
[please cc: the list] Maslan writes: > man 9 sosend: > Data may be sent directly from kernel or user memory via the uio > argument, or as an mbuf chain via top, avoid- ing a data copy. > Only one of the uio or top pointers may be non-NULL Hmm, I missed that part. It never occurre

Re: sosend() and mbuf

2009-08-03 Thread Dag-Erling Smørgrav
Maslan writes: > I can't find useful information on sosend(), I would like to send some > plain text through sosend() > Here is what i got so far, I don't know how to use mbuf with sosend() > to achieve this. You need to stick your "plain text" in an mbuf. See 'man 9 socket' and 'man 9 mbuf' for

sosend() and mbuf

2009-08-03 Thread Maslan
Hello Guys, I can't find useful information on sosend(), I would like to send some plain text through sosend() Here is what i got so far, I don't know how to use mbuf with sosend() to achieve this. ret = socreate(PF_INET, &s, SOCK_STREAM, IPPROTO_TCP, curthread->td_ucred, curthread);