* adding a system call
@ 2011-02-22 15:14 mohit verma
2011-02-22 15:18 ` mohit verma
0 siblings, 1 reply; 9+ messages in thread
From: mohit verma @ 2011-02-22 15:14 UTC (permalink / raw)
To: kernelnewbies
hi all ,
i followed the link and tried to add a system call in kernel-version 2.6.37
here is the code :
#include<linux/linkage.h>
#include<linux/kernel.h>
#include<linux/fs.h> //for getname
#include<linux/err.h> //for PTR_ERR
asmlinkage int sys_hariohm(const char __user *filename)
{
char *tmp = getname(filename);
int fd=PTR_ERR(tmp);
if (!IS_ERR(tmp))
{
printk("filename %s \n",tmp);
putname(tmp);
return fd;
}
else
{
return 2;
}
}
the compilation process was silent (without any error).
but when i try to boot into the kernel having this system call , i get the
errors like :
do_exit() ,do_group_exit() , syscall_init() error lines with some addresses.
can someone help me understand what is wrong with this code?
thanks in advance :)
--
........................
*MOHIT VERMA*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110222/7eff007d/attachment.html
^ permalink raw reply [flat|nested] 9+ messages in thread* adding a system call 2011-02-22 15:14 adding a system call mohit verma @ 2011-02-22 15:18 ` mohit verma 2011-02-22 17:50 ` Mulyadi Santosa 0 siblings, 1 reply; 9+ messages in thread From: mohit verma @ 2011-02-22 15:18 UTC (permalink / raw) To: kernelnewbies hi all , > i followed the link and tried to add a system call in kernel-version 2.6.37 > > here is the code : > > > #include<linux/linkage.h> > #include<linux/kernel.h> > #include<linux/fs.h> //for getname > #include<linux/err.h> //for PTR_ERR > asmlinkage int sys_hariohm(const char __user *filename) > { > char *tmp = getname(filename); > int fd=PTR_ERR(tmp); > if (!IS_ERR(tmp)) > { > printk("filename %s \n",tmp); > putname(tmp); > return fd; > } > else > { > return 2; > } > } > > > the compilation process was silent (without any error). > but when i try to boot into the kernel having this system call , i get the > errors like : > > do_exit() ,do_group_exit() , syscall_init() error lines with some > addresses. > > can someone help me understand what is wrong with this code? > > thanks in advance :) > > and also when i tried to boot into this kernel , it was showing some * initrafs* error. > -- > ........................ > *MOHIT VERMA* > > -- ........................ *MOHIT VERMA* -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110222/59532f0c/attachment.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* adding a system call 2011-02-22 15:18 ` mohit verma @ 2011-02-22 17:50 ` Mulyadi Santosa 2011-02-22 18:01 ` mohit verma 0 siblings, 1 reply; 9+ messages in thread From: Mulyadi Santosa @ 2011-02-22 17:50 UTC (permalink / raw) To: kernelnewbies On Tue, Feb 22, 2011 at 22:18, mohit verma <mohit89mlnc@gmail.com> wrote: > hi all , >> >> i followed the link and tried to add a system call in kernel-version >> 2.6.37 >> here is the code : >> >> >> #include<linux/linkage.h> >> #include<linux/kernel.h> >> #include<linux/fs.h>? //for getname >> #include<linux/err.h> //for PTR_ERR >> asmlinkage int sys_hariohm(const char __user *filename) >> { >> ??? char *tmp = getname(filename); >> ???? int fd=PTR_ERR(tmp); >> ??????? if (!IS_ERR(tmp)) >> ??????? { >> ??????? printk("filename %s \n",tmp); >> ??????? putname(tmp); >> ??????? return fd; >> ??????? } >> ??????? else >> ??????? { >> ??????? return 2; >> ??????? } >> } which syscall number did you assigned to this syscall? and exactly how do you assign it? NB: your code style doesn't follow the Linux kernel coding standart.... -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* adding a system call 2011-02-22 17:50 ` Mulyadi Santosa @ 2011-02-22 18:01 ` mohit verma 2011-02-22 18:10 ` Mulyadi Santosa 0 siblings, 1 reply; 9+ messages in thread From: mohit verma @ 2011-02-22 18:01 UTC (permalink / raw) To: kernelnewbies hi mulyadi, i used syscall number 264 . and for the coding standard , can u tell me where am i off the track ? On Tue, Feb 22, 2011 at 11:20 PM, Mulyadi Santosa <mulyadi.santosa@gmail.com > wrote: > On Tue, Feb 22, 2011 at 22:18, mohit verma <mohit89mlnc@gmail.com> wrote: > > hi all , > >> > >> i followed the link and tried to add a system call in kernel-version > >> 2.6.37 > >> here is the code : > >> > >> > >> #include<linux/linkage.h> > >> #include<linux/kernel.h> > >> #include<linux/fs.h> //for getname > >> #include<linux/err.h> //for PTR_ERR > >> asmlinkage int sys_hariohm(const char __user *filename) > >> { > >> char *tmp = getname(filename); > >> int fd=PTR_ERR(tmp); > >> if (!IS_ERR(tmp)) > >> { > >> printk("filename %s \n",tmp); > >> putname(tmp); > >> return fd; > >> } > >> else > >> { > >> return 2; > >> } > >> } > > which syscall number did you assigned to this syscall? and exactly how > do you assign it? > > NB: your code style doesn't follow the Linux kernel coding standart.... > > -- > regards, > > Mulyadi Santosa > Freelance Linux trainer and consultant > > blog: the-hydra.blogspot.com > training: mulyaditraining.blogspot.com > -- ........................ *MOHIT VERMA* -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110222/193b6a1e/attachment-0001.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* adding a system call 2011-02-22 18:01 ` mohit verma @ 2011-02-22 18:10 ` Mulyadi Santosa 2011-02-22 18:19 ` mohit verma 0 siblings, 1 reply; 9+ messages in thread From: Mulyadi Santosa @ 2011-02-22 18:10 UTC (permalink / raw) To: kernelnewbies On Wed, Feb 23, 2011 at 01:01, mohit verma <mohit89mlnc@gmail.com> wrote: > hi mulyadi, > > i used syscall number 264 . and for the coding standard? , can u tell me > where am i? off the track ? Exactly, how do you add "264" as the syscall number? the diff...I mean... NB: find lindent script for style reformatting... -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* adding a system call 2011-02-22 18:10 ` Mulyadi Santosa @ 2011-02-22 18:19 ` mohit verma 2011-02-22 18:39 ` Mulyadi Santosa 0 siblings, 1 reply; 9+ messages in thread From: mohit verma @ 2011-02-22 18:19 UTC (permalink / raw) To: kernelnewbies mulyadi , i followed the link https://sites.google.com/a/ce-jmi.edu.in/tarique/adding-a-system-call-to-linux-2 . modified files are: 1. /usr/src/kernels/linux-2.6.37/arch/x86/kernel/syscall_table_32.S 2. /usr/src/kernels/linux-2.6.37/include/asm-frv/unistd.h 3. /usr/src/kernels/linux-2.6.37/include/linux/syscalls.h 4. /usr/src/kernels/linux-2.6.37/Makefile and i added: 1. #define __NR_hariohm 264 __SYSCALL(__NR_hariohm, sys_hariohm) in unistd.h file. 2.asmlinkage int sys_hariohm(const char __user *filename); in file syscalls.h 3. .long sys_hariohm /* our system call */ in syscall_table_32.S 4 core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ *hariohm/* in makefile On Tue, Feb 22, 2011 at 11:40 PM, Mulyadi Santosa <mulyadi.santosa@gmail.com > wrote: > On Wed, Feb 23, 2011 at 01:01, mohit verma <mohit89mlnc@gmail.com> wrote: > > hi mulyadi, > > > > i used syscall number 264 . and for the coding standard , can u tell me > > where am i off the track ? > > Exactly, how do you add "264" as the syscall number? the diff...I mean... > > NB: find lindent script for style reformatting... > > -- > regards, > > Mulyadi Santosa > Freelance Linux trainer and consultant > > blog: the-hydra.blogspot.com > training: mulyaditraining.blogspot.com > -- ........................ *MOHIT VERMA* -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110222/9bdb30ff/attachment.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* adding a system call 2011-02-22 18:19 ` mohit verma @ 2011-02-22 18:39 ` Mulyadi Santosa 2011-02-22 18:44 ` mohit verma 0 siblings, 1 reply; 9+ messages in thread From: Mulyadi Santosa @ 2011-02-22 18:39 UTC (permalink / raw) To: kernelnewbies On Wed, Feb 23, 2011 at 01:19, mohit verma <mohit89mlnc@gmail.com> wrote: > and i added: > 1. #define __NR_hariohm 264 > __SYSCALL(__NR_hariohm, sys_hariohm) in unistd.h file. grepping inside unistd.h, I got #undef __NR_syscalls #define __NR_syscalls 264 So, it seems that you violate one rule: you add a syscall but didn't increase the number of total syscalls registered. Am I right or am I right? -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* adding a system call 2011-02-22 18:39 ` Mulyadi Santosa @ 2011-02-22 18:44 ` mohit verma 2011-02-22 21:21 ` Anuz Pratap Singh Tomar 0 siblings, 1 reply; 9+ messages in thread From: mohit verma @ 2011-02-22 18:44 UTC (permalink / raw) To: kernelnewbies ok mulyadi , i got u late what u wanted to see . here are the diff files sorry for delay. On Wed, Feb 23, 2011 at 12:09 AM, Mulyadi Santosa <mulyadi.santosa@gmail.com > wrote: > On Wed, Feb 23, 2011 at 01:19, mohit verma <mohit89mlnc@gmail.com> wrote: > > and i added: > > 1. #define __NR_hariohm 264 > > __SYSCALL(__NR_hariohm, sys_hariohm) in unistd.h file. > > grepping inside unistd.h, I got > > #undef __NR_syscalls > #define __NR_syscalls 264 > > So, it seems that you violate one rule: you add a syscall but didn't > increase the number of total syscalls registered. > > Am I right or am I right? > > -- > regards, > > Mulyadi Santosa > Freelance Linux trainer and consultant > > blog: the-hydra.blogspot.com > training: mulyaditraining.blogspot.com > -- ........................ *MOHIT VERMA* -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110223/51a33a1b/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: my4 Type: application/octet-stream Size: 454 bytes Desc: not available Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110223/51a33a1b/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: my3 Type: application/octet-stream Size: 529 bytes Desc: not available Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110223/51a33a1b/attachment-0001.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: my2 Type: application/octet-stream Size: 517 bytes Desc: not available Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110223/51a33a1b/attachment-0002.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: my1 Type: application/octet-stream Size: 375 bytes Desc: not available Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110223/51a33a1b/attachment-0003.obj ^ permalink raw reply [flat|nested] 9+ messages in thread
* adding a system call 2011-02-22 18:44 ` mohit verma @ 2011-02-22 21:21 ` Anuz Pratap Singh Tomar 0 siblings, 0 replies; 9+ messages in thread From: Anuz Pratap Singh Tomar @ 2011-02-22 21:21 UTC (permalink / raw) To: kernelnewbies On Tue, Feb 22, 2011 at 6:44 PM, mohit verma <mohit89mlnc@gmail.com> wrote: > ok mulyadi , > i got u late what u wanted to see . here are the diff files > sorry for delay. > > There is a good illustration of "how to add syscalls to kernel" y given in Robert Love's book LKD, refer it. when you attach files like these please follow a convention like naming them as mypatch.patch, mypatch.diff or even mypatch.txt. not all mail clients can read these files and may drop them. Please DON'T top post, its annoying. For coding standards please refer for coding style guide by Linus, its inside the Documentation directory inside the kernel source. There are many utilities like patchcheck.pl and indent, which can make your code more readable. -A > > On Wed, Feb 23, 2011 at 12:09 AM, Mulyadi Santosa < > mulyadi.santosa at gmail.com> wrote: > >> On Wed, Feb 23, 2011 at 01:19, mohit verma <mohit89mlnc@gmail.com> wrote: >> > and i added: >> > 1. #define __NR_hariohm 264 >> > __SYSCALL(__NR_hariohm, sys_hariohm) in unistd.h file. >> >> grepping inside unistd.h, I got >> >> #undef __NR_syscalls >> #define __NR_syscalls 264 >> >> So, it seems that you violate one rule: you add a syscall but didn't >> increase the number of total syscalls registered. >> >> Am I right or am I right? >> >> -- >> regards, >> >> Mulyadi Santosa >> Freelance Linux trainer and consultant >> >> blog: the-hydra.blogspot.com >> training: mulyaditraining.blogspot.com >> > > > > -- > ........................ > *MOHIT VERMA* > > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110222/c2278f6a/attachment.html ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-02-22 21:21 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-02-22 15:14 adding a system call mohit verma 2011-02-22 15:18 ` mohit verma 2011-02-22 17:50 ` Mulyadi Santosa 2011-02-22 18:01 ` mohit verma 2011-02-22 18:10 ` Mulyadi Santosa 2011-02-22 18:19 ` mohit verma 2011-02-22 18:39 ` Mulyadi Santosa 2011-02-22 18:44 ` mohit verma 2011-02-22 21:21 ` Anuz Pratap Singh Tomar
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).