Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7615013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:32:59+00:00 2026-05-31T02:32:59+00:00

I am following the open() system call to find out when the struct file_operations

  • 0

I am following the open() system call to find out when the struct file_operations and struct file get connected during a creation of file.

The main path is as follows:

sys_open -> do_sys_open -> do_filp_open -> nameidata_to_filp -> __dentry_open

In __dentry_open

 static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
                                     int flags, struct file *f,
                                     int (*open)(struct inode *, struct file *),
                                     const struct cred *cred)
{
    struct inode *inode;
    int error;

    f->f_flags = flags;
    f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK |
                            FMODE_PREAD | FMODE_PWRITE;
    inode = dentry->d_inode;
    if (f->f_mode & FMODE_WRITE) {
            error = __get_file_write_access(inode, mnt);
            if (error)
                    goto cleanup_file;
            if (!special_file(inode->i_mode))
                    file_take_write(f);
    }

    f->f_mapping = inode->i_mapping;
    f->f_path.dentry = dentry;
    f->f_path.mnt = mnt;
    f->f_pos = 0;
    f->f_op = fops_get(inode->i_fop);//I think it is here that they get connected
    file_move(f, &inode->i_sb->s_files);

    error = security_dentry_open(f);

    ...

But when and in which function that the i_fop in inode gets initialized?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:33:01+00:00Added an answer on May 31, 2026 at 2:33 am

    Have you seen this and this:

    The open(2) system call is implemented in fs/open.c:sys_open function
    and the real work is done by fs/open.c:filp_open() function, which is
    split into two parts:

    open_namei(): fills in the nameidata structure containing the dentry
    and vfsmount structures. dentry_open(): given a dentry and vfsmount,
    this function allocates a new struct file and links them together; it
    also invokes the filesystem specific f_op->open() method which was set
    in inode->i_fop when inode was read in open_namei() (which provided
    inode via dentry->d_inode).

    It is actually set at path_walk function (if file exists):

    path_walk(const char *name, struct nameidata *nd) {
    /* ... */
                   /* if . or .. then special, otherwise: */
                    dentry = cached_lookup(nd->dentry, &this);
    /* ... */ 
                    if (!dentry)
                     dentry = real_lookup(nd->dentry, &this);
    

    dentry contains the inode information in its d_inode member. So the initialization inode is in open_namei function (or somewhere down there), before the dentry_open. Just track the dentry structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file with the following structure: system.action.webMessage=An error has happened during web
My unit test keeps getting the following error: System.InvalidOperationException: The Connection is not open.
Consider the following: with open(path, mode) as f: return [line for line in f
I'm trying to find the appropriate place to store a system path in PostgreSQL.
I am getting a crash with following values :- Poll is the system call
To visualize data from F# interactive console, I can do the following: open System.Windows.Forms
I've tried the following code in VS2010: open System.Security.Cryptography let rsaTest1 = let ecKey
I have the following lines of code: xslt.Load(XmlReader.Create(new FileStream(@C:\website\TransList.xslt, System.IO.FileMode.Open))); xslt.Transform(mydoc.CreateReader(),null, sw); It works
When using os.system to open a file, eg: os.system(r'C:/foo.txt') , the current Python process,
Using ASP.net, what methods can I use to do the following: Open up a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.