Re: help needed with getmntinfo()
Re: help needed with getmntinfo()
- Subject: Re: help needed with getmntinfo()
- From: Terry Lambert <email@hidden>
- Date: Thu, 23 Apr 2009 04:18:13 -0700
On Apr 23, 2009, at 2:32 AM, rohan a <email@hidden> wrote:
Hi,
Thanks for the help.
However, I am writing code to display file-system attributes using
the getattrlist() call.
Now if the program is called like this :
#checkvol /Volumes/part2
where /Volumes/part2 is the volume to be queried.
Here /Volumes/part2 is not identified and hence gives no output.
What can I do here?
Don't call it on /Volumes/part2. The getattrlist you are calling will
return information for the symbolic link itself, not the link target.
Since getmntinfo() will never return "/Volumes/part2" anyway, given
your example, I guess I don't understand where you are getting your
knowledge of that name in the first place so that you can give the
bogus argument to your program instad of the correct argument, /. It
would be like calling it on /tmp (also a symlink and not a mount
point) or on /etc/ttys (a plain file, not a mount point).
If you are iterating /Volumes, I guess I need to point out again that
not all file systems hat mounted there, so it's not a useful way to
make sure you've seem all of them (for that, we have getmntinfo).
I will also point out, since your program is named "checkvol" that if
that's a file system consistency checker that any file system mounted
other than read only will pretty much always show as inconsistent.
That's why we do fsck on / with it mounted read-only, and also why we
fsck other filesystem before we mount them.
If you absolutely have to go though /Volumes for some bizarre and
unexplainable reason, then you will need to lstat the path, see that
it's a symbolic link, and use readlink(2) to read the link target,
then use the link target as the path instead, internally. Of course it
might be a relative path, and it might have . or .. in it, and if so,
you will have to start with the dirname(3) and recompite the path as
an absolute path before calling getattrlist() to make sure it fits in
PATH_MAX characters. Of course going that route you could need to
write a lot of code to handle complicated paths, like subtracting a
path component when you see ../, or simply dropping ".".
Or you could just call getmntinfo() to get a full list of mount points.
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden