From 9ca70cf6a082bb146eaaa0b09361643feca38875 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Wed, 17 Jul 2002 10:18:52 +0000 Subject: [PATCH] Create new BSD inodes (and get 32 bit UID/GID) --- CHANGES | 10 +++++- compat/include/bsdcompat.h | 22 +++--------- dump/main.c | 4 +-- dump/traverse.c | 72 ++++++++++++++++++++------------------ 4 files changed, 53 insertions(+), 55 deletions(-) diff --git a/CHANGES b/CHANGES index 9881651..0b2d3e1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.184 2002/07/01 11:57:11 stelian Exp $ +$Id: CHANGES,v 1.185 2002/07/17 10:18:52 stelian Exp $ Changes between versions 0.4b29 and 0.4b30 (released ????????????????) ====================================================================== @@ -21,6 +21,14 @@ Changes between versions 0.4b29 and 0.4b30 (released ????????????????) media, and localized in english and german. Thanks to Georg Lippold for the new scripts. +5. Made dump save 32 bit UID/GID. Internally, this was achieved + by switching from the old BSD inode format to the new BSD + inode format, which means that the tape format was changed. + However, since all restore versions out there should + transparently support both inode formats, the change should + have no side effects. Thanks to John Yu for + reporting the bug. + Changes between versions 0.4b28 and 0.4b29 (released June 8, 2002) ================================================================== diff --git a/compat/include/bsdcompat.h b/compat/include/bsdcompat.h index 16de840..8b87378 100644 --- a/compat/include/bsdcompat.h +++ b/compat/include/bsdcompat.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - AlcĂ´ve , 2000-2002 * - * $Id: bsdcompat.h,v 1.17 2002/06/10 14:05:00 stelian Exp $ + * $Id: bsdcompat.h,v 1.18 2002/07/17 10:18:52 stelian Exp $ */ #include @@ -96,7 +96,9 @@ struct dinode { __u8 di_frag; __u8 di_fsize; __u16 di_pad1; - __u32 di_spare[2]; + __u16 di_uidhigh; + __u16 di_gidhigh; + __u32 di_spare; }; #define di_rdev di_db[0] @@ -134,21 +136,7 @@ struct dinode { #endif /* - * This is the direct structure used by dump. In needs to be - * different from direct because linux dump generates only - * 'old inode format' dumps. And BSD supposes that the old - * inode dumps have the d_namelen field written in machine byte - * order... - */ -struct olddirect { - __u32 d_ino; - __u16 d_reclen; - __u16 d_namlen; - char d_name[MAXNAMLEN + 1]; -}; - -/* - * The direct structure used by restore. + * The direct structure used by dump/restore. */ struct direct { __u32 d_ino; diff --git a/dump/main.c b/dump/main.c index 173ec03..3ef7bc1 100644 --- a/dump/main.c +++ b/dump/main.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.72 2002/06/05 13:29:15 stelian Exp $"; + "$Id: main.c,v 1.73 2002/07/17 10:18:52 stelian Exp $"; #endif /* not lint */ #include @@ -711,9 +711,7 @@ main(int argc, char *argv[]) if (TP_BSIZE != (1 << tp_bshift)) quit("TP_BSIZE (%d) is not a power of 2", TP_BSIZE); maxino = fs->super->s_inodes_count + 1; -#if 0 spcl.c_flags |= DR_NEWINODEFMT; -#endif #else /* __linux __*/ if ((diskfd = open(disk, O_RDONLY)) < 0) { msg("Cannot open %s\n", disk); diff --git a/dump/traverse.c b/dump/traverse.c index cfa16b3..bd16f9b 100644 --- a/dump/traverse.c +++ b/dump/traverse.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: traverse.c,v 1.47 2002/06/10 14:05:00 stelian Exp $"; + "$Id: traverse.c,v 1.48 2002/07/17 10:18:52 stelian Exp $"; #endif /* not lint */ #include @@ -786,7 +786,7 @@ dumpino(struct dinode *dp, dump_ino_t ino, int metaonly) unsigned long cnt; fsizeT size, remaining; char buf[TP_BSIZE]; - struct old_bsd_inode obi; + struct new_bsd_inode nbi; int i; #ifdef __linux__ struct block_context bc; @@ -806,22 +806,24 @@ dumpino(struct dinode *dp, dump_ino_t ino, int metaonly) } CLRINO(ino, dumpinomap); #ifdef __linux__ - memset(&obi, 0, sizeof(obi)); - obi.di_mode = dp->di_mode; - obi.di_uid = dp->di_uid; - obi.di_gid = dp->di_gid; - obi.di_qsize.v = i_size; - obi.di_atime = dp->di_atime; - obi.di_mtime = dp->di_mtime; - obi.di_ctime = dp->di_ctime; - obi.di_nlink = dp->di_nlink; - obi.di_blocks = dp->di_blocks; - obi.di_flags = dp->di_flags; - obi.di_gen = dp->di_gen; - memmove(&obi.di_db, &dp->di_db, (NDADDR + NIADDR) * sizeof(daddr_t)); + memset(&nbi, 0, sizeof(nbi)); + nbi.di_mode = dp->di_mode; + nbi.di_nlink = dp->di_nlink; + nbi.di_ouid = dp->di_uid; + nbi.di_ogid = dp->di_gid; + nbi.di_size = i_size; + nbi.di_atime.tv_sec = dp->di_atime; + nbi.di_mtime.tv_sec = dp->di_mtime; + nbi.di_ctime.tv_sec = dp->di_ctime; + memmove(&nbi.di_db, &dp->di_db, (NDADDR + NIADDR) * sizeof(daddr_t)); + nbi.di_flags = dp->di_flags; + nbi.di_blocks = dp->di_blocks; + nbi.di_gen = dp->di_gen; + nbi.di_uid = (((int32_t)dp->di_uidhigh) << 16) | dp->di_uid; + nbi.di_gid = (((int32_t)dp->di_gidhigh) << 16) | dp->di_gid; if (dp->di_file_acl) warn("ACLs in inode #%ld won't be dumped", (long)ino); - memmove(&spcl.c_dinode, &obi, sizeof(obi)); + memmove(&spcl.c_dinode, &nbi, sizeof(nbi)); #else /* __linux__ */ spcl.c_dinode = *dp; #endif /* __linux__ */ @@ -961,19 +963,19 @@ static int convert_dir(struct ext2_dir_entry *dirent, int offset, int blocksize, char *buf, void *private) { struct convert_dir_context *p; - struct olddirect *dp; + struct direct *dp; int reclen; p = (struct convert_dir_context *)private; reclen = EXT2_DIR_REC_LEN((dirent->name_len & 0xFF) + 1); if (((p->offset + reclen - 1) / p->bs) != (p->offset / p->bs)) { - dp = (struct olddirect *)(p->buf + p->prev_offset); + dp = (struct direct *)(p->buf + p->prev_offset); dp->d_reclen += p->bs - (p->offset % p->bs); p->offset += p->bs - (p->offset % p->bs); } - dp = (struct olddirect *)(p->buf + p->offset); + dp = (struct direct *)(p->buf + p->offset); dp->d_ino = dirent->inode; dp->d_reclen = reclen; dp->d_namlen = dirent->name_len & 0xFF; @@ -995,7 +997,7 @@ dumpdirino(struct dinode *dp, dump_ino_t ino) { fsizeT size; char buf[TP_BSIZE]; - struct old_bsd_inode obi; + struct new_bsd_inode nbi; struct convert_dir_context cdc; errcode_t retval; struct ext2_dir_entry *de; @@ -1035,22 +1037,24 @@ dumpdirino(struct dinode *dp, dump_ino_t ino) dir_size = cdc.offset; #ifdef __linux__ - memset(&obi, 0, sizeof(obi)); - obi.di_mode = dp->di_mode; - obi.di_uid = dp->di_uid; - obi.di_gid = dp->di_gid; - obi.di_qsize.v = dir_size; /* (u_quad_t)dp->di_size; */ - obi.di_atime = dp->di_atime; - obi.di_mtime = dp->di_mtime; - obi.di_ctime = dp->di_ctime; - obi.di_nlink = dp->di_nlink; - obi.di_blocks = dp->di_blocks; - obi.di_flags = dp->di_flags; - obi.di_gen = dp->di_gen; - memmove(&obi.di_db, &dp->di_db, (NDADDR + NIADDR) * sizeof(daddr_t)); + memset(&nbi, 0, sizeof(nbi)); + nbi.di_mode = dp->di_mode; + nbi.di_nlink = dp->di_nlink; + nbi.di_ouid = dp->di_uid; + nbi.di_ogid = dp->di_gid; + nbi.di_size = dir_size; /* (u_quad_t)dp->di_size; */ + nbi.di_atime.tv_sec = dp->di_atime; + nbi.di_mtime.tv_sec = dp->di_mtime; + nbi.di_ctime.tv_sec = dp->di_ctime; + memmove(&nbi.di_db, &dp->di_db, (NDADDR + NIADDR) * sizeof(daddr_t)); + nbi.di_flags = dp->di_flags; + nbi.di_blocks = dp->di_blocks; + nbi.di_gen = dp->di_gen; + nbi.di_uid = (((int32_t)dp->di_uidhigh) << 16) | dp->di_uid; + nbi.di_gid = (((int32_t)dp->di_gidhigh) << 16) | dp->di_gid; if (dp->di_file_acl) warn("ACLs in inode #%ld won't be dumped", (long)ino); - memmove(&spcl.c_dinode, &obi, sizeof(obi)); + memmove(&spcl.c_dinode, &nbi, sizeof(nbi)); #else /* __linux__ */ spcl.c_dinode = *dp; #endif /* __linux__ */ -- 2.39.5