* RE: find_task_by_pid() problem
@ 2010-08-10 3:32 Namhyung Kim
2010-08-10 8:39 ` Pistis Valentino
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2010-08-10 3:32 UTC (permalink / raw)
To: Pistis Valentino; +Cc: linux-kernel
> I'm using the routine find_task_by_vpid () linux / sched.h (the oldest
> find_task_by_pid() don't exist), but when I try to compile the file I
> hello_world.c returns an error:
You can only use kernel's EXPORTed symbol, ie. EXPORT_SYMBOL*(), when you
write a module program because kernel links it on its own way.
Try this instead.
pid_task(find_vpid(...), PIDTYPE_PID)
--
Regards,
Namhyung Kim
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: find_task_by_pid() problem
2010-08-10 3:32 find_task_by_pid() problem Namhyung Kim
@ 2010-08-10 8:39 ` Pistis Valentino
0 siblings, 0 replies; 3+ messages in thread
From: Pistis Valentino @ 2010-08-10 8:39 UTC (permalink / raw)
To: Namhyung Kim; +Cc: linux-kernel
2010/8/10 Namhyung Kim <namhyung@gmail.com>:
>> I'm using the routine find_task_by_vpid () linux / sched.h (the oldest
>> find_task_by_pid() don't exist), but when I try to compile the file I
>> hello_world.c returns an error:
>
> You can only use kernel's EXPORTed symbol, ie. EXPORT_SYMBOL*(), when you
> write a module program because kernel links it on its own way.
> Try this instead.
>
> pid_task(find_vpid(...), PIDTYPE_PID)
>
Great!
It works!
pid_task(find_vpid(pid), PIDTYPE_PID);
> --
> Regards,
> Namhyung Kim
>
>
>
Thank you!
Ciao
Valentino from Sardegna!
^ permalink raw reply [flat|nested] 3+ messages in thread
* find_task_by_pid() problem
@ 2010-08-10 1:14 Pistis Valentino
0 siblings, 0 replies; 3+ messages in thread
From: Pistis Valentino @ 2010-08-10 1:14 UTC (permalink / raw)
To: linux-kernel
Hello everyone,
first of all, thank you all for your work on the Linux kernel.
I am not very practical programming kernel, I admit, but studying how
to build a kernel module I found a possible problem.
I'm using the routine find_task_by_vpid () linux / sched.h (the oldest
find_task_by_pid() don't exist), but when I try to compile the file I
hello_world.c returns an error:
foo@siduxbox: ~ / LPSO / modules / hello_world $ make
make-C / usr/src/linux-2.6.34.2 subdirs = / home / foo / LPSO /
modules / modules hello_world
make [1]: Entering directory `/ usr/src/linux-2.6.34.2 '
Building modules, stage 2.
MODPOST 1 modules
WARNING: "find_task_by_vpid [/
home/foo/LPSO/modules/hello_world/hello_world_6.ko] undefined!
make [1]: Leaving directory `/ usr/src/linux-2.6.34.2 '
foo@siduxbox: ~ / LPSO / modules / $ hello_world
My surprise is why the function is undefined if it is present in sched.h?
In any case, the function is not defined in sched.c, but directly to
the file pid.c.
Given that pid.h not present the prototype of the function in question.
I'm using Debian Sidux with Linux 2.6.34.2 compiled.
I just can not understand why give me this problem .
I tried to use kernel 2.6.20 for using the old "DEFINE
find_task_by_pid" , but I have problems compiling the kernel and can
not use them.
You could at least tell me if this is a bug or am I not use good routines.
Thank you all
================
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/pid.h>
MODULE_LICENSE ("Dual BSD/GPL");
//static int num=1;
//static char *string="Ciao";
static int p=0;
/*struct task_struct *find_task(pid_t pid)
{
struct task_struct *task = current;
do
{ if(task->pid == pid)
return(task);
task = task->next_task;
}
while(task != current);
return(NULL);
}
*/
static int hello_init (void)
{
printk(KERN_ALERT "*********** INIT **********\n");
printk(KERN_ALERT "Hello, world\n");
pid_t pid = p;
struct task_struct *task, *parent;
task=current;
parent=find_task_by_vpid(pid);
printk(KERN_ALERT "Some info from some Process\n");
//Always initialize the task_struct
printk("\nThe current task is: %s [%d]\n",task->comm , task->pid);
printk("\nThe parent task is: %s [%d]\n",parent->comm , parent->pid);
printk("\nThe credential of current task is:\n Priority = %d\n
euid = %d\n egid = %d\n",task->prio , task->real_cred->euid,
task->real_cred->egid);
printk("\nThe credential of parent task is:\n Priority = %d\n euid
= %d\n egid = %d\n",parent->prio , parent->real_cred->euid,
parent->real_cred->egid);
return 0;
}
static void hello_exit (void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
printk(KERN_ALERT "*********** EXIT **********\n");
}
module_init(hello_init);
module_exit(hello_exit);
//module_param(num, int, S_IRUGO);
//module_param(string, charp, S_IRUGO);
module_param(p, int, S_IRUGO);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-10 8:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-10 3:32 find_task_by_pid() problem Namhyung Kim
2010-08-10 8:39 ` Pistis Valentino
-- strict thread matches above, loose matches on Subject: below --
2010-08-10 1:14 Pistis Valentino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox