3

In the EXT2 file.c the open file operation (.open) is being pointed to dquot_file_open which furthur points to generic_file_open which is present in fs/open.c.

The generic_file_open looks like it just has the below code

int generic_file_open(struct inode * inode, struct file * filp)
{
    if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
        return -EOVERFLOW;
    return 0;
}

Where are the ACL permissions being checked when a file is about to be opened?

When is I googled and went through the code using LXR I found the below path.

do_sys_open -> do_filp_open -> path_openat -> do_last -> may_open -> inode_permission -> do_inode_permission -> generic_permission -> acl_permission_check -> check_acl -> posix_acl_permission

but I could not understand how the .open of EXT2 is linked to do_sys_open.

Any help in letting me know the path to checking the acl permissions during a file open would be greatly appreciated.

rookie_developer
  • 1,359
  • 3
  • 15
  • 27

2 Answers2

2

You're looking at it from the wrong end: names like do_sys_open are system call entry points, and will ultimately go through the VFS layer to find the ext2 open routine after validating permissions.

geekosaur
  • 59,309
  • 11
  • 123
  • 114
  • thanks a lot @geeosaur .. I was under the impression that ext2 `open` routine would be called as soon as the open system call is called. your post was of great help .. I understood that initially `do_sys_open` would be called and ext2 `open` will be called after calling a chain of routines from `do_sys_open` – rookie_developer Apr 26 '12 at 02:20
1

I think you got sidetracked by the ACL code; once the permission has been granted, follow nameidata_to_filp to __dentry_open:

Within __dentry_open():

    f->f_op = fops_get(inode->i_fop);
    /* ... */
    if (!open && f->f_op)
            open = f->f_op->open;
    if (open) {
            error = open(inode, f);
            if (error)
                    goto cleanup_all;
    }

This saves the inode->i_fop->open function pointer to the autovariable open, then proceeds to call it on the inode and f.

sarnold
  • 102,305
  • 22
  • 181
  • 238
  • thanks for the reply @sarnold .. Yeah I was a bit off track since my aim was to find where the permission checking is done .. It was also important for me to note that the function `nameidata_to_filp` is called from `do_last` after the permission checking is done. ext2 `open` is called from `__dentry_open()`. Thanks a lot for the information. – rookie_developer Apr 26 '12 at 02:27