mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* accessing the struct task_struct using a pid
@ 2002-06-15 21:06 Amit Nadgar
  2002-06-15 21:13 ` William Lee Irwin III
  0 siblings, 1 reply; 2+ messages in thread
From: Amit Nadgar @ 2002-06-15 21:06 UTC (permalink / raw)
  To: linux-kernel

guys,
   I am writing a kernel module where I am trying to
access the task_structs. Now I have tried this using
various mathods.
   1) Using the pidhash array.
      Here when I do a insmod I get a unresolved
symbol.
   2) Directly accessing the location of pidhash as
seen in System.map.
      Here when the pidhash_fn hashes the supplied pid
the particular location into which it indexes in NULL.
  3) Starting from the init_task.
     here the next task after the init task is found
to be NULL.

Could some one help me in this matter.
   -vangough

Following is the piece of code which executes when an
apploication program does a sys_ptrace. 

int new_syscall(long request,long pid,long addr,long
data)
  struct task_struct *my_init_task = (struct
task_struct *)&init_task; 
  struct task_struct *task_ptr;
  if(my_init_task)
  {
	task_ptr = my_init_task;
	while(task_ptr && (task_ptr->next_task !=
my_init_task))
        {
  		printk("<1> task_ptr pointer is %x\n",task_ptr);
  		printk("<1> task_ptr->pid is %d\n",task_ptr->pid);
		printk("<1> task_ptr->next_task is
%x",task_ptr->next_task);	
		task_ptr = (struct task_struct*)task_ptr->next_task;
	}
  }
  else 
  {
	printk("<1> my_init_task pointer is
%d\n",my_init_task);
	return 0;
  }
 
_memcpy(sys_call_table[SYS_PTRACE_NUMBER],syscall_code,
				sizeof(syscall_code));
  
/*  ((long int (*)
(long,long,long,long))sys_call_table[SYS_PTRACE_NUMBER])(request,pid,addr,data);*/
}


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: accessing the struct task_struct using a pid
  2002-06-15 21:06 accessing the struct task_struct using a pid Amit Nadgar
@ 2002-06-15 21:13 ` William Lee Irwin III
  0 siblings, 0 replies; 2+ messages in thread
From: William Lee Irwin III @ 2002-06-15 21:13 UTC (permalink / raw)
  To: Amit Nadgar; +Cc: linux-kernel

On Sat, Jun 15, 2002 at 02:06:20PM -0700, Amit Nadgar wrote:
>    I am writing a kernel module where I am trying to
> access the task_structs. Now I have tried this using
> various mathods.
>    1) Using the pidhash array.
>       Here when I do a insmod I get a unresolved symbol.

EXPORT_SYMBOL(pidhash) or something. Make sure you included sched.h

On Sat, Jun 15, 2002 at 02:06:20PM -0700, Amit Nadgar wrote:
>    2) Directly accessing the location of pidhash as seen in System.map.
>       Here when the pidhash_fn hashes the supplied pid the particular
>	location into which it indexes in NULL.

How early are you trying to do this?

On Sat, Jun 15, 2002 at 02:06:20PM -0700, Amit Nadgar wrote:
>   3) Starting from the init_task.
>      here the next task after the init task is found to be NULL.

Don't do that.

On Sat, Jun 15, 2002 at 02:06:20PM -0700, Amit Nadgar wrote:
>	Could some one help me in this matter.

I'm afraid there's only so much help that can be given. Some effort may
be required on your part to make this work. Help with basic concepts
and Linux conventions is more likely to be found on irc.openprojects.net
#kernelnewbies or the kernelnewbies@nl.linux.org mailing list.


Cheers,
Bill

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-06-15 21:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-15 21:06 accessing the struct task_struct using a pid Amit Nadgar
2002-06-15 21:13 ` William Lee Irwin III

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®