initramfs: fix symlink test
PATCH 1/1 initramfs: fix symlink test
We want to see if the symlink exists which means -L, not if the target of the symlink exists.
--- fs/initramfs/initramfs.mk | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/initramfs/initramfs.mk +2 -2
@@ -7,7 +7,7 @@ ############################################################# define ROOTFS_INITRAMFS_INIT_SYMLINK - if [ ! -e $(TARGET_DIR)/init ]; then \ + if [ ! -L $(TARGET_DIR)/init ]; then \ ln -s sbin/init $(TARGET_DIR)/init; \ fi endef
@@ -20,4 +20,4 @@ endef ROOTFS_INITRAMFS_POST_TARGETS += linux26-rebuild-with-initramfs -$(eval $(call ROOTFS_TARGET,initramfs)) +$(eval $(call ROOTFS_TARGET,initramfs))
Signature · 1 line
1.7.3.2
PATCH 1/1 initramfs: fix symlink test
Quoted 4 lines · On Tue, 16 Nov 2010 09:58:46 -0500 Mike Frysinger <[email protected]> wrote:
We want to see if the symlink exists which means -L, not if the target of the symlink exists.
Signed-off-by Mike Frysinger <[email protected]>
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/1 initramfs: fix symlink test
In reply to Mike FrysingerAm Dienstag, 16. November 2010, 15:58:46 schrieb Mike Frysinger:
Quoted 22 lines
We want to see if the symlink exists which means -L, not if the target of the symlink exists.
Signed-off-by Mike Frysinger <[email protected]>--- fs/initramfs/initramfs.mk | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)fs/initramfs/initramfs.mk +1
-1@@ -7,7 +7,7 @@ ############################################################# define ROOTFS_INITRAMFS_INIT_SYMLINK - if [ ! -e $(TARGET_DIR)/init ]; then \ + if [ ! -L $(TARGET_DIR)/init ]; then \ ln -s sbin/init $(TARGET_DIR)/init; \ fi endef
fs/initramfs/initramfs.mk endef · line 23
Quoted 6 lines
fs/initramfs/initramfs.mk +1
-1@@ -20,4 +20,4 @@ endef ROOTFS_INITRAMFS_POST_TARGETS += linux26-rebuild-with-initramfs -$(eval $(call ROOTFS_TARGET,initramfs)) +$(eval $(call ROOTFS_TARGET,initramfs))
Ack for not testing if the link target exists, but what if $(TARGET_DIR)/init exists but is not a symlink? My custom skeleton contains an /init shell script? or is that considered unsupported?
Maybe something along the lines of
[ ! -e $(TARGET_DIR)/init -a ! -L $(TARGET_DIR)/init ]
?
Regards,
Malte
PATCH v2 1/1 initramfs: fix init symlink creation
In reply to Mike FrysingerThe -e test will dereference the symlink, so if there is no /bin/init, we will constantly try to create the symlink. So rather than error on subsequent runs when the link exists, use the force flag to ln.
---
v2
- drop the -L change and just recreate the symlink for people who install their own file at /init
fs/initramfs/initramfs.mk | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/initramfs/initramfs.mk +2 -2
@@ -8,7 +8,7 @@ define ROOTFS_INITRAMFS_INIT_SYMLINK if [ ! -e $(TARGET_DIR)/init ]; then \ - ln -s sbin/init $(TARGET_DIR)/init; \ + ln -sf sbin/init $(TARGET_DIR)/init; \ fi endef
@@ -20,4 +20,4 @@ endef ROOTFS_INITRAMFS_POST_TARGETS += linux26-rebuild-with-initramfs -$(eval $(call ROOTFS_TARGET,initramfs)) +$(eval $(call ROOTFS_TARGET,initramfs))
Signature · 1 line
1.7.3.2
PATCH v2 1/1 initramfs: fix init symlink creation
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Mike" == Mike Frysinger <[email protected]> writes:
Mike> The -e test will dereference the symlink, so if there is no /bin/init, Mike> we will constantly try to create the symlink. So rather than error on Mike> subsequent runs when the link exists, use the force flag to ln.
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard