From a07b54e9f4c84f80cd7f8e53f051c0a7489b402d Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Fri, 26 Mar 2004 20:56:18 -0800 Subject: [PATCH] [PATCH] Fix x86-64 32bit getdents for new glibc The newest CVS glibc assumes that Linux >=2.6.4 always passes d_type. This patch adds this to the 32bit getdents on x86-64 too Patch originally from Marcus Meissner --- arch/x86_64/ia32/sys_ia32.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c index d2c08a0a2bf51..02f3d4a30d9e1 100644 --- a/arch/x86_64/ia32/sys_ia32.c +++ b/arch/x86_64/ia32/sys_ia32.c @@ -512,7 +512,7 @@ filldir32 (void *__buf, const char *name, int namlen, loff_t offset, ino_t ino, { struct linux32_dirent * dirent; struct getdents32_callback * buf = (struct getdents32_callback *) __buf; - int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1, 4); + int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 2, 4); buf->error = -EINVAL; /* only used if we fail.. */ if (reclen > buf->count) @@ -526,6 +526,7 @@ filldir32 (void *__buf, const char *name, int namlen, loff_t offset, ino_t ino, put_user(reclen, &dirent->d_reclen); copy_to_user(dirent->d_name, name, namlen); put_user(0, dirent->d_name + namlen); + put_user(d_type, (char *)dirent + reclen - 1); dirent = ((void *)dirent) + reclen; buf->current_dir = dirent; buf->count -= reclen; @@ -881,7 +882,10 @@ static char *badfs[] = { static int checktype(char *user_type) { int err = 0; - char **s,*kernel_type = getname(user_type); + char **s,*kernel_type; + if (!user_type) + return 0; + kernel_type = getname(user_type); if (!kernel_type || IS_ERR(kernel_type)) return -EFAULT; for (s = badfs; *s; ++s) -- 2.53.0