diff options
-rw-r--r-- | lib/ext2fs/ChangeLog | 4 | ||||
-rw-r--r-- | lib/ext2fs/e2image.h | 2 | ||||
-rw-r--r-- | misc/ChangeLog | 4 | ||||
-rw-r--r-- | misc/e2image.c | 23 |
4 files changed, 30 insertions, 3 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index c22cec83..ee128cac 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,7 @@ +2001-02-08 Theodore Tso <tytso@valinux.com> + + * e2image.h (struct ext2_image_hdr): Fix type for fs_hostname + 2001-02-07 Theodore Tso <tytso@valinux.com> * mkjournal.c (ext2fs_create_journal_superblock): Fix the setting diff --git a/lib/ext2fs/e2image.h b/lib/ext2fs/e2image.h index c72c29dd..75d7c044 100644 --- a/lib/ext2fs/e2image.h +++ b/lib/ext2fs/e2image.h @@ -16,7 +16,7 @@ struct ext2_image_hdr { __u32 magic_number; /* This must be EXT2_ET_MAGIC_E2IMAGE */ char magic_descriptor[16]; /* "Ext2 Image 1.0", w/ null padding */ - __u32 fs_hostname[64];/* Hostname of machine of image */ + char fs_hostname[64];/* Hostname of machine of image */ char fs_netaddr[32]; /* Network address */ __u32 fs_netaddr_type;/* 0 = IPV4, 1 = IPV6, etc. */ __u32 fs_device; /* Device number of image */ diff --git a/misc/ChangeLog b/misc/ChangeLog index 56bc104b..e44e6e66 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,3 +1,7 @@ +2001-02-08 Theodore Tso <tytso@valinux.com> + + * e2image.c (main): Add code to write the e2image header. + 2001-02-07 Theodore Tso <tytso@valinux.com> * tune2fs.8.in: Update man page to reflect that 2.0.39 supports diff --git a/misc/e2image.c b/misc/e2image.c index f7c42d02..cae30a6e 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -85,6 +85,7 @@ int main (int argc, char ** argv) int raw_flag = 0; int fd = 0; struct ext2_image_hdr hdr; + struct stat st; #ifdef ENABLE_NLS setlocale(LC_MESSAGES, ""); @@ -117,7 +118,7 @@ int main (int argc, char ** argv) exit(1); } - fd = open(argv[optind+1], O_CREAT|O_TRUNC|O_RDWR, 0600); + fd = open(argv[optind+1], O_CREAT|O_RDWR, 0600); if (fd < 0) { com_err(program_name, errno, _("while trying to open %s"), argv[optind+1]); @@ -154,7 +155,25 @@ int main (int argc, char ** argv) com_err(program_name, retval, _("while writing inode bitmap")); exit(1); } - + + hdr.magic_number = EXT2_ET_MAGIC_E2IMAGE; + strcpy(hdr.magic_descriptor, "Ext2 Image 1.0"); + gethostname(hdr.fs_hostname, sizeof(hdr.fs_hostname)); + + if (stat(device_name, &st) == 0) + hdr.fs_device = st.st_rdev; + + if (fstat(fd, &st) == 0) { + hdr.image_device = st.st_dev; + hdr.image_inode = st.st_ino; + } + memcpy(hdr.fs_uuid, fs->super->s_uuid, sizeof(hdr.fs_uuid)); + + hdr.image_time = time(0); + write_header(fd, &hdr); + ext2fs_close (fs); exit (0); } + + |