mkinitrd unification across distributions
 help / color / mirror / Atom feed
From: "Amadeusz Żołnowski" <aidecoe-2qtfh70TtYba5EbDDlwbIw@public.gmane.org>
To: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: "Amadeusz Żołnowski" <aidecoe-2qtfh70TtYba5EbDDlwbIw@public.gmane.org>
Subject: [PATCH] inst_symlink: create parent dir if doesn't exist
Date: Mon, 26 Mar 2012 00:11:53 +0200	[thread overview]
Message-ID: <1332713513-17889-1-git-send-email-aidecoe@aidecoe.name> (raw)

If symlink is yet alone in target directory, inst_symlink will fail to
create it.  This is how to reproduce the bug:

 # mkdir /tmp/test
 # ln -s /bin/cp /tmp/test/cp
 # ./dracut -l -f -H /tmp/test.img -I /tmp/test/cp

Result:

[...]

I: *** Including modules done ***
ln: failed to create symbolic link
`/var/tmp/initramfs.Z5isVu//tmp/test/cp': No such file or directory
ln: failed to create symbolic link
`/var/tmp/initramfs.Z5isVu//tmp/test/cp': No such file or directory
I: Wrote /tmp/test.img:

[...]

Following patch creates directory for the symlink if it doesn't exist.
---
 dracut-functions.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/dracut-functions.sh b/dracut-functions.sh
index f4ccf53..adca47d 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -545,8 +545,11 @@ inst_symlink() {
             inst "$_realsrc"
         fi
     fi
+    set -x
+    [[ ! -e $initdir/${_target%/*} ]] && inst_dir "${_target%/*}"
     [[ -d ${_target%/*} ]] && _target=$(readlink -f ${_target%/*})/${_target##*/}
     ln -sfn $(convert_abs_rel "${_target}" "${_realsrc}") "$initdir/$_target"
+    set +x
 }
 
 # attempt to install any programs specified in a udev rule
-- 
1.7.8.5

             reply	other threads:[~2012-03-25 22:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-25 22:11 Amadeusz Żołnowski [this message]
     [not found] ` <1332713513-17889-1-git-send-email-aidecoe-2qtfh70TtYba5EbDDlwbIw@public.gmane.org>
2012-03-26  7:39   ` [PATCH] inst_symlink: create parent dir if doesn't exist Amadeusz Żołnowski
2012-03-26  7:39   ` Amadeusz Żołnowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1332713513-17889-1-git-send-email-aidecoe@aidecoe.name \
    --to=aidecoe-2qtfh70ttyba5ebddlwbiw@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox