From e90ecdd191fff4e3de4b6d67b59b91a9b283aa53 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Mon, 11 Feb 2008 17:11:36 -0300 Subject: [PATCH] Added read_nodes.sh and create_nodes.sh helpers to udev package, which are not expected to be installed. --- filesystem/udev/create_nodes.sh | 52 +++++++++++++++++++++++++++++++++ filesystem/udev/read_nodes.sh | 44 ++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100755 filesystem/udev/create_nodes.sh create mode 100755 filesystem/udev/read_nodes.sh diff --git a/filesystem/udev/create_nodes.sh b/filesystem/udev/create_nodes.sh new file mode 100755 index 000000000..4bc21cd6a --- /dev/null +++ b/filesystem/udev/create_nodes.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../udev/create_nodes.sh +# Copyright (C) 2008 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- SDE-COPYRIGHT-NOTE-END --- + +cd "${1:-.}" + +while read type node mode uid gid data; do + case "$type" in + c) + rm -f "$node" + ;; + esac + + case "$type" in + d) + mkdir -v "$node" + ;; + l) + ln -snvf "$data" "$node" + ;; + c) + echo "mknod: Creating $node c $data" + mknod "$node" c $data + ;; + s) + echo "mkfifo: Creating $node" + mkfifo "$node" + ;; + esac + + case "$type" in + l) + ;; + *) + chmod "$mode" "$node" + ;; + esac + + chown "$uid:$gid" "$node" +done + diff --git a/filesystem/udev/read_nodes.sh b/filesystem/udev/read_nodes.sh new file mode 100755 index 000000000..d23a6596e --- /dev/null +++ b/filesystem/udev/read_nodes.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../udev/read_nodes.sh +# Copyright (C) 2008 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- SDE-COPYRIGHT-NOTE-END --- + +nodes_read() { + local prefix="$1" dir="$2" node= nodename= mode= type= data= + for nodename in $( cd "$dir"; ls -1d * 2> /dev/null ); do + node="$dir/$nodename" + mode=$( stat -c '%a %U %G' "$node" ) + label="$prefix$nodename" + type='?' + data= + + if [ -L "$node" ]; then + type='l' + data=$( readlink "$node" ) + elif [ -d "$node" ]; then + type='d' + elif [ -c "$node" ]; then + type='c' + data=$( stat -c '%t %T' "$node" ) + elif [ -S "$node" ]; then + type='s' + fi + + echo "$type $label $mode${data:+ $data}" + [ "$type" != d ] || nodes_read "$label/" "$node" + done +} + +for dir; do + nodes_read "" "${dir%/}" +done