Re: FreeBSD Memory Management questions ?

2005-06-20 Thread Aziz Kezzou
On 6/20/05, John Baldwin [EMAIL PROTECTED] wrote:
 On Sunday 19 June 2005 10:49 pm, Aziz Kezzou wrote:
   On Tue, Jun 14, 2005 at 04:21:41AM -0400, Aziz Kezzou wrote:
1 - Right now to access the memory address space of a user process
from kernel mode, I only have to set, on x86 systems, the register CR3
to the right value.  How can I do that on other architectures ? is
there an architecture-independant way of doing that ?
  
   Addition to the previous answer.  It is also possible to temporally
   map several pages of user memory into the kernel address space.
   Check pmap_qenter(9) and see physio - vmapbuf, for example, how to
   use it.  Another method, it is possible to COW a single user page and
   then use it in the kernel, but with this method an user process will
   not see any modification in this page made by the kernel and vice
   versa. Check socow_setup - vm_page_cowsetup, for example, how to
   use it.
 
  Very interesting !
 
  Right now I am using the fact that the kernel address space is maped
  on i386 machines into the user address space. So when I am executing a
  system call I can access kernel memory.
  I am wondering if there is an architecture-independant way of doing
  that ? (Notice that I need not only read kernel memory but also free
  it. e.g, mbufs ) or at least could you tell me if that's  possible on
  other architectures ?
 
 Are you modifying kernel memory from userland or are you trying to access user
 memory from kernel code?
 

I want to be able to modify BOTH user and kernel memory in kernel mode.

Typically, a user process invoques a system call. While executing the
system call I need to have r/w access to the calling process's memory
(which is normally OK) and also r/w access to kernel's memory. Note :
the user pages that are access from kernel mode are wired to avoid a
page-fault inside the kernel, is that necessary ?

Also is there a way of sharing part of the user memory space with the
kernel. In a way that both have access to it and both see each others
work (i.e, no copy-on-write ) ?

Thanks,
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: FreeBSD Memory Management questions ?

2005-06-19 Thread Aziz Kezzou
 On Tue, Jun 14, 2005 at 04:21:41AM -0400, Aziz Kezzou wrote:
 
  1 - Right now to access the memory address space of a user process
  from kernel mode, I only have to set, on x86 systems, the register CR3
  to the right value.  How can I do that on other architectures ? is
  there an architecture-independant way of doing that ?
 
 Addition to the previous answer.  It is also possible to temporally
 map several pages of user memory into the kernel address space.
 Check pmap_qenter(9) and see physio - vmapbuf, for example, how to
 use it.  Another method, it is possible to COW a single user page and
 then use it in the kernel, but with this method an user process will
 not see any modification in this page made by the kernel and vice
 versa. Check socow_setup - vm_page_cowsetup, for example, how to
 use it.

Very interesting !

Right now I am using the fact that the kernel address space is maped
on i386 machines into the user address space. So when I am executing a
system call I can access kernel memory.
I am wondering if there is an architecture-independant way of doing
that ? (Notice that I need not only read kernel memory but also free
it. e.g, mbufs ) or at least could you tell me if that's  possible on
other architectures ?

Thanks for your help,
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


How to check root powers on a struct proc ?

2005-06-17 Thread Aziz Kezzou
Hi all,
I am trying to check that a process (struct proc) has root powers when
it calls my KLD system call.
I know from kern_jail.c that I can use suser() but this function takes
a struct thread* instead of struct proc* although the credentials
(struct ucred *p_ucred;) are stored in proc !

Is there an esay way to get a struct thread* from a struct proc* ? or
should I simply use the function:  int suser_cred(struct ucred *cred,
int flag); with cred = p- p_ucred

BTW what would the value of flag  be?

Thanks,
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How to check root powers on a struct proc ?

