Where do I find documentation for the output of ls -l?

There have been multiple questions asked about this, like Understanding ls output, What are columns in ls -la?, What does ‘ls -la’ do?, What do the fields in ls -al output mean?, etc..
I’ve also come across many other websites with articles attempting to explain it.

What every single one of them seems to have in common is that despite writing down the meaning of the columns, there are never any links/references to where they acquired that information in the first place. An answer in the third question links to the coreutils manual, but much like the manpage that still provides no clarification.

The aforementioned resources are incomplete, as I’m developing a driver and found out ls -l provides the major and minor number for block/character devices (which is different from the regular output for files or directories):
enter image description here
Here the major/minor numbers for the device are 1 and 3 respectively.
I only discovered this because someone mentioned it in an answer (unrelated question). Had I wanted to know what these numbers meant before, I probably wouldn’t have been able to find out save for the unlikely event I stumbled on that answer. Or went looking in the source code.

It seems pretty weird for a tool that pretty much every single linux user uses, not to have any proper information available about it’s output. So am I missing something? Where is it documented?

EDIT: Muru in the comments referred to yet another question How to find what the fields in ls -l mean – the suggested answers in that question mention mostly the manpages (one outright pastes it), which for GNU coreutils does not provide a complete answer (manpage makes no mention of major/minor device numbers). The BSD manpage does, but Stephen’s answer of the posix standard is (I think) the most correct.

Asked By: TrisT

||

ls is specified by POSIX, that’s the common reference. The output formats are described in the “STDOUT” section.

Answered By: Stephen Kitt

Yes, the fact that the size field is replaced by major, minor for device files as has been the case since at least Research Unix v5 in 1974 and documented there since at least Research Unix v6 (couldn’t find a v5 man page) was not documented in the documentation of the GNU implementation of ls (now fixed following this bug report, thanks to you).

The POSIX specification of the ls utility which most ls implementations including GNU ls¹ do try to conform to does mention that the size is replaced by some implementation-defined […] <device-info> information associated with the device in question, though in the case of GNU ls like in the original Unix implementation, that is always major, minor. Contrary to the original Unix implementation though, GNU ls guarantees that there be always at least one space in addition to the comma between major and minor device number².


¹ at least when in a POSIX environment like when the POSIXLY_CORRECT environment variable is set and none of the BLOCKSIZE, BLOCK_SIZE, LS_BLOCK_SIZE ones are, though none of those are relevant in this instance.

² that’s also the case of several other ls implementations such as the ones from busybox or toybox also commonly found on Linux-based systems (and themselves not POSIX-compliant), but not all. The one from ast-open for instance never includes a space and 0-pads all numbers to a length of 3 (like 001,005) while some still space-pad them to a length of 3 resulting in a variable number of whitespace delimited fields ( 1, 5 vs 7,128 for instance). One of the many reasons why the output of ls -l cannot be parsed reliably nor portably.

Answered By: Stéphane Chazelas