large RPM --dump file modes

Viewed 14

    when using the command 
    rpm -ql package --dump | cut -d " " -f 1,5,6,7
    the man page says --dump returns (for fields 1,5,6,7) path mode owner group
    My output is
        /blah/file    040750 username groupname
        /blah/fileA  0120750 username groupname
        /blah/fileC  0100640 username groupname
    
    I understand the mode's last 3 digits. Normally, I would assume the 
    extra (left-most) digits would fall into 
    
    +1000 = sticky
    +2000 = gid
    +4000 = uid

But I can't get there with the 012 and 010 - it doesn't add up. It should only go to 070. what are these extra digits?

found more info - this field is permissions AND file type now looking for numeric file types. Anyone?

1 Answers

https://en.wikipedia.org/wiki/Unix_file_types says: In the stat structure, file type and permissions (the mode) are stored together in a st_mode bit field, which has a size of at least 12 bits (3 bits to specify the type among the seven possible types of files; 9 bits for permissions). The layout for permissions is defined by POSIX to be at the least-significant 9 bits, but the rest is undefined.[1]

By convention, the mode is a 16-bit value written out as a six-digit octal number without a leading zero. The format part occupies the lead 4-bits (2 octal digits), and "010" (1000 in binary) usually stands for a regular file. The next 3 bits (1 digit) are usually used for setuid, setgid, and sticky. The last part is already defined by POSIX to contain the permission. An example is "100644" for a typical file. This format can be seen in git, tar, and ar, among other places.[2]

The type of a file can be tested using macros like S_ISDIR. Such a check is usually performed by masking the mode with S_IFMT (often the octal number "170000" for the lead 4 bits convention) and checking whether the result matches S_IFDIR. S_IFMT is not a core POSIX concept, but a X/Open System Interfaces (XSI) extension; systems conforming to only POSIX may use some other methods.[1]

Related