stat.c (ead5d1f4d877e92c051e1a1ade623d0d30e71619) | stat.c (da9aa5d96bfe49e903ce2bc01cfb8a776c2619e9) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/fs/stat.c 4 * 5 * Copyright (C) 1991, 1992 Linus Torvalds 6 */ 7 8#include <linux/export.h> --- 112 unchanged lines hidden (view full) --- 121 retval = security_inode_getattr(path); 122 if (retval) 123 return retval; 124 return vfs_getattr_nosec(path, stat, request_mask, query_flags); 125} 126EXPORT_SYMBOL(vfs_getattr); 127 128/** | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/fs/stat.c 4 * 5 * Copyright (C) 1991, 1992 Linus Torvalds 6 */ 7 8#include <linux/export.h> --- 112 unchanged lines hidden (view full) --- 121 retval = security_inode_getattr(path); 122 if (retval) 123 return retval; 124 return vfs_getattr_nosec(path, stat, request_mask, query_flags); 125} 126EXPORT_SYMBOL(vfs_getattr); 127 128/** |
129 * vfs_statx_fd - Get the enhanced basic attributes by file descriptor | 129 * vfs_fstat - Get the basic attributes by file descriptor |
130 * @fd: The file descriptor referring to the file of interest 131 * @stat: The result structure to fill in. | 130 * @fd: The file descriptor referring to the file of interest 131 * @stat: The result structure to fill in. |
132 * @request_mask: STATX_xxx flags indicating what the caller wants 133 * @query_flags: Query mode (KSTAT_QUERY_FLAGS) | |
134 * 135 * This function is a wrapper around vfs_getattr(). The main difference is 136 * that it uses a file descriptor to determine the file location. 137 * 138 * 0 will be returned on success, and a -ve error code if unsuccessful. 139 */ | 132 * 133 * This function is a wrapper around vfs_getattr(). The main difference is 134 * that it uses a file descriptor to determine the file location. 135 * 136 * 0 will be returned on success, and a -ve error code if unsuccessful. 137 */ |
140int vfs_statx_fd(unsigned int fd, struct kstat *stat, 141 u32 request_mask, unsigned int query_flags) | 138int vfs_fstat(int fd, struct kstat *stat) |
142{ 143 struct fd f; | 139{ 140 struct fd f; |
144 int error = -EBADF; | 141 int error; |
145 | 142 |
146 if (query_flags & ~KSTAT_QUERY_FLAGS) 147 return -EINVAL; 148 | |
149 f = fdget_raw(fd); | 143 f = fdget_raw(fd); |
150 if (f.file) { 151 error = vfs_getattr(&f.file->f_path, stat, 152 request_mask, query_flags); 153 fdput(f); 154 } | 144 if (!f.file) 145 return -EBADF; 146 error = vfs_getattr(&f.file->f_path, stat, STATX_BASIC_STATS, 0); 147 fdput(f); |
155 return error; 156} | 148 return error; 149} |
157EXPORT_SYMBOL(vfs_statx_fd); | |
158 159static inline unsigned vfs_stat_set_lookup_flags(unsigned *lookup_flags, 160 int flags) 161{ 162 if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | 163 AT_EMPTY_PATH | KSTAT_QUERY_FLAGS)) != 0) 164 return -EINVAL; 165 --- 602 unchanged lines hidden --- | 150 151static inline unsigned vfs_stat_set_lookup_flags(unsigned *lookup_flags, 152 int flags) 153{ 154 if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT | 155 AT_EMPTY_PATH | KSTAT_QUERY_FLAGS)) != 0) 156 return -EINVAL; 157 --- 602 unchanged lines hidden --- |