Skip to content

Commit 0018784

Browse files
Bijan Mottahedehaxboe
authored andcommitted
statx: allow system call to be invoked from io_uring
This is a prepatory patch to allow io_uring to invoke statx directly. Signed-off-by: Bijan Mottahedeh <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 1d9e128 commit 0018784

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

fs/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,5 @@ int sb_init_dio_done_wq(struct super_block *sb);
188188
*/
189189
unsigned vfs_stat_set_lookup_flags(unsigned *lookup_flags, int flags);
190190
int cp_statx(const struct kstat *stat, struct statx __user *buffer);
191+
int do_statx(int dfd, const char __user *filename, unsigned flags,
192+
unsigned int mask, struct statx __user *buffer);

fs/stat.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,24 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer)
567567
return copy_to_user(buffer, &tmp, sizeof(tmp)) ? -EFAULT : 0;
568568
}
569569

570+
int do_statx(int dfd, const char __user *filename, unsigned flags,
571+
unsigned int mask, struct statx __user *buffer)
572+
{
573+
struct kstat stat;
574+
int error;
575+
576+
if (mask & STATX__RESERVED)
577+
return -EINVAL;
578+
if ((flags & AT_STATX_SYNC_TYPE) == AT_STATX_SYNC_TYPE)
579+
return -EINVAL;
580+
581+
error = vfs_statx(dfd, filename, flags, &stat, mask);
582+
if (error)
583+
return error;
584+
585+
return cp_statx(&stat, buffer);
586+
}
587+
570588
/**
571589
* sys_statx - System call to get enhanced stats
572590
* @dfd: Base directory to pathwalk from *or* fd to stat.
@@ -583,19 +601,7 @@ SYSCALL_DEFINE5(statx,
583601
unsigned int, mask,
584602
struct statx __user *, buffer)
585603
{
586-
struct kstat stat;
587-
int error;
588-
589-
if (mask & STATX__RESERVED)
590-
return -EINVAL;
591-
if ((flags & AT_STATX_SYNC_TYPE) == AT_STATX_SYNC_TYPE)
592-
return -EINVAL;
593-
594-
error = vfs_statx(dfd, filename, flags, &stat, mask);
595-
if (error)
596-
return error;
597-
598-
return cp_statx(&stat, buffer);
604+
return do_statx(dfd, filename, flags, mask, buffer);
599605
}
600606

601607
#ifdef CONFIG_COMPAT

0 commit comments

Comments
 (0)