Symlink behaviour [was; Testing if two files are on the same file system]

2017-10-25 Thread Martijn Dekker
Op 25-10-17 om 14:40 schreef Stephane Chazelas: > The behaviour of df on symlinks is unspecified AFAICT Hmmm... Base Definitions, 3.381 Symbolic Link: | A type of file with the property that when the file is encountered | during pathname resolution, a string stored by the file is used to | modify

Re: Testing if two files are on the same file system

2017-10-25 Thread Stephane Chazelas
2017-10-25 12:01:04 +0200, Martijn Dekker: [...] > > I'm not sure what the output of "LC_ALL=C df -P" should be for a > > mount point like a UTF-8 /home/stéphane > > That's a good point. I had actually added LC_ALL=C to my 'df' > invocation, more out of habit than anything. I should remove it. I'

Re: Testing if two files are on the same file system

2017-10-25 Thread Stephane Chazelas
2017-10-25 11:17:56 +0200, Martijn Dekker: [...] > I'd like to be able to do something like: > > if is onsamefs "$file1" "$file2"; then > ln "$file2" "$file1"# hard links are possible Should probably be: ln -f -- "$file2" "$file1" -- Stephane

Re: Testing if two files are on the same file system

2017-10-25 Thread Stephane Chazelas
2017-10-25 10:11:35 +0200, Vincent Lefevre: > On 2017-10-24 21:11:45 +0200, Joerg Schilling wrote: > > Nick Stoughton wrote: > > > > If you are correct, this is a Linux kernel bug. > > > > > > Why? The stat command is not standardized. The --file-system argument > > > changes the output of %i to s

Re: Testing if two files are on the same file system

2017-10-25 Thread Robert Elz
Date:Wed, 25 Oct 2017 11:17:56 +0200 From:Martijn Dekker Message-ID: | if is onsamefs "$file1" "$file2"; then | ln "$file2" "$file1"# hard links are possible | else | ln -s "$file2" "$file1" | fi That's just creating a race condition. Much be

Re: Testing if two files are on the same file system

2017-10-25 Thread Martijn Dekker
Op 24-10-17 om 11:22 schreef Stephane Chazelas: > using sed on the output of df > # > > the output "df -P" is only specified in the POSIX locale. That's now how I read the spec at http://pubs.opengroup.org/onlinepubs/9699919799/utilities/df.html#tag_20_33_10 It says

Re: Testing if two files are on the same file system

2017-10-25 Thread Martijn Dekker
Op 23-10-17 om 17:36 schreef Vincent Lefevre: > The initial question was actually not clear. First, you should define > what a file system is. If this is not what is identified by st_dev[*], > what is it? That's a good point. What I mean is an instance of a file system on a particular device or pa

Re: Testing if two files are on the same file system

2017-10-25 Thread Robert Elz
Date:Wed, 18 Oct 2017 15:01:23 +0200 From:Martijn Dekker Message-ID: <4d781f3b-085c-d2ca-1912-b08410266...@inlv.org> | Is there a way, using POSIX shell and utilities, to reliably test if two | files are on the same file system? I have been ignoring this question

Re: Testing if two files are on the same file system

2017-10-25 Thread Vincent Lefevre
On 2017-10-24 21:11:45 +0200, Joerg Schilling wrote: > Nick Stoughton wrote: > > > If you are correct, this is a Linux kernel bug. > > > > Why? The stat command is not standardized. The --file-system argument > > changes the output of %i to something other than the inode ... no bug. > > Whether i