core/linux/os.c
/* we assume that opening for writing wants to create file */
we assume that opening for writing wants to create file
we assume that opening for writing wants to create file
file_t
os_open(const char *fname, int os_open_flags)
{
    int res;
    int flags = 0;
    if (TEST(OS_OPEN_ALLOW_LARGE, os_open_flags))
        flags |= O_LARGEFILE;
    if (!TEST(OS_OPEN_WRITE, os_open_flags)) 
        res = open_syscall(fname, flags|O_RDONLY, 0);
    else {    
        res = open_syscall(fname, flags|O_RDWR|O_CREAT|
                           (TEST(OS_OPEN_APPEND, os_open_flags) ? 
                            O_APPEND : 0)|
                           (TEST(OS_OPEN_REQUIRE_NEW, os_open_flags) ? 
                            O_EXCL : 0), 
                           S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
    }
    if (res < 0)
        return INVALID_FILE;
    return res;
}
file_t os_open ( const char * fname , int os_open_flags ) { int res ; int flags = 0 ; if ( TEST ( OS_OPEN_ALLOW_LARGE , os_open_flags ) ) flags |= O_LARGEFILE ; if ( ! TEST ( OS_OPEN_WRITE , os_open_flags ) ) res = open_syscall ( fname , flags | O_RDONLY , 0 ) ; else { res = open_syscall ( fname , flags | O_RDWR | O_CREAT | ( TEST ( OS_OPEN_APPEND , os_open_flags ) ? O_APPEND : 0 ) | ( TEST ( OS_OPEN_REQUIRE_NEW , os_open_flags ) ? O_EXCL : 0 ) , S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP ) ; } if ( res < 0 ) return INVALID_FILE ; return res ; }
we assume that opening for writing wants to create file
we assume that opening for writing wants to create file