[klibc] symlinks and initramfs (was klibc-1.2.1: kinit works...)
H. Peter Anvin
hpa at zytor.com
Wed Feb 1 18:26:35 PST 2006
Chris Wedgwood wrote:
>
> 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.
Hard links of files are characterized by being ordinary files with link
count > 1. Furthermore, the file numbers have to match (since content
is typically only included with the first instance, we have to keep
track of them.)
Thus, we should be able to trivially deduce if it's a hard link with
content (> 0 bytes), which means overwrite the existing entry, or not.
Since the issue in question was overwriting a symbolic link with either
another symbolic link or a file, it should be a non-issue.
-hpa
More information about the klibc
mailing list