[lkml]   [2004]   [Feb]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    SubjectRe: [PATCH] Add getdents32t syscall

    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

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


    --- 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;
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at
     \ /
      Last update: 2009-11-18 23:46    [W:0.020 / U:9.088 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site