Re: hard link identification
On May 22, 2012, at 2:26 PM, Robert Bonomi wrote: dte...@freebsd.org wrote; For directories, the link-count is quite obviously the number of filesystem entities contained within. That is *INCORRECT*. Details. The OP wanted to know about files. I chose to not elaborate on the directory-case of the value (as it was not important to the OP). -- Devin _ The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: hard link identification
Devin Teske devin.te...@fisglobal.com wrote: On May 22, 2012, at 2:26 PM, Robert Bonomi wrote: dte...@freebsd.org wrote; For directories, the link-count is quite obviously the number of filesystem entities contained within. That is *INCORRECT*. Details. The OP wanted to know about files. I chose to not elaborate on the directory-case of the value (as it was not important to the OP). FACT: The count for a directory is _NOT_ the number of filesystem entities containted within, as you claimed. (Unless your notion of a 'filesystem entry' excludes (1) regular files, (2), named pipess, (3) device nodes, (4) unix sockets, (5) symlinks, AND everything else, _except_directories_, that appear as entries in a directory.) Tell me, according to your claim that for directories, the link-count is quite obviously the number of filesystem entities contained within, just _approximately_, what is the expected link count for a directory containing 135 regular files, 9 'dot files' (including '.' and '..'), and 26 sub- directories? No need for an exact answer. Just pick one -- do you claim the number is going to be close to 26, or to 170? The 'details' of the link count for a directory became significant only when someone posted grossly incorrect information about what that number meant. A 'name' inside a directory points to an 'inode'. the inode has a count of how many 'names' point to that inode. It doesn't make NOT ONE D*MN BIT of difference whether the contents of that inode are a directory, a regular file, a symlink, or whateverC -- the 'link count' has always exactly the same meaning. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: hard link identification
On 22 May 2012 13:06, Gary Aitken free...@dreamchaser.org wrote: Is there any way to tell if something is a hard link, other than ls -i of relevant files and seeing that the inode is the same? or a better way? Hard links are not special. You can't tell something is a hard link because normal files are exactly the same. You can use stat(1) to see how many hard links point to a file though. -- Eitan Adler ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
RE: hard link identification
-Original Message- From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd- questi...@freebsd.org] On Behalf Of Gary Aitken Sent: Tuesday, May 22, 2012 1:06 PM To: freebsd-questions@freebsd.org Subject: hard link identification Is there any way to tell if something is a hard link, other than ls -i of relevant files and seeing that the inode is the same? or a better way? I was a bit confused when looking at /root/.cshrc and then discovering a .cshrc in / as well. ls -l quickly enumerates the link-count of items in the current working directory (displayed as the second column, by-default). For directories, the link-count is quite obviously the number of filesystem entities contained within. For files, the link-count is the number of links to the same file. If this number is higher than 1, then the file you're looking at is a hard-link (which is also indistinguishable from the original). -- Devin _ The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
RE: hard link identification
dte...@freebsd.org wrote; For directories, the link-count is quite obviously the number of filesystem entities contained within. That is *INCORRECT*. The link-count on a directory is the number of dir- ectory entries (file names) tht resolve to it, just as with any other file. The count starts at *TWO* -- one for the directory name itself, plus one for the '.' self-refernce 'in' that directory -- plus one for the '..' reference in each and every sub-directory that is in that directory, PLUS one (albeit rare) for any other hard-linked names that also resolve to that diretory. To wit: $ mkdir foo# 'ls -l foo' will show a link-count of 2 $ touch foo/bar# 'ls -l foo' will show a link-count of 2 $ mkdir foo/baz# 'ls -l foo' will show a link-count of 3 $ ln -s foo foo2 # 'ls -l foo' will show a link-count of 3 $ ln foo quux # 'ls -l foo' will show a link-count of 4 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org