Frage

Could there ever be a situation in which touch would work and mkdir would fail, within a directory.

I understand that both these calls involve writing to the inode of the parent directory. So if touch worked, doesn't it automatically mean that the inode is writable and hence, the mkdir couldn't possibly fail.

This was Android (I only heard a report, didn't actually see this case) and the commands were being run from the terminal emulator, in the /system directory (after requesting su), but that shouldn't make a difference IMO.


EDIT: mkdir failed with "permission denied"

War es hilfreich?

Lösung

There are a couple of ways I can think of by which this could happen:

1) If you have reached the maximum number of sub-directories in a directory (typically around 32000), you will not be able to mkdir, but you will be able to touch a file.

2) If you are very low on disk space, you will not be able to mkdir because it requires 4K, but you will be able to touch a file.

Andere Tipps

Perhaps you don't have write permissions on the parent directory? You would still be able to touch existing files in the directory if you own them or have write permissions on them. (However, calling touch on a file that does not exist will still fail since the directory is read-only.)

What's the output of stat on the parent directory and the touched files?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top