Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b447b91 authored by Nick Kralevich's avatar Nick Kralevich
Browse files

Add mode when open(O_CREAT) is used.

When creating a new file using open(..., O_CREAT), it is an error
to fail to specify a creation mode. If a mode is not specified, a
random stack provided value is used as the "mode".

This will become a compile error in a future Android change.

Change-Id: I8635e8b69587ed107253870d991c3fcf563ca876
parent 0cedfe09
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@

#include <gtest/gtest.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>

@@ -43,7 +45,7 @@ protected:
        mFileName = new char[totalLen];
        snprintf(mFileName, totalLen, "%s%s", mExternalStorage, TEST_FILENAME);

        int fd = ::open(mFileName, O_CREAT | O_TRUNC);
        int fd = ::open(mFileName, O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
        if (fd < 0) {
            FAIL() << "Couldn't create " << mFileName << " for tests";
        }