Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\open.c Create Date:2022-07-28 20:00:57
Last Modify:2020-03-18 10:16:03 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:do_dentry_open

Proto:static int do_dentry_open(struct file *f, struct inode *inode, int (*open)(struct inode *, struct file *))

Type:int

Parameter:

TypeParameterName
struct file *f
struct inode *inode
int (*open
740  static const struct file_operations empty_fops = {}
743  path_get( & f_path)
744  cached value = inode
745  f_mapping = i_mapping
748  f_wb_err = lemap_sample_wb_err - sample the current errseq_t to test for later errors*@mapping: mapping to be sampled* Writeback errors are always reported relative to a particular sample point* in the past. This function provides those sample points.
750  If Value for the false possibility is greater at compile time(f_flags & O_PATH) Then
751  f_mode = File is opened with O_PATH; almost nothing can be done with it | FMODE_OPENED
752  f_op = empty_fops
753  Return 0
757  If Value for the false possibility is greater at compile time(f_flags & File is opened for execution with sys_execve / sys_uselib && !S_ISREG(i_mode)) Then
758  error = -EACCES
759  Go to cleanup_file
762  If f_mode & le is open for writing && Not special_file(i_mode) Then
763  error = gets write permission for a file
764  If Value for the false possibility is greater at compile time(error) Then Go to cleanup_file
766  error = __mnt_want_write(mnt)
769  Go to cleanup_file
771  f_mode |= Write access to underlying fs
775  If S_ISREG(i_mode) || S_ISDIR(i_mode) Then f_mode |= File needs atomic accesses to f_pos
778  f_op = Alas, no aliases. Too much hassle with bringing module.h everywhere (rmer ->i_op->default_file_ops )
779  If WARN_ON(!f_op) Then
780  error = -ENODEV
781  Go to cleanup_all
784  error = security_file_open(f)
785  If error Then Go to cleanup_all
788  error = break_lease(locks_inode(f), f_flags)
789  If error Then Go to cleanup_all
793  f_mode |= le is seekable | le can be accessed using pread | le can be accessed using pwrite
794  If Not open Then open = open
796  If open Then
797  error = open(inode, f)
798  If error Then Go to cleanup_all
801  f_mode |= FMODE_OPENED
802  If (f_mode & (le is open for reading | le is open for writing )) == le is open for reading Then i_readcount_inc(inode)
804  If f_mode & le is open for reading && Value is more likely to compile time(read || read_iter) Then f_mode |= Has read method(s)
807  If f_mode & le is open for writing && Value is more likely to compile time(write || write_iter) Then f_mode |= Has write method(s)
811  f_write_hint = WRITE_LIFE_NOT_SET
812  f_flags &= ~( O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC)
814  Initialise a struct file's readahead state. Assumes that the caller has* memset *ra to zero.
817  If f_flags & O_DIRECT Then
818  If Not a_ops || Not direct_IO Then Return -EINVAL
826  If f_mode & le is open for writing && filemap_nr_thps(i_mapping) Then runcate_pagecache - unmap and remove pagecache that has been truncated*@inode: inode*@newsize: new file size* inode's new i_size must already be written before truncate_pagecache* is called.* This function should typically be called before the filesystem
829  Return 0
831  cleanup_all :
832  If WARN_ON_ONCE(error > 0) Then error = -EINVAL
834  fops_put(f_op)
835  If f_mode & Write access to underlying fs Then
836  releases this write permission
837  __mnt_drop_write(mnt)
839  cleanup_file :
840  path_put( & f_path)
841  mnt = NULL
842  dentry = NULL
843  cached value = NULL
844  Return error
Caller
NameDescribe
finish_opensh_open - finish opening a file*@file: file pointer*@dentry: pointer to dentry*@open: open callback*@opened: state of open* This can be used to finish opening a file passed to i_op->atomic_open()
vfs_openvfs_open - open the file at the given path*@path: path to open*@file: newly allocated file with f_flag initialized*@cred: credentials to use
open_with_fake_path