From owner-freebsd-questions Thu Jul 12 13:27: 9 2001 Delivered-To: freebsd-questions@freebsd.org Received: from eniac.cable.net.co (eniac.cable.net.co [196.27.25.66]) by hub.freebsd.org (Postfix) with ESMTP id 5E50A37B401 for ; Thu, 12 Jul 2001 13:27:03 -0700 (PDT) (envelope-from ycardena@yahoo.com) Received: from pcdisis05.cable.net.co ([216.72.56.125]) by eniac.cable.net.co (Post.Office MTA v3.5.3 release 223 ID# 637-71558U30000L25000S0V35) with SMTP id co for ; Thu, 12 Jul 2001 15:30:58 -0500 Received: from PCSIT03 (172.28.221.31) by pcdisis05.cable.net.co (172.28.221.185) with esmtp ; Thu, 12 Jul 2001 15:26:04 -0500 Message-ID: <3B4E06F1.2030808@yahoo.com> Date: Thu, 12 Jul 2001 15:22:09 -0500 From: Yonny Cardenas Organization: Ingenieria Integral Ltda User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; m18) Gecko/20010131 Netscape6/6.01 X-Accept-Language: es-co, en MIME-Version: 1.0 To: questions@freebsd.org Subject: Some questions about kernel programming Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Dear Friends I have some questions about kernel programming: 1. Why I can call some system calls functions into the kernel but another not?, for example: I can call printf(), but I can't call socket(). 2. Into kernel I can call the socket "low level" functions that this system calls invoke sosocket(), soconnect(), etc. but, How I do replace the send() system call? Perhaps, Can I call write() into kernel with same parameters? For example : /* res = send(skt, buf, buflen, 0); */ res = write (skt, buf, buflen); 3. How I can copy a pointer string ( character array ) from user space to kernel space using copyin() without the following problem (I can't pass the length the explicitly from user land): struct MySystemCall_args { char * address; }; int MySystemCall( p,uap) struct proc *p; register struct MySystemCall_args *uap; { char *the_address; printf(" ---> uap->address : %s\n", uap->address ); printf(" ---> (strlen (uap->address) * sizeof(char)) : %d \n", (strlen (uap->address) * sizeof(char)) ); copyin(uap->address, the_address, (strlen (uap->address) * sizeof(char)) ); printf("the_address: %s \n", the_address ); printf("strlen (the_address): %d \n", strlen (the_address) ); When this code run in mode kernel: ---> uap->address : 127.0.0.1 ---> (strlen (uap->address) * sizeof(char)) : 9 the_address : 127.0.0.1\M-"\M-Y\M-GX\M-p+\M-@@\M-_\M-*\M-@ strlen (the_address): 20 This crash the kernel later... Thanks for your help. -- +------------------------------------------------------------------+ | YONNY CARDENAS B. Apartado Aereo 22828 | | Systems Engineer Santafe de Bogota D.C. | | Colombia - South America | | Student M.Sc. Tels: +571 6095477 | | UNIVERSIDAD DE LOS ANDES mailto: y-carden@uniandes.edu.co | | ycardena@yahoo.com | +------------------------------------------------------------------+ UNIX is BSD, and FreeBSD is an advanced 4.4BSD To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message