diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2017-02-12 21:56:44 -0500 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2017-02-14 17:54:50 -0500 |
commit | 8ff1b6b6033aad55fadf076f066da5d8b7d2e631 (patch) | |
tree | 9f1a00ad14a0b47920bfe16a4c4fc21bcfd83f9c /firmware/common | |
parent | dc22522c2c21f058333e4383d644cb18f355ac76 (diff) | |
download | rockbox-8ff1b6b6033aad55fadf076f066da5d8b7d2e631.tar.gz 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')
-rw-r--r-- | firmware/common/file.c | 20 |
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:; | |||
349 | /* actually do the open gruntwork */ | 349 | /* actually do the open gruntwork */ |
350 | static int open_internal_inner2(const char *path, | 350 | static int open_internal_inner2(const char *path, |
351 | struct filestr_desc *file, | 351 | struct filestr_desc *file, |
352 | unsigned int callflags) | 352 | unsigned int callflags, |
353 | int oflag) | ||
353 | { | 354 | { |
354 | int rc; | 355 | int rc; |
355 | 356 | ||
356 | struct path_component_info compinfo; | 357 | struct path_component_info compinfo; |
357 | 358 | ||
358 | if (callflags & FF_CREAT) | 359 | if (oflag & O_CREAT) |
359 | callflags |= FF_PARENTINFO; | 360 | callflags |= FF_PARENTINFO; |
360 | 361 | ||
361 | rc = open_stream_internal(path, callflags, &file->stream, &compinfo); | 362 | rc = open_stream_internal(path, callflags, &file->stream, &compinfo); |
@@ -369,7 +370,7 @@ static int open_internal_inner2(const char *path, | |||
369 | 370 | ||
370 | if (rc > 0) | 371 | if (rc > 0) |
371 | { | 372 | { |
372 | if (callflags & FF_EXCL) | 373 | if (oflag & O_EXCL) |
373 | { | 374 | { |
374 | DEBUGF("File exists\n"); | 375 | DEBUGF("File exists\n"); |
375 | FILE_ERROR(EEXIST, -2); | 376 | FILE_ERROR(EEXIST, -2); |
@@ -386,7 +387,7 @@ static int open_internal_inner2(const char *path, | |||
386 | compinfo.filesize = MAX_DIRECTORY_SIZE; /* allow file ops */ | 387 | compinfo.filesize = MAX_DIRECTORY_SIZE; /* allow file ops */ |
387 | } | 388 | } |
388 | } | 389 | } |
389 | else if (callflags & FF_CREAT) | 390 | else if (oflag & O_CREAT) |
390 | { | 391 | { |
391 | if (compinfo.attr & ATTR_DIRECTORY) | 392 | if (compinfo.attr & ATTR_DIRECTORY) |
392 | { | 393 | { |
@@ -483,15 +484,10 @@ static int open_internal_inner1(const char *path, int oflag, | |||
483 | /* O_CREAT and O_APPEND are fine without write mode | 484 | /* O_CREAT and O_APPEND are fine without write mode |
484 | * for the former, an empty file is created but no data may be written | 485 | * for the former, an empty file is created but no data may be written |
485 | * for the latter, no append will be allowed anyway */ | 486 | * for the latter, no append will be allowed anyway */ |
486 | if (oflag & O_CREAT) | 487 | if (!(oflag & O_CREAT)) |
487 | { | 488 | oflag &= ~O_EXCL; /* result is undefined: we choose "ignore" */ |
488 | callflags |= FF_CREAT; | ||
489 | |||
490 | if (oflag & O_EXCL) | ||
491 | callflags |= FF_EXCL; | ||
492 | } | ||
493 | 489 | ||
494 | rc = open_internal_inner2(path, file, callflags); | 490 | rc = open_internal_inner2(path, file, callflags, oflag); |
495 | if (rc < 0) | 491 | if (rc < 0) |
496 | FILE_ERROR(ERRNO, rc * 10 - 3); | 492 | FILE_ERROR(ERRNO, rc * 10 - 3); |
497 | 493 | ||