예제 #1
0
int getNewFullPath(const char *pathname, char **fullpath) {
    char *temp = NULL;
    *fullpath = (char *)kmalloc(PATH_MAX, GFP_KERNEL);
    if (!*fullpath) {
        conivent_printf("getNewFullPath kmalloc error");
        return -1;
    }
    temp = getfullPath(pathname, *fullpath);
    if (temp == NULL) {
        conivent_printf("getNewFullPath kmalloc error");
        return -1;
    }
    return 0;
}
예제 #2
0
int copyStringFromUser(const char *userstring, char **kernelstring) {
    *kernelstring = (char *)kmalloc(PATH_MAX, GFP_KERNEL);
    if (!*kernelstring) {
        conivent_printf("copyStringFromUser kmalloc error");
        return -1;
    }
    getstringfromuser(userstring, *kernelstring);
    return 0;
}
예제 #3
0
// return 0 success others failed
int getNewPathFromFd(unsigned int fd, char **path) {
    *path = (char *)kmalloc(PATH_MAX, GFP_KERNEL);
    
    if (!path) {
        conivent_printf("getNewPathFromFd kmalloc error");
        return -1;
    }
    
    return getPathFromFd(fd, *path);
}
static int lkm_init(void) {
    
    unsigned int orig_cr0;
    printk(KERN_ALERT "lkm_init\n");
    conivent_printf("lkm_init");
    syscall_table = (unsigned int*) get_sys_call_table();
    if(syscall_table == 0)
    {
        printk(KERN_ALERT "can't find syscall_table addr\n");
        return -1;
    }
    origin_mkdir = syscall_table[__NR_mkdir];
    //printk("addr of old_handler %x\n", old_handler);
    orig_cr0 = clear_and_return_cr0();
    syscall_table[__NR_mkdir] = (unsigned long) modified_mkdir;
    setback_cr0(orig_cr0);
    return 0;
}