1997-04-29 20:17:09 +04:00
|
|
|
/*
|
|
|
|
* tst_uuid.c --- test program from the UUID library
|
|
|
|
*
|
1998-12-04 11:13:52 +03:00
|
|
|
* Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
|
1997-04-29 20:17:09 +04:00
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
|
|
|
*/
|
|
|
|
|
1997-04-29 18:53:37 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "uuid.h"
|
|
|
|
|
|
|
|
int
|
ChangeLog, debugfs.8.in, debugfs.c:
Add a -V option which displays the current version.
ChangeLog, unix.c:
unix.c (e2fsck_update_progress): Remove unused variables.
ChangeLog, inode.c:
inode.c (get_next_blockgroup): Fix bug where if get_next_blockgroup()
is called early because of a missing inode table in a block group, the
current_inode counter wasn't incremented correctly.
ChangeLog, tst_uuid.c:
tst_uuid.c (main): Fixed bogus declaration of the main's argv parameter.
ChangeLog, test_icount.c:
test_icount.c (main): Fix main() declaration so that it returns int,
not void.
Many files:
fsck.c (ignore): Remove unused variable cp.
chattr.c (fatal_error):
tune2fs.c (usage):
lsattr.c (usage):
dumpe2fs.c (usage):
badblocks.c (usage): Remove volatile from declaration.
fsck.c: Change use of strdup to be string_copy, since we don't trust
what glibc is doing with strdup. (Whatever it is, it isn't pretty.)
1998-06-27 09:11:14 +04:00
|
|
|
main(int argc, char **argv)
|
1997-04-29 18:53:37 +04:00
|
|
|
{
|
|
|
|
uuid_t buf, tst;
|
|
|
|
char str[100];
|
1998-12-04 11:13:52 +03:00
|
|
|
struct timeval tv;
|
|
|
|
time_t time_reg;
|
1997-04-29 18:53:37 +04:00
|
|
|
unsigned char *cp;
|
|
|
|
int i;
|
|
|
|
int failed = 0;
|
1999-06-18 04:32:03 +04:00
|
|
|
int type, variant;
|
1997-04-29 18:53:37 +04:00
|
|
|
|
|
|
|
uuid_generate(buf);
|
|
|
|
uuid_unparse(buf, str);
|
1999-06-18 04:32:03 +04:00
|
|
|
printf("UUID generate = %s\n", str);
|
|
|
|
printf("UUID: ");
|
|
|
|
for (i=0, cp = (unsigned char *) &buf; i < 16; i++) {
|
|
|
|
printf("%02x", *cp++);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
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");
|
|
|
|
failed++;
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
uuid_generate_random(buf);
|
|
|
|
uuid_unparse(buf, str);
|
|
|
|
printf("UUID random string = %s\n", str);
|
1997-04-29 18:53:37 +04:00
|
|
|
printf("UUID: ");
|
|
|
|
for (i=0, cp = (unsigned char *) &buf; i < 16; i++) {
|
|
|
|
printf("%02x", *cp++);
|
|
|
|
}
|
|
|
|
printf("\n");
|
1999-06-18 04:32:03 +04:00
|
|
|
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");
|
|
|
|
failed++;
|
|
|
|
}
|
|
|
|
if (type != 4) {
|
|
|
|
printf("Incorrect UUID type; was expecting "
|
|
|
|
"4 (random type)!\n");
|
|
|
|
failed++;
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
uuid_generate_time(buf);
|
|
|
|
uuid_unparse(buf, str);
|
|
|
|
printf("UUID string = %s\n", str);
|
|
|
|
printf("UUID time: ");
|
|
|
|
for (i=0, cp = (unsigned char *) &buf; i < 16; i++) {
|
|
|
|
printf("%02x", *cp++);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
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");
|
|
|
|
failed++;
|
|
|
|
}
|
|
|
|
if (type != 1) {
|
|
|
|
printf("Incorrect UUID type; was expecting "
|
|
|
|
"1 (time-based type)!\\n");
|
|
|
|
failed++;
|
|
|
|
}
|
1998-12-04 11:13:52 +03:00
|
|
|
tv.tv_sec = 0;
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
time_reg = uuid_time(buf, &tv);
|
2001-01-12 21:30:54 +03:00
|
|
|
printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec,
|
1998-12-04 11:13:52 +03:00
|
|
|
ctime(&time_reg));
|
1997-04-29 18:53:37 +04:00
|
|
|
uuid_parse(str, tst);
|
1999-06-18 04:32:03 +04:00
|
|
|
if (!uuid_compare(buf, tst))
|
1997-04-29 18:53:37 +04:00
|
|
|
printf("UUID parse and compare succeeded.\n");
|
|
|
|
else {
|
|
|
|
printf("UUID parse and compare failed!\n");
|
|
|
|
failed++;
|
|
|
|
}
|
|
|
|
uuid_clear(tst);
|
|
|
|
if (uuid_is_null(tst))
|
|
|
|
printf("UUID clear and is null succeeded.\n");
|
|
|
|
else {
|
|
|
|
printf("UUID clear and is null failed!\n");
|
|
|
|
failed++;
|
|
|
|
}
|
|
|
|
uuid_copy(buf, tst);
|
1999-06-18 04:32:03 +04:00
|
|
|
if (!uuid_compare(buf, tst))
|
1997-04-29 18:53:37 +04:00
|
|
|
printf("UUID copy and compare succeeded.\n");
|
|
|
|
else {
|
|
|
|
printf("UUID copy and compare failed!\n");
|
|
|
|
failed++;
|
|
|
|
}
|
|
|
|
if (failed) {
|
|
|
|
printf("%d failures.\n", failed);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|