X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=dump%2Ftraverse.c;h=bd16f9b7a696de34a607213a7e898b92b8973c67;hp=c8547604a7c0751f14833407938e762acf1ca56f;hb=9ca70cf6a082bb146eaaa0b09361643feca38875;hpb=0cedbda5e645e6a30ef47fa3e0fae683160d4431 diff --git a/dump/traverse.c b/dump/traverse.c index c854760..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.44 2002/04/04 08:20:23 stelian Exp $"; + "$Id: traverse.c,v 1.48 2002/07/17 10:18:52 stelian Exp $"; #endif /* not lint */ #include @@ -51,6 +51,7 @@ static const char rcsid[] = #include #include #endif +#include #include #include @@ -668,12 +669,13 @@ searchdir(struct ext2_dir_entry *dp, int offset, int blocksize, char *buf, void ip = getino(dp->inode); if (TSTINO(dp->inode, dumpinomap)) { CLRINO(dp->inode, dumpinomap); - CLRINO(dp->inode, usedinomap); *tapesize -= blockest(ip); } - /* Add dir back to the dir map, to propagate nodump */ + /* Add dir back to the dir map and remove from + * usedinomap to propagate nodump */ if ((ip->di_mode & IFMT) == IFDIR) { SETINO(dp->inode, dumpdirmap); + CLRINO(dp->inode, usedinomap); *ret |= HASSUBDIRS; } } else { @@ -784,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; @@ -804,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__ */ @@ -827,7 +831,6 @@ dumpino(struct dinode *dp, dump_ino_t ino, int metaonly) spcl.c_count = 0; if (metaonly && (dp->di_mode & S_IFMT)) { - printf("Write header with spcl.c_count=%d\n",spcl.c_count); spcl.c_flags |= DR_METAONLY; spcl.c_count = 0; writeheader(ino); @@ -960,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; @@ -994,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; @@ -1034,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__ */ @@ -1278,7 +1283,6 @@ void bread(daddr_t blkno, char *buf, int size) { int cnt, i; - extern int errno; loop: #ifdef __linux__ @@ -1306,11 +1310,12 @@ loop: goto loop; } if (cnt == -1) - msg("read error from %s: %s: [block %d]: count=%d\n", - disk, strerror(errno), blkno, size); + msg("read error from %s: %s: [block %d, ext2blk %d]: count=%d\n", + disk, strerror(errno), blkno, + dbtofsb(sblock, blkno), size); else - msg("short read error from %s: [block %d]: count=%d, got=%d\n", - disk, blkno, size, cnt); + msg("short read error from %s: [block %d, ext2blk %d]: count=%d, got=%d\n", + disk, blkno, dbtofsb(sblock, blkno), size, cnt); if (++breaderrors > breademax) { msg("More than %d block read errors from %d\n", breademax, disk); @@ -1338,11 +1343,12 @@ loop: if ((cnt = read(diskfd, buf, (int)dev_bsize)) == dev_bsize) continue; if (cnt == -1) { - msg("read error from %s: %s: [sector %d]: count=%d\n", - disk, strerror(errno), blkno, dev_bsize); + msg("read error from %s: %s: [sector %d, ext2blk %d]: count=%d\n", + disk, strerror(errno), blkno, + dbtofsb(sblock, blkno), dev_bsize); continue; } - msg("short read error from %s: [sector %d]: count=%d, got=%d\n", - disk, blkno, dev_bsize, cnt); + msg("short read error from %s: [sector %d, ext2blk %d]: count=%d, got=%d\n", + disk, blkno, dbtofsb(sblock, blkno), dev_bsize, cnt); } }