[Slackbuilds-users] find/chmod revisited
B Watson
yalhcru at gmail.com
Thu Nov 12 07:37:15 UTC 2015
I've always known the template code that sanitizes the source permissions
is a bit slow... for mame, it takes a full minute to execute (using tmpfs
for TMP), since there are over 18 thousand files/dirs in the mame src.
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
...executes one chmod process for each file/dir it finds. For mame:
$ find /tmp/mame-mame0167/|wc -l
18664
That's a lot of child processes! So I thought "maybe I can use xargs
and cut the time down some". Result is this:
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -print0 | \
xargs -0 chmod 755
find -L . \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -print0 | \
xargs -0 chmod 644
...which (on tmpfs) executes so fast I can't measure it accurately.
Maybe the template code could be updated? mame isn't the only build
that is affected by this. Anything with lots of files will be noticeably
faster with this change.
More information about the SlackBuilds-users
mailing list