fs: move struct linux_dirent into headers
PATCH 1/2 fs: move struct linux_dirent into headers
Move the definition of linux_dirent to include/linux/dirent.h, where the newer linux_dirent64 already lives. This is done in preparation for moving both of these struct definitions into uapi/ so userspace code doesn't need to duplicate them.
--- fs/readdir.c | 8 +------- include/linux/dirent.h | 7 +++++++ 2 files changed, 8 insertions(+), 7 deletions(-)
fs/readdir.c +1 -7
@@ -202,14 +202,8 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,/* * New, all-improved, singing, dancing, iBCS2-compliant getdents() -* interface. +* interface. */ -struct linux_dirent { -unsigned long d_ino; -unsigned long d_off; -unsigned short d_reclen; -char d_name[1 ]; -};struct getdents_callback {struct dir_context ctx;
include/linux/dirent.h +7 -0
@@ -2,6 +2,13 @@ #ifndef _LINUX_DIRENT_H #define _LINUX_DIRENT_H +struct linux_dirent { + unsigned long d_ino; + unsigned long d_off; + unsigned short d_reclen; + char d_name[1]; +}; + struct linux_dirent64 { u64 d_ino; s64 d_off;
Signature · 1 line
2.30.1 (Apple Git-130)
PATCH 2/2 fs: move dirent.h into uapi
The structures defined in dirent.h are part of Linux's uAPI, but it was previously necessary for user code to duplicate the struct definitions themselves. Let's make them public.
---
include/{ => uapi}/linux/dirent.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
rename include/{ => uapi}/linux/dirent.h (66%)include/uapi/linux/dirent.h renamed from include/linux/dirent.h +3 -3
@@ -1,6 +1,6 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _LINUX_DIRENT_H -#define _LINUX_DIRENT_H +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_DIRENT_H +#define _UAPI_LINUX_DIRENT_H struct linux_dirent { unsigned long d_ino;
Signature · 1 line
2.30.1 (Apple Git-130)
Quoted 36 lines · Gaelan Steele
Move the definition of
linux_direnttoinclude/linux/dirent.h, where the newerlinux_dirent64already lives. This is done in preparation for moving both of these struct definitions into uapi/ so userspace code doesn't need to duplicate them.Signed-off-by Gaelan Steele <[email protected]>--- fs/readdir.c | 8 +------- include/linux/dirent.h | 7 +++++++ 2 files changed, 8 insertions(+), 7 deletions(-)fs/readdir.c +1
-7@@ -202,14 +202,8 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,/* * New, all-improved, singing, dancing, iBCS2-compliant getdents() -* interface. +* interface. */ -struct linux_dirent { -unsigned long d_ino; -unsigned long d_off; -unsigned short d_reclen; -char d_name[1 ]; -};struct getdents_callback {struct dir_context ctx;include/linux/dirent.h +0
-0
include/linux/dirent.h line 9
Quoted 8 lines
include/linux/dirent.h +5
-0@@ -2,6 +2,13 @@ #ifndef _LINUX_DIRENT_H #define _LINUX_DIRENT_H +struct linux_dirent { + unsigned long d_ino; + unsigned long d_off; + unsigned short d_reclen; + char d_name[1];
These are not valid user/kernel api types. If you want them in userspace, please use the correct ones (__u64, __u16, __u8, etc.)
thanks,
greg k-h