mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Jakub Jelinek <jakub@redhat.com>
Cc: linux-kernel@vger.kernel.org, drepper@redhat.com
Subject: Re: [PATCH] Add getdents32t syscall
Date: Thu, 26 Feb 2004 14:15:06 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0402261411420.7830@ppc970.osdl.org> (raw)
In-Reply-To: <20040226193819.GA3501@sunsite.ms.mff.cuni.cz>



On Thu, 26 Feb 2004, Jakub Jelinek wrote:
> 
> glibc struct dirent has d_type field (similarly to struct dirent64).
> Because no 32-bit getdents syscall provides this field to userland,
> glibc needs to use getdents64 syscall even for 32-bit getdents
> (and readdir etc.) and convert dirent entries from struct dirent64
> to struct dirent.  The code is quite complicated and as the former
> is bigger and the size of 64-bit dirents cannot be predicted accurately,
> it can happen that glibc reads too many entries and has to seek back
> on the dir etc.

Nooo..

Please just use the old "getdents()", and if you really really need this, 
add the "type" char after the end of the name.

This is a two-liner change (yeah, and we'd need to add a flag saying we do 
this). 

In other words, what's wrong with this much simpler "extended getdents" 
instead?

		Linus

--- 1.23/fs/readdir.c	Tue Feb  3 21:29:14 2004
+++ edited/fs/readdir.c	Thu Feb 26 14:12:57 2004
@@ -139,7 +139,7 @@
 {
 	struct linux_dirent __user * dirent;
 	struct getdents_callback * buf = (struct getdents_callback *) __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)
@@ -157,6 +157,8 @@
 	if (copy_to_user(dirent->d_name, name, namlen))
 		goto efault;
 	if (__put_user(0, dirent->d_name + namlen))
+		goto efault;
+	if (__put_user(d_type, dirent->d_name + namlen + 1))
 		goto efault;
 	buf->previous = dirent;
 	dirent = (void *)dirent + reclen;

  parent reply	other threads:[~2004-02-26 22:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-26 19:38 Jakub Jelinek
2004-02-26 22:03 ` Randy.Dunlap
2004-02-26 22:15 ` Linus Torvalds [this message]
2004-02-26 22:25   ` Linus Torvalds
2004-02-26 22:29     ` Ulrich Drepper
2004-02-26 23:00       ` Linus Torvalds
2004-02-26 22:32     ` Jakub Jelinek
2004-02-26 23:15       ` Linus Torvalds
2004-02-27  1:33         ` Ulrich Drepper
2004-02-27  6:16           ` Linus Torvalds
2004-02-27  7:05             ` Ulrich Drepper
2004-02-28 23:21           ` Jamie Lokier
2004-02-27  1:46         ` Andreas Dilger
2004-02-27  3:36       ` Theodore Ts'o
2004-02-29  0:25   ` Jamie Lokier
2004-02-27 19:28 ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.58.0402261411420.7830@ppc970.osdl.org \
    --to=torvalds@osdl.org \
    --cc=drepper@redhat.com \
    --cc=jakub@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®