ls gives incorrect directory listing

Bug #1019316 reported by jan5000
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
coreutils (Ubuntu)
Opinion
Low
Unassigned

Bug Description

/* At this point I am expecting some files in /TEST/EXPORT, want to see them in received order... */

ubuntu@test-0001:~/TEST/EXPORT$ ls -ltr
total 0

/* None???!!! what? */

ubuntu@test-0001:~/TEST/EXPORT$ ls

/* Huh? - seen this many times now...I know the trick to making it work...*/

ubuntu@test-0001:~/TEST/EXPORT$ cd ..
ubuntu@test-0001:~/TEST$ cd EXPORT
ubuntu@test-0001:~/TEST/EXPORT$ ls -ltr
total 32
-rw-rw-r-- 1 ubuntu ubuntu 241 Jun 29 15:51 AA_TEST000002_20120629145129_abcde_efghi_20120629145127.kkk
-rw-rw-r-- 1 ubuntu ubuntu 20 Jun 29 16:03 AA_TEST000002_20120629150314_xyz
-rw-rw-r-- 1 ubuntu ubuntu 242 Jun 29 16:06 AA_ABC1234568_20120629150615_abcde_efghi_20050101120218.kkk
-rw-rw-r-- 1 ubuntu ubuntu 20 Jun 29 16:06 AA_TEST000002_20120629150643_xyz
-rw-rw-r-- 1 ubuntu ubuntu 20 Jun 29 16:10 AA_TEST000002_20120629151012_xyz
-rw-rw-r-- 1 ubuntu ubuntu 20 Jun 29 16:13 AA_TEST000002_20120629151342_xyz
-rw-rw-r-- 1 ubuntu ubuntu 20 Jun 29 16:17 AA_ABC1234568_20120629151707_xyz
-rw-rw-r-- 1 ubuntu ubuntu 20 Jun 29 16:17 AA_TEST000002_20120629151711_xyz

/* That's more like it!!! */

ubuntu@test-0001:~/TEST/EXPORT$ ls --version
ls (GNU coreutils) 8.13
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Richard M. Stallman and David MacKenzie.

ubuntu@test-0001:~/TEST/EXPORT$ lsb_release -rd
Description: Ubuntu 12.04 LTS
Release: 12.04

Tags: bot-comment
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/1019316/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
affects: ubuntu → coreutils (Ubuntu)
Revision history for this message
C de-Avillez (hggdh2) wrote :

Thank you for opening this bug and helping make Ubuntu better. I know of at least one situation where this can happen -- but I do not know if it applies to you:

0. open a terminal; on it, follow steps 1-4
1. mkdir /tmp/test/here
2. cd /tmp/test/here
3. touch a
4. ls

You should now see the file 'a' under this directory structure.

5. open *ANOTHER* terminal, and do NOT close the first. On this new terminal:
6. rm -rf /tmp/test/here
7. Go back to the FIRST terminal
8. ls
You should see zero files
8. Go to the SECOND terminal
9. mkdir /tmp/test/here
10. touch /tmp/test/here/b
11. ls

You should see the file 'b' you just touched.

12. go back to the FIRST terminal
13. ls

You will see NO files.

This is expected, and not an error.

Now, how did you go? Who creates the directories? Removes them? Please give us more details on what is going on in the background.

Changed in coreutils (Ubuntu):
importance: Undecided → Low
status: New → Incomplete
Revision history for this message
jan5000 (jan5000) wrote :

Thanks for that. Interesting.
I have a script (called "clean") which manually removes some of my application directories and their contents (i.e. the EXPORT directory, and subdirectories) , and I have a program (which I wrote) which when it starts will recreate a new EXPORT directory, and subdirectories if they don't exist. Depending on whether you run ls from a new terminal or one which has been around for a while, and depending on when you run the clean script or program, you sometimes get unexpected results in terms of directory listings in terminal windows which don't reflect what actually happened in the directory moments before.

 I must admit I am concious of not trusting (a bit strong, I apologise) ls (when I am developing my application), unless I either bounce to the parent and back again (i.e. as per my report ), or I cd to it from a new terminal. It's very difficult to explain because it's inconsistent. But I see from your example you've illustrated similar ls behaviour.

Can you explain: "This is expected, and not an error". You would have thought that all termnials (and ls running on each termianl) would keep "in sync" with any changes to the directory which may occur from other terminals or indeed (in my case) other programs or scripts, and report the "truth", As a "Windows lover" said to me yesterday (tongue in cheek) "That wouldn't have happened on Windows 7". Sadly (as a Linux application developer / Windows 7 (when I have to) user) I did not have any defence to offer...

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for coreutils (Ubuntu) because there has been no activity for 60 days.]

