From: Mark Huang Date: Thu, 4 May 2006 14:12:22 +0000 (+0000) Subject: - fix broken hardlink handling: copy hardlink filenames instead of storing X-Git-Tag: before-fedora-2_6_18-1_2239_FC5-vs2_0_2_2-rc6-merge~50 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=c0caf9cfdfd743c036162aab4f3157e89b42b7e7;p=linux-2.6.git - fix broken hardlink handling: copy hardlink filenames instead of storing pointers to them, since the filenames may be in temporary storage (e.g., see read_into(); if the filename crosses a collection boundary, read_into() will reset collected to temporary storage). This fixes the weird intermittent bugs I've been seeing in initramfs creation, basically, 0 byte hardlinked files. --- diff --git a/init/initramfs.c b/init/initramfs.c index 02c5ce649..6d70d82d5 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -26,10 +26,12 @@ static void __init free(void *where) /* link hash */ +#define N_ALIGN(len) ((((len) + 1) & ~3) + 2) + static __initdata struct hash { int ino, minor, major; struct hash *next; - char *name; + char name[N_ALIGN(PATH_MAX)]; } *head[32]; static inline int hash(int major, int minor, int ino) @@ -57,7 +59,7 @@ static char __init *find_link(int major, int minor, int ino, char *name) q->ino = ino; q->minor = minor; q->major = major; - q->name = name; + strcpy(q->name, name); q->next = NULL; *p = q; return NULL; @@ -133,8 +135,6 @@ static inline void eat(unsigned n) count -= n; } -#define N_ALIGN(len) ((((len) + 1) & ~3) + 2) - static __initdata char *collected; static __initdata int remains; static __initdata char *collect;