Re: Patch to implement getattr [patch]

Jamie Lokier (lkd@tantalophile.demon.co.uk)
Thu, 15 Jul 1999 02:06:42 +0200


Alexander Viro wrote:
> > cpio, tar, cp etc. use stat() to check inumbers to find hard links. Of
> > course if inumbers change then they won't find the hard links.
>
> It doesn't happen fast. And such usage of stat() brings a race - you do
> stat() on foo, somebody does rename("bar", "foo"), you do stat() on baz
> and happily decide that foo and baz are identical. They *were* identical,
> all right, but they are different now.

Yes quite, I had been mulling over that a few days ago.

cpio et al. cannot check for hard links perfectly, if the names change
while they're scanning. FAT makes it different but only very rarely,
and no less correctly.

> > Isn't there problem that if the file is renamed, then leaves the kernel
> > cache, and is brought back by a later stat(), it gets a different ino?
>
> rename() has nothing with it. Internal cache is slave to icache - when
> inode is going to be purged it leaves the internal cache. Forcibly. Glue
> allows to do it safely - look at the posting I refered to and you'll see
> how it's done.

Yes yes, I believe the code is perfect :)
rename() mentioned only because it can change directory entry location.

-- Jamie

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/