Two questions about opendir and readdir
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Two questions about opendir and readdir




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Two questions about opendir and readdir  
music4


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-29-04 12:52 PM

Greetings,

Generally, I work on Solaris 2.8 operating system.

1. In which case I have to use readdir64()? If every file's size is less
than 2G under a dir, but total size of the dir is larger than 2G, do I need
to use readdir64()?

2. What's order of output of readdir()? It seems readdir get file entries by
mtime order, but I could not find a documenation to clarify that. Is it
true?

Thanks in advance,
Evan







[ Post a follow-up to this message ]



    Re: Two questions about opendir and readdir  
Juha Laiho


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-29-04 10:55 PM

"music4" <music4@163.net> said:
>2. What's order of output of readdir()? It seems readdir get file entries b
y
>mtime order, but I could not find a documenation to clarify that. Is it
>true?

Order is not specified;
On "old" filesystems (so, derivatives of FFS/UFS), it was "directory order",
as directory was a simple data inode where entries had a constant size, and
each new entry was written to first unused position in the directory data.
So, the directory order was just the order in which the entries happened to
be in the directory data.
On newer filesystems (VxFS, Linux reiserfs, others) the directory structure
is some kind of hash; I guess the "directory order" there depends on the
hash scan mechanism, as no "simple" order exists any more.
--
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)





[ Post a follow-up to this message ]



    Re: Two questions about opendir and readdir  
Aaron Isotton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-29-04 10:55 PM

On Thu, 29 Jul 2004 17:04:47 +0800, music4 wrote:
> Generally, I work on Solaris 2.8 operating system
>
> 1. In which case I have to use readdir64()? If every file's size is
less
> than 2G under a dir, but total size of the dir is larger than 2G, do I
> need to use readdir64()?

readdir() will fail if 'One of the values in the structure to be returned
cannot be represented correctly.'; in this case, errno will be set to
EOVERFLOW.

See also:

http://www.unix.org/version2/whatsnew/lfs.html

I'm not totally sure about how this applies to SUSv3; in fact, SUSv3 does
/not/ specify any function readdir64().

> 2. What's order of output of readdir()? It seems readdir get file entries 
by
> mtime order, but I could not find a documenation to clarify that. Is it
> true?

SUSv3 does not specify any special order of the entries returned by
readdir(); I think that this is OS- and File-System dependent; probably
the files are being returned in the order they are stored in the file
system.

Greetings,
Aaron
--
Aaron Isotton | http://www.isotton.com/
You know it's Monday when you wake up and it's Tuesday. -- Garfield






[ Post a follow-up to this message ]



    Re: Two questions about opendir and readdir  
David Schwartz


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-29-04 10:55 PM


"music4" <music4@163.net> wrote in message
news:ceaejd$juj@netnews.proxy.lucent.com...

> 1. In which case I have to use readdir64()? If every file's size is less
> than 2G under a dir, but total size of the dir is larger than 2G, do I
> need
> to use readdir64()?

It has nothing to do with the sizes of the files but with the size of
the directory itself (which has nothing to do with the sizes of the files in
it). You can't really have a directory over 2G in any sensible way I can
think of, so readdir64 should almost never be needed.

> 2. What's order of output of readdir()? It seems readdir get file entries
> by
> mtime order, but I could not find a documenation to clarify that. Is it
> true?

The order is arbitrary. You can't rely on it being anything specific.

DS







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 05:10 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register