From bf9e9d0b2506aad0a3e51fb13a8c4fcfe05f8ee1 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Tue, 29 Apr 2014 23:34:12 +0200 Subject: [PATCH] Fix mkinitrd not maintaining correct hard link count. --- mkinitrd/mkinitrd.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mkinitrd/mkinitrd.cpp b/mkinitrd/mkinitrd.cpp index 3b3cf389..43f23146 100644 --- a/mkinitrd/mkinitrd.cpp +++ b/mkinitrd/mkinitrd.cpp @@ -161,11 +161,13 @@ Node* RecursiveSearch(const char* real_path, const char* virt_path, if ( lstat(real_path, &st) ) { perror(real_path); return NULL; } Node* cached = LookupCache(st.st_dev, st.st_ino); - if ( cached ) { cached->refcount++; return cached; } + if ( cached ) + return cached->nlink++, cached->refcount++, cached; Node* node = (Node*) calloc(1, sizeof(Node)); if ( !node ) { return NULL; } + node->nlink = 1; node->refcount = 1; node->mode = st.st_mode; node->ino = (*ino)++;