./jiff.o: unresolved symbol sys_call_table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi
 
   This is my source code. On loading the module its giving the error
 
       
  ./jiff.o: unresolved symbol sys_call_table
 
 
 
  The source code is
 
  
  /*mple of simple character device driver (jiff)
 */
 
#include <linux/module.h>
 
#if defined(CONFIG_SMP)
#define __SMP__
#endif
 
#if defined(CONFIG_MODVERSIONS)
#define MODVERSIONS
#include <linux/modversions.h>
#endif
 
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/fs.h>           /* file modes and device registration */
#include <linux/proc_fs.h>
#include <linux/poll.h>
#include "jiff.h"
#include <sys/syscall.h>
#include <asm/uaccess.h>
 
#include <asm/uaccess.h>
 
/*The system call table. */
extern void *sys_call_table[];
 
/*Storing the original pointer for the system call*/
asmlinkage int (*original_call)(const char *, int,int);
 
/*Our system call for open which is going to replace the original call*/
 
asmlinkage int deba_sys_open(const char *filename,int flags,int mode)
{
        printk("This is my open function ");
        printk("if you want to do some verification then do it here");
        printk("now the original function call is going to be called");
        return original_call(filename,flags,mode);
}
/* forward declarations for _fops */
static ssize_t jiff_read(struct file *file, char *buf, size_t count, loff_t *offset);
static int jiff_open(struct inode *inode, struct file *file);
static int jiff_release(struct inode *inode, struct file *file);
 
static int jiff_release(struct inode *inode, struct file *file);
 
static struct file_operations jiff_fops = {
        read:           jiff_read,
        open:           jiff_open,
        release:        jiff_release,
};
 
/* data */
static char *jiff_buffer;
 

/*Setable parameter*/
static char jiff_debug=1;
static char *jiff_name=NULL;
 
/* This keeps us from having the "taint" flag */
/* Besides, the GPL is a good thing */
MODULE_LICENSE("GPL");
 

static ssize_t jiff_read(struct file *file, char *buf, size_t count,
                          lstatic ssize_t jiff_read(struct file *file, char *buf, size_t count,
                          loff_t *offset)
{
 

        count=snprintf(jiff_buffer, 32, "%ld\n", jiffies);
 
        /* copy the data the our buffer */
 
        if (copy_to_user(buf,jiff_buffer,count))
                return -EFAULT;
 
        /* return data written */
        return count;
}
 

static int jiff_open(struct inode *inode, struct file *file)
{
        /* increment usage count */
        MOD_INC_USE_
        if (file->f_mode & FMODE_READ) {
                MSG("opened for reading\n");
        } else if (file->f_mode & FMODE_WRITE) {
                MSG("opened for writing \n");
        }
 
        MSG("major: %d minor: %d\n", MAJOR(inode->i_rdev), MINOR(inode->i_rdev));
        return 0;
}
 
static int jiff_release(struct inode *inode, struct file *file)
{
        MOD_DEC_USE_COUNT;
        MSG("jiff_release\n");
        return 0;
}
 

int init_module(void)
{
        int res;
COUNT;{
        int res;
        struct page *page;
 
        if (jiff_name == NULL)
                jiff_name = "jiff";
 
        /* get a free page */
        jiff_buffer = (char *) __get_free_page(GFP_KERNEL);
 
        if (jiff_buffer == NULL)
                return -ENOMEM;
 
        page = virt_to_page(jiff_buffer);
 
        /* register device with kernel */
        original_call=sys_call_table[ __NR_open ];
        sys_call_table[ __NR_open ]=deba_sys_open;
 

        res = register_chrdev(JIFF_MAJOR, jiff_name, &jiff_fops);
        if (res) {
                MSG("can't r        if (res) {
                MSG("can't register device with kernel\n");
                return res;
        }
 

        /* all done */
        MSG("module loaded\n");
        return 0;
}
 
void cleanup_module(void)
{
        struct page *page;
 
        /* unregister device and proc entry */
        unregister_chrdev(JIFF_MAJOR, "jiff");
        if(sys_call_table[ __NR_open ]!=deba_sys_open){
                printk("Someone might have made another function name");
                printk("We are replacing the original function call");
        }
        sys_call_table[ __NR_open ]=original_call;
        MSG("unloaded\n");
        return;
}
        /* unreserve page and free it */
        page = virt_to_page(jiff_buffer);
        free_page((unsigned long) jiff_buffer);
        if(sys_call_table[ __NR_open ]!=deba_sys_open){
                printk("Someone might have made another function name");
egister device with kernel\n");

 
 
 
        if (file->f_mode & FMODE_READ) {
off_t *offset)

 

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux