From: Andreas Dilger <adilger@clusterfs.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Jakub Jelinek <jakub@redhat.com>,
linux-kernel@vger.kernel.org, drepper@redhat.com
Subject: Re: [PATCH] Add getdents32t syscall
Date: Thu, 26 Feb 2004 18:46:48 -0700 [thread overview]
Message-ID: <20040227014648.GW1257@schnapps.adilger.int> (raw)
In-Reply-To: <Pine.LNX.4.58.0402261504230.7830@ppc970.osdl.org>
On Thu, 26 Feb 2004, Jakub Jelinek wrote:
> Userland struct dirent is:
> (since 1997 or so), so with the extended getdents syscall glibc would need
> to memmove every name by 1 byte.
Actually, before you go through contortions trying to return this stuff to
user space, you should fix the GNU tools to use the information properly.
For example, rm stats the file each time before trying to unlink it even
if it has the file type information from getdents64(). It also tries to
do silly things like unlink() on a directory instead of rmdir, even after
the stat (RH9 coreutils 4.5.3-19 and 2.4.24):
$ mkdir /tmp/foo
$ touch /tmp/foo/f{1,2,3,4,5}
$ strace rm -r /tmp/foo
:
:
lstat64("/tmp/foo", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
access("/tmp/foo", W_OK) = 0
unlink("/tmp/foo") = -1 EISDIR (Is a directory)
Um, hello - we just saw that it was a directory so why not try rmdir()?
It does the same thing when the directory is empty too.
open(".", O_RDONLY|O_LARGEFILE|O_DIRECTORY) = 3
lstat64("/tmp/foo", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
chdir("/tmp/foo") = 0
lstat64(".", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 4
fstat64(4, {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
fcntl64(4, F_SETFD, FD_CLOEXEC) = 0
getdents64(4, /* 7 entries */, 4096) = 168
lstat64("f1", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
access("f1", W_OK) = 0
unlink("f1") = 0
lstat64("f2", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
access("f2", W_OK) = 0
unlink("f2") = 0
:
:
So, for each file, we just got the file type info from getdents64(),
we still stat the file (not sure why), we check the permissions even
though we just statted it (could check perms from stat info or just
try to unlink and handle the error return code), and finally an unlink.
getdents64(4, /* 0 entries */, 4096) = 0
close(4) = 0
fchdir(3) = 0
lstat64(".", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
lstat64("/tmp/foo", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
access("/tmp/foo", W_OK) = 0
rmdir("/tmp/foo") = 0
Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/
next prev parent reply other threads:[~2004-02-27 1:48 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
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 [this message]
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=20040227014648.GW1257@schnapps.adilger.int \
--to=adilger@clusterfs.com \
--cc=drepper@redhat.com \
--cc=jakub@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.