Changed in coreutils (Ubuntu):
status: Incomplete → Expired
Revision history for this message
C de-Avillez (hggdh2) wrote :

Sorry for the delay, this fell in a crack. I reset it to OPINION -- this is not a bug, anyway. I will still be looking at it.

As far as I can remember (sorry, no more Windows available to test) you cannot remove a Windows directory if it is in use -- if, for example, you are sitting on a command prompt under it. This type of restriction does not (usually) exist in UNIX/Linux: you *can* remove an in-use file (or directory). Of course, doing so will cause all types of trouble for any user of the (now nonexistent) directory -- like the problem you see, and I showed how to replicate.

There is no 'sync-ing' -- the moment you delete a file (or directory) it is gone. And the terminal you had under the directory now is sitting over nothing.

Changed in coreutils (Ubuntu):
status: Expired → Opinion
Revision history for this message
jan5000 (jan5000) wrote : Re: [Bug 1019316] Re: ls gives incorrect directory listing
Download full text (3.3 KiB)

I understand now.

"you cannot remove a Windows directory if it is in use -- if, for example,
you are sitting on a command prompt under it. This type of restriction
does not (usually) exist in UNIX/Linux: you *can* remove an in-use file
(or directory)."

The penny has dropped!

Thank you!

________________________________
 From: C de-Avillez <email address hidden>
To: <email address hidden>
Sent: Monday, 3 September 2012, 21:19
Subject: [Bug 1019316] Re: ls gives incorrect directory listing

Sorry for the delay, this fell in a crack. I reset it to OPINION -- this
is not a bug, anyway. I will still be looking at it.

As far as I can remember (sorry, no more Windows available to test) you
cannot remove a Windows directory if it is in use -- if, for example,
you are sitting on a command prompt under it. This type of restriction
does not (usually) exist in UNIX/Linux: you *can* remove an in-use file
(or directory). Of course, doing so will cause all types of trouble for
any user of the (now nonexistent) directory -- like the problem you see,
and I showed how to replicate.

There is no 'sync-ing' -- the moment you delete a file (or directory) it
is gone. And the terminal you had under the directory now is sitting
over nothing.

** Changed in: coreutils (Ubuntu)
       Status: Expired => Opinion

--
You received this bug notification because you are subscribed to the bug
report.
https://bugs.launchpad.net/bugs/1019316

Title:
  ls gives incorrect directory listing

Status in “coreutils” package in Ubuntu:
  Opinion

Bug description:

  /* At this point I am expecting some files in /TEST/EXPORT, want to see them in received order... */

  ubuntu@test-0001:~/TEST/EXPORT$ ls -ltr
  total 0

  /* None???!!! what? */

  ubuntu@test-0001:~/TEST/EXPORT$ ls

  /* Huh? - seen this many times now...I know the trick to making it
  work...*/

  ubuntu@test-0001:~/TEST/EXPORT$ cd ..
  ubuntu@test-0001:~/TEST$ cd EXPORT
  ubuntu@test-0001:~/TEST/EXPORT$ ls -ltr
  total 32
  -rw-rw-r-- 1 ubuntu ubuntu 241 Jun 29 15:51 AA_TEST000002_20120629145129_abcde_efghi_20120629145127.kkk
  -rw-rw-r-- 1 ubuntu ubuntu  20 Jun 29 16:03 AA_TEST000002_20120629150314_xyz
  -rw-rw-r-- 1 ubuntu ubuntu 242 Jun 29 16:06 AA_ABC1234568_20120629150615_abcde_efghi_20050101120218.kkk
  -rw-rw-r-- 1 ubuntu ubuntu  20 Jun 29 16:06 AA_TEST000002_20120629150643_xyz
  -rw-rw-r-- 1 ubuntu ubuntu  20 Jun 29 16:10 AA_TEST000002_20120629151012_xyz
  -rw-rw-r-- 1 ubuntu ubuntu  20 Jun 29 16:13 AA_TEST000002_20120629151342_xyz
  -rw-rw-r-- 1 ubuntu ubuntu  20 Jun 29 16:17 AA_ABC1234568_20120629151707_xyz
  -rw-rw-r-- 1 ubuntu ubuntu  20 Jun 29 16:17 AA_TEST000002_20120629151711_xyz

  /* That's more like it!!! */

  ubuntu@test-0001:~/TEST/EXPORT$ ls --version
  ls (GNU coreutils) 8.13
  Copyright (C) 2011 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.

  Written by Richard M. Stallman and David MacKenzie.

  ubuntu@test-0001:~/TEST/EXPORT$ lsb_release -rd
  Description:    Ubuntu 12.04 LTS
  Release:   ...

Read more...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.