Whamcloud - gitweb
ChangeLog, Makefile.in, tst_uuid.c, uuid.h, uuid_time.c:
authorTheodore Ts'o <tytso@mit.edu>
Fri, 4 Dec 1998 08:13:52 +0000 (08:13 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 4 Dec 1998 08:13:52 +0000 (08:13 +0000)
  Makefile.in: Update version numbers of the UUID shared library, since
   we've added a new function (uuid_time()).
  uuid_time.c: New file which returns the time field of a UUID.  (Good
   for debugging purposes)
libext2fs.texinfo:
  Update version number for 1.13 release.

doc/libext2fs.texinfo
lib/uuid/ChangeLog
lib/uuid/Makefile.in
lib/uuid/tst_uuid.c
lib/uuid/uuid.h
lib/uuid/uuid_time.c [new file with mode: 0644]

index fa115c5..0ad2d39 100644 (file)
@@ -1,7 +1,7 @@
 \input texinfo    @c -*-texinfo-*-
 @c %**start of header
 @setfilename libext2fs.info
-@settitle The EXT2FS Library (version 1.12)
+@settitle The EXT2FS Library (version 1.13)
 @synindex tp fn
 @comment %**end of header
 
@@ -60,7 +60,7 @@ by the author.
 
 @title The EXT2FS Library
 @subtitle The EXT2FS Library
-@subtitle Version 1.12
+@subtitle Version 1.13
 @subtitle July 1998
 
 @author by Theodore Ts'o
@@ -101,7 +101,7 @@ by the Foundation.
 
 @top The EXT2FS Library
 
-This manual documents the EXT2FS Library, version 1.12.
+This manual documents the EXT2FS Library, version 1.13.
 
 @end ifinfo
 
index c1f7f32..eeb708b 100644 (file)
@@ -1,3 +1,11 @@
+1998-12-04  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+       * Makefile.in: Update version numbers of the UUID shared library,
+               since we've added a new function (uuid_time()).
+
+       * uuid_time.c: New file which returns the time field of a UUID.
+               (Good for debugging purposes)
+
 1998-07-09  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
        * Release of E2fsprogs 1.12
index 20f6c78..8b1a4a1 100644 (file)
@@ -24,7 +24,8 @@ OBJS=         clear.o \
                pack.o \
                parse.o \
                unpack.o \
-               unparse.o
+               unparse.o \
+               uuid_time.o
 
 SRCS=          $(srcdir)/clear.c \
                $(srcdir)/compare.c \
@@ -34,7 +35,8 @@ SRCS=         $(srcdir)/clear.c \
                $(srcdir)/pack.c \
                $(srcdir)/parse.c \
                $(srcdir)/unpack.c \
-               $(srcdir)/unparse.c
+               $(srcdir)/unparse.c \
+               $(srcdir)/uuid_time.c
 
 LIBRARY= libuuid
 LIBDIR= uuid
@@ -42,20 +44,20 @@ LIBDIR= uuid
 DLL_ADDRESS = 0x67900000
 DLL_JUMPSIZE = 0x1000
 DLL_GOTSIZE  = 0x1000
-DLL_VERSION = 0.0
+DLL_VERSION = 0.1
 DLL_IMAGE = libuuid
 DLL_STUB = libuuid
 DLL_MYDIR = uuid
 DLL_INSTALL_DIR = $(root_libdir)
 
-ELF_VERSION = 1.1
+ELF_VERSION = 1.2
 ELF_SO_VERSION = 1
 ELF_IMAGE = libuuid
 ELF_MYDIR = uuid
 ELF_INSTALL_DIR = $(root_libdir)
 ELF_OTHER_LIBS = -lc
 
-BSDLIB_VERSION = 1.0
+BSDLIB_VERSION = 1.1
 BSDLIB_IMAGE = libuuid
 BSDLIB_MYDIR = uuid
 BSDLIB_INSTALL_DIR = $(root_libdir)
@@ -76,7 +78,7 @@ BSDLIB_INSTALL_DIR = $(root_libdir)
 @ELF_CMT@      $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
 @BSDLIB_CMT@   $(CC) $(ALL_CFLAGS) -fpic -o pic/$*.o -c $<
 
-all:: tst_uuid
+all:: tst_uuid uuid_time
 
 tst_uuid.o: $(srcdir)/tst_uuid.c
        $(CC) $(ALL_CFLAGS) -c $(srcdir)/tst_uuid.c -o tst_uuid.o
@@ -84,6 +86,9 @@ tst_uuid.o: $(srcdir)/tst_uuid.c
 tst_uuid: tst_uuid.o $(LIBUUID)
        $(CC) $(ALL_LDFLAGS) -o tst_uuid tst_uuid.o $(LIBUUID)
 
+uuid_time: $(srcdir)/uuid_time.c
+       $(CC) $(ALL_CFLAGS) -DDEBUG $(srcdir)/uuid_time.c -o uuid_time $(LIBUUID)
+
 installdirs::
        $(top_srcdir)/mkinstalldirs $(DESTDIR)$(libdir)  \
                $(DESTDIR)$(includedir)/uuid
@@ -100,7 +105,7 @@ uninstall::
 
 clean::
        $(RM) -f \#* *.s *.o *.a *~ *.bak core profiled/* checker/*
-       $(RM) -f ../libuuid.a ../libuuid_p.a tst_uuid
+       $(RM) -f ../libuuid.a ../libuuid_p.a tst_uuid uuid_time
 
 mostlyclean:: clean
 distclean:: clean
index c474af7..f798470 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * tst_uuid.c --- test program from the UUID library
  *
- * Copyright (C) 1996, 1997 Theodore Ts'o.
+ * Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
  *
  * %Begin-Header%
  * This file may be redistributed under the terms of the GNU Public
@@ -19,6 +19,8 @@ main(int argc, char **argv)
 {
        uuid_t          buf, tst;
        char            str[100];
+       struct timeval  tv;
+       time_t          time_reg;
        unsigned char   *cp;
        int i;
        int failed = 0;
@@ -31,6 +33,11 @@ main(int argc, char **argv)
                printf("%02x", *cp++);
        }
        printf("\n");
+       tv.tv_sec = 0;
+       tv.tv_usec = 0;
+       time_reg = uuid_time(buf, &tv);
+       printf("UUID time is: (%d, %d): %s\n", tv.tv_sec, tv.tv_usec,
+              ctime(&time_reg));
        uuid_parse(str, tst);
        if (uuid_compare(buf, tst))
                printf("UUID parse and compare succeeded.\n");
index 08f924c..cf3a89f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Public include file for the UUID library
  * 
- * Copyright (C) 1996, 1997 Theodore Ts'o.
+ * Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
  *
  * %Begin-Header%
  * This file may be redistributed under the terms of the GNU Public
@@ -9,6 +9,10 @@
  * %End-Header%
  */
 
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
 typedef unsigned char uuid_t[16];
 
 /* clear.c */
@@ -32,5 +36,7 @@ int uuid_parse(char *in, uuid_t uu);
 /* unparse.c */
 void uuid_unparse(uuid_t uu, char *out);
 
+/* uuid_time.c */
+time_t uuid_time(uuid_t uu, struct timeval *ret_tv);
 
 
diff --git a/lib/uuid/uuid_time.c b/lib/uuid/uuid_time.c
new file mode 100644 (file)
index 0000000..2d9804f
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * uuid_time.c --- Interpret the time field from a uuid
+ *
+ * Copyright (C) 1998 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+#include <linux/ext2_fs.h>
+
+#include "uuidP.h"
+
+time_t uuid_time(uuid_t uu, struct timeval *ret_tv)
+{
+       struct uuid             uuid;
+       __u32                   high;
+       struct timeval          tv;
+       unsigned long long      clock_reg;
+
+       uuid_unpack(uu, &uuid);
+       
+       high = uuid.time_mid | ((uuid.time_hi_and_version & 0xFFF) << 16);
+       clock_reg = uuid.time_low | ((unsigned long long) high << 32);
+
+       clock_reg -= (((unsigned long long) 0x01B21DD2) << 32) + 0x13814000;
+       tv.tv_sec = clock_reg / 10000000;
+       tv.tv_usec = (clock_reg % 10000000) / 10;
+
+       if (ret_tv)
+               *ret_tv = tv;
+
+       return tv.tv_sec;
+}
+
+#ifdef DEBUG
+int
+main(int argc, char **argv)
+{
+       uuid_t          buf;
+       time_t          time_reg;
+       struct timeval  tv;
+
+       if (argc != 2) {
+               fprintf(stderr, "Usage: %s uuid\n", argv[0]);
+               exit(1);
+       }
+       if (uuid_parse(argv[1], buf)) {
+               fprintf(stderr, "Invalid UUID: %s\n", argv[1]);
+               exit(1);
+       }
+       time_reg = uuid_time(buf, &tv);
+
+       printf("UUID time is: (%d, %d): %s\n", tv.tv_sec, tv.tv_usec,
+              ctime(&time_reg));
+       
+       return 0;
+}
+#endif