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