Re: File type nomenclature in 170 Lassi Kortela 31 Jul 2020 16:25 UTC

>>> I very strongly prefer the predicates to returning a magic symbol,
>>
>> [...]
>
> Well, they're officially required POSIX sys/stat.h macros:
> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html

Those macros are just convenience to test for the various (st_mode &
S_IFMT) values: S_IFBLK, S_IFCHR, S_IFIFO, S_IFREG, S_IFDIR, S_IFLNK,
S_IFSOCK. Those values are required to exist by POSIX as well. Hence
from the C point of view it shouldn't make a difference whether
predicates or symbols are used.

>> block and character devices
>
> OpenBSD appears to still maintain the distinction:
>
>   0 brw-r-----  1 root  operator    0,   0 Jul 19  2019 wd0a
>   0 crw-r-----  1 root  operator    3,   0 Jul 19  2019 rwd0a
>
> Plus several man and FAQ pages did not contradict the above.
>
> I'd be particularly unhappy if we decide to throw it away because
> Linux does things its own way (especially since I anticipate mostly
> abandoning Linux for OpenBSD in a very few years).  Back in the UNIX™
> days it could make quite a difference which you used.

Yes, the technical distinction is still there (and won't go away since
it's enshrined in POSIX). But I can't think of any practical thing that
a modern userland program can do to a block device that it can't do to a
character device (or vice versa).

What you need to know in practice is which device driver a paticular
device node is using: disk, network, terminal, etc. And it varies by OS
whether e.g. a disk is a block or character device. On Linux the only
block devices left seem to be disks; on FreeBSD there are none.