Page MenuHomePhabricator

eina_file_open() opens file with write access, which is wrong by design
Open, HighPublic

Description

this commit:

https://git.enlightenment.org/core/efl.git/commit/src/lib/eina/eina_file_win32.c?id=b36e2fc701865db12c21fc94e92f52cc2471ab47

add write access to files opened by eina_file_open on Windows. By design, it should be read-only (see documentation)

This must be fixed.

vtorri created this task.Mar 3 2017, 10:40 AM
raster added a comment.Mar 6 2017, 4:54 PM

actually even though this looks wrong i think this is a side-effect of window's bizarre file/io semantics. based on a bunch of "windows fixes" for when writing eet files recently i think this is here because IN CASE you happen to also have the file open for writing somewhere else you need to also open for write here or things "god bad". that's a guess.

other than this it certainly sounds/looks wrong and the git commit log doesn't provide any information on why this is needed.

is this why? ... ?

i.furs added a subscriber: i.furs.Mar 31 2017, 2:06 AM

https://git.enlightenment.org/core/efl.git/commit/src/lib/eina/eina_file_win32.c?id=b36e2fc701865db12c21fc94e92f52cc2471ab47

handle = CreateFile(filename,
  • GENERIC_READ, FILE_SHARE_READ,
  • NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY,

+ GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,

NULL)

GENERIC_READ - opens the file read-only
FILE_SHARE_READ | FILE_SHARE_WRITE - other processes have the right to read and write to this file

for Linux
eina_file_open
...
fd = open(filename, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
O_RDONLY - opens the file read-only
S_IRWXU | S_IRWXG | S_IRWXO - - other processes have the right to read and write to this file

yeah. that was added. the question is - why? i think it's because some other code may then also open the file read/write and thus opening a second time fails because it's already open read-only.... right?

jpeg reassigned this task from jpeg to i.furs.Apr 18 2017, 5:58 AM
jpeg added a subscriber: jpeg.
zmike edited projects, added Restricted Project; removed efl.Jun 11 2018, 6:54 AM
zmike edited projects, added efl: system integration; removed Restricted Project.Jun 11 2018, 9:19 AM

Wondering what @vtorri thinks about this?

zmike reassigned this task from i.furs to vtorri.Jun 20 2018, 8:41 AM
zmike removed a project: efl (efl-1.21).
zmike added a subscriber: zmike.Jan 15 2019, 6:10 AM

What's going on with this?