|
15 | 15 | * published by the Free Software Foundation.
|
16 | 16 | */
|
17 | 17 |
|
| 18 | +#include <linux/stddef.h> |
18 | 19 | #include <linux/kernel.h>
|
19 | 20 | #include <linux/linkage.h>
|
20 | 21 | #include <linux/compat.h>
|
@@ -891,8 +892,6 @@ asmlinkage long compat_sys_mount(char __user * dev_name, char __user * dir_name,
|
891 | 892 | return retval;
|
892 | 893 | }
|
893 | 894 |
|
894 |
| -#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de))) |
895 |
| - |
896 | 895 | struct compat_old_linux_dirent {
|
897 | 896 | compat_ulong_t d_ino;
|
898 | 897 | compat_ulong_t d_offset;
|
@@ -981,7 +980,8 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
|
981 | 980 | struct compat_linux_dirent __user * dirent;
|
982 | 981 | struct compat_getdents_callback *buf = __buf;
|
983 | 982 | compat_ulong_t d_ino;
|
984 |
| - int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 2, sizeof(compat_long_t)); |
| 983 | + int reclen = ALIGN(offsetof(struct compat_linux_dirent, d_name) + |
| 984 | + namlen + 2, sizeof(compat_long_t)); |
985 | 985 |
|
986 | 986 | buf->error = -EINVAL; /* only used if we fail.. */
|
987 | 987 | if (reclen > buf->count)
|
@@ -1068,8 +1068,8 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
|
1068 | 1068 | {
|
1069 | 1069 | struct linux_dirent64 __user *dirent;
|
1070 | 1070 | struct compat_getdents_callback64 *buf = __buf;
|
1071 |
| - int jj = NAME_OFFSET(dirent); |
1072 |
| - int reclen = ALIGN(jj + namlen + 1, sizeof(u64)); |
| 1071 | + int reclen = ALIGN(offsetof(struct linux_dirent64, d_name) + namlen + 1, |
| 1072 | + sizeof(u64)); |
1073 | 1073 | u64 off;
|
1074 | 1074 |
|
1075 | 1075 | buf->error = -EINVAL; /* only used if we fail.. */
|
|
0 commit comments