Skip to content

Commit 0b2c669

Browse files
Christoph HellwigAl Viro
authored andcommitted
fs: implement vfs_stat and vfs_lstat in terms of vfs_fstatat
Go through vfs_fstatat instead of duplicating the *stat to statx mapping three times. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent da9aa5d commit 0b2c669

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

include/linux/fs.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,21 +3165,19 @@ extern int iterate_dir(struct file *, struct dir_context *);
31653165
extern int vfs_statx(int, const char __user *, int, struct kstat *, u32);
31663166
int vfs_fstat(int fd, struct kstat *stat);
31673167

3168-
static inline int vfs_stat(const char __user *filename, struct kstat *stat)
3168+
static inline int vfs_fstatat(int dfd, const char __user *filename,
3169+
struct kstat *stat, int flags)
31693170
{
3170-
return vfs_statx(AT_FDCWD, filename, AT_NO_AUTOMOUNT,
3171+
return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT,
31713172
stat, STATX_BASIC_STATS);
31723173
}
3173-
static inline int vfs_lstat(const char __user *name, struct kstat *stat)
3174+
static inline int vfs_stat(const char __user *filename, struct kstat *stat)
31743175
{
3175-
return vfs_statx(AT_FDCWD, name, AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT,
3176-
stat, STATX_BASIC_STATS);
3176+
return vfs_fstatat(AT_FDCWD, filename, stat, 0);
31773177
}
3178-
static inline int vfs_fstatat(int dfd, const char __user *filename,
3179-
struct kstat *stat, int flags)
3178+
static inline int vfs_lstat(const char __user *name, struct kstat *stat)
31803179
{
3181-
return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT,
3182-
stat, STATX_BASIC_STATS);
3180+
return vfs_fstatat(AT_FDCWD, name, stat, AT_SYMLINK_NOFOLLOW);
31833181
}
31843182

31853183
extern const char *vfs_get_link(struct dentry *, struct delayed_call *);

0 commit comments

Comments
 (0)