aboutsummaryrefslogtreecommitdiffstats
path: root/mdev/lib/ttydev
diff options
context:
space:
mode:
Diffstat (limited to 'mdev/lib/ttydev')
-rwxr-xr-xmdev/lib/ttydev51
1 files changed, 51 insertions, 0 deletions
diff --git a/mdev/lib/ttydev b/mdev/lib/ttydev
new file mode 100755
index 0000000..a330d8f
--- /dev/null
+++ b/mdev/lib/ttydev
@@ -0,0 +1,51 @@
+#!/bin/busybox ash
+
+#
+# This will work, but it is a useless overhead for every tty
+# that might be created. Only use it, if there is really some
+# dirty compatibility with udev that won't resolve otherwise!
+# You have been warned!
+#
+
+# $MDEV
+# $ACTION
+
+if [ "${MDEV}" = "console" ] || [ "${MDEV}" = "null" ];
+then
+ chmod 600 ${MDEV}
+fi
+
+CHAR=$(cat /sys/${DEVPATH}/dev)
+
+case "$ACTION" in
+ add|"")
+ if [ -n "${CHAR}" ];
+ then
+ mkdir -p char
+ cd char
+ [ -e "${CHAR}" ] && rm -f ${CHAR}
+ ln -s ../${MDEV} ${CHAR}
+ cd ..
+ fi
+ ;;
+ remove)
+ [ -e char/${CHAR} ] && rm -f char/${CHAR}
+
+ if [ -e char ];
+ then
+ cd char
+ SLS=$(ls -l \
+ | awk "/..\/${MDEV}/ {print \$9 }")
+ for FILE in ${SLS};
+ do
+ rm -f ${FILE}
+ done
+ cd ..
+
+ rmdir char 2>/dev/null
+ fi
+ ;;
+esac
+
+exit 0
+