1

I am trying to follow how Linux deals with EXT3 files. I am looking at fs/ext3/file.c where there are file operations that deal with the files are present:

const struct file_operations ext3_file_operations = {
    .llseek         = generic_file_llseek,
    .read           = do_sync_read,
    .write          = do_sync_write,
    .aio_read       = generic_file_aio_read,
    .aio_write      = generic_file_aio_write,
    .unlocked_ioctl = ext3_ioctl,
#ifdef CONFIG_COMPAT
    .compat_ioctl   = ext3_compat_ioctl,
#endif
    .mmap           = generic_file_mmap,
    .open           = dquot_file_open,
    .release        = ext3_release_file,
    .fsync          = ext3_sync_file,
    .splice_read    = generic_file_splice_read,
    .splice_write   = generic_file_splice_write,
};

How can I find when does .open is replaced by the function "dquot_file_open" for example? Should I follow the system call defined in fs/open.c:

SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)

Or should I be looking at other functions?

I am working on Linux 3.7.6 for User-Mode-Linux

hkassir72
  • 135
  • 10

1 Answers1

2

The Linux kernel is organized in an OOP manner (though written in C). The struct file_operations is really a class, the members (function pointers) are the function members ("methods" for Java heads) of the class. The code you quote serves to set up the ext3 object by filling in the function pointers. This is done at compile/link time.

The open(2) system call calls this indirectly, by finding out the struct file_operations relevant for the file system at hand, and calling its open member.

I'd suggest you take a look at the kernelnewbies page for an overall view and more detailed help.

vonbrand
  • 11,412
  • 8
  • 32
  • 52
  • Yes I know this information. My question is where does the open function interact with the "file_operations" of EXT3? – hkassir72 May 08 '13 at 13:43