[klibc] symlinks and initramfs (was klibc-1.2.1: kinit works...)

Chris Wedgwood cw at f00f.org
Wed Feb 1 18:20:39 PST 2006


On Tue, Jan 31, 2006 at 09:45:29AM -0800, H. Peter Anvin wrote:

> No, the point he's making is that we need to make sure that the
> in-kernel cpio extractor can handle overwriting a symlink with a
> file, which I'm not sure the current one does.

It doesn't, but we could do something like:

diff --git a/init/initramfs.c b/init/initramfs.c
index 0c5d9a3..6f741a1 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -250,6 +250,7 @@ static int __init do_name(void)
 		return 0;
 	if (S_ISREG(mode)) {
 		if (maybe_link() >= 0) {
+			sys_unlink(collected); /* nuke if already there */
 			wfd = sys_open(collected, O_WRONLY|O_CREAT, mode);
 			if (wfd >= 0) {
 				sys_fchown(wfd, uid, gid);

But it's not clear that's the right thing to do (ie. what if the
target is a hrd link and we want to overwrite it in-place to all other
hard-links to it are affected).  And then again we might not.



More information about the klibc mailing list