2005-06-17 Thread Aziz Kezzou
 Aziz Kezzou wrote:
  Hi all,
  I am trying to check that a process (struct proc) has root powers when
  it calls my KLD system call.
  I know from kern_jail.c that I can use suser() but this function takes
  a struct thread* instead of struct proc* although the credentials
  (struct ucred *p_ucred;) are stored in proc !
 
 no.. the thread has a credential that it inherrits from the proc.
 when a thread changes the credential of the process as a whole, the
 other threads in the kernel don't notice until they return from their
 syscalls.. in the mean time they continue to use the reference they
 hold to the old credential. This is so that a credential doesn;t change half 
 way
 through a syscall.  the active credential at entry will be the active 
 credential
 for that thread until it completes its time in the kernel.
 
 
  Is there an esay way to get a struct thread* from a struct proc* ? or
  should I simply use the function:  int suser_cred(struct ucred *cred,
  int flag); with cred = p- p_ucred
 
 why get a struct proc?  the thread has a pointer to the cred it is running
 under.
 
 

I probably didn't make myself clear enough.
When my KLD system call is called I get a reference on the calling
process as struct proc *p. Now how do I check if the calling process
has root powers ?

Would the following work  ? :
static int ukcoe_register_ud( struct proc *p, struct
ukcoe_register_ud_args* arg ) {
int error;
error = suser_cred(p-p_cred, 0);
if(error) return error;

/* do the actual work*/
return 0;
}

Thanks,
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


FreeBSD Memory Management questions ?

2005-06-14 Thread Aziz Kezzou
Hi all,
I have two questions concerning FreeBSD Memory management :

1 - Right now to access the memory address space of a user process
from kernel mode, I only have to set, on x86 systems, the register CR3
to the right value.  How can I do that on other architectures ? is
there an architecture-independant way of doing that ?

2- I have noticed that while in kernel mode the value of CR3 is equal
to that of the user process beeing interrupted. Doesn't the kernel
supposed to have its own page-directory, i.e it's own CR3  value ?
or is kernel virtual address resolution does  not go through CR3 at
all ?
 
Thanks for your help,
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


How to do a routing lookup inside the kernel in FreeBSD ?

2005-06-09 Thread Aziz Kezzou
Hi all,
I am trying to figure out from the kernel source code (FreeBSD 5.3)
how can I perform a routing lookup in a KLD module.
Since I am short in time, if anyone knows how do to do this I would
appreciate. Any pointers to the right portion of the code are also
apperciated.
Thanks,
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Fork mystries....

2005-06-04 Thread Aziz Kezzou
Thank you guys,
I got it fork is creating a different process.
Currently, I am working a lot that I forget even the basic principales ;-) 
I need a break ...
-aziz


On 6/3/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Aziz,
 
   Fork is for process creation.  Look up pthread_create() and/or POSIX
 thread
 creation, etc.  You should be able to find a lot of info on google with a
 quick
 search:  
 
 http://math.arizona.edu/~swig/documentation/pthreads/
 
   From the OS standpoint a process is like a different program when you fork
 it.
  A thread is more like a single program with a bunch of subsections all
 running
 at the same time, then the OS and CPU jump back and forth giving a little
 run-time to each subsection.  Threads share a common space; processes [as
 far as
 I recal] do not (which is where inter process communication comes into
 play).
 
   Anyway, have fun! :)
 
 Ray
 
 
 At 07:55 PM 6/3/2005 -0400, Aziz Kezzou wrote:
 | Hi all,
 | It's probably not the right mailing list to ask but I am really
 | surprised about global variable sharing in a multithreaded C
 | application. If I remember well my multithreading course global
 | variables are shared between threads, right ?
 |  
 | Example :
 | 
 | int counter = 0;
 | int main() {
 |   if( fork()==0) {
 | while(1) {
 |   sleep(1);
 |   counter++;
 |   printf(Son : counter = %d\n, counter);  
 | }
 |   } else {
 | while(1) {
 |   sleep(1);
 |   printf(Parent : counter = %d\n, counter);  
 | }
 |  }   
 |   return 0;
 | }
 | 
 | 
 | All I get is :
 | Parent : counter = 0
 | Son : counter = 1
 | Son : counter = 2
 | Parent : counter = 0
 | Son : counter = 3
 | Parent : counter = 0
 | Son : counter = 4
 | Parent : counter = 0
 | 
 | why counter isn't shared between the two threads ??!
 | thanks,
 | -aziz
 | ___
 | freebsd-hackers@freebsd.org mailing list
 | http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
 | To unsubscribe, send any mail to
 [EMAIL PROTECTED]
 | 
 | 

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Fork mystries....

