Re: Do hard links have creation dates?
Re: Do hard links have creation dates?
- Subject: Re: Do hard links have creation dates?
- From: Oleg Krupnov <email@hidden>
- Date: Mon, 16 Mar 2009 17:55:09 +0200
I would agree, but there's one detail that makes me doubt.
Here is my code:
FSCatalogInfo catInfo;
FSGetCatalogInfo(fsRef, kFSCatInfoCreateDate | kFSCatInfoNodeFlags,
&catInfo, NULL, NULL, NULL);
if (catInfo.nodeFlags & kFSNodeHardLinkMask)
{
int whatIsThisNodeId = catInfo.nodeID;
}
I don't know what exactly this catInfo.nodeID means, but they are
different for the two hard links, and also they are not equal to the
inodes. (To get the actual inode I have to call POSIX stats() for the
file. )
It makes me think that the file system must use some kind of data
structure to differentiate between the links, even though they refer
to the same file. So the question boils down to this one: does the
file system also stores creation dates alongside with the link ids
(the nodeID), referring to the links themselves, not the files they
refer to?
The catInfo.createDate field is equal for all hard links, so I incline
to think that the answer is NO. But I still want to make sure !
On Mon, Mar 16, 2009 at 5:42 PM, Dave Carrigan <email@hidden> wrote:
>
> On Mar 16, 2009, at 8:27 AM, Oleg Krupnov wrote:
>
>> If I create a file and then a hard link to that file, is there a way
>> to distinguish their creation dates (e.g. to sort by date)?
>
>
> A hard link is simply an entry in the directory that points to the physical
> file. No matter how many hard links there are, there is only a single file,
> so what you're asking for doesn't really make sense within the context of
> Posix hard links.
>
>> It appears that in Terminal and in Finder, the both files appear to
>> have the same creation date. But I wonder if I'm missing some other
>> way to distinguish the dates.
>
>
> There is only one file, and thus only one creation date.
>
> Another way to think of it is that all files are hard links; it's just that
> most files have a hard link count of 1. When you create a new link, you
> increase the hard link count for that file by 1. When you remove a hard link
> by calling unlink(2), then you decrease the hard link count by 1. When the
> count reaches zero, the system reclaims the file's blocks.
>
> --
> Dave Carrigan
> email@hidden
> Seattle, WA, USA
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden