Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Kernel hacking - problem with getting the inode of file.

    I've got a problem with getting the inode struct which is in file->dentry struct. One way to get the file struct is :
    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
    Ok, i solved like (hope it ll be helpful for others)

            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");

Posting Permissions

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