my version runs in ~2 seconds with bash 4
pretty good improvement, but ash reduces it to under 1 second
I then tried it with busybox built to:
1)prefer applets, 2)run as a standalone shell and 3)run nofork applets directly
This got it down to just over 1/4 second
but out of curiousity I took a look at mknod and found out that it is only listed as a noexec applet, so I modified include/applets.src.h to change mknode from NOEXEC to NOFORK and that reduced the execution time to just over 1/10th of a second

Process to figure out what to do:
1) need to know environment variables and args that are passed
--->use env >>somefile in a dummy script
--->echo /root/dummy /proc/sys/kernel/hotplug
2)use this data to analyze what we may need to do.

attaching a gzip output from removing then reinserting a usb flash drive

Had strange messages for using double quotes in the
mknod "$DEV"/"$NAME" b $MAJOR $MINOR 2>$ERR line >
'sdb1' '8' '17'
/root/my-applications/bin/dyn_mknod: line 44: can't create : nonexistent directory Never had such before ..
BB is Lupu BusyBox v1.16.2 (2010-06-19 18:02:46 GMT-8 )
running a luma preview by plazdayz from 2010 ..
Funny the system still runs without the nodes

Anyway nice code . Have such similar in my /etc/init.d/alsa, but much more heavy:

there is no need to prepend busybox ... (if busybox has it ash will use it)
and ERR-... should be ERR=... (probably the error source)
and what was the point of adding the rm ... ?
its usually better to use [ ! -f "$VAR" ] && command "$VAR"
... as it is, your rework will remove all existing nodes that are found and not recreate it (bad when Puppy uses a static /dev), but rerunning mknod on an existing device is quick and fails harmlessly (thus the 2>/dev/null)
keep in mind this script should only run once, so there shouldn't be any preexisting nodes (aside from the static ones that could be wrong)
also unnecessary echoes in loops really slow down scripts and should only be used for debugging - you can use OUTPUT="$OUTPUT
$NEWDATA" in the loop and then echo $OUTPUT afterwards

but Puppy's busybox is pretty conservatively built, if you're building it for an initrd, the following should be enabled 1)prefer applets, 2)standalone shell and 3)run nofork applets directly
This alone makes a 5x speed improvement.

Another related tip
"$VAR1/$VAR2" makes the whole thing one string because all variables are expanded inside double quotes (but not in single quotes) - using "$A"/"$B" is unnecessary and just slows it down

FYI - this makes it possible to construct a large command with many arguments (including quoted ones) - especially useful with programs like dialog Xdialog

the while read blocks like that will skip the last line unless you do something like
while read LINE || [ "$LINE" ];do

guess we've been lucky the last thing is not important

in this case the LINE is a uevent file with shell formatted contents that can be sourced as a file with variable names, (but we may need to NULL out previous VARs if it is found that some uevent files do not contain all of MAJOR, MINOR, DEVNAME and DEVTYPE) such as:

Code:

while read LINE || [ "$LINE" ];do
MAJOR="" MINOR="" DEVNAME="" DEVTYPE=""
. "$LINE" #this is the full path of the uevent file
#now we can do stuff with MAJOR, MINOR, DEVNAME and DEVTYPE, no parsing required
done

EDIT: ... wow - I need to look into what kernel version got /sys/dev/{char,block} - that would be so much easier (has symlinks to ALL char and block devices in appropriate subdirectories) I guess the kernel docs are more outdated than I even thought_________________Web Programming - Pet Packaging 100 & 101

I uncovered a bug ... mknod will only accept major and minor 0..255, but the kernel supports higher values, so the mknod in busybox fails on /dev/bus/usb/004/001 (amongst others) because it has a minor value of 384 ... so I patched busybox mknod to use MINOR&0xff making it have an actual minor value of 128 - IDK if this is OK or not - probably not

musl-libc doesn't account for it, but it looks like uclibc and glibc do (prepends the extra bit in an unsigned int vs using just an unsigned short) - posting to musl-libc list_________________Web Programming - Pet Packaging 100 & 101

The idea of sourceing is really fine !
Would probably come to it after several years due to not using eval gtkdialog or source /etc/rc.d/PUPSTATE much .
Most sourced files are actualy scripts containing functions .

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum