linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug: getcwd: cannot access parent directories
@ 2018-09-21  8:16 Roel Van de Paar
  2018-09-27  1:54 ` Roel Van de Paar
  0 siblings, 1 reply; 4+ messages in thread
From: Roel Van de Paar @ 2018-09-21  8:16 UTC (permalink / raw)
  To: linux-kernel

[1.] One line summary of the problem:

"cd: error retrieving current directory: getcwd: cannot access parent
directories: No such file or directory" on move of directories to
another volume

[2.] Full description of the problem/report:

Example output (testcase below):

/tmp/1/2$ cd ..
cd: error retrieving current directory: getcwd: cannot access parent
directories: No such file or directory
/tmp/1/2/..$ cd ..
cd: error retrieving current directory: getcwd: cannot access parent
directories: No such file or directory
/tmp/1/2/../..$ cd ..
cd: error retrieving current directory: getcwd: cannot access parent
directories: No such file or directory
/tmp/1/2/../../..$ cd ..
cd: error retrieving current directory: getcwd: cannot access parent
directories: No such file or directory
/tmp/1/2/../../../..$ cd ..
cd: error retrieving current directory: getcwd: cannot access parent
directories: No such file or directory
/tmp/1/2/../../../../..$ cd ..
cd: error retrieving current directory: getcwd: cannot access parent
directories: No such file or directory
/tmp/1/2/../../../../../..$ cd ..
/tmp$

- The number of ".." required is not correct
- The number of ".." matches the number of subdirs (see below)

[4.] Kernel information

Tested on latest updates of:
* Ubuntu Xenial
* Ubuntu Bionic
* Centos 7

[7.] A small shell script or example program which triggers the
problem (if possible)

In session 1
  cd /tmp
  mkdir -p 1/2
  cd 1/2

In session 2 (another terminal session)
  cd /tmp
  mkdir -p 3/4/5/6/7
  mv 1 3/4/5/6/7
  mv 3 /dev/shm   # where /dev/shm is some other disk. /dev/shm
reproduction works too. If the disk is the same, the issue will not
show.

Back to session 1
  cd ..   # fail
  cd ..   # fail
  cd ..   # fail
  cd ..   # fail
  cd ..   # fail
  cd ..   # fail
  cd ..   # works, but to completely incorrect directory given the
many 'cd ..'```

The problem is made more clear here by using 3/4/5/6/7 but you can
also just use a single subdir to see it

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug: getcwd: cannot access parent directories
  2018-09-21  8:16 Bug: getcwd: cannot access parent directories Roel Van de Paar
@ 2018-09-27  1:54 ` Roel Van de Paar
  2018-09-27 19:46   ` Casey Schaufler
  0 siblings, 1 reply; 4+ messages in thread
From: Roel Van de Paar @ 2018-09-27  1:54 UTC (permalink / raw)
  To: linux-kernel

Ping :)

On 21 September 2018 at 18:16, Roel Van de Paar
<roel.vandepaar@percona.com> wrote:
>
> [1.] One line summary of the problem:
>
> "cd: error retrieving current directory: getcwd: cannot access parent
> directories: No such file or directory" on move of directories to
> another volume
>
> [2.] Full description of the problem/report:
>
> Example output (testcase below):
>
> /tmp/1/2$ cd ..
> cd: error retrieving current directory: getcwd: cannot access parent
> directories: No such file or directory
> /tmp/1/2/..$ cd ..
> cd: error retrieving current directory: getcwd: cannot access parent
> directories: No such file or directory
> /tmp/1/2/../..$ cd ..
> cd: error retrieving current directory: getcwd: cannot access parent
> directories: No such file or directory
> /tmp/1/2/../../..$ cd ..
> cd: error retrieving current directory: getcwd: cannot access parent
> directories: No such file or directory
> /tmp/1/2/../../../..$ cd ..
> cd: error retrieving current directory: getcwd: cannot access parent
> directories: No such file or directory
> /tmp/1/2/../../../../..$ cd ..
> cd: error retrieving current directory: getcwd: cannot access parent
> directories: No such file or directory
> /tmp/1/2/../../../../../..$ cd ..
> /tmp$
>
> - The number of ".." required is not correct
> - The number of ".." matches the number of subdirs (see below)
>
> [4.] Kernel information
>
> Tested on latest updates of:
> * Ubuntu Xenial
> * Ubuntu Bionic
> * Centos 7
>
> [7.] A small shell script or example program which triggers the
> problem (if possible)
>
> In session 1
>   cd /tmp
>   mkdir -p 1/2
>   cd 1/2
>
> In session 2 (another terminal session)
>   cd /tmp
>   mkdir -p 3/4/5/6/7
>   mv 1 3/4/5/6/7
>   mv 3 /dev/shm   # where /dev/shm is some other disk. /dev/shm
> reproduction works too. If the disk is the same, the issue will not
> show.
>
> Back to session 1
>   cd ..   # fail
>   cd ..   # fail
>   cd ..   # fail
>   cd ..   # fail
>   cd ..   # fail
>   cd ..   # fail
>   cd ..   # works, but to completely incorrect directory given the
> many 'cd ..'```
>
> The problem is made more clear here by using 3/4/5/6/7 but you can
> also just use a single subdir to see it

Roel Van de Paar, Technical Director - Quality Assurance, Percona

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug: getcwd: cannot access parent directories
  2018-09-27  1:54 ` Roel Van de Paar
