I'm writing a program that does something similar to the disk usage utility on Linux, and I'm having trouble when it comes to Hard links.
I currently have the program running, and it determines whether a program has hard links. I use stat() on the file to determine this.
if (st.st_nlink > 1)
When I run this, both the link and the program that it is linked to return, but the disk usage utility would only report the program and not its hard link.
How do I tell the difference between a program and its hard link(s) in Linux using C?