Re: Problems with dirent and nfs
Re: Problems with dirent and nfs
- Subject: Re: Problems with dirent and nfs
- From: Jim Luther <email@hidden>
- Date: Wed, 18 Mar 2009 08:25:00 -0700
On Mar 18, 2009, at 5:39 AM, email@hidden wrote:
I'm using scandir to get directory entries for mounted volumes.
In the returned directory entries I can use d_type to quickly
identify directories.
However when scanning an nfs mount I don't get this information.
d_type is DT_UNKNOWN rather than DT_DIR.
Any suggests for getting a correct d_type or any other way to
quickly determine the type of each entry?
Thanks,
Adam
Not all file systems are created equal. In this case, the NFS version
2 and 3 READDIR procedures do not supply the file type (d_type) across
the wire and so getdirentries(2), readdir(3), and things built upon
readdir(3) like scandir(3) and fts(3) do not get a file type from NFS
volumes. File systems that can supply the file type do supply it. So,
when you get DT_UNKNOWN as the d_type, you'll need to stat() or lstat
() each item to get its real file type.
You might want to look at fts(3) as a possible alternative to scandir
(3). It already knows how to handle DT_UNKNOWN, and it offers a lot
more flexibility.
- Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden