Vfs_getattr and apivfs_getattr of Kernel File System APIs

Source: Internet
Author: User

Vfs_getattr and apivfs_getattr of Kernel File System APIs

Vfs_getattr for Kernel File System APIs

Int vfs_getattr (const struct path * path, struct kstat * stat, u32 request_mask, unsigned int query_flags) is used to obtain the file's enhanced basic attributes, that is, the basic extended attributes. The source code analysis is shown: int vfs_getattr (const struct path * path, struct kstat * stat, u32 request_mask, unsigned int query_flags) {int retval; # perform security checks on the files indicated by path, for example, selinuxretval = security_inode_getattr (path); if (retval) return retval; # security check has been performed before. Therefore, the basic extension attribute return vfs_getattr_nosec (path, stat, request_mask, query_flags);} int vfs_getattr_nosec (const struct path * path, struct kstat * stat, u32 request_mask, unsigned int query_flags) {# obtain the path that indicates the inodestruct inode * inode = d_backing_inode (path-> dentry) of the file; # Clear stat, because stat will save the extension and return it to the user memset (stat, 0, sizeof (* stat); stat-> result_mask | = STATX_BASIC_STATS; request_mask & = STATX_ALL; query_flags & = KSTAT_QUERY_FLAGS; # The extension attributes of the file can be saved to inode, then, the function provided by inode is returned to the user if (inode-> I _op-> getattr) return inode-> I _op-> getattr (path, stat, request_mask, query_flags ); # If inode is not saved, call the common functions provided by the file system to obtain the extension attribute generic_fillattr (inode, stat); return 0;} of the file ;}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.