All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel@vger.kernel.org, drepper@redhat.com
Subject: Re: [PATCH] Add getdents32t syscall
Date: Thu, 26 Feb 2004 17:32:26 -0500	[thread overview]
Message-ID: <20040226223212.GA31589@devserv.devel.redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0402261415590.7830@ppc970.osdl.org>

On Thu, Feb 26, 2004 at 02:25:01PM -0800, Linus Torvalds wrote:
> 
> 
> 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.

Userland struct dirent is:

struct dirent
  {
#ifndef __USE_FILE_OFFSET64
    __ino_t d_ino;
    __off_t d_off;
#else
    __ino64_t d_ino;
    __off64_t d_off;
#endif
    unsigned short int d_reclen;
    unsigned char d_type;
    char d_name[256];           /* We must not include limits.h! */
  };

(since 1997 or so), so with the extended getdents syscall glibc would need
to memmove every name by 1 byte.

> 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.

This has a few problems:
- unless glibc is configured to assume 2.6.4+ kernel, it would need to
  do on first readdir one small getdents (instead of as big getdents as
  needed)
- how to find what is the right small size for the test (it would need to
  retry if it did not fit any entries)
- and if on the old kernel, it would need to seek back so that getdents64
  can be used
Yes, this would only happen the first time getdents is called, but still,
aren't syscalls quite cheap?

	Jakub

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

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-26 19:38 [PATCH] Add getdents32t syscall Jakub Jelinek
2004-02-26 22:03 ` Randy.Dunlap
2004-02-26 22:15 ` Linus Torvalds
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 [this message]
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=20040226223212.GA31589@devserv.devel.redhat.com \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.