{
__u16 crc1, crc2, crc3;
dgrp_t swabgroup;
- struct ext2_group_desc *desc = ext2fs_group_desc(fs, fs->group_desc, group);
+ struct ext2_group_desc *desc;
size_t size;
struct ext2_super_block *sb = fs->super;
int offset = offsetof(struct ext2_group_desc, bg_checksum);
struct ext4_group_desc swabdesc;
#endif
+ desc = ext2fs_group_desc(fs, fs->group_desc, group);
size = fs->super->s_desc_size;
if (size < EXT2_MIN_DESC_SIZE)
size = EXT2_MIN_DESC_SIZE;
if (offset < size)
crc3 = ext2fs_crc16(crc3, (char *)desc + offset, size - offset);
- printf("%s: UUID %s(%04x), grp %u(%04x): %04x=%04x\n",
+ printf("%s UUID %s=%04x, grp %u=%04x: %04x=%04x\n",
msg, e2p_uuid2str(sb->s_uuid), crc1, group, crc2, crc3,
ext2fs_group_desc_csum(fs, group));
}
uuid_t buf, tst;
char str[100];
struct timeval tv;
- time_t time_reg;
+ time_t time_reg, time_gen;
unsigned char *cp;
int i;
int failed = 0;
printf("%02x", *cp++);
}
printf("\n");
- type = uuid_type(buf); variant = uuid_variant(buf);
+ type = uuid_type(buf);
+ variant = uuid_variant(buf);
printf("UUID type = %d, UUID variant = %d\n", type, variant);
if (variant != UUID_VARIANT_DCE) {
printf("Incorrect UUID Variant; was expecting DCE!\n");
}
printf("\n");
+ time_gen = time(0);
uuid_generate_time(buf);
uuid_unparse(buf, str);
printf("UUID string = %s\n", str);
printf("%02x", *cp++);
}
printf("\n");
- type = uuid_type(buf); variant = uuid_variant(buf);
+ type = uuid_type(buf);
+ variant = uuid_variant(buf);
printf("UUID type = %d, UUID variant = %d\n", type, variant);
if (variant != UUID_VARIANT_DCE) {
printf("Incorrect UUID Variant; was expecting DCE!\n");
"1 (time-based type)!\\n");
failed++;
}
+
tv.tv_sec = 0;
tv.tv_usec = 0;
time_reg = uuid_time(buf, &tv);
- printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec,
- ctime(&time_reg));
+ printf("UUID generated at %lu reports %lu (%ld.%ld)\n",
+ time_gen, time_reg, tv.tv_sec, tv.tv_usec);
+ /* allow 1s margin in case of rollover between sampling
+ * the current time and when the UUID is generated. */
+ if (time_reg > time_gen + 1) {
+ printf("UUID time comparison failed!\n");
+ failed++;
+ } else {
+ printf("UUID time comparison succeeded.\n");
+ }
+
uuid_parse(str, tst);
- if (!uuid_compare(buf, tst))
+ if (!uuid_compare(buf, tst)) {
printf("UUID parse and compare succeeded.\n");
- else {
+ } else {
printf("UUID parse and compare failed!\n");
failed++;
}
printf("UUID copy and compare failed!\n");
failed++;
}
+
failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981b", 1);
failed += test_uuid("84949CC5-4701-4A84-895B-354C584A981B", 1);
failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981bc", 0);