2005-06-03 Thread Aziz Kezzou
Hi all,
It's probably not the right mailing list to ask but I am really
surprised about global variable sharing in a multithreaded C
application. If I remember well my multithreading course global
variables are shared between threads, right ?
 
Example :

int counter = 0;
int main() {
  if( fork()==0) {
while(1) {
  sleep(1);
  counter++;
  printf(Son : counter = %d\n, counter);  
}
  } else {
while(1) {
  sleep(1);
  printf(Parent : counter = %d\n, counter);  
}
 }   
  return 0;
}


All I get is :
Parent : counter = 0
Son : counter = 1
Son : counter = 2
Parent : counter = 0
Son : counter = 3
Parent : counter = 0
Son : counter = 4
Parent : counter = 0

why counter isn't shared between the two threads ??!
thanks,
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Routing loop + raw IP packets : looking for clues ...

2005-05-31 Thread Aziz Kezzou
Hi all,
For the purpose of my project I am simpulating a 3-hop network with
QEMU on my workstation, as follows :

|-|   
|---| 
|-|
|Daemon1(user process)|---tun0---| Daemon 2 on QEMU |---tun1---|
Daemon 3 (user porcess) |
|-|
|---|
|-|

My workstation  is running FC3 and QEMU is running FreeBSD5.3
I am tryning to exchange raw IP packets between daemon 1 and 3 through
daemon 2. I've succeded to by pass  the system routing and get packets
sent from daemon 1 to daemon 2 and from daemon 2 to daemon 3. BUT, on
daemon 3 I can not receive them ??!!

However, when I listen with tcpdump on tun0 and tun1 I see the packets
travelling as expected :
daemon1(192.168.0.1)--(192.168.0.2)daemon2(192.168.1.2)--
daemon3(192.168.0.2)

What could prevent me from receiving packets intended for daemon 3? I
am suspecting some hard coded rule to prevent routing loops (which is
my case) in the Linux kernel, am I on the right track ?

Note : I disabled completely my firewalls, so this could not be the reason.

Any help is highly appreciated.

-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Pseudo-device driver select ??

2005-05-26 Thread Aziz Kezzou
Hi all,
I am trying to implement a small kld pseudo-device driver on FreeBSD 5.3 that 
behaves just like a socket with regards to the select system call.

Currently, I am using the sample echo pseudo-device driver from
http://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/driverbasics-char.html
 as an example. However, whenever  I call select on the file
descriptor of /dev/echo it always returns even when there is no data
to be read.

I looked at the socket code and it looks like I need to provide my own
fo_select function in the fileops data structure. Am i right ? How
do I do that ? The sample echo pseudo-device driver above uses 
struct cdevsw  instead...

Thanks
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Pseudo-device driver select ??

2005-05-26 Thread Aziz Kezzou
 
 Aziz Kezzou wrote:
  Hi all,
  I am trying to implement a small kld pseudo-device driver on FreeBSD 5.3 
  that
  behaves just like a socket with regards to the select system call.
 
  Currently, I am using the sample echo pseudo-device driver from
  http://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/driverbasics-char.html
   as an example. However, whenever  I call select on the file
  descriptor of /dev/echo it always returns even when there is no data
  to be read.
 
  I looked at the socket code and it looks like I need to provide my own
  fo_select function in the fileops data structure. Am i right ? How
  do I do that ? The sample echo pseudo-device driver above uses
  struct cdevsw  instead...
 
  Thanks
  -aziz
  ___
  freebsd-net@freebsd.org mailing list
  http://lists.freebsd.org/mailman/listinfo/freebsd-net
  To unsubscribe, send any mail to [EMAIL PROTECTED]
 
 
 look at spec_poll()
 I beleive that when your device is opened the fileops{} will
 point to the spec ops and you're code will be entered via
 spec_poll() - now you just need to implement the poll/select notion
 for your device.
  

Thanks, 
Actually, il turned out to be very simple.
I needed only to provide a d_poll function as part of the structure
cdevsw, as follows :

/* Character device entry points */
static struct cdevsw echo_cdevsw = {
.d_version = D_VERSION,
.d_open = echo_open,
.d_close = echo_close,
.d_read = echo_read,
.d_write = echo_write,
.d_poll = echo_poll,
.d_name = echo,
};

with echo_poll :
static  int
echo_poll(struct cdev *dev, int events, struct thread *td)
{

  uprintf( echo_poll called : data_available = %d!\n, data_available );
  if(data_available == 0) 
return 0;  
  data_available = 0;  
  return 1;
}
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Pseudo-device driver select ??

2005-05-26 Thread Aziz Kezzou
 
  Aziz Kezzou wrote:
   Hi all,
   I am trying to implement a small kld pseudo-device driver on FreeBSD 5.3 
   that
   behaves just like a socket with regards to the select system call.
  
   Currently, I am using the sample echo pseudo-device driver from
   http://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/driverbasics-char.html
as an example. However, whenever  I call select on the file
   descriptor of /dev/echo it always returns even when there is no data
   to be read.
  
   I looked at the socket code and it looks like I need to provide my own
   fo_select function in the fileops data structure. Am i right ? How
   do I do that ? The sample echo pseudo-device driver above uses
   struct cdevsw  instead...
  
   Thanks
   -aziz
   ___
   freebsd-net@freebsd.org mailing list
   http://lists.freebsd.org/mailman/listinfo/freebsd-net
   To unsubscribe, send any mail to [EMAIL PROTECTED]
  
  
  look at spec_poll()
  I beleive that when your device is opened the fileops{} will
  point to the spec ops and you're code will be entered via
  spec_poll() - now you just need to implement the poll/select notion
  for your device.
 
 
 Thanks,
 Actually, il turned out to be very simple.
 I needed only to provide a d_poll function as part of the structure
 cdevsw, as follows :
 
 /* Character device entry points */
 static struct cdevsw echo_cdevsw = {
 .d_version = D_VERSION,
 .d_open = echo_open,
 .d_close = echo_close,
 .d_read = echo_read,
 .d_write = echo_write,
 .d_poll = echo_poll,
 .d_name = echo,
 };
 
 with echo_poll :
 static  int
 echo_poll(struct cdev *dev, int events, struct thread *td)
 {
 
   uprintf( echo_poll called : data_available = %d!\n, data_available );
   if(data_available == 0)
 return 0;
   data_available = 0;
   return 1;
 }
 

Now the question is, if I don't have any data available when select
(i.e d_poll ) is called, how do I notify select  when data arrives ?
looks like d_poll is called only once (the name is a bit misleading
here ;-) , isn't it ?

Any hints ? 
Thanks.
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


weird NFS problem ?

2005-05-25 Thread Aziz Kezzou
Hi all,
I am experiencing a weird problem while mounting nfs files. 

Configuration :
- NFS client : FreeBSD 5.3 running on QEMU, IP = 192.168.0.2
- NFS server : FC3, the host, IP = 192.168.0.1

Firewalling: 
absolutely everything is authorized from 192.168.0.2 on 192.168.0.1

Problem :
some UDP ports on 192.168.0.2  are unreachable without any reason I know of ?!!

Command:
arwen# mount -t nfs 192.168.0.1:/home/akezzou/pfe/cvs /mnt/host
[udp] 192.168.0.1:/home/akezzou/pfe/cvs: RPCPROG_MNT: RPC: Timed out
[udp] 192.168.0.1:/home/akezzou/pfe/cvs: RPCPROG_MNT: RPC: Timed out

