[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: task_struct and it's fields
Thanks for the reply.
The code is as follows:
void printFileName( struct task_struct *taskP ,int k)
{
int j =0;
struct dentry *dentP = NULL;
struct file *fileP = NULL;
struct files_struct *file_struct = NULL ;
file_struct = taskP->files;
if ( file_struct )
{
if ( file_struct->fd_array )
{
fileP = file_struct->fd_array;
for ( j =0; j < NR_OPEN_DEFAULT; j++ )
{
if ( fileP++ )
{
printk("owner = [%d]\n",fileP->f_uid);
^^^^^^^^^^^
<offending variable.>
}
}
I thought that, even if there's no files associated with this task
then atleast the associated member of task_struct would be initialised
to zero or NULL.Is my assumption correct?
My basic aim is to find out the process name and it;s inode # and file
name, by traversing thru task_struct's.When i went thru the task_struct
and it's members, no where i could find the info, which can tell me,
how this task came into existence. I mean, if there is a task, then
there should be a corresponding file on disk and a corresponding inode,
whence this file is loaded into memory.I am looking for this info.
Help me out in figuring this.
Thanks
Venkat
-----Original Message-----
From: Greg KH [mailto:greg@wirex.com]
Sent: Friday, March 09, 2001 4:51 PM
To: Narayana, Venkat A.
Cc: 'kernelnewbies@nl.linux.org'
Subject: Re: task_struct and it's fields
On Fri, Mar 09, 2001 at 04:32:06PM -0600, Narayana, Venkat A. wrote:
> Hi
> I am trying to write a small kernel module, which will walk thru the task
> list, i.e starting from
> init_task, and try to figure out the associated file for that task.
> While doing that, whati noticed is that the 'struct files_struct *files'
> member, would not
> allow me access it's members, i.e whenever i access them i get
segmentation
> fault.
> I am not sure what wrong i am doing.
Are you checking that the *files variable is not NULL before trying to
walk the list? Not all processes have files associated with them (I
think.)
Example code of what you are trying to do would be more helpful to try
to determine your problem.
hope this helps,
greg k-h
--
greg@(kroah|wirex).com
http://immunix.org/~greg
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.surriel.com/kernelnewbies.shtml
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.surriel.com/kernelnewbies.shtml