Re: Status of getdirentriesattr()?
Re: Status of getdirentriesattr()?
- Subject: Re: Status of getdirentriesattr()?
- From: Jim Luther <email@hidden>
- Date: Fri, 07 Sep 2012 15:22:38 -0700
James,
> Can anyone tell me the status of getdirentriesattr()?
As far as I know, getdirentriesattr(2) is not deprecated.
> One document says it's deprecated in 10.6. Another one doesn't say anything. Yet, in the docs included in Xcode 4.4.1 it's been removed from the documentation entirely.
Could you let me know where it is said to be deprecated?
I don't know why it's not in the Xcode documentation set. There's a man page for it:
man 2 getdirentriesattr
> It's also stated that it's not supported on all filesystems.
That is true. It's only supported on file systems that set the VOL_CAP_INT_READDIRATTR capability bit.
In addition to that limitation, getdirentriesattr(2) does not support the attributes ATTR_CMN_EXTENDED_SECURITY, ATTR_CMN_UUID, ATTR_CMN_GRPUUID, and ATTR_CMN_FULLPATH so if you need any of those attributes, you'll have to use getattrlist(2). ATTR_CMN_EXTENDED_SECURITY, ATTR_CMN_UUID, ATTR_CMN_GRPUUID are only supported by file systems that set the VOL_CAP_INT_EXTENDED_SECURITY capability bit.
> Second question: is the only alternative to use readdir() to get an entry, construct a complete pathname to the item, and then use getattrlist() to obtain the metadata? Something akin to this loop:
Yes, that's what you'll need to do.
Check out fts(3). It does that work for you nicely. Tools like find(1) are built on fts(3).
You'll want to set the FTS_NOSTAT option. Since you're going to call getattrlist() to get the attributes, there's no need for fts() to lstat every file system object. In fact, look at all of the fts options carefully. You probably also want to set:
FTS_PHYSICAL if you don't want fts to follow symlinks.
FTS_NOCHDIR if you don't want fts changing the current directory.
FTS_XDEV if you don't want fts to cross mount points.
> Finally, do I need to be worried about _DARWIN_FEATURE_64_BIT_INODE? Casual testing would indicate that it's always defined, so regardless of whether I'm compiling 32- or 64-bit code, the structs and functions will still use the 64-bit inode structures (which is clearly what I want).
Use:
man 2 stat
and look for _DARWIN_FEATURE_64_BIT_INODE. That's the non-obvious place where you'll find the documentation for _DARWIN_FEATURE_64_BIT_INODE.
- Jim
On Sep 5, 2012, at 11:21 AM, James Bucanek <email@hidden> wrote:
> Greetings,
>
> I'm migrating away from the deprecated FS API and I am in the process of rewriting my directory reading routines.
>
> Can anyone tell me the status of getdirentriesattr()?
>
> One document says it's deprecated in 10.6. Another one doesn't say anything. Yet, in the docs included in Xcode 4.4.1 it's been removed from the documentation entirely. It's also stated that it's not supported on all filesystems.
>
> I'm trying to read all of the entries in a directory, along with most of their metadata, as fast as I can. getdirentriesattr() would appear to fit the bill--unless it's really deprecated or not well supported.
>
> Second question: is the only alternative to use readdir() to get an entry, construct a complete pathname to the item, and then use getattrlist() to obtain the metadata? Something akin to this loop:
>
> while ( (dirEntry=readdir(dir)) != NULL )
> {
> strlcpy( itemPath, path, sizeof(itemPath));
> strlcat( itemPath, "/", sizeof(itemPath));
> strlcat( itemPath, dirEntry->d_name, sizeof(itemPath));
> if ( getattrlist(itemPath,&attrRequest,&attrBuffer,sizeof(attrBuffer))==0 )
> {
> ...
> }
> }
>
> Finally, do I need to be worried about _DARWIN_FEATURE_64_BIT_INODE? Casual testing would indicate that it's always defined, so regardless of whether I'm compiling 32- or 64-bit code, the structs and functions will still use the 64-bit inode structures (which is clearly what I want).
>
> Thanks
>
> James
> --
> James Bucanek
>
>
> _______________________________________________
> 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
_______________________________________________
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