Tcpdump output :
[EMAIL PROTECTED] bin]# /usr/sbin/tcpdump -i tun0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on tun0, link-type EN10MB (Ethernet), capture size 96 bytes
21:04:51.560121 IP 192.168.0.2.675  192.168.0.1.sunrpc: UDP, length 56
21:04:51.561806 arp who-has 192.168.0.2 tell 192.168.0.1
21:04:51.564088 arp reply 192.168.0.2 is-at 52:54:00:12:34:56
21:04:51.564118 IP 192.168.0.1.sunrpc  192.168.0.2.675: UDP, length 28
21:04:51.570214 IP 192.168.0.2.1117046890  192.168.0.1.nfs: 40 null
21:04:51.570368 IP 192.168.0.1.nfs  192.168.0.2.1117046890: reply ok 24 null
21:04:51.575164 IP 192.168.0.2.954  192.168.0.1.sunrpc: UDP, length 56
21:04:51.576338 IP 192.168.0.1.sunrpc  192.168.0.2.954: UDP, length 28
21:04:51.581561 IP 192.168.0.2.621  192.168.0.1.650: UDP, length 108
21:05:04.528129 IP 192.168.0.1.650  192.168.0.2.621: UDP, length 68
21:05:04.530154 IP 192.168.0.2  192.168.0.1: icmp 36: 192.168.0.2 udp
port 62 1 unreachable
21:06:01.613750 IP 192.168.0.2.1006  192.168.0.1.sunrpc: UDP, length 56
21:06:01.616083 IP 192.168.0.1.sunrpc  192.168.0.2.1006: UDP, length 28
21:06:01.622336 IP 192.168.0.2.1117192688  192.168.0.1.nfs: 40 null
21:06:01.626734 IP 192.168.0.1.nfs  192.168.0.2.1117192688: reply ok 24 null
21:06:01.637315 IP 192.168.0.2.843  192.168.0.1.sunrpc: UDP, length 56
21:06:01.641915 IP 192.168.0.1.sunrpc  192.168.0.2.843: UDP, length 28
21:06:01.646715 IP 192.168.0.2.792  192.168.0.1.650: UDP, length 108
21:06:06.614378 arp who-has 192.168.0.2 tell 192.168.0.1
21:06:06.615755 arp reply 192.168.0.2 is-at 52:54:00:12:34:56
21:06:16.682754 IP 192.168.0.1.650  192.168.0.2.792: UDP, length 68
21:06:16.684556 IP 192.168.0.2  192.168.0.1: icmp 36: 192.168.0.2 udp
port 79 2 unreachable
21:07:11.659900 IP 192.168.0.2.764  192.168.0.1.sunrpc: UDP, length 56
21:07:11.662292 IP 192.168.0.1.sunrpc  192.168.0.2.764: UDP, length 28
21:07:11.668228 IP 192.168.0.2.1117147813  192.168.0.1.nfs: 40 null
21:07:11.671916 IP 192.168.0.1.nfs  192.168.0.2.1117147813: reply ok 24 null
21:07:11.676171 IP 192.168.0.2.693  192.168.0.1.sunrpc: UDP, length 56
21:07:11.683197 IP 192.168.0.1.sunrpc  192.168.0.2.693: UDP, length 28
21:07:11.688238 IP 192.168.0.2.958  192.168.0.1.650: UDP, length 108
21:07:16.660731 arp who-has 192.168.0.2 tell 192.168.0.1
21:07:16.661668 arp reply 192.168.0.2 is-at 52:54:00:12:34:56

 
Any hint is greatly appreciated.
thanks,
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: KLD module with C++ iostreams ?

2005-04-21 Thread Aziz KEZZOU
 David Leimbach wrote:
  Interesting question.  People usually have to implement the C++
  runtime to be usable from within the kernel.  Things like exceptions
  and stdout may not be defined in kernel space :)
 
  I'm not terribly familiar with how it works on FreeBSD but I know it
  took a special effort to get C++ support into linux.
 
  Dave
 
  On 4/20/05, Aziz KEZZOU [EMAIL PROTECTED] wrote:
 
 Hi hackers,
 I am wondering if I can use c++ iostreams inside the kernel ?
 After all the code : cout  Hello world!  endl;
 ends accessing the stdout just like : printf(Hello world!\n); right ?
 
 No, that's not true, all the iostreams stuff is totally independent.
 The iostreams stuff is coming from some of the ugliest code in C++.
 But, that's not the question, or at very least, it shouldn't BE the
 question.  There is ZERO need to bring in features from C++, all it will
 do is to directly confuse the code base by greatly adding to the
 complexity of the code, without giving anything like equivalent features.
 
 Some very, very elegant work has been code, OO-ing the kernel code,
 adding OO features, all without violating the C language code base.
 Adding in C++ features over stdio stuff is so senseless, it's nearly
 obscene.
 
 If the gain at the end of the road was large enough, I wouldn't be
 against it so stridently, but I see *so* little gain.
 
 BTW, you know where the ugliest code in computer science today is: half
 is in the actual implementation of the cstdio/template code, the other
 half is the iostreams stuff.  The fact that they energize some very
 elegant code is causing many folks never to see the fact of the horrible
 code lumps that exist out in the backyard.
 
 
 So if I could compile my KLD module with static linkage to libstdc++,
 that should be ok, right ?
 
 Any one did or knows how to do this ?
 

