]> pd.if.org Git - pdclib/blobdiff - platform/example/functions/_PDCLIB/open.c
New file permissions.
[pdclib] / platform / example / functions / _PDCLIB / open.c
index 79497266350fb49992c533adb00bd546fe2b8e5e..133b729d16cd9562dabc0669aed3c4c08118e707 100644 (file)
@@ -26,11 +26,9 @@ int _PDCLIB_open( char const * const filename, unsigned int mode )
 {
     /* This is an example implementation of _PDCLIB_open() fit for use with
        POSIX kernels.
-       FIXME: The permissions of newly created files should not be hardcoded
-       here.
     */
     int osmode;
-    switch ( mode & ~_PDCLIB_FBIN )
+    switch ( mode & ( _PDCLIB_FREAD | _PDCLIB_FWRITE | _PDCLIB_FAPPEND | _PDCLIB_FRW ) )
     {
         case _PDCLIB_FREAD: /* "r" */
             osmode = O_RDONLY;
@@ -56,7 +54,7 @@ int _PDCLIB_open( char const * const filename, unsigned int mode )
     int rc;
     if ( osmode & O_CREAT )
     {
-        rc = open( filename, osmode, S_IRUSR | S_IWUSR );
+        rc = open( filename, osmode, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
     }
     else
     {