函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:fs\stat.c Create Date:2022-07-29 10:32:55
首页 Copyright©Brick

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
 * vfs_getattr_nosec - getattr without security checks
 * @path: file to get attributes from
 * @stat: structure to return attributes in
 * @request_mask: STATX_xxx flags indicating what the caller wants
 * @query_flags: Query mode (KSTAT_QUERY_FLAGS)
 *
 * Get attributes without calling security_inode_getattr.
 *
 * Currently the only caller other than vfs_getattr is internal to the
 * filehandle lookup code, which uses only the inode number and returns no
 * attributes to any user.  Any other code probably wants vfs_getattr.
 */
int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
              u32 request_mask, unsigned int query_flags)
{
    struct inode *inode = d_backing_inode(path->dentry);
 
    memset(stat, 0, sizeof(*stat));
    stat->result_mask |= STATX_BASIC_STATS;
    request_mask &= STATX_ALL;
    query_flags &= KSTAT_QUERY_FLAGS;
 
    /* allow the fs to override these if it really wants to */
    if (IS_NOATIME(inode))
        stat->result_mask &= ~STATX_ATIME;
    if (IS_AUTOMOUNT(inode))
        stat->attributes |= STATX_ATTR_AUTOMOUNT;
 
    if (inode->i_op->getattr)
        return inode->i_op->getattr(path, stat, request_mask,
                        query_flags);
 
    generic_fillattr(inode, stat);
    return 0;
}