Thank you guys for responding to my post.
Certainly, it is not a good idea to use _all_ C++ stuff inside the
kernel ; in the linux community a similar suggestion resulted in a big
discussion of pros  cons. I was asking because I have a big portion
of C++ code that I am planning to move inside the kernel.

But, having compared the effort/time required to port C++ iostreams
into the kernel and the effort/time required to get rid of iostreams ,
I think I will abandon this challenge for now ;-)

Just to let you know virtual methods and templates, among others,
are supported inside the kernel...

Greetings,
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


KLD module with C++ iostreams ?

2005-04-20 Thread Aziz KEZZOU
Hi hackers,
I am wondering if I can use c++ iostreams inside the kernel ?
After all the code : cout  Hello world!  endl; 
ends accessing the stdout just like : printf(Hello world!\n); right ?

So if I could compile my KLD module with static linkage to libstdc++,
that should be ok, right ?

Any one did or knows how to do this ?

Thanks,
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


clear/set/test_bit header ??

2005-04-13 Thread Aziz KEZZOU
Hi hackers,
I am trying to port a software from Linux to FreeBSD (5.3). But, I
can't find the equivalent header in FreeBSD of asm/bitops.h in Linux
?

Here are the prototypes of the functions I am using:
int clear_bit(int offset, int * flag);
int set_bit(int offset, int * flag);
int test_bit(int offset, int * flag);

Any hints?

Also if you know about a website which does this header-mapping
(Linux-FreeBSD), I am interested to know about it ;-)

Thanks,
-aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: running freebsd in qemu using the -nographic option ?

2005-03-24 Thread Aziz KEZZOU
 Aziz KEZZOU wrote:
 
 Hi all,
 I am running freebsd 5.3 under qemu (a fast IA32 emulator). My host
 system is linux. Everything works fine, but I want to get rid of this
 small non-scrollable window, not practical when gcc says I made many
 many errors :-)...
 
 
 
 you can scroll it after hittong tthe scroll lock key
 
 Instead I want to get a console. In qemu's  documentation it says :
 ==
 `-nographic'
 Normally, QEMU uses SDL to display the VGA output. With this
 option, you can totally disable graphical output so that QEMU is a
 simple command line application. The emulated serial port is
 redirected on the console. Therefore, you can still use QEMU to debug
 a Linux kernel with a serial console.
 ==
 
 So basically what I need is, some how, to tell the freebsd kernel to
 forward its output/input to a serial port. In linux this is done by
 supplying the parameter console=ttyS0. Is there something equivalent
 in FreeBSD ?
 
 
 
 
 in /boot/loader.conf add:
 
 console=comconsole
 
 that should do it..

Thank you guys, that seems easy to do...but I don't have access to
/etc/boot.conf : all I have is a disk image generated by bximage,
which I can't mount !!

The pb is that with my new install the SDL window doesn't work any
more : qemu says Could not initialize SDL - exit. I did xhost +
but didn't change any thing ?!  Anyway I am not spending any more time
to get the SDL window which I don't really need :-)

So basically what I want to do now is mount the freeBSD image in a
loopback and modify the boot.conf file directly. Anyone knows how to
do this under linux (2.6 if relevant) ? BSD seems to have a weird
way of organizing the disk. Which file system shoud I support ?

Thanks,
Aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


running freebsd in qemu using the -nographic option ?

2005-03-23 Thread Aziz KEZZOU
Hi all,
I am running freebsd 5.3 under qemu (a fast IA32 emulator). My host
system is linux. Everything works fine, but I want to get rid of this
small non-scrollable window, not practical when gcc says I made many
many errors :-)...

Instead I want to get a console. In qemu's  documentation it says :
==
`-nographic'
Normally, QEMU uses SDL to display the VGA output. With this
option, you can totally disable graphical output so that QEMU is a
simple command line application. The emulated serial port is
redirected on the console. Therefore, you can still use QEMU to debug
a Linux kernel with a serial console.
==

