2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1996, 1997, 1998
5 * Sleepycat Software. All rights reserved.
11 static const char sccsid
[] = "@(#)os_fid.c 10.11 (Sleepycat) 4/26/98";
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
24 #include "common_ext.h"
28 * Return a unique identifier for a file.
30 * PUBLIC: int __db_fileid __P((DB_ENV *, const char *, int, u_int8_t *));
33 __db_fileid(dbenv
, fname
, timestamp
, fidp
)
44 /* Clear the buffer. */
45 memset(fidp
, 0, DB_FILE_ID_LEN
);
47 /* Check for the unthinkable. */
48 if (sizeof(sb
.st_ino
) +
49 sizeof(sb
.st_dev
) + sizeof(time_t) > DB_FILE_ID_LEN
)
52 /* On UNIX, use a dev/inode pair. */
53 if (stat(fname
, &sb
)) {
54 __db_err(dbenv
, "%s: %s", fname
, strerror(errno
));
59 * Use the inode first and in reverse order, hopefully putting the
60 * distinguishing information early in the string.
62 for (p
= (u_int8_t
*)&sb
.st_ino
+
63 sizeof(sb
.st_ino
), i
= 0; i
< sizeof(sb
.st_ino
); ++i
)
65 for (p
= (u_int8_t
*)&sb
.st_dev
+
66 sizeof(sb
.st_dev
), i
= 0; i
< sizeof(sb
.st_dev
); ++i
)
71 for (p
= (u_int8_t
*)&now
+
72 sizeof(now
), i
= 0; i
< sizeof(now
); ++i
)