6
2
I am not sure if the following issue is specific to busybox: I have an embedded device with busybox installed. From what I understand, when a directory is created, usually 2 hidden files will be automatically created: .
to represent the current directory and ..
to represent the parent directory. For example, by typing mkdir -p /tmp/normal_dir; cd /tmp/normal_dir; ls -a
, the output will be . ..
.
However, I have seen a case where an existing directory (/tmp/strange_dir
) does not show .
and ..
. That is, by typing cd /tmp/strange_dir; ls -a
, the output is empty, although navigating to the parent directory still works. That is, by typing cd ..
, the content is correct.
My question is: How could such a directory without .
and ..
(like /tmp/strange_dir
) be created? I am puzzled.
Interesting question. Might be better to ask on Unix.SE. My instinct is to
stat
the directory; doescd strange_dir; stat -l .
give anything? – Sean Allred – 2015-08-18T04:03:48.050Do others directory show
.
and..
?, maybe what's modified is thels
command, for example by creating an aliasls
that internally calls the regularls
but strips from the output the.
and..
results. – Javier Mr – 2015-08-18T06:37:32.657Only '/tmp/strange_dir' has this issue. Typing 'stat -L /tmp/strange_dir' results in an output that is similar to any other directory I have tried. One major observed difference is that the Size is 0 while other directories have Size greater than 0. For example, creating a new directory by using 'mkdir -p' will result in a Size of 40. Maybe Size 0 is the direct cause of not showing '.' and '..'. So the next question might be: How to create a directory with Size equal to 0? – jonathanzh – 2015-08-18T16:33:38.913
Are you sure it's actually a directory and not something else ("Everything is a file")?
– Breakthrough – 2015-08-19T04:54:46.563@Breakthrough: The OP says that
cd /tmp/strange_dir
works; that would seem to prove that it is a directory. – Scott – 2015-08-19T09:16:32.213@Scott not necessarily; it's possible that
– Breakthrough – 2015-08-19T10:47:29.230strange_dir
is a symlink to another directory in this case, or it could be something like a hardware device mapped with a pseudo-filesystem, like/proc
(see On linux, what does it mean when a directory has size 0 instead of 4096? from Server Fault).@Breakthrough: It seems to me that you're splitting hairs. If
strange_dir
is a symlink, it must be a symlink to a directory, which is where you end up when youcd strange_dir
. And filesystem mount points are still directories — even/proc
and/sys
have.
and..
— although it's true that "autofs" mount points are a bit funky. – Scott – 2015-08-19T13:04:05.170@Scott @Breakthrough Based on your comments I'm guessing that
strange_dir
may be related to autofs or pseudo-filesystem. But how to confirm this? – jonathanzh – 2015-08-19T22:28:34.800(1) IMNSHO, it’s unlikely that you’d have either an autofs or a pseudo-filesystem in
/tmp
. Isstrange_dir
really in/tmp
, or are you just saying that for anonymity purposes? (2) Look in/etc
for files whose names begin withauto
. In particular, look atauto.master
and any files whose names it lists. That should give you a clue as to whether you have an autofs. … (Cont’d) – Scott – 2015-08-20T01:50:28.287(Cont’d) … (3) I would suggest that you rename
strange_dir
(or, if you prefer, delete it). If you can’t rename or delete it, that may give us a clue as to what it is (i.e., depending on the error message, it might tell us that it might be something special). If you can rename or delete it, wait for a while and see whether it comes back. (Try tocd
to it, even if it doesn’t appear to exist.) If it doesn’t come back, reboot and see whether it comes back then. If it does, that will tell us that it was/is something special. If it doesn’t come back, it was probably just an anomaly. – Scott – 2015-08-20T01:52:16.223@Scott (1) The actual directory name is
/tmp/pluginshare/nbd/vfs
. I used/tmp/strange_dir
just for simplicity. (2) There is no file whose name begins withauto
under/etc
. (3) Trying to renamevfs
will result in a message like this: [mv: can't rename 'vfs': Device or resource busy]. The directory is always there after rebooting the device. – jonathanzh – 2015-08-20T17:09:02.857Thanks for the update.
vfs
might stand for Virtual File System, which would suggest that this is something magical. The fact that you cannot rename it, and that you get a somewhat unusual error message, tends to confirm that it is something special and not just a fluke. (The fact that it's still there after a reboot, if you couldn't rename it, is unsurprising and doesn't really tell us anything.) I'm running out of ideas; I suggest that you research VFS. If you figure out what you have, please post an answer here. If you don't, maybe you should ask a new question that reflects your research. – Scott – 2015-08-20T18:04:26.983... and, as Sean Allred suggested (in the first comment), if you do come back and post a new, smarter, more focused question, it might be better on unix.stackexchange. (But pick one site; don't post it on both.) – Scott – 2015-08-20T18:08:30.533