So basically what I need is, some how, to tell the freebsd kernel to
forward its output/input to a serial port. In linux this is done by
supplying the parameter console=ttyS0. Is there something equivalent
in FreeBSD ?

Thanks for your help,
Aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


How to send a signal from inside the kernel?

2005-03-17 Thread Aziz KEZZOU
Hi all,
I would like to send a signal (e.g SIGUSR1) to a user process from
inside the kernel (kld module).
Can any one tell me how to do it ?
I tried the following code inspired from sys/kern/kern_sig.c :
==
#include sys/types.h 
#include sys/signal.h

int process_pid;
struct kill_args {
int pid;
int signum;
};

void send_SIGUSR1() {
  struct kill_args uap;
  uap.pid = process_pid;
  uap.signum = SIGUSR1;  
  kill((struct thread *)0, uap);
}
===

but that causes a page fault in kernel mode (ie. Kernel panic :-)

Any help is appreciated, thanks.
Aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How to send a signal from inside the kernel?

2005-03-17 Thread Aziz KEZZOU
 Aziz KEZZOU wrote this message on Thu, Mar 17, 2005 at 12:34 -0500:
  Hi all,
  I would like to send a signal (e.g SIGUSR1) to a user process from
  inside the kernel (kld module).
  Can any one tell me how to do it ?
  I tried the following code inspired from sys/kern/kern_sig.c :
  ==
  #include sys/types.h
  #include sys/signal.h
 
  int process_pid;
  struct kill_args {
int pid;
int signum;
  };
 
  void send_SIGUSR1() {
struct kill_args uap;
uap.pid = process_pid;
uap.signum = SIGUSR1;
kill((struct thread *)0, uap);
  }
  ===
 
  but that causes a page fault in kernel mode (ie. Kernel panic :-)
 
  Any help is appreciated, thanks.
 
 Take a look at psignal(9)...  You'll need to look up the struct proc
 for psignal with pfind(9)...   and then PROC_UNLOCK the struct proc
 after you've used psignal...
 
 so:
 struct proc *p;
 
 p = pfind(pid);
 if (p != NULL) {
 psignal(p, SIGUSR1);
 PROC_UNLOCK(p);
 }
 
 I haven't tried the code above, but that should do what you want...

It works, thanks a lot !!
Here are the headers needed in case someone reads this thread:

#include unistd.h /*needed only for NULL, can be removed*/
#include sys/types.h
#include sys/param.h
#include sys/lock.h
#include sys/mutex.h
#include sys/proc.h 

Have fun,
Aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


generic network protocols parser ?

2005-03-04 Thread Aziz KEZZOU
Hi all,
I am wondering if any one knows  about a generic parser which takes a
packet (mbuf) of a certain protocol (e.g RSVP ) as input and generates
some data structre representing the packet ?

I've been searching for a while and found that ethereal and tcpdump
for example use specific data structres and functions to dissect each
protocol packets. Is this the only approach possible ?

My supervisor suggested using a TLV (Type/Length/Value) approach
instead. Any opinions about that?

If no such a parser exists is there any practical reason why ?

Thanks,
Aziz
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


intercepting RSVP packets with netgraph

2005-02-27 Thread Aziz KEZZOU
Hi all,
I've read every thing I could find about netgraph but I still can not
figure out how to intercept (divert) all IP packets of a certain type
(say RSVP)  and call my own function to process them.

Notice that the processing has to occur at the kernel level.

Any help is appreciated. Thanks in advance.

Aziz Kezzou
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: Sharing data between user space and kernel

2005-02-25 Thread Aziz KEZZOU
sleeping().  What you probably want to do is
actually allocate wired kernel pages and export them
to userspace.  Take a
look at the GEOM gstat(8) implementation, which does
exactly that. 
However, you have to make sure that if you ever
decide to reuse that
kernel memory for something else (i.e., free it back
to the allocator),
you've GC'd all userspace references to it. 


Could you please point me to the place where GEOM
gstat is implemented ? I don't seem to find it :-(

Thanks a lot,
neo 







Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vos mails ! 
Créez votre Yahoo! Mail sur http://fr.mail.yahoo.com/
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]