FYI, this won't work on Windows (in case you care ;-): Microsoft's ino_t is only 16 bits, even though NTFS uses a 64-bit index value. int64_t may be a better choice.
Cheers, Tim Kientzle On Thu, Oct 1, 2009 at 11:35 AM, Stephen R. van den Berg <[email protected]>wrote: > --- > > Add support for filesystems with inode-fields wider than 32-bits (I > witnessed > this bug on a large XFS filesystem). > This patch fixes the bug that hardlinked files are *not* included at > all (i.e. both files are listed, but the content is not transmitted with > either of them). > > The patch is relative to the bleeding edge version of cpio on the git > repostory. > > src/copyin.c | 8 ++++---- > src/copyout.c | 4 ++-- > src/copypass.c | 2 +- > src/extern.h | 6 +++--- > src/util.c | 6 +++--- > 5 files changed, 13 insertions(+), 13 deletions(-) > > diff --git a/src/copyin.c b/src/copyin.c > index 5b7594b..8ba2bc9 100644 > --- a/src/copyin.c > +++ b/src/copyin.c > @@ -258,7 +258,7 @@ create_defered_links (struct cpio_file_stat *file_hdr) > { > struct deferment *d; > struct deferment *d_prev; > - int ino; > + ino_t ino; > int maj; > int min; > int link_res; > @@ -306,7 +306,7 @@ create_defered_links_to_skipped (struct cpio_file_stat > *file_hdr, > { > struct deferment *d; > struct deferment *d_prev; > - int ino; > + ino_t ino; > int maj; > int min; > if (file_hdr->c_filesize == 0) > @@ -1460,8 +1460,8 @@ process_copy_in () > struct cpio_file_stat *h; > h = &file_hdr; > fprintf (stderr, > - "magic = 0%o, ino = %d, mode = 0%o, uid = %d, gid = %d\n", > - h->c_magic, h->c_ino, h->c_mode, h->c_uid, h->c_gid); > + "magic = 0%o, ino = %ld, mode = 0%o, uid = %d, gid = %d\n", > + h->c_magic, (long)h->c_ino, h->c_mode, h->c_uid, h->c_gid); > fprintf (stderr, > "nlink = %d, mtime = %d, filesize = %d, dev_maj = 0x%x\n", > h->c_nlink, h->c_mtime, h->c_filesize, h->c_dev_maj); > diff --git a/src/copyout.c b/src/copyout.c > index dd9bac2..b3bb0ad 100644 > --- a/src/copyout.c > +++ b/src/copyout.c > @@ -110,7 +110,7 @@ static int > count_defered_links_to_dev_ino (struct cpio_file_stat *file_hdr) > { > struct deferment *d; > - int ino; > + ino_t ino; > int maj; > int min; > int count; > @@ -167,7 +167,7 @@ writeout_other_defers (struct cpio_file_stat *file_hdr, > int out_des) > { > struct deferment *d; > struct deferment *d_prev; > - int ino; > + ino_t ino; > int maj; > int min; > ino = file_hdr->c_ino; > diff --git a/src/copypass.c b/src/copypass.c > index 8941b76..20929a6 100644 > --- a/src/copypass.c > +++ b/src/copypass.c > @@ -387,7 +387,7 @@ process_copy_pass () > > int > link_to_maj_min_ino (char *file_name, int st_dev_maj, int st_dev_min, > - int st_ino) > + ino_t st_ino) > { > int link_res; > char *link_name; > diff --git a/src/extern.h b/src/extern.h > index a832897..6144be1 100644 > --- a/src/extern.h > +++ b/src/extern.h > @@ -119,7 +119,7 @@ void process_copy_out (void); > /* copypass.c */ > void process_copy_pass (void); > int link_to_maj_min_ino (char *file_name, int st_dev_maj, > - int st_dev_min, int st_ino); > + int st_dev_min, ino_t st_ino); > int link_to_name (char *link_name, char *link_target); > > /* dirname.c */ > @@ -169,9 +169,9 @@ void warn_if_file_changed (char *file_name, off_t > old_file_size, > time_t old_file_mtime); > void create_all_directories (char *name); > void prepare_append (int out_file_des); > -char *find_inode_file (unsigned long node_num, > +char *find_inode_file (ino_t node_num, > unsigned long major_num, unsigned long minor_num); > -void add_inode (unsigned long node_num, char *file_name, > +void add_inode (ino_t node_num, char *file_name, > unsigned long major_num, unsigned long minor_num); > int open_archive (char *file); > void tape_offline (int tape_des); > diff --git a/src/util.c b/src/util.c > index 1eb92ae..16a4320 100644 > --- a/src/util.c > +++ b/src/util.c > @@ -686,7 +686,7 @@ prepare_append (int out_file_des) > > struct inode_val > { > - unsigned long inode; > + ino_t inode; > unsigned long major_num; > unsigned long minor_num; > char *file_name; > @@ -713,7 +713,7 @@ inode_val_compare (const void *val1, const void *val2) > } > > char * > -find_inode_file (unsigned long node_num, unsigned long major_num, > +find_inode_file (ino_t node_num, unsigned long major_num, > unsigned long minor_num) > { > struct inode_val sample; > @@ -732,7 +732,7 @@ find_inode_file (unsigned long node_num, unsigned long > major_num, > /* Associate FILE_NAME with the inode NODE_NUM. (Insert into hash table.) > */ > > void > -add_inode (unsigned long node_num, char *file_name, unsigned long > major_num, > +add_inode (ino_t node_num, char *file_name, unsigned long major_num, > unsigned long minor_num) > { > struct inode_val *temp; > -- > 1.6.2.151.gdc0be > > -- > Sincerely, > Stephen R. van den Berg. > > "If he learns from his mistakes, pretty soon he'll know everything." > > >
