summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
12e0a31)
SCCS-vsn: lib/libc/db/btree/bt_open.c 5.21
*/
#if defined(LIBC_SCCS) && !defined(lint)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_open.c 5.20 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_open.c 5.21 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
/*
#endif /* LIBC_SCCS and not lint */
/*
* open a backing temporary file. Otherwise, it's a disk-based tree.
*/
if (fname) {
* open a backing temporary file. Otherwise, it's a disk-based tree.
*/
if (fname) {
+ switch(flags & O_ACCMODE) {
+ case O_RDONLY:
+ SET(t, BTF_RDONLY);
+ break;
+ case O_RDWR:
+ break;
+ case O_WRONLY:
+ default:
+ goto einval;
+ }
+
- (O_CREAT|O_EXCL|O_EXLOCK|O_RDONLY|O_RDWR|O_SHLOCK|O_TRUNC|O_WRONLY)
+ (O_CREAT|O_EXCL|O_EXLOCK|O_RDONLY|O_RDWR|O_SHLOCK|O_TRUNC)
if ((t->bt_fd = open(fname, flags & USEFLAGS, mode)) < 0)
goto err;
if ((t->bt_fd = open(fname, flags & USEFLAGS, mode)) < 0)
goto err;
- if ((flags & O_ACCMODE) == O_RDONLY)
- SET(t, BTF_RDONLY);
+ if ((flags & O_ACCMODE) != O_RDWR)
+ goto einval;
if ((t->bt_fd = tmp()) == -1)
goto err;
SET(t, BTF_INMEM);
if ((t->bt_fd = tmp()) == -1)
goto err;
SET(t, BTF_INMEM);