Skip to content

Instantly share code, notes, and snippets.

@aveexy
Created October 2, 2022 20:53
Show Gist options
  • Save aveexy/0259926f22503f0303586f2110ac5216 to your computer and use it in GitHub Desktop.
Save aveexy/0259926f22503f0303586f2110ac5216 to your computer and use it in GitHub Desktop.
Make a simple copy of the /dev directory, usefull for systems that have no devfs and don't support mount --bind of regular directories
#!/bin/sh
create_nod() {
name=$(basename "$1")
major=$(ls -la "$1" | sed -r 's/ +/ /g' | cut -d " " -f5 | sed 's/.$//')
minor=$(ls -la "$1" | sed -r 's/ +/ /g' | cut -d " " -f6)
mknod "$name" $2 $major $minor
}
for f in /dev/*; do
if [ -b "$f" ]; then
create_nod "$f" b
elif [ -c "$f" ]; then
create_nod "$f" c
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment