-
Notifications
You must be signed in to change notification settings - Fork 63
/
compat.c
123 lines (109 loc) · 3.5 KB
/
compat.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <linux/version.h>
#include <linux/fs.h>
#include "compat.h"
#include "vfs.h"
#ifndef STATX_BASIC_STATS
#define STATX_BASIC_STATS 0x000007ffU
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
int compat_ksmbd_vfs_get_dos_attrib_xattr(const struct path *path,
struct dentry *dentry,
struct xattr_dos_attrib *da)
{
return ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path->mnt), dentry,
da);
}
int compat_ksmbd_vfs_set_dos_attrib_xattr(const struct path *path,
struct xattr_dos_attrib *da,
bool get_write)
{
return ksmbd_vfs_set_dos_attrib_xattr(mnt_idmap(path->mnt), path, da,
get_write);
}
ssize_t compat_ksmbd_vfs_getxattr(struct path *path, struct dentry *dentry,
char *xattr_name, char **xattr_buf)
{
return ksmbd_vfs_getxattr(mnt_idmap(path->mnt), dentry,
xattr_name, xattr_buf);
}
#else
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
int compat_inode_permission(struct path *path, struct inode *inode, int mask)
{
return inode_permission(mnt_idmap(path->mnt), inode, mask);
}
int compat_ksmbd_vfs_get_dos_attrib_xattr(const struct path *path,
struct dentry *dentry,
struct xattr_dos_attrib *da)
{
return ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path->mnt), dentry,
da);
}
int compat_ksmbd_vfs_set_dos_attrib_xattr(const struct path *path,
struct xattr_dos_attrib *da,
bool get_write)
{
return ksmbd_vfs_set_dos_attrib_xattr(mnt_idmap(path->mnt), path, da,
get_write);
}
ssize_t compat_ksmbd_vfs_getxattr(struct path *path, struct dentry *dentry,
char *xattr_name, char **xattr_buf)
{
return ksmbd_vfs_getxattr(mnt_idmap(path->mnt), dentry,
xattr_name, xattr_buf);
}
#else
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
int compat_inode_permission(struct path *path, struct inode *inode, int mask)
{
return inode_permission(mnt_user_ns(path->mnt), inode, mask);
}
int compat_ksmbd_vfs_get_dos_attrib_xattr(const struct path *path,
struct dentry *dentry,
struct xattr_dos_attrib *da)
{
return ksmbd_vfs_get_dos_attrib_xattr(mnt_user_ns(path->mnt), dentry,
da);
}
int compat_ksmbd_vfs_set_dos_attrib_xattr(const struct path *path,
struct xattr_dos_attrib *da,
bool get_write)
{
return ksmbd_vfs_set_dos_attrib_xattr(mnt_user_ns(path->mnt), path, da,
get_write);
}
ssize_t compat_ksmbd_vfs_getxattr(struct path *path, struct dentry *dentry,
char *xattr_name, char **xattr_buf)
{
return ksmbd_vfs_getxattr(mnt_user_ns(path->mnt), dentry,
xattr_name, xattr_buf);
}
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0)
int compat_inode_permission(struct path *path, struct inode *inode, int mask)
{
return inode_permission(inode, mask);
}
int compat_ksmbd_vfs_get_dos_attrib_xattr(const struct path *path,
struct dentry *dentry,
struct xattr_dos_attrib *da)
{
return ksmbd_vfs_get_dos_attrib_xattr(mnt_user_ns(path->mnt), dentry,
da);
}
int compat_ksmbd_vfs_set_dos_attrib_xattr(const struct path *path,
struct xattr_dos_attrib *da,
bool get_write)
{
return ksmbd_vfs_set_dos_attrib_xattr(mnt_user_ns(path->mnt), path,
da, get_write);
}
ssize_t compat_ksmbd_vfs_getxattr(struct path *path, struct dentry *dentry,
char *xattr_name, char **xattr_buf)
{
return ksmbd_vfs_getxattr(mnt_user_ns(path->mnt), dentry,
xattr_name, xattr_buf);
}
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0) */
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) */
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0) */