summaryrefslogtreecommitdiffstats
path: root/firmware/common/file.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-02-12 21:56:44 -0500
committerMichael Sevakis <jethead71@rockbox.org>2017-02-14 17:54:50 -0500
commit8ff1b6b6033aad55fadf076f066da5d8b7d2e631 (patch)
tree9f1a00ad14a0b47920bfe16a4c4fc21bcfd83f9c /firmware/common/file.c
parentdc22522c2c21f058333e4383d644cb18f355ac76 (diff)
downloadrockbox-8ff1b6b6033aad55fadf076f066da5d8b7d2e631.tar.gz
rockbox-8ff1b6b6033aad55fadf076f066da5d8b7d2e631.tar.bz2
rockbox-8ff1b6b6033aad55fadf076f066da5d8b7d2e631.zip
Remove FF_CREAT and FF_EXCL flags in from file code.
These flags aren't stored for an open file because they're simply actions for open() to take, corresponding to O_CREAT and O_EXCL. Just pass the oflag argument along to the deeper call, with some minor filtering. Change-Id: Ic8bcfba718ebf4228bdc45de3088af1974820557
Diffstat (limited to 'firmware/common/file.c')
-rw-r--r--firmware/common/file.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c
index 028bdbe9f0..cb918c6eab 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -349,13 +349,14 @@ file_error:;
/* actually do the open gruntwork */
static int open_internal_inner2(const char *path,
struct filestr_desc *file,
- unsigned int callflags)
+ unsigned int callflags,
+ int oflag)
{
int rc;
struct path_component_info compinfo;
- if (callflags & FF_CREAT)
+ if (oflag & O_CREAT)
callflags |= FF_PARENTINFO;
rc = open_stream_internal(path, callflags, &file->stream, &compinfo);
@@ -369,7 +370,7 @@ static int open_internal_inner2(const char *path,
if (rc > 0)
{
- if (callflags & FF_EXCL)
+ if (oflag & O_EXCL)
{
DEBUGF("File exists\n");
FILE_ERROR(EEXIST, -2);
@@ -386,7 +387,7 @@ static int open_internal_inner2(const char *path,
compinfo.filesize = MAX_DIRECTORY_SIZE; /* allow file ops */
}
}
- else if (callflags & FF_CREAT)
+ else if (oflag & O_CREAT)
{
if (compinfo.attr & ATTR_DIRECTORY)
{
@@ -483,15 +484,10 @@ static int open_internal_inner1(const char *path, int oflag,
/* O_CREAT and O_APPEND are fine without write mode
* for the former, an empty file is created but no data may be written
* for the latter, no append will be allowed anyway */
- if (oflag & O_CREAT)
- {
- callflags |= FF_CREAT;
-
- if (oflag & O_EXCL)
- callflags |= FF_EXCL;
- }
+ if (!(oflag & O_CREAT))
+ oflag &= ~O_EXCL; /* result is undefined: we choose "ignore" */
- rc = open_internal_inner2(path, file, callflags);
+ rc = open_internal_inner2(path, file, callflags, oflag);
if (rc < 0)
FILE_ERROR(ERRNO, rc * 10 - 3);