Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

os.h

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1997-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: os.h,v 12.10 2005/10/31 02:22:24 bostic Exp $
00008  */
00009 
00010 #ifndef _DB_OS_H_
00011 #define _DB_OS_H_
00012 
00013 #if defined(__cplusplus)
00014 extern "C" {
00015 #endif
00016 
00017 /* Number of times to retry system calls that return EINTR or EBUSY. */
00018 #define DB_RETRY        100
00019 
00020 #ifdef __TANDEM
00021 /*
00022  * OSS Tandem problem: fsync can return a Guardian file system error of 70,
00023  * which has no symbolic name in OSS.  HP says to retry the fsync. [#12957]
00024  */
00025 #define RETRY_CHK(op, ret) do {                                         \
00026         int __retries = DB_RETRY;                                       \
00027         do {                                                            \
00028                 (ret) = (op);                                           \
00029         } while ((ret) != 0 && (((ret) = __os_get_errno()) == EAGAIN || \
00030             (ret) == EBUSY || (ret) == EINTR || (ret) == EIO ||         \
00031             (ret) == 70) &&                                             \
00032             --__retries > 0);                                           \
00033 } while (0)
00034 #else
00035 #define RETRY_CHK(op, ret) do {                                         \
00036         int __retries = DB_RETRY;                                       \
00037         do {                                                            \
00038                 (ret) = (op);                                           \
00039         } while ((ret) != 0 && (((ret) = __os_get_errno()) == EAGAIN || \
00040             (ret) == EBUSY || (ret) == EINTR || (ret) == EIO) &&        \
00041             --__retries > 0);                                           \
00042 } while (0)
00043 #endif
00044 
00045 #define RETRY_CHK_EINTR_ONLY(op, ret) do {                              \
00046         int __retries = DB_RETRY;                                       \
00047         do {                                                            \
00048                 (ret) = (op);                                           \
00049         } while ((ret) != 0 &&                                          \
00050             (((ret) = __os_get_errno()) == EINTR) && --__retries > 0);  \
00051 } while (0)
00052 
00053 /*
00054  * Flags understood by __os_open.
00055  */
00056 #define DB_OSO_ABSMODE  0x0001          /* Absolute mode specified. */
00057 #define DB_OSO_CREATE   0x0002          /* POSIX: O_CREAT */
00058 #define DB_OSO_DIRECT   0x0004          /* Don't buffer the file in the OS. */
00059 #define DB_OSO_DSYNC    0x0008          /* POSIX: O_DSYNC. */
00060 #define DB_OSO_EXCL     0x0010          /* POSIX: O_EXCL */
00061 #define DB_OSO_RDONLY   0x0020          /* POSIX: O_RDONLY */
00062 #define DB_OSO_REGION   0x0040          /* Opening a region file. */
00063 #define DB_OSO_SEQ      0x0080          /* Expected sequential access. */
00064 #define DB_OSO_TEMP     0x0100          /* Remove after last close. */
00065 #define DB_OSO_TRUNC    0x0200          /* POSIX: O_TRUNC */
00066 
00067 /*
00068  * Seek options understood by __os_seek.
00069  */
00070 typedef enum {
00071         DB_OS_SEEK_CUR,                 /* POSIX: SEEK_CUR */
00072         DB_OS_SEEK_END,                 /* POSIX: SEEK_END */
00073         DB_OS_SEEK_SET                  /* POSIX: SEEK_SET */
00074 } DB_OS_SEEK;
00075 
00076 /*
00077  * We group certain seek/write calls into a single function so that we
00078  * can use pread(2)/pwrite(2) where they're available.
00079  */
00080 #define DB_IO_READ      1
00081 #define DB_IO_WRITE     2
00082 
00083 /* DB filehandle. */
00084 struct __fh_t {
00085         /*
00086          * The file-handle mutex is only used to protect the handle/fd
00087          * across seek and read/write pairs, it does not protect the
00088          * the reference count, or any other fields in the structure.
00089          */
00090         db_mutex_t mtx_fh;              /* Mutex to lock. */
00091 
00092         int     ref;                    /* Reference count. */
00093 
00094 #if defined(DB_WIN32)
00095         HANDLE  handle;         /* Windows/32 file handle. */
00096 #endif
00097         int     fd;                     /* POSIX file descriptor. */
00098 
00099         char    *name;                  /* File name (ref DB_FH_UNLINK) */
00100 
00101         /*
00102          * Last seek statistics, used for zero-filling on filesystems
00103          * that don't support it directly.
00104          */
00105         db_pgno_t pgno;
00106         u_int32_t pgsize;
00107         u_int32_t offset;
00108 
00109 #define DB_FH_NOSYNC    0x01            /* Handle doesn't need to be sync'd. */
00110 #define DB_FH_OPENED    0x02            /* Handle is valid. */
00111 #define DB_FH_UNLINK    0x04            /* Unlink on close */
00112         u_int8_t flags;
00113 };
00114 
00115 /* Standard 600 mode for __db_omode. */
00116 #define OWNER_RW        "rw-------"
00117 
00118 #if defined(__cplusplus)
00119 }
00120 #endif
00121 
00122 #include "dbinc_auto/os_ext.h"
00123 #endif /* !_DB_OS_H_ */

Generated on Sun Dec 25 12:14:22 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2