@ 2018-09-27 19:46   ` Casey Schaufler
  2018-09-27 21:01     ` Roel Van de Paar
  0 siblings, 1 reply; 4+ messages in thread
From: Casey Schaufler @ 2018-09-27 19:46 UTC (permalink / raw)
  To: Roel Van de Paar, linux-kernel

On 9/26/2018 6:54 PM, Roel Van de Paar wrote:
> Ping :)
>
> On 21 September 2018 at 18:16, Roel Van de Paar
> <roel.vandepaar@percona.com> wrote:
>> [1.] One line summary of the problem:
>>
>> "cd: error retrieving current directory: getcwd: cannot access parent
>> directories: No such file or directory" on move of directories to
>> another volume
>>
>> [2.] Full description of the problem/report:
>>
>> Example output (testcase below):
>>
>> /tmp/1/2$ cd ..
>> cd: error retrieving current directory: getcwd: cannot access parent
>> directories: No such file or directory
>> /tmp/1/2/..$ cd ..
>> cd: error retrieving current directory: getcwd: cannot access parent
>> directories: No such file or directory
>> /tmp/1/2/../..$ cd ..
>> cd: error retrieving current directory: getcwd: cannot access parent
>> directories: No such file or directory
>> /tmp/1/2/../../..$ cd ..
>> cd: error retrieving current directory: getcwd: cannot access parent
>> directories: No such file or directory
>> /tmp/1/2/../../../..$ cd ..
>> cd: error retrieving current directory: getcwd: cannot access parent
>> directories: No such file or directory
>> /tmp/1/2/../../../../..$ cd ..
>> cd: error retrieving current directory: getcwd: cannot access parent
>> directories: No such file or directory
>> /tmp/1/2/../../../../../..$ cd ..
>> /tmp$
>>
>> - The number of ".." required is not correct
>> - The number of ".." matches the number of subdirs (see below)
>>
>> [4.] Kernel information
>>
>> Tested on latest updates of:
>> * Ubuntu Xenial
>> * Ubuntu Bionic
>> * Centos 7
>>
>> [7.] A small shell script or example program which triggers the
>> problem (if possible)
>>
>> In session 1
>>   cd /tmp
>>   mkdir -p 1/2
>>   cd 1/2
>>
>> In session 2 (another terminal session)
>>   cd /tmp
>>   mkdir -p 3/4/5/6/7
>>   mv 1 3/4/5/6/7
>>   mv 3 /dev/shm   # where /dev/shm is some other disk. /dev/shm
>> reproduction works too. If the disk is the same, the issue will not
>> show.

Please try doing this under strace, in particular

	strace mv 3 /dev/shm

What you will see is that the mv command does a copy/delete
when changing filesystems. The original "2" directory, which
is your current working directory, will have no parent as the
original "1" will have been removed.

>>
>> Back to session 1
>>   cd ..   # fail
>>   cd ..   # fail
>>   cd ..   # fail
>>   cd ..   # fail
>>   cd ..   # fail
>>   cd ..   # fail
>>   cd ..   # works, but to completely incorrect directory given the
>> many 'cd ..'```
>>
>> The problem is made more clear here by using 3/4/5/6/7 but you can
>> also just use a single subdir to see it
> Roel Van de Paar, Technical Director - Quality Assurance, Percona

The system is working properly.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug: getcwd: cannot access parent directories
  2018-09-27 19:46   ` Casey Schaufler
@ 2018-09-27 21:01     ` Roel Van de Paar
  0 siblings, 0 replies; 4+ messages in thread
From: Roel Van de Paar @ 2018-09-27 21:01 UTC (permalink / raw)
  To: Casey Schaufler; +Cc: linux-kernel

Hi Casey,

On 28 September 2018 at 05:46, Casey Schaufler <casey@schaufler-ca.com> wrote:

> Please try doing this under strace, in particular
>
>         strace mv 3 /dev/shm
>
> What you will see is that the mv command does a copy/delete
> when changing filesystems. The original "2" directory, which
> is your current working directory, will have no parent as the
> original "1" will have been removed.
>
>>>
>>> Back to session 1
>>>   cd ..   # fail
>>>   cd ..   # fail
>>>   cd ..   # fail
>>>   cd ..   # fail
>>>   cd ..   # fail
>>>   cd ..   # fail
>>>   cd ..   # works, but to completely incorrect directory given the
>>> many 'cd ..'```
>>>
>>> The problem is made more clear here by using 3/4/5/6/7 but you can
>>> also just use a single subdir to see it
>> Roel Van de Paar, Technical Director - Quality Assurance, Percona
>
> The system is working properly.

Thank you for the analysis.

I can see your point, but it looks like this could be improved by
matching the behavior when not changing filesystems.

Also, there is a difference between working when it is a different
filesystem or not - so there is inconsistency in operation.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-27 21:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-21  8:16 Bug: getcwd: cannot access parent directories Roel Van de Paar
2018-09-27  1:54 ` Roel Van de Paar
2018-09-27 19:46   ` Casey Schaufler
2018-09-27 21:01     ` Roel Van de Paar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).