From: rgonzale@darkterminal.net (rgonzale at darkterminal.net)
To: kernelnewbies@lists.kernelnewbies.org
Subject: creating own syscall on 2.6.37.3 and getting error on compilaton...
Date: Sun, 21 Oct 2012 15:28:51 -0500 [thread overview]
Message-ID: <20121021202851.GA15762@darkstar.darkterminal.net> (raw)
I'm trying to implement my own system call on Linux kernel 2.6.37.3 using this guide.
http://enzam.wordpress.com/2011/03/2...nel-ubuntu-os/
Here's the code that I have for kernel/mysystemcalls.c
It just takes an int for an argument and then spits out the PIDs for the process that is running on that CPU.
Code:
#include<linux/linkage.h>
#include<linux/cpumask.h>
asmlinkage long sys_current_pid(int i) {
struct rq *rq;
int num_cpu;
num_cpu = num_online_cpus();
if(i <= 0 || i > num_cpu)
return -1;
rq = cpu_rq(i);
if(rq->curr != NULL)
return rq->curr->pid;
else
return -1;
}
But on kernel compilation I get this.
Code:
kernel/mysystemcalls.c: In function 'sys_current_pid':
kernel/mysystemcalls.c:12: error: implicit declaration of function 'cpu_rq'
kernel/mysystemcalls.c:12: warning: assignment makes pointer from integer without a cast
kernel/mysystemcalls.c:13: error: dereferencing pointer to incomplete type
kernel/mysystemcalls.c:14: error: dereferencing pointer to incomplete type
make[1]: *** [kernel/mysystemcalls.o] Error 1
make[1]: *** Waiting for unfinished jobs....
The definition for cpu_rq() is in kernel/sched.c.
Here's the pertinent piece of Makefile in kernel/Makefile
Code:
#
# Makefile for the linux kernel.
#
obj-y = sched.o fork.o exec_domain.o panic.o printk.o \
cpu.o exit.o itimer.o time.o softirq.o resource.o \
sysctl.o sysctl_binary.o capability.o ptrace.o timer.o user.o \
signal.o sys.o kmod.o workqueue.o pid.o \
rcupdate.o extable.o params.o posix-timers.o \
kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
notifier.o ksysfs.o pm_qos_params.o sched_clock.o cred.o \
async.o range.o jump_label.o
obj-y += mysystemcalls.o
I would think that since sched.o(the first c file that gets compiled) has the definition for the cpu_rq() then mysystemcalls.c should be able to see that function. What am I missing?
-Tristan
next reply other threads:[~2012-10-21 20:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-21 20:28 rgonzale at darkterminal.net [this message]
[not found] ` <CAPbg-_5YTVBhWmGrog22dF7Cx=rWEk_+zGtRNtSgTHJyNhL+0A@mail.gmail.com>
2012-10-21 22:15 ` Fwd: creating own syscall on 2.6.37.3 and getting error on compilaton Filipe Rinaldi
[not found] ` <20121022001000.GC15840@darkstar.darkterminal.net>
2012-10-22 11:00 ` Filipe Rinaldi
[not found] ` <8040E2F5-7D5C-413C-9A15-7A2CFE15BCD8@darkterminal.net>
[not found] ` <CAPbg-_70sTgwovmgKw17dVP6yLvwgNLeapiVt=54Tzb0ZLz7-Q@mail.gmail.com>
2012-10-23 8:50 ` Fwd: " Filipe Rinaldi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121021202851.GA15762@darkstar.darkterminal.net \
--to=rgonzale@darkterminal.net \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).