Changeset View
Changeset View
Standalone View
Standalone View
libexec/rc/rc.d/tmp
Context not available. | |||||
mount_tmpmfs() | mount_tmpmfs() | ||||
{ | { | ||||
if ! /bin/df /tmp | grep -q "^/dev/md[0-9].* /tmp"; then | while read line; do | ||||
mount_md ${tmpsize} /tmp "${tmpmfs_flags}" | case $line in | ||||
chmod 01777 /tmp | /dev/md[0-9]*\ /tmp) | ||||
fi | return;; | ||||
esac | |||||
done <<*EOF | |||||
$(df /tmp) | |||||
*EOF | |||||
cy: Another way to do this, might be df /tmp | while read line... To me it looks cleaner. | |||||
seAuthorUnsubmitted Done Inline ActionsMy initial attempt actually used "df /tmp | while ...", but I find the here doc version more straight forward. Here is a version that uses "df /tmp | while ...": mount_tmpmfs() { df /tmp | while read line; do case $line in /dev/md[0-9]*\ /tmp) return 1;; esac done if [ $? = 0 ]; then mount_md ${tmpsize} /tmp "${tmpmfs_flags}" chmod 01777 /tmp fi } The while loop is executed in a sub-shell and thus needs to be exited with "return 1" to pass a value to the if condition. This is easy to understand if you know about the while loop being executed in a sub-shell, I think that the here-doc version does not require such knowledge. The pipe-based version requires 2 forked sub-processes (the df command and the shell executing the while loop), but the here-doc version only forks the df process and I do prefer it for these reasons. se: My initial attempt actually used "df /tmp | while ...", but I find the here doc version more… | |||||
glebiusUnsubmitted Not Done Inline ActionsTo me the here-doc looks more efficient than pipe. glebius: To me the here-doc looks more efficient than pipe. | |||||
mount_md ${tmpsize} /tmp "${tmpmfs_flags}" | |||||
chmod 01777 /tmp | |||||
} | } | ||||
# If we do not have a writable /tmp, create a memory | # If we do not have a writable /tmp, create a memory | ||||
Context not available. |
Another way to do this, might be df /tmp | while read line... To me it looks cleaner.