Cache only mkinitrd nodes with multiple hardlinks.

This commit is contained in:
Jonas 'Sortie' Termansen 2015-07-25 02:41:45 +02:00
parent 9554bab714
commit 3191e18966
1 changed files with 9 additions and 6 deletions

View File

@ -174,9 +174,12 @@ Node* RecursiveSearch(const char* real_path, const char* virt_path,
return NULL; return NULL;
} }
if ( !S_ISDIR(st.st_mode) && 2 <= st.st_nlink )
{
Node* cached = LookupCache(st.st_dev, st.st_ino); Node* cached = LookupCache(st.st_dev, st.st_ino);
if ( cached ) if ( cached )
return cached->nlink++, cached->refcount++, cached; return cached->nlink++, cached->refcount++, cached;
}
Node* node = (Node*) calloc(1, sizeof(Node)); Node* node = (Node*) calloc(1, sizeof(Node));
if ( !node ) if ( !node )
@ -201,7 +204,7 @@ Node* RecursiveSearch(const char* real_path, const char* virt_path,
if ( !S_ISDIR(st.st_mode)) if ( !S_ISDIR(st.st_mode))
{ {
if ( !AddToCache(node, st.st_dev, st.st_ino) ) if ( 2 <= st.st_nlink && !AddToCache(node, st.st_dev, st.st_ino) )
{ {
free(real_path_clone); free(real_path_clone);
free(node); free(node);
@ -302,7 +305,7 @@ Node* RecursiveSearch(const char* real_path, const char* virt_path,
} }
closedir(dir); closedir(dir);
if ( !successful || !AddToCache(node, st.st_dev, st.st_ino) ) if ( !successful )
{ {
FreeNode(node); FreeNode(node);
return NULL; return NULL;