summaryrefslogtreecommitdiff
path: root/ubi-utils/old-tools/scripts/mkdevs.pl
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-01-23 19:42:44 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-01-23 20:01:03 +0200
commit45941c0018cc0937beeb9d4aa8e6a6070c7a3466 (patch)
treee65cad8bac744151b047136e9643abf1e343dd97 /ubi-utils/old-tools/scripts/mkdevs.pl
parent3ad29ab55ad71d706152781b70a43d9f6be407b9 (diff)
ubi-utils: return old tools
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/old-tools/scripts/mkdevs.pl')
-rwxr-xr-xubi-utils/old-tools/scripts/mkdevs.pl32
1 files changed, 32 insertions, 0 deletions
diff --git a/ubi-utils/old-tools/scripts/mkdevs.pl b/ubi-utils/old-tools/scripts/mkdevs.pl
new file mode 100755
index 0000000..f0fd464
--- /dev/null
+++ b/ubi-utils/old-tools/scripts/mkdevs.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/perl -w
+
+#
+# Author: Artem B. Bityutskiy <dedekind@oktetlabs.ru>
+#
+# A small scrip which creates UBI device nodes in /dev. UBI allocates
+# major number dynamically, so the script looks at /proc/devices to find
+# out UBI's major number.
+#
+
+
+my $proc = '/proc/devices';
+my $regexp = '(\d+) (ubi\d+)$';
+
+
+open FILE, "<", $proc or die "Cannot open $proc file: $!\n";
+my @file = <FILE>;
+close FILE;
+
+foreach (@file) {
+ next if not m/$regexp/g;
+ print "found $2\n";
+
+ system("rm -rf /dev/$2");
+ system("mknod /dev/$2 c $1 0");
+
+ for (my $i = 0; $i < 128; $i += 1) {
+ system("rm -rf /dev/$2_$i");
+ my $j = $i + 1;
+ system("mknod /dev/$2_$i c $1 $j");
+ }
+}