Hard Link - Link Counter

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:

    Before I had my first child, I never really looked forward in anticipation to the future. As I watched my son grow and learn, I began to imagine the world this generation of children would live in. I thought of the children they would have, and of their children. I felt connected to life both before my time and beyond it. Children are our link to future generations that we will never see.
    Louise Hart (20th century)

    The individual protests against the world, but he doesn’t get beyond protest, he is just a single protester. When he wants to be more than that, he has to counter power with power, he has to oppose the system with another system.
    Friedrich Dürrenmatt (1921–1990)