* struct dirent *ent->d_type weirdness
@ 2005-09-19 13:58 Kristian Köhntopp
2005-09-19 14:33 ` Vladimir V. Saveliev
0 siblings, 1 reply; 5+ messages in thread
From: Kristian Köhntopp @ 2005-09-19 13:58 UTC (permalink / raw)
To: reiserfs-list
I have a machine running under 2.6.13-SMP, using reiserfs 3.6. On
this machine, directories are flagged strangely and thus code
which operates properly under ext3 fails with reiserfs.
Why is this, and what am I doing wrong?
My goal is to walk a spool directory recursively and deal with
all files inside directories that I encounter. For that, I check
struct dirent *ent->d_type and get unexpected results.
mx15:/tmp # uname -a
Linux mx15 2.6.13web #4 SMP Fri Sep 16 16:03:39 CEST 2005 i686
unknown
mx15:/tmp # cat rtest.cpp
#include <stdio.h>
#include <dirent.h>
int main(int argc, char** argv)
{
struct dirent *ent = NULL;
DIR *dd = NULL;
dd = opendir(argv[1]);
if (dd != NULL) {
while ((ent = readdir(dd)) != NULL) {
/* disable actual test and print ent->d_type */
/* ent->d_type==DT_DIR && ent->d_name[1]==0 && ent->d_name[0]>0
&& ent->d_name[0]!='.'*/
if (1) {
printf("%s (%d) \n", ent->d_name, ent->d_type);
}
}
closedir(dd);
}
}
mx15:/tmp # ./rtest /netsite/var/spool/wmail.reiser
. (0)
.. (0)
head (0)
dbclub02 (0)
mx15:/tmp # df -Th /netsite/var/spool/wmail.reiser
Dateisystem Typ Größe Benut Verf Ben% Eingehängt auf
/reiserfile
reiserfs 2.0G 33M 2.0G
2% /netsite/var/spool/wmail.reiser
Kristian
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: struct dirent *ent->d_type weirdness
2005-09-19 13:58 struct dirent *ent->d_type weirdness Kristian Köhntopp
@ 2005-09-19 14:33 ` Vladimir V. Saveliev
2005-09-19 16:25 ` Kristian Koehntopp
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Vladimir V. Saveliev @ 2005-09-19 14:33 UTC (permalink / raw)
To: Kristian Köhntopp; +Cc: reiserfs-list
Hello
Kristian Köhntopp wrote:
> I have a machine running under 2.6.13-SMP, using reiserfs 3.6. On
> this machine, directories are flagged strangely and thus code
> which operates properly under ext3 fails with reiserfs.
>
> Why is this, and what am I doing wrong?
>
> My goal is to walk a spool directory recursively and deal with
> all files inside directories that I encounter. For that, I check
> struct dirent *ent->d_type and get unexpected results.
>
Yes, unfortunately, reiserfs does not support entry types.
Probably it should, but there is nothing wrong to not support it:
man readdir:
According to POSIX, the dirent structure contains a field char d_name[] of unspecified size, with at most NAME_MAX charac╜
ters preceding the terminating null character. Use of other fields will harm the portability of your programs. POSIX
1003.1-2001 also documents the field ino_t d_ino as an XSI extension.
>
> mx15:/tmp # uname -a
> Linux mx15 2.6.13web #4 SMP Fri Sep 16 16:03:39 CEST 2005 i686
> unknown
>
> mx15:/tmp # cat rtest.cpp
> #include <stdio.h>
> #include <dirent.h>
>
> int main(int argc, char** argv)
> {
> struct dirent *ent = NULL;
> DIR *dd = NULL;
>
> dd = opendir(argv[1]);
> if (dd != NULL) {
> while ((ent = readdir(dd)) != NULL) {
> /* disable actual test and print ent->d_type */
> /* ent->d_type==DT_DIR && ent->d_name[1]==0 && ent->d_name[0]>0
> && ent->d_name[0]!='.'*/
> if (1) {
> printf("%s (%d) \n", ent->d_name, ent->d_type);
> }
> }
> closedir(dd);
> }
> }
> mx15:/tmp # ./rtest /netsite/var/spool/wmail.reiser
> . (0)
> .. (0)
> head (0)
> dbclub02 (0)
> mx15:/tmp # df -Th /netsite/var/spool/wmail.reiser
> Dateisystem Typ Größe Benut Verf Ben% Eingehängt auf
> /reiserfile
> reiserfs 2.0G 33M 2.0G
> 2% /netsite/var/spool/wmail.reiser
>
>
>
> Kristian
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: struct dirent *ent->d_type weirdness
2005-09-19 14:33 ` Vladimir V. Saveliev
@ 2005-09-19 16:25 ` Kristian Koehntopp
2005-09-19 17:14 ` Andreas Dilger
2005-09-22 15:03 ` Grzegorz Jaśkiewicz
2 siblings, 0 replies; 5+ messages in thread
From: Kristian Koehntopp @ 2005-09-19 16:25 UTC (permalink / raw)
To: reiserfs-list; +Cc: Vladimir V. Saveliev
On Monday 19 September 2005 16:33, Vladimir V. Saveliev wrote:
> Yes, unfortunately, reiserfs does not support entry types.
> Probably it should, but there is nothing wrong to not support it:
Thank you. I'll have the code in question changed to Posix conformance.
Kristian
--
Kristian =?iso-8859-15?q?K=F6hntopp?= <kris@xn--khntopp-90a.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: struct dirent *ent->d_type weirdness
2005-09-19 14:33 ` Vladimir V. Saveliev
2005-09-19 16:25 ` Kristian Koehntopp
@ 2005-09-19 17:14 ` Andreas Dilger
2005-09-22 15:03 ` Grzegorz Jaśkiewicz
2 siblings, 0 replies; 5+ messages in thread
From: Andreas Dilger @ 2005-09-19 17:14 UTC (permalink / raw)
To: Vladimir V. Saveliev; +Cc: Kristian Köhntopp, reiserfs-list
On Sep 19, 2005 18:33 +0400, Vladimir V. Saveliev wrote:
> Kristian Köhntopp wrote:
> > My goal is to walk a spool directory recursively and deal with
> > all files inside directories that I encounter. For that, I check
> > struct dirent *ent->d_type and get unexpected results.
> >
> Yes, unfortunately, reiserfs does not support entry types.
>
> > /* disable actual test and print ent->d_type */
> > /* ent->d_type==DT_DIR && ent->d_name[1]==0 && ent->d_name[0]>0
> > && ent->d_name[0]!='.'*/
You need to stat() the entry to find the type if d_type is DT_UNKNOWN.
I would continue to use d_type as an optimization, however, as this
reduces the number of syscalls needed when it is supported, and for
network filesystems a stat() may be an expensive operation.
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: struct dirent *ent->d_type weirdness
2005-09-19 14:33 ` Vladimir V. Saveliev
2005-09-19 16:25 ` Kristian Koehntopp
2005-09-19 17:14 ` Andreas Dilger
@ 2005-09-22 15:03 ` Grzegorz Jaśkiewicz
2 siblings, 0 replies; 5+ messages in thread
From: Grzegorz Jaśkiewicz @ 2005-09-22 15:03 UTC (permalink / raw)
To: Vladimir V. Saveliev; +Cc: Kristian Köhntopp, reiserfs-list
On 9/19/05, Vladimir V. Saveliev <vs@namesys.com> wrote:
> Hello
>
> Yes, unfortunately, reiserfs does not support entry types.
> Probably it should, but there is nothing wrong to not support it:
I guess it shouldn't be hard, and this would make some code nicer. I
have run into this problem quite few times, and I wish reiserfs4 has
this implemented.
--
GJ
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-09-22 15:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-19 13:58 struct dirent *ent->d_type weirdness Kristian Köhntopp
2005-09-19 14:33 ` Vladimir V. Saveliev
2005-09-19 16:25 ` Kristian Koehntopp
2005-09-19 17:14 ` Andreas Dilger
2005-09-22 15:03 ` Grzegorz Jaśkiewicz
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.