+static void
+dump_xattr(dump_ino_t ino, struct dinode *dp) {
+
+ if (dp->di_extraisize != 0) {
+#ifdef HAVE_EXT2FS_READ_INODE_FULL
+ char inode[EXT2_INODE_SIZE(fs->super)];
+ errcode_t err;
+ u_int32_t *magic;
+
+ memset(inode, 0, EXT2_INODE_SIZE(fs->super));
+ err = ext2fs_read_inode_full(fs, (ext2_ino_t)ino,
+ (struct ext2_inode *) inode,
+ EXT2_INODE_SIZE(fs->super));
+ if (err) {
+ com_err(disk, err, "while reading inode #%ld\n", (long)ino);
+ exit(X_ABORT);
+ }
+
+ magic = (void *)inode + EXT2_GOOD_OLD_INODE_SIZE + dp->di_extraisize;
+ if (*magic == EXT2_XATTR_MAGIC) {
+ char xattr[EXT2_INODE_SIZE(fs->super)];
+ int i;
+ char *cp;
+
+ if (vflag)
+ msg("dumping EA (inode) in inode #%ld\n", (long)ino);
+ memset(xattr, 0, EXT2_INODE_SIZE(fs->super));
+ memcpy(xattr, (void *)magic,
+ EXT2_INODE_SIZE(fs->super) -
+ (EXT2_GOOD_OLD_INODE_SIZE + dp->di_extraisize));
+ magic = (u_int32_t *)xattr;
+ *magic = EXT2_XATTR_MAGIC2;
+
+ spcl.c_type = TS_INODE;
+ spcl.c_dinode.di_size = EXT2_INODE_SIZE(fs->super);
+ spcl.c_flags |= DR_EXTATTRIBUTES;
+ spcl.c_extattributes = EXT_XATTR;
+ spcl.c_count = howmany(EXT2_INODE_SIZE(fs->super), TP_BSIZE);
+ for (i = 0; i < spcl.c_count; i++)
+ spcl.c_addr[i] = 1;
+ writeheader(ino);
+ for (i = 0, cp = xattr; i < spcl.c_count; i++, cp += TP_BSIZE)
+ writerec(cp, 0);
+ spcl.c_flags &= ~DR_EXTATTRIBUTES;
+ spcl.c_extattributes = 0;
+ }
+#endif
+ }
+
+ if (dp->di_file_acl) {
+
+ if (vflag)
+ msg("dumping EA (block) in inode #%ld\n", (long)ino);
+
+ spcl.c_type = TS_INODE;
+ spcl.c_dinode.di_size = sblock->fs_bsize;
+ spcl.c_flags |= DR_EXTATTRIBUTES;
+ spcl.c_extattributes = EXT_XATTR;
+ blksout(&dp->di_file_acl, EXT2_FRAGS_PER_BLOCK(fs->super), ino);
+ spcl.c_flags &= ~DR_EXTATTRIBUTES;
+ spcl.c_extattributes = 0;
+ }
+}
+