How does POSIX distinguish files from directories?

214 Views Asked by At

How does POSIX distinguish files from directories?

On DOS and Windows, a directory is nothing more than a file with the D attribute. I tried to figure out how to differ them on POSIX-compatible operating systems like Linux and BSD, but it doesn't look as a quick and simple task. (This is probably because I don't use such an operating system, and therefore cannot test anything myself.)

I ask this question to improve my manual about naming files. Currently, it has the following passage:

Directory names can also be referred as file names; directories are nothing more than files with the D attribute.

I'm not sure this quote would be correct for POSIX.

1

There are 1 best solutions below

2
AudioBubble On

The operating system identifies files by what is known as an inode, stored in inode tables based on the types of files, rather than by their names or locations in directories. A device is also filename and stored in the directory /dev/ (e.g. /dev/ttyn)