Skip to contentSkip to conversation

check mktemp return value

PATCH Dave Young 2 participants 3 messages Oct 10, 2011 2 messages not in the archive

lore
Share & tools
lore

Dave Young

author
#0 lore raw

in slackware the default mktemp is not from coreutils. A simply make in test directory mangled my rootfs due to initdir is blank

Also mktemp could failed with other reason like ENOSPC or EPERM

---
 dracut |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
dracut +4 -0
index c9329bd..8237f7a 100755
@@ -472,6 +472,10 @@ fi
 
 readonly TMPDIR=/var/tmp
 readonly initdir=$(mktemp --tmpdir=/var/tmp/ -d -t initramfs.XXXXXX)
+[ -z $initdir ] && {
+    dfatal "mktemp failed."
+    exit 1
+}
 
 # clean up after ourselves no matter how we die.
 trap 'ret=$?;[[ $keep ]] && echo "Not removing $initdir." >&2 || rm -rf

"$initdir";exit $ret;' EXIT

Signature · 1 line
1.7.4.4

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 27 lines · Dave Young

in slackware the default mktemp is not from coreutils. A simply make in test directory mangled my rootfs due to initdir is blank

Also mktemp could failed with other reason like ENOSPC or EPERM

---
 dracut |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
dracut +4 -0
index c9329bd..8237f7a 100755
@@ -472,6 +472,10 @@ fi
 
 readonly TMPDIR=/var/tmp
 readonly initdir=$(mktemp --tmpdir=/var/tmp/ -d -t initramfs.XXXXXX)
+[ -z $initdir ] && {
+    dfatal "mktemp failed."
+    exit 1
+}
 
 # clean up after ourselves no matter how we die.
 trap 'ret=$?;[[ $keep ]] && echo "Not removing $initdir." >&2 || rm -rf
Quoted 1 line

"$initdir";exit $ret;' EXIT

pushed...

had to hand edit, because your mailer automatically broke the line.

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#4 lore raw
Quoted 26 lines · Harald Hoyer
Quoted 25 lines · Dave Young

in slackware the default mktemp is not from coreutils. A simply make in test directory mangled my rootfs due to initdir is blank

Also mktemp could failed with other reason like ENOSPC or EPERM

---
 dracut |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
dracut +4 -0
index c9329bd..8237f7a 100755
@@ -472,6 +472,10 @@ fi
 
 readonly TMPDIR=/var/tmp
 readonly initdir=$(mktemp --tmpdir=/var/tmp/ -d -t initramfs.XXXXXX)
+[ -z $initdir ] && {
+    dfatal "mktemp failed."
+    exit 1
+}
 
Quoted 7 lines
Quoted 3 lines
dracut +0 -0
 # clean up after ourselves no matter how we die.
 trap 'ret=$?;[[ $keep ]] && echo "Not removing $initdir." >&2 || rm -rf

"$initdir";exit $ret;' EXIT

pushed...

had to hand edit, because your mailer automatically broke the line.

Sorry about that, I think I have to return to mutt for patch sending

Signature · 2 lines
Thanks
Dave