1

I have a permission error in a Rancher container's shell when accessing certain directory, but the permissions are correctly set. Then I noticed that the link count for said directory is zero, as shown: enter image description here

But for any directory, the minimum amount of links is 2, self . and parent ... So why would it show a 0 here? I don't get it. Right now I don't have access to this shell to check which inode it's pointing to (ls -i), but I guess it would be empty (I don't really know, TBH).

I'll try removing and then mkdiring it again to see if that solves it, but I'd really like to understand why this is happening.

Thanks!!

PS: I don't know if it being a Rancher container affects in any way.

2
  • "For any directory, the minimum amount of links is 2" This isn't universally true. Some filesystems neither include nor count . or .. links (I believe btrfs is one such filesystem). So, what was the command, and what was the error?
    – Fox
    Mar 1, 2018 at 22:07
  • 1
    @Fox In this case it applies. On a fresh container, this very same image has the two hard links for that folder. Tried removing it with rm -rf /backup but didn't work. It says that "the resource is busy". Mar 2, 2018 at 14:53

1 Answer 1

0

POSIX requires the link count to be at least 2, and in general, 2 + the number of subdirs, as long as the directory isn't rmdir'd. If the directory is deleted, then the link count is generally 0.

Not all filesystems are POSIX, however. While generally filesystems usable as root filesystem on UNIX generally are, btrfs is the lone exception, as it works mostly fine as root fs, but is non-POSIX.

On GNU/Linux (and many, but not all other POSIX systems), when a filesystem does not follow POSIX semantics, it usually uses a link count of 1, which does not occur during normal operations (0, 2 and higher are possible, but not 1). Utilities such as GNU find will adapt to this by special-casing directories with link count of 1 as being non-POSIX, resulting in potentially slower operation.

In your case, a link count of 1 would indi9cate that this is a non-POISIX filesystem, while a link count 0 zero smells more like a bug in the filesystem implementation, as it is not a sensible value.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .