İs it possible now to use a system call in module programming ? after I "make" the module below I am getting warnings like that no errors

WARNING: "sys_getcwd" [/home....mod/mod01/mod01.ko] undefined!

/*
 *  hello-5.c - Demonstrates command line argument passing to a module.
 */
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/stat.h>
#include <asm/unistd.h>
#include <asm/uaccess.h>


#include <linux/syscalls.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/fsnotify.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/hash.h>
#include <linux/cache.h>
#include <linux/module.h>
#include <linux/mount.h>
#include <linux/file.h>
#include <asm/uaccess.h>
#include <linux/security.h>
#include <linux/seqlock.h>
#include <linux/swap.h>
#include <linux/bootmem.h>
#include <linux/fs_struct.h>


MODULE_LICENSE("GPL");
MODULE_AUTHOR("Peter Jay Salzman");



char buf[1000];

static int __init hello_5_init(void)
{
        
	sys_getcwd(buf,1000);
	
        printk("%s,%d\n",buf,sizeof(buf));
}

static void __exit hello_5_exit(void)
{
        printk(KERN_INFO "Goodbye, world 5\n");
}

module_init(hello_5_init);
module_exit(hello_5_exit);

and I can't insmod the module sure. maybe using system_calls in kernel 2.6.x is forbidden

Hi Friend ,

Yes it is possible to use system call from the linux modules . But there is a limit on what system calls can be used . sys_open () can be used however sys_mknod can't be used . Check kallsyms in the proc filesystem to get the list of exported symbols . One more important point to note here is , the sys_function will expect the parameters to from the user space but the buf belongs to the kernel space . So you have the extend the user space upto the kernel space so that buf will belong to the userspace . This can be done by setfs(getds())

Hi Friend ,

Yes it is possible to use system call from the linux modules . But there is a limit on what system calls can be used . sys_open () can be used however sys_mknod can't be used . Check kallsyms in the proc filesystem to get the list of exported symbols . One more important point to note here is , the sys_function will expect the parameters to from the user space but the buf belongs to the kernel space . So you have the extend the user space upto the kernel space so that buf will belong to the userspace . This can be done by setfs(getds())

Thx for reply, friend.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.