]> www.infradead.org Git - mtd-utils.git/commitdiff
ubi-utils: create control device node as well
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 18 Jan 2008 12:34:14 +0000 (14:34 +0200)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 18 Jan 2008 12:34:14 +0000 (14:34 +0200)
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/scripts/mkdevs.pl

index f0fd46477506cabc2fadd78259f7dfe49f150d78..46d47c5dbf0eeed3287e8764897a5f02a41d62c3 100755 (executable)
@@ -8,11 +8,22 @@
 # out UBI's major number.
 #
 
+# Create the control device as well if this UBI version supports them (were
+# added sice Linux kernel 2.6.24)
+my $ctrl = "/sys/class/misc/ubi_ctrl/dev";
+
+if (-e "$ctrl") {
+       open FILE, "<", $ctrl or die "Cannot open $ctrl file: $!\n";
+       my $devnums = <FILE>;
+       close FILE;
+
+       $devnums =~ m/(\d+):(\d+)/;
+       system("mknod /dev/ubi_ctrl c $1 $2");
+}
 
 my $proc = '/proc/devices';
 my $regexp = '(\d+) (ubi\d+)$';
 
-
 open FILE, "<", $proc or die "Cannot open $proc file: $!\n";
 my @file = <FILE>;
 close FILE;
@@ -30,3 +41,4 @@ foreach (@file) {
                system("mknod /dev/$2_$i c $1 $j");
        }
 }
+