Re: passing array from kernel space to user space

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've thinked  solution like this (similar to the one
taha has suggested):

static ssize_t read(struct file *file, char __user
*buf, size_t count,
loff_t *pos){
   int element_size =  sizeof(char)/ sizeof(pid_t) /*
To get the
array size for pids*/
   int char_array_size = count / element_size;
   char *char_array = (char*) pid_array;

   /* .... This is your array ... fill what ever you
want to fill in  
*/
}


but I've a doubt. 
the array i had to pass to the user space is a array
of string, therefore of char pointers. So the solution
i've wrote above is sufficient?

thanks.
Vincenzo MAllozzi
--- taha hafeez <tawushafeez@xxxxxxxxx> ha scritto: 

> On Mon, 2006-04-03 at 00:26 +0200, Vincenzo Mallozzi
> wrote:
> > --- taha siddiqi <tawushafeez@xxxxxxxxx> wrote:
> > 
> > > Hi
> > > 
> > > Same answer, "please explain the situation !!"
> > > 
> > > taha
> > > 
> > > Thanks.
> > 
> > The array I want to pass from kernel space to user
> > space contains pid_t elements.
> > First, I pass the length of the array from user
> space
> > to kernel space.
> > Then, I build the array with the given length
> filling
> > it with the pid of processes I need to monitor.
> > Finally, I've to pass this array of pids to the
> user
> > space.
> > I hope I've well explained the situation.
> > Thanks all.
> > Vincenzo Mallozzi.
> > 
> 
> Well, I think I get you now....
> 
> Correct me if I am wrong... 
> 
> 
>             data buffer
> USER_SPACE ------------>  KERNEL SPACE [fill data
> with pid_t]
>       ^                       |
>       |                       | 
>       *------<----------------*
>             data buffer
> 
> Why do we need to pass the data buffer to kernel ? 
> Does it contain any information that kernel needs ?
> if not, then that step can be avoided ?
> 
> Then you just need a read call implementation of 
> struct file_operations {}.
> 
> taha
> 
> 
> 
> 



	

	
		
___________________________________ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux