Skip to contentSkip to conversation

s390: getdents patch for 32 -> 64 converter

PATCH New Sripathi Kodi 1 participant 1 message Feb 1, 2005 s390

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390: getdents patch for 32 -> 64 converter

Hi,

This patch solves a problem with working of getdents while using 32 bit binaries on 64 bit Linux/390. glibc expects d_type to be passed if we have a kernel version after 2.6.4, so we have to also handle it in the 32bit syscall converter. Similar patch was given for PPC by Marcus Meissner (http://ozlabs.org/pipermail/linuxppc64-dev/2004-March/001359.html) and was integrated into 2.6.5.

Thanks,
Sripathi.

home/sripathi/12795/mainline/compat_linux.c renamed from arch/s390/kernel/compat_linux.c +2 -1
@@ -433,7 +433,7 @@ static int filldir(void * __buf, const c
 {
 	struct linux_dirent32 * dirent;
 	struct getdents_callback32 * buf = (struct getdents_callback32 *) __buf;
-	int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
+	int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 2);
 
 	buf->error = -EINVAL;	/* only used if we fail.. */
 	if (reclen > buf->count)
@@ -447,6 +447,7 @@ static int filldir(void * __buf, const c
 	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);
 	buf->current_dir = ((void *)dirent) + reclen;
 	buf->count -= reclen;
 	return 0;