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:25:01 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0402261415590.7830@ppc970.osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.58.0402261411420.7830@ppc970.osdl.org>



On Thu, 26 Feb 2004, Linus Torvalds wrote:
> 
> In other words, what's wrong with this much simpler "extended getdents" 
> instead?

Actually, let's put the "d_type" always at the last character, so that you 
don't have to search for it. Ie like the appended.

Then you just get

	d_type = ((unsigned char *)dirent)[dirent->d_reclen-1];

inside glibc. Instead of having a new system call.

You can even trivially check whether the system call fills in the d_type 
field or not:

 - pre-fill the dirent area with 0xff or something
 - do a small old-style "readdir()"
 - check the first entry: the above gives a d_type of 0xff, then you have 
   an old-style readdir. If it gives 0, then you have to test whether it 
   is an old-style readdir (and the zero is the end-of-name marker) or a 
   new-style readdir (and the zero is DT_UNKNOWN). You can trivially do 
   that by checking the length of the name, and comparing it with the 
   reclen.

See? No new system call, and trivial detection of whether the new code is 
there or not.

		Linus

--
--- 1.23/fs/readdir.c	Tue Feb  3 21:29:14 2004
+++ edited/fs/readdir.c	Thu Feb 26 14:17:05 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, (char *) dirent + reclen - 1))
 		goto efault;
 	buf->previous = dirent;
 	dirent = (void *)dirent + reclen;

  reply	other threads:[~2004-02-26 22:19 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
2004-02-26 22:25   ` Linus Torvalds [this message]
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.0402261415590.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®