]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
1999-06-07 Roland McGrath <roland@baalperazim.frob.com>
authorRoland McGrath <roland@gnu.org>
Mon, 7 Jun 1999 18:09:37 +0000 (18:09 +0000)
committerRoland McGrath <roland@gnu.org>
Mon, 7 Jun 1999 18:09:37 +0000 (18:09 +0000)
* db2/os/os_oflags.c (__db_oflags): Fix checking of O_ACCMODE bits to
be POSIX compliant.  Prior definition was broken for Hurd.
Reported by Mark Kettenis <kettenis@gnu.org>.

db2/os/os_oflags.c

index 388c1c6faa3e433d5a5e6887fe3b429f6a3451a5..976b84d709a69d0254896803475a54c9e59e99cf 100644 (file)
@@ -33,16 +33,21 @@ __db_oflags(oflags)
        u_int32_t 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.
+        * Convert POSIX 1003.1 open(2) flags to DB flags.
         */
        dbflags = 0;
+       switch (oflags & O_ACCMODE) {
+       case O_RDONLY:
+               dbflags |= DB_RDONLY;
+               break;
+       case O_WRONLY:
+       case O_RDWR:
+               break;
+       default:                /* Bogus flags value from user.  */
+         /* XXX no way to return error from here */
+       }
        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);