-   Linux - Kernel (
-   -   Bug in mount bind: files turn into directories (

Pepijn Schmitz 05-05-2010 11:56 AM

Bug in mount bind: files turn into directories
I'm sorry for this lengthy post, but the problem is complex and hard to explain. In short: Linux sometimes thinks that everything in directories mounted with the bind option is a directory! Hopefully someone here can tell me what's going on or help me debug the problem.

I'm having a bizarre problem on my Ubuntu Karmic 64-bit workstation: a number of directories mounted using the "bind" option has suddenly started to show every file in them with the same permissions as the directory itself, including the fact that it is a directory! In other words, Linux suddenly thinks all the files in my bound directories are directories!

Here's a part of my /etc/fstab:


//diskstation/home /home/pepijn_remote cifs credentials=/home/pepijn.smbcredentials,uid=pepijn,gid=pepijn,iocharset=utf8 0 0
/home/pepijn_remote/Documents /home/pepijn/Documents none bind 0 0
/home/pepijn_remote/Downloads /home/pepijn/Downloads none bind 0 0

As you can see, I mount my remote home directory from my NAS on /home/pepijn_remote using CIFS. I then bind some of the directories from that share in my real home directory. This has worked perfectly for months now.

But then suddenly all hell broke loose. Programs started going haywire. It turned out that this was because Linux had suddenly decided that all the files in my directories were now directories! As you can imagine my IDE went berserk. To illustrate, here's (the first few lines of) the result of an "ls -al" in /home/pepijn_remote/Documents:


total 256
drwxrwxrw- 12 pepijn pepijn 0 2010-03-07 12:24 .
drwxr-xr-x 10 pepijn pepijn 0 2010-02-09 22:50 ..
-rw-r--r-- 1 pepijn pepijn 14702 2010-02-12 12:43 Afrekening Merlot.ods
-rw-r--r-- 1 pepijn pepijn 22287 2010-01-15 19:37 Afrekening New York en Atlanta.ods
-rw-r--r-- 1 pepijn pepijn 13153 2010-02-18 11:34 Amerika 2010.ods
drwxrwxrwx 3 pepijn pepijn 0 2010-01-06 13:04 Belastingdienst

Perfectly normal. But here's the result of the same command in /home/pepijn/Documents (which should be exactly the same, and has been for months):


total 12
drwxrwxrw- 12 pepijn pepijn 0 2010-03-07 12:24 .
drwxr-xr-x 139 pepijn pepijn 12288 2010-03-07 12:44 ..
drwxrwxrw- 12 pepijn pepijn 0 2010-03-07 12:24 Afrekening Merlot.ods
drwxrwxrw- 12 pepijn pepijn 0 2010-03-07 12:24 Afrekening New York en Atlanta.ods
drwxrwxrw- 12 pepijn pepijn 0 2010-03-07 12:24 Amerika 2010.ods
drwxrwxrw- 12 pepijn pepijn 0 2010-03-07 12:24 Belastingdienst

As you can see it thinks every file is a directory! In fact, the permissions of every entry are precisely the same as for ., the current directory. I have verified that the same goes for the other directories redirected using the "bind" option, they all have the same permissions as . for every file in the directory.

When it happens it plays havoc with my system, since any process which processes directories recursively (such as trackerd, the search indexer) gets stuck in an endless loop, consuming more and more resources.

It gets even more bizarre: not only does Linux think every file is a directory, but it even thinks non-existent files are directories!!! I can "cd" to a non-existent directory completely successfully as far as the shell is concerned, it even thinks I'm in the directory. Here's a snippet I copy and pasted from my terminal window:


~/Documents$ cd aasdghf
~/Documents/aasdghf$ cd fnurk
~/Documents/aasdghf/fnurk$ cd blah

Needless to say, I don't have a directory (nor a file) called aasdghf in my Documents directory. If I do an "ls" at this point I see the contents of the Documents directory (with every file listed as a directory with the same permissions as the Documents directory itself). If I try to do the same from /home/pepijn_remote I get:


/home/pepijn_remote/Documents$ cd aasdghf
bash: cd: aasdghf: No such file or directory

The problem is recurrent, but very unpredictable. When it happens, I can unmount all bound directories (after hunting down every process with open files on them) and mount them again and it will be fine for a while. When it first happened I was working in Netbeans (which I don't think had anything to do with the problem), it was not after rebooting or installing something or anything like that.

One program which seems to trigger the bug very often is Filezilla. For some reason when I start that the problem will almost always immediately occur. But not every time, and it also sometimes happens when Filezilla is not running.

I've filed a bug with Ubuntu, but they seem uninterested in helping me. I haven't received one single reply.

Hopefully someone here can help me! Is this a known problem? How can I debug it and try and find out what on Earth is going on? Many thanks in advance to anyone who can help me!

uname -a:
Linux peregrin 2.6.31-21-generic #59-Ubuntu SMP Wed Mar 24 07:28:27 UTC 2010 x86_64 GNU/Linux

mount --version:
mount from util-linux-ng 2.16 (with libblkid and selinux support)

Kind regards,
Pepijn Schmitz

smoker 05-09-2010 07:19 AM

I think you ought to read man mount and man fstab.
Forget what I wrote before, I was looking at an old version of man mount.

I suggest you use symlinks to your home directory, or use bind as specified in man mount.

Pepijn Schmitz 05-10-2010 04:34 AM

Forget what you wrote before? What do you mean? Yours is the first reply.

And I am using bind exactly as specified in man mount. If you think I'm not, could you please specify what you think I'm doing wrong?

Reg. Linux user - 74778

All times are GMT -5. The time now is 01:10 AM.