Why in Midnight Commander the chmod has 5 digits and what for?

4

1

In the file menu if I go to chmod, it returnes the chmod value for the folder / file.

I understand the last 3 digits, the second is setuid/setgid/sticky bit (have read the docs on it but its use is not that clear to me)... and then there is the first digit which I guess is for file/folder and what else? Like for a folder the digit is 4, for file 0... what about the 2 and 6? I checked that the symbolic link doesn't have a separate chmod first digit value.

obeliksz

Posted 2013-11-04T14:13:46.350

Reputation: 343

Can you provide the actual text from the documentation that describes ths feature? – Ramhound – 2013-11-04T14:19:43.497

Answers

2

chmod, as you probably know, is short for “change mode”.  “mode” here refers to the st_mode field in the inode.  stat(2), the man page for the stat, fstat, and lstat system calls, shows st_mode values of up to seven digits.  Here’s an excerpt:

   S_IFSOCK   0140000   socket
   S_IFLNK    0120000   symbolic link
   S_IFREG    0100000   regular file
   S_IFBLK    0060000   block device
   S_IFDIR    0040000   directory
   S_IFCHR    0020000   character device
   S_IFIFO    0010000   FIFO

OK, the first digit is always zero, to indicate that the number is octal; we can ignore that.  MC seems to be ignoring the second one too.  So you can see that regular files have 0 for the third (i.e., the fifth from the right) digit, and directories have 4.   2 and 6 are character device and block device, respectively; you should see these only in /dev.  Named pipes should be 1, and file system sockets should be 4.    If symbolic links are displaying as 0, that’s odd; maybe somebody thought that displaying 2 would be too confusing.

Scott

Posted 2013-11-04T14:13:46.350

Reputation: 17 653