Fixes #2919.
Suggested by Karel Zak <kzak@redhat.com>.
The original code used an obsolete formula to make a device number from
given major and minor numbers.
ts_device_make is a new helper function based on the formula of
__SYSMACROS_DEFINE_MAKEDEV macro defined in
/usr/include/bits/sysmacros.h of GNU libc.
Suggested by Karel Zak <kzak@redhat.com> in #2919.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
return $res
}
+# Based on __SYSMACROS_DEFINE_MAKEDEV macro
+# defined in /usr/include/bits/sysmacros.h of GNU libc.
+function ts_makedev
+{
+ local major="$1"
+ local minor="$2"
+ local dev
+
+ dev=$(( ( major & 0x00000fff ) << 8))
+ dev=$((dev | ( major & 0xfffff000 ) << 32))
+ dev=$((dev | ( minor & 0x000000ff ) << 0))
+ dev=$((dev | ( minor & 0xffffff00 ) << 12))
+ echo $dev
+}
+
function ts_is_uuid()
{
printf "%s\n" "$1" | grep -E -q '^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$'
echo 'DEV[RUN]:' $?
local MAJ=${DEV%:*}
local MIN=${DEV#*:}
- local DEVNUM=$(( ( MAJ << 8 ) + MIN ))
+ local DEVNUM=$(ts_makedev "$MAJ" "$MIN")
local STAT_DEVNUM=$(stat -c "%d" "$FILE")
echo 'STAT[RUN]:' $?
if [ "${DEVNUM}" == "${STAT_DEVNUM}" ]; then