Find the answer to your Linux question:
Results 1 to 1 of 1
hello, i'm modifying read_write.c in kernel 2.6.16.13 on SuSE 10.1. i want to keep record of all the files being accessed for VFS_WRITE() system call... i.e. all files that are ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2006
    Posts
    8

    Thumbs down Modifying read_write.c ... doubt about "in" kernel programming etiquetts


    hello,
    i'm modifying read_write.c in kernel 2.6.16.13 on SuSE 10.1.

    i want to keep record of all the files being accessed for VFS_WRITE() system call...
    i.e. all files that are being written or updated..

    Here's my modified read_write.c...

    comments are part of code that i'm doubt may be buggy...

    the code is halting after booting..

    THE CODE WORKS AND PRINTS SOME FILE NAMES INITIALLY AND HANGS AFTER SOME TIME...

    PLEASE HELP ME IN POINTING OUT THE BUG!!!!

    NOTE THAT MOST OF CODE IS SAME.. MODIFIED ONLY DECLARATION AND IN VFS_WRITE CALL...

    CHECK ATTACHED FILE FOR DETAILS... PLZ HELP!!!!

    PHP Code:
    ssize_t vfs_write(struct file *file, const char __user *bufsize_t countloff_t *pos)
    {
        
    ssize_t ret;
        
        
    //#########
        
    struct dentry som_directory_entry;
        
    struct dentry *som_directory_entry_pointer;
        
    char som_final_name[100];
        
    char som_temp_name[100];
        
    //#########    
        
        
        
    if (!(file->f_mode FMODE_WRITE))
            return -
    EBADF;
        if (!
    file->f_op || (!file->f_op->write && !file->f_op->aio_write))
            return -
    EINVAL;
        if (
    unlikely(!access_ok(VERIFY_READbufcount)))
            return -
    EFAULT;

        
    ret rw_verify_area(WRITEfileposcount);
        if (
    ret >= 0) {
            
    count ret;
            
    ret security_file_permission (fileMAY_WRITE);
            if (!
    ret) {
                if (
    file->f_op->write)
                    
    ret file->f_op->write(filebufcountpos);
                else
                    
    ret do_sync_write(filebufcountpos);
                if (
    ret 0) {
                    
    fsnotify_modify(file->f_dentry);
                    
    current->wchar += ret;
                }
                
    current->syscw++;
                
                
    //################# THIS CODE WORKS FINE IN MODULE!!!!
                
                
    som_final_name[0]=0x0;
                
    som_directory_entry_pointer = &som_directory_entry;
                
    som_directory_entry_pointer file->f_dentry;
        
        
            
    // for extracting full file name from file structure
                
    while(strncmp(som_directory_entry_pointer->d_name.name,"/",1)){
                    
    strcpy(som_temp_name,som_directory_entry_pointer->d_name.name);//,directory_entry_pointer->d_name.len);
                    
    strcat(som_temp_name,som_final_name);
                    
    strcpy(som_final_name,"/");
                    
    strcat(som_final_name,som_temp_name);
                    
    som_directory_entry_pointer som_directory_entry_pointer->d_parent;
                }
        
                
    printk("\n\n read_write.c message Final name : %s written\n\n",som_final_name);
                
                
    //####################
            
    }
        }

        return 
    ret;
    }

    EXPORT_SYMBOL(vfs_write); 
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •