From b4e0dff8258e29ed2f69a43b6c1dff0a693ee97a Mon Sep 17 00:00:00 2001 From: Dmitry V. Levin Date: Thu, 19 Nov 2009 22:05:17 +0000 Subject: [PATCH] Fix creation of newc/crc archives with files containing multiple hard links * src/copyout.c (count_defered_links_to_dev_ino): Make return type unsigned. Fix local variable types to match cpio_file_stat members types. (last_link): Make link count type unsigned. (writeout_other_defers): Fix local variable types to match cpio_file_stat members types. (writeout_final_defers): Make link count type unsigned. --- If a hardlink that was going to be archived had an inode number greater than MAX_INT, it was archived as an empty file. src/copyout.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/copyout.c b/src/copyout.c index 23da993..b0b9921 100644 --- a/src/copyout.c +++ b/src/copyout.c @@ -108,14 +108,14 @@ struct deferment *deferouts = NULL; /* Count the number of other (hard) links to this file that have already been defered. */ -static int +static unsigned int count_defered_links_to_dev_ino (struct new_cpio_header *file_hdr) { struct deferment *d; - int ino; - int maj; - int min; - int count; + ino_t ino; + long maj; + long min; + unsigned int count; ino = file_hdr->c_ino; maj = file_hdr->c_dev_maj; min = file_hdr->c_dev_min; @@ -135,7 +135,7 @@ count_defered_links_to_dev_ino (struct new_cpio_header *file_hdr) static int last_link (struct new_cpio_header *file_hdr) { - int other_files_sofar; + unsigned int other_files_sofar; other_files_sofar = count_defered_links_to_dev_ino (file_hdr); if (file_hdr->c_nlink == (other_files_sofar + 1) ) @@ -169,9 +169,9 @@ writeout_other_defers (struct new_cpio_header *file_hdr, int out_des) { struct deferment *d; struct deferment *d_prev; - int ino; - int maj; - int min; + ino_t ino; + long maj; + long min; ino = file_hdr->c_ino; maj = file_hdr->c_dev_maj; min = file_hdr->c_dev_min; @@ -268,7 +268,7 @@ static void writeout_final_defers (int out_des) { struct deferment *d; - int other_count; + unsigned int other_count; while (deferouts != NULL) { d = deferouts;