filesystem timestamps and their usage

Oliver Fromme olli at lurza.secnetix.de
Thu Sep 13 08:05:11 PDT 2007


deeptech71 at gmail.com wrote:
 > I know that every stuff like this is different here and there, and
 > actually the topic should have been named something like "let's make
 > a filesystem, what timestamps would you recommend?". I've already
 > looked up information about the UFS times (didn't know what birthtime
 > is though). But thanks anyway. What surprized me is that these are
 > standardized.

Of course they are.  After all, the "U" in UFS means UNIX.
And how do you think NFS would work across different systems
if time stamp semantics weren't standardized?

 > How do you detect UFS hard links from a program?

What do you mean, exactly?  Every file is an inode,
and every directory entry (file name) is a hard link
to an inode.  An inode can have zero, one, or more
names (hard links) within a file system.  So, asking
how to "detect hard links" does not make sense.

Do you mean how to find the number of hard links of
an inode?  That's stored in the st_nlink value when
you perform a stat(2), lstat(2) or fstat(2) syscall.

 > Do these "virtual files" have the same birth time?

Hard links are not "virtual files".  A hard link is a
directory entry that points to an inode.  There is
nothing virtual about it.

All properties ("meta data") of a file are stored in
the inode.  That includes owner, permissions, flags,
and all the time stamps, including the birth time.

A directory entry is just a name (character string)
and a pointer to the inode.  So if you have multiple
entries (hard links) pointing to the same inode,
they point to the same meta data.  In other words,
multiple hard links of the same inode cannot have
different time stamps, permissions, owner etc.

You can easily test it yourself:

$ date; touch a; sleep 10; date; ln a b; ls -liTU a b
Thu Sep 13 17:02:49 CEST 2007
Thu Sep 13 17:02:59 CEST 2007
3651805 -rw-------  2 olli  olli  0 Sep 13 17:02:49 2007 a
3651805 -rw-------  2 olli  olli  0 Sep 13 17:02:49 2007 b
$ 

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

Passwords are like underwear.  You don't share them,
you don't hang them on your monitor or under your keyboard,
you don't email them, or put them on a web site,
and you must change them very often.


More information about the freebsd-chat mailing list