[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#48960: stat v8.30 - device number in decimal shown as 16bit number i

From: L A Walsh
Subject: bug#48960: stat v8.30 - device number in decimal shown as 16bit number instead of to converted 8bit
Date: Fri, 11 Jun 2021 11:21:04 -0700
User-agent: Thunderbird (Windows/20100228)

On 2021/06/11 00:37, Wolfgang Rohm wrote:

Stat prints the device number, major and minor, in hex and decimal. They are both 8bit numbers clamped together. While the hex number is perfectly fine, the decimal doesn't respect how this number has come to existence. There is no meaning in the decimal value, if the the hex value is taken as one 16bit number and then converted.

For example "fd00h" is converted to "64768d". There is no major device with 647 and no minor device with 768. Its just completely wrong.
   Aside from complete bogus output on my system for either
hex or decimal and the "seemingly" undocumented appearance of 'd'
to convert a 16-bit decimal value back to 2 8-bit values
divide the number by 256 or shift the value right by 8 bits
for the high number and either mod the number with 256 or
'and' (&) the value with 0xff:

decimal_devno=64768   #(dropping the 'd' on the end)
printf "%s:%s\n" "$high" "$low"


 or via shifts+masks

low=$((decimal_devno & 0xff))
printf "%s:%s\n" "$high" "$low"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]