Find the answer to your Linux question:
Results 1 to 2 of 2
Hello, I've got a problem with getting the inode struct which is in file->dentry struct. One way to get the file struct is : Code: struct file *filep; filep=filp_open(filename, 0, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2004
    Posts
    5

    Kernel hacking - problem with getting the inode of file.


    Hello,
    I've got a problem with getting the inode struct which is in file->dentry struct. One way to get the file struct is :
    Code:
    struct file *filep;
    filep=filp_open(filename, 0, 0);
            if (IS_ERR(filep))
                    return -EIO;
    and when i try to play with file with permission like /bin/su (includeing it)
    -rws--x--x 1 root bin 35780 Jun 21 21:20 /bin/su*
    the i got I/O error.
    How to solve it? Maybe there is other way to get the inode struct in kernel when we know only the name of a file?

  2. #2
    Just Joined!
    Join Date
    Aug 2004
    Posts
    5
    Ok, i solved like (hope it ll be helpful for others)


    Code:
            struct nameidata nd;
            int err=0;
    
            if (path_init([b]filename[/b], LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd))
                    err = path_walk(name, &nd);
            if (!err)
                    printk(KERN_ALERT "Feel free to use nd.dentry->d_inode :)\n");
            path_release(&nd);

Posting Permissions

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