diff mbox series

fs: ensure hard links in TARGET_DIR are correctly copied for filesystem input

Message ID 20180527204857.6081-1-peter@korsgaard.com
State Accepted
Commit 065e7672e1e933f8b5257eddc9d1d8b7021a1687
Headers show
Series fs: ensure hard links in TARGET_DIR are correctly copied for filesystem input | expand

Commit Message

Peter Korsgaard May 27, 2018, 8:48 p.m. UTC
Fixes #11046

Commit bb2a57a17a7 (fs: run packages' filesystem hooks in a copy of target/)
changed the file system logic to run file system hooks from packages on a
copy of TARGET_DIR, and finally use this copy as input for the file system
generation.

This copy was done with rsync, which by default does not preserve hard
links, leading to an expansion of the file system images when hard links are
present.

Fix it by passing the -H option to rsync (preserve hard links).

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
Alternatively we can use 'cp -a' instead of rsync.

 fs/common.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Yann E. MORIN May 27, 2018, 9:39 p.m. UTC | #1
Peter, All,

On 2018-05-27 22:48 +0200, Peter Korsgaard spake thusly:
> Fixes #11046
> 
> Commit bb2a57a17a7 (fs: run packages' filesystem hooks in a copy of target/)
> changed the file system logic to run file system hooks from packages on a
> copy of TARGET_DIR, and finally use this copy as input for the file system
> generation.
> 
> This copy was done with rsync, which by default does not preserve hard
> links, leading to an expansion of the file system images when hard links are
> present.
> 
> Fix it by passing the -H option to rsync (preserve hard links).
> 
> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>

Not sure how I was not able to reproduce the issue. But the rsync docs
say we should use it, so:

Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

Regards,
Yann E. MORIN.

> ---
> Alternatively we can use 'cp -a' instead of rsync.
> 
>  fs/common.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/common.mk b/fs/common.mk
> index 9baf367729..abf35418cb 100644
> --- a/fs/common.mk
> +++ b/fs/common.mk
> @@ -71,7 +71,7 @@ $(ROOTFS_COMMON_TAR): $(ROOTFS_COMMON_DEPENDENCIES) target-finalize
>  	@$(call MESSAGE,"Generating common rootfs tarball")
>  	rm -rf $(FS_DIR)
>  	mkdir -p $(FS_DIR)
> -	rsync -au $(BASE_TARGET_DIR)/ $(TARGET_DIR)
> +	rsync -auH $(BASE_TARGET_DIR)/ $(TARGET_DIR)
>  	echo '#!/bin/sh' > $(FAKEROOT_SCRIPT)
>  	echo "set -e" >> $(FAKEROOT_SCRIPT)
>  	echo "chown -h -R 0:0 $(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
> -- 
> 2.11.0
>
Peter Korsgaard May 27, 2018, 9:46 p.m. UTC | #2
>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:

 > Fixes #11046
 > Commit bb2a57a17a7 (fs: run packages' filesystem hooks in a copy of target/)
 > changed the file system logic to run file system hooks from packages on a
 > copy of TARGET_DIR, and finally use this copy as input for the file system
 > generation.

 > This copy was done with rsync, which by default does not preserve hard
 > links, leading to an expansion of the file system images when hard links are
 > present.

 > Fix it by passing the -H option to rsync (preserve hard links).

 > Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
 > ---
 > Alternatively we can use 'cp -a' instead of rsync.

Committed, thanks.
diff mbox series

Patch

diff --git a/fs/common.mk b/fs/common.mk
index 9baf367729..abf35418cb 100644
--- a/fs/common.mk
+++ b/fs/common.mk
@@ -71,7 +71,7 @@  $(ROOTFS_COMMON_TAR): $(ROOTFS_COMMON_DEPENDENCIES) target-finalize
 	@$(call MESSAGE,"Generating common rootfs tarball")
 	rm -rf $(FS_DIR)
 	mkdir -p $(FS_DIR)
-	rsync -au $(BASE_TARGET_DIR)/ $(TARGET_DIR)
+	rsync -auH $(BASE_TARGET_DIR)/ $(TARGET_DIR)
 	echo '#!/bin/sh' > $(FAKEROOT_SCRIPT)
 	echo "set -e" >> $(FAKEROOT_SCRIPT)
 	echo "chown -h -R 0:0 $(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)