treewide: replace /sys/devices/virtual/ubi by /sys/class/ubi
authorDaniel Golle <daniel@makrotopia.org>
Wed, 15 Feb 2023 03:06:05 +0000 (03:06 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Wed, 15 Feb 2023 03:27:59 +0000 (03:27 +0000)
Starting from Linux Kernel version 6.3 UBI devices will no longer be
considered virtual, but rather have an MTD device parent. Hence they
will no longer be listed under /sys/devices/virtual/ubi which is
used in multiple places in OpenWrt. Prepare for future kernels by
using /sys/class/ubi instead of /sys/devuces/virtual/ubi.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
package/base-files/files/lib/upgrade/nand.sh
target/linux/bcm4908/base-files/lib/preinit/75_rootfs_prepare
target/linux/ipq40xx/base-files/lib/upgrade/linksys.sh
target/linux/ipq806x/base-files/lib/upgrade/linksys.sh
target/linux/kirkwood/base-files/lib/upgrade/linksys.sh
target/linux/mvebu/cortexa9/base-files/lib/upgrade/linksys.sh

index e7ac34f5d0cf3abfa66735db2151e059a642fdb8..907945b349bec3c86f0cb8bee7a2543c3f76e824 100644 (file)
@@ -28,7 +28,7 @@ ubi_mknod() {
 
 nand_find_volume() {
        local ubidevdir ubivoldir
-       ubidevdir="/sys/devices/virtual/ubi/$1"
+       ubidevdir="/sys/class/ubi/"
        [ ! -d "$ubidevdir" ] && return 1
        for ubivoldir in $ubidevdir/${1}_*; do
                [ ! -d "$ubivoldir" ] && continue
@@ -41,13 +41,12 @@ nand_find_volume() {
 }
 
 nand_find_ubi() {
-       local ubidevdir ubidev mtdnum
+       local ubidevdir ubidev mtdnum cmtdnum
        mtdnum="$( find_mtd_index $1 )"
        [ ! "$mtdnum" ] && return 1
-       for ubidevdir in /sys/devices/virtual/ubi/ubi*; do
-               [ ! -d "$ubidevdir" ] && continue
+       for ubidevdir in /sys/class/ubi/ubi*; do
+               [ ! -e "$ubidevdir/mtd_num" ] && continue
                cmtdnum="$( cat $ubidevdir/mtd_num )"
-               [ ! "$mtdnum" ] && continue
                if [ "$mtdnum" = "$cmtdnum" ]; then
                        ubidev=$( basename $ubidevdir )
                        ubi_mknod "$ubidevdir"
index 09c12cd31db3806a67fc7acd4ddbafe797e25f97..829dd6adf1343a9ae0eeffceee6500777a6b17a5 100644 (file)
@@ -23,7 +23,7 @@ rootfs_prepare() {
        ubinfo /dev/ubi0 -N metadata1 > /dev/null 2>&1 || return
 
        # Find UBI volume device (e.g. ubi0_123)
-       local ubivol="$(grep rootfs_data /sys/devices/virtual/ubi/ubi*/ubi*/name | sed -n 's/.*\(ubi\d*_\d*\).*/\1/p')"
+       local ubivol="$(grep rootfs_data /sys/class/ubi/ubi*/name | sed -n 's/.*\(ubi\d*_\d*\).*/\1/p')"
        if [ -n "$ubivol" ]; then
                bcm4908_verify_rootfs_data $ubivol
        else
index 5d25c20ad713c3b1c54a08051d31f44cad70ce44..c0d45d640ddf9b6db88b8db5590acc2e46b1bf6b 100644 (file)
@@ -3,7 +3,7 @@ linksys_get_target_firmware() {
 
        cur_boot_part="$(/usr/sbin/fw_printenv -n boot_part)"
        if [ -z "${cur_boot_part}" ]; then
-               mtd_ubi0=$(cat /sys/devices/virtual/ubi/ubi0/mtd_num)
+               mtd_ubi0=$(cat /sys/class/ubi/ubi0/mtd_num)
                case "$(grep -E "^mtd${mtd_ubi0}:" /proc/mtd | cut -d '"' -f 2)" in
                kernel|rootfs)
                        cur_boot_part=1
index 1feffc7aa2420b7ef4ba9d0a29a2cd1657984f7a..5f883637da58db39dda21bad817a46e115f5c85f 100644 (file)
@@ -8,7 +8,7 @@ linksys_get_target_firmware() {
 
        cur_boot_part=$(/usr/sbin/fw_printenv -n boot_part)
        if [ -z "${cur_boot_part}" ] ; then
-               mtd_ubi0=$(cat /sys/devices/virtual/ubi/ubi0/mtd_num)
+               mtd_ubi0=$(cat /sys/class/ubi/ubi0/mtd_num)
                case $(grep -E ^mtd${mtd_ubi0}: /proc/mtd | cut -d '"' -f 2) in
                kernel1|rootfs1)
                        cur_boot_part=1
index 7e20276fe5f6f307086f94ac2a1c322c32b6131e..9067f00e1a88d8fb42b597f074bd36551ea9f50d 100644 (file)
@@ -8,7 +8,7 @@ linksys_get_target_firmware() {
 
        cur_boot_part=$(/usr/sbin/fw_printenv -n boot_part)
        if [ -z "${cur_boot_part}" ] ; then
-               mtd_ubi0=$(cat /sys/devices/virtual/ubi/ubi0/mtd_num)
+               mtd_ubi0=$(cat /sys/class/ubi/ubi0/mtd_num)
                case $(grep -E ^mtd${mtd_ubi0}: /proc/mtd | cut -d '"' -f 2) in
                kernel|rootfs)
                        cur_boot_part=1
index 826bf8c9b50f0ecfce13c91d230d72786c34ffba..1a23a9bbc256c7e517e255504fb3c73c6ee0e24f 100644 (file)
@@ -8,7 +8,7 @@ linksys_get_target_firmware() {
 
        cur_boot_part=$(/usr/sbin/fw_printenv -n boot_part)
        if [ -z "${cur_boot_part}" ] ; then
-               mtd_ubi0=$(cat /sys/devices/virtual/ubi/ubi0/mtd_num)
+               mtd_ubi0=$(cat /sys/class/ubi/ubi0/mtd_num)
                case $(grep -E ^mtd${mtd_ubi0}: /proc/mtd | cut -d '"' -f 2) in
                kernel1|rootfs1)
                        cur_boot_part=1