Link Counter
Most file systems that support hard links use reference counting. An integer value is stored with each physical data section. This integer represents the total number of links that have been created to point to the data. When a new link is created, this value is increased by one. When a link is removed, the value is decreased by one. If the link count becomes zero, the operating system usually automatically deallocates the data space of the file if no process has the file opened for access. The maintenance of this value assists users in preventing data loss. This is a simple method for the file system to track the use of a given area of storage, as zero values indicate free space and nonzero values indicate used space.
On POSIX-compliant operating systems, such as many Unix-variants, the reference count for a file or directory is returned by the stat or fstat system calls in the st_nlink
field of struct stat
.
Read more about this topic: Hard Link
Famous quotes containing the words link and/or counter:
“The secret of biography resides in finding the link between talent and achievement. A biography seems irrelevant if it doesnt discover the overlap between what the individual did and the life that made this possible. Without discovering that, you have shapeless happenings and gossip.”
—Leon Edel (b. 1907)
“Speaking of contraries, see how the brook
In that white wave runs counter to itself.
It is from that in water we were from
Long, long before we were from any creature.”
—Robert Frost (18741963)