aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db2/os/os_oflags.c')
-rw-r--r--db2/os/os_oflags.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/db2/os/os_oflags.c b/db2/os/os_oflags.c
new file mode 100644
index 0000000000..3656eef1c4
--- /dev/null
+++ b/db2/os/os_oflags.c
@@ -0,0 +1,48 @@
+/*-
+ * See the file LICENSE for redistribution information.
+ *
+ * Copyright (c) 1997
+ * Sleepycat Software. All rights reserved.
+ */
+
+#include "config.h"
+
+#ifndef lint
+static const char sccsid[] = "@(#)os_oflags.c 10.2 (Sleepycat) 10/24/97";
+#endif /* not lint */
+
+#ifndef NO_SYSTEM_INCLUDES
+#include <sys/types.h>
+
+#include <fcntl.h>
+#endif
+
+#include "db_int.h"
+
+/*
+ * __db_oflags --
+ * Convert open(2) flags to DB flags.
+ *
+ * PUBLIC: int __db_oflags __P((int));
+ */
+int
+__db_oflags(oflags)
+ int oflags;
+{
+ int dbflags;
+
+ /*
+ * XXX
+ * Convert POSIX 1003.1 open(2) flags to DB flags. Not an exact
+ * science as most POSIX implementations don't have a flag value
+ * for O_RDONLY, it's simply the lack of a write flag.
+ */
+ dbflags = 0;
+ if (oflags & O_CREAT)
+ dbflags |= DB_CREATE;
+ if (!(oflags & (O_RDWR | O_WRONLY)) || oflags & O_RDONLY)
+ dbflags |= DB_RDONLY;
+ if (oflags & O_TRUNC)
+ dbflags |= DB_TRUNCATE;
+ return (dbflags);
+}