Commit Graph

90 Commits

Author SHA1 Message Date
Stefan Schmidt f3d9b8ee70 esacpe: remove library from tree
This has not been used for a while and is not even buildable after our
switch to meson. It was a niche to start with given that it needed the
PS3 OS to run on. I asked for any remaining users at EDD and on the list
but heard nothing. Time to remove.

Signed-off-by: Stefan Schmidt <s.schmidt@samsung.com>
Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10778
2019-12-04 12:21:24 -08:00
Stefan Schmidt 1d0a636953 eina: fix spelling in new eina_file_statgen API
Introduced in 9b294d6284 the new eina_file_statgen_* API has a typo in
its disable function. Fixing this before it gets out into a release.

Thanks goes to the https://abi-laboratory.pro service for offering their
great API/ABI reports to the open source communities to help finding such
things!

Differential Revision: https://phab.enlightenment.org/D9962
2019-09-16 12:02:42 +02:00
Carsten Haitzler fd48be23c2 eina file - make coverity happy and lock+unlock on init
coverity doesnt like inconsistent behavior of code, so make it
consistent even  if pointless as this is during init when we wont have
threads .... yet.

CID 1403903
2019-08-11 12:47:38 +01:00
Carsten Haitzler 9b294d6284 eina file - stat generation inexactness support
this is a performance optimization. it brings in a "stat generation".
for now it's disabled by default so we retain previous behavior. this
stops eina file from opening and stating a file every time you open
... it only does it if stat generation is off, or, if the generation
changed since the last time it opened that file. this makes cache hits
not have a 3 syscall cost (open+fstat+close). this optimizes that
lower end of things path. but .. it comes at a cost. if the file
changes before generation ticks over (which this forces to tick over
every time the loop exits idle by default).

now here is something to ask.

1. should we have this on by default and accept the "inexactness"
since you can eina_file_statgen_next() before any call that would do
i/o to force it to look at the real file stat info...
2. should we tick over every idle enter OR every N idle enters  or
every frame we render instead? ... i want to avoid getting a timestamp
or having a timer interrupt often... so what should we do?

at least this introduces the idea, some api's and an env var to turn
this on. it definitely cuts down syscalls during things like creation
of widdgets or objects in large batches etc.
2019-07-28 11:51:15 +01:00
Vincent Torri ce9cad3a3b Eina: replace Evil.h with evil_private.h and remove Evil.h when not necessary
Test Plan: compilation

Reviewers: raster, zmike, cedric

Reviewed By: zmike

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8903
2019-05-16 13:48:59 -04:00
Shinwoo Kim cbe9b6f770 eina_file: check copied using copied
Summary:
From (1) "the following commit" message, the changed condition in this patch
should check if the virtualized file is copied or not.

In eina_file_virtualize
head_padded = 16 * ((sizeof(Eina_File) + slen + 15) / 16);
file->global_map = ((char *)file) + head_padded;

In eina_file_dup
file->global_map != (void*)(file->filename + strlen(file->filename) + 1)

Because of this discord condition makes eina_file_dup copies always.

(1) This is "the following commit":
commit 4766316935
Author: Cedric Bail <cedric@osg.samsung.com>
Date:   Wed Mar 8 10:13:36 2017 -0800

    eina: force copy of not copied virtualized file while doing an eina_file_dup.

    The other way around is pretty much impossible as you don't know who does
    an eina_file_dup and for how long they keep there reference.

    T5234

Reviewers: zmike, Hermet

Reviewed By: zmike

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6857
2018-08-17 12:42:18 -04:00
Vincent Torri 4916973a60 efl: remove inclusion of dirent.h where it is not used
Test Plan: compilation

Reviewers: cedric

Subscribers: jpeg

Differential Revision: https://phab.enlightenment.org/D5733

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2018-01-12 11:06:12 -08:00
Al Poole a538f47854 eina_file: make sure we use a stringshare when virtualized.
As the filename is now a stringshare, also make sure virtual
files use stringshares for the filename! Also when unmapping
we still need to test whether it is copied or not as unmap
will break on less tolerant architectures.

@fix T6449
2017-11-30 13:57:25 +00:00
Cedric Bail 6e64a104a6 eina: use a stringshare to store the filename internally.
T6164
2017-10-17 16:15:19 -07:00
Cedric BAIL 674a75ca8b eina: continue to check for magic. 2017-10-05 09:28:13 -07:00
Cedric Bail 4ccc5d4f68 eina: allow eina_file_close(NULL) to simplify code using Eina_File. 2017-10-04 20:56:15 -07:00
Vincent Torri 0cdd501246 EFL For WIN32: Replace HAVE_EVIL define with _WIN32 2017-09-22 05:06:10 -05:00
Carsten Haitzler 15cdd9b71b eina file - use recursive locks for cache and file to avoid deadlock
since we have a sigbusd handler that flags an eina file with io errors
it has to walk the file cache and every file... taking locks. if those
locks were taking already in the current thread the sighandler was
called in... we'd deadlock. since this basicallly never happens (when
do we see i/o errors really? not much)... we never saw this as it'd
also reauire this race condition to happen too. but it is a problem
waiting to happen. this fixes that by moving to recrusive locks.

@fix
2017-08-30 11:31:02 +09:00
Al Poole 9aeaef55c4 eina_file: fix unmap of unmapped region when Eina_File has copied data and not a map;
Summary:
This was causing problems on non-Linux architectures as eina_file_real_close unmapped not mapped data. Added a "copied" flag to Eina_File which is set on eina_file_virtualize (on copied data), and tested for when eina_file_real_close does the unmap. I'm surprised Linux allowed this. Certainly all of the BSDs crashed with the previous behaviour.

@fix T5479

Test Plan: Example inlcude Rage and Enlightenment Thumb on BSD systems which use eina_file_virtualize with emotion to obtain album artwork.

Reviewers: raster, cedric, jpeg

Reviewed By: jpeg

Maniphest Tasks: T5479

Differential Revision: https://phab.enlightenment.org/D5006
2017-07-07 13:22:53 +09:00
Carsten Haitzler eeb1eb1b74 eina - fix eina_file_virtualize to copy data to an aligned addr
so we copy data to an UNALINED memory address (just after whatever
string we packed on the end of the eina file struct header). this is
bad. especially for non-intel architectures. this forces a 16 byte
alignment which should cover us.

@fix
2017-07-07 12:08:01 +09:00
Jean-Philippe Andre daf87093f8 eina file: Fix rare crash in line iteration
I'm not sure about the rest of this code, so it's possible that
the index is increased even if it shouldn't. But I've observed
a crash at this line, apparently when reaching the end pointer.
2017-07-03 16:23:40 +09:00
Cedric BAIL 9d8549f7a3 eina: add an API to correctly do close on exec. 2017-04-18 16:53:26 -07:00
Cedric Bail 4766316935 eina: force copy of not copied virtualized file while doing an eina_file_dup.
The other way around is pretty much impossible as you don't know who does
an eina_file_dup and for how long they keep there reference.

T5234
2017-03-08 12:24:41 -08:00
Ivan Furs 8a10ef10cb eina_file: delete handle->fm(handel of function CreateFileMapping)
Summary: CreateFileMapping return handle. The handle before use is always closed. This handle can be immediately closed after use.

Reviewers: cedric, raster, vtorri, rimmed, an.kroitor, FurryMyad, NikaWhite

Reviewed By: raster

Subscribers: artem.popov, cedric, jpeg

Tags: #windows

Differential Revision: https://phab.enlightenment.org/D4699
2017-03-06 19:18:46 +09:00
Jean-Philippe Andre 509cce5e43 eina: Set magic number in eina_file_virtualize
This fixes make check
2016-12-09 11:08:38 +09:00
Jean-Philippe Andre f1d546df5d eina: Set magic type name for Eina_File 2016-12-08 16:30:34 +09:00
Jean-Philippe Andre 208e152baf eina: Reinstall magic checks on Eina_File
file != NULL does not mean it's valid. Since Eina_File is
a basic eina type a magic check is still better than nothing.
It can avoid doing eina_file_dup() on a closed file for instance.

This "fixes" a crash in eina_file_close with invalid files.

Now I can go hunt the root cause...
2016-12-08 16:30:34 +09:00
Carsten Haitzler ed1101d994 fix possible eina file shutdown issue
i am not sure as i cannto reproduce this, but i hope this fixes T4677
by ensuring if eina_file_shutdown is called it cannto double-free a
hash.
2016-10-14 16:40:09 +09:00
Carsten Haitzler 7ee4eba33f efl - new cmp "fix" code - remove one duplicated cmp 2016-05-26 12:49:58 +09:00
Carsten Haitzler 41842ca9f9 efl - fix many bounds over/underflow where we use int for ptr cmp
this addresses more things brought up in comments in

fixes T3638 commentd

@fix
2016-05-26 12:17:07 +09:00
Jean-Philippe Andre e472f97d96 Eina: Fix eina_file_mk[ds]temp when a path is passed
If the template is a path, mkstemp and mkdtemp would fail
miserably as they would try to create a file inside
/run/user/1000//path/to/file.XXXXXX even if the path did not
exist.

This patch fixes that by creating temp files inside the sys temp
dir iif the templatename is just a basic name without path
separator.

@fix
2016-01-19 18:18:29 +09:00
Vincent Torri 9e5852fcfb eina: use eina_file_path_join() and eina_environment_tmp_get() when needed
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-12-01 12:13:12 -08:00
Vincent Torri a1243410a7 eina/efreet: open file with binary file on Windows
@fix

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-11-06 10:53:29 -08:00
Cedric BAIL a089818335 eina: correctly prepare path before sanitizing it. 2015-10-28 06:45:10 +01:00
Cedric BAIL 046d806388 Revert "Eina: Fix 58b194e0ad56fe83cce3946a5deb0045ee0cbce2"
This reverts commit 22b45f220c.

eina_file_cleanup always does an eina_tmpstr_del. This is now capable of doing
double or even triple free in some case.
2015-10-28 06:38:14 +01:00
Vincent Torri 22b45f220c Eina: Fix 58b194e0ad
Fixes the windows build as it has a matching implementation for eina_file_cleanup.

Fixes T2804
2015-10-28 03:34:10 +01:00
Cedric BAIL 58b194e0ad eina: make sure to cleanup the right string. 2015-10-23 12:32:02 -07:00
Andy Williams 128a78940b eina: include blank lines in file iterator T2237
any line that would not have been included before has length == 0
2015-03-27 21:42:45 +00:00
Andy Williams a6290f8505 eina: Change newline parsing to handle crlf better
Adjust test to demonstrate failure, existing code only worked for
windows newlines on blank line.
@fix T2236
2015-03-27 09:56:22 +00:00
Jaeun Choi 3cd2801be7 eina: safety check for NULL pointer
data should not be NULL. it is used as the source of memcpy.

@fix
2015-03-19 16:15:20 +09:00
Tom Hacohen 8fbee3fac0 Eina tmpstr: remove usage of tmpstr_strlen(). 2015-02-09 14:02:40 +00:00
Daniel Hirt 7143bd7fb5 eina: fix valgrind invalid read of size in eina_file_path_sanitize.
Summary:
Apparently eina_tmpstr_strlen counts the null character as well. This
doesn't follow how strlen works, as the latter excludes it from the count.
This resulted in mistreatment of the string in _eina_file_escape, with
tmp_str paths that had "../".

This fix will do for now, but it is advised that we avoid using
eina_tmpstr_strlen, to prevent such confusions in the future.

Test Plan:
The following lines will throw a valgrind 'invalid read of size 1' error
prior this fix:
  char *path = "home/mydir/../myfile";
  Eina_Tmpstr *tmp_str = eina_tmpstr_add(path);
  char *ret_path = eina_file_path_sanitize(path);

@fix

Reviewers: cedric, stefan_schmidt

Subscribers: tasn, cedric

Differential Revision: https://phab.enlightenment.org/D1929

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-02-04 14:08:36 +01:00
Daniel Hirt 7cbf22212f Revert "eina: eina_file - fix "invalid read of size 1" in valgrind"
This reverts commit f52f562891.

This is reverted because it breaks eina_file_path_sanitize when using
  "/../" in paths, for example:
eina_file_path_sanitize("/home/../mydir/myfile")
  returns: "/mydir/myfili"

What invalid read size does this fix? Why was no test case specified?
Anyway, this change affects too much code to leave it in like this.
2015-02-02 14:41:37 +02:00
Romain Perier f52f562891 eina: eina_file - fix "invalid read of size 1" in valgrind
@fix

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-01-30 10:49:58 +01:00
Jean-Philippe Andre 03cc403228 Eina file: Fix calls to getenv
There seems to be an intent to check that UID==EUID
before calling getenv to get the temp directory.
But that was lost in commits 61478af3a6 and
then in e105abc99e.
2014-10-30 18:23:49 +09:00
Stefan Schmidt e105abc99e eina_file: Give TMPDIR presedence over XDG_RUNTIME_DIR when defined
XDG_RUNTIME_DIR gives us a nice securty benefit by only allowing the
same user to read wand write files.

In some configuration this is problematic though. If one looks at the
bug report this fixes  for example you can see that there are build
scripts that use a special build user.

The way this has always worked on unix is that you can define your
own tempdir with TMPDIR. When I was making the original change towards
XDG_RUNTIME_DIR I expected some trouble with it but it worked quite
well so far.

To avoid breaking scripts out there and maybe configurations we
haven't tested yet give TMPDIR precedence over XDG_RUNTIME_DIR.

Fixes T1766
2014-10-29 15:51:11 +01:00
Vincent Torri 291c546143 eina: do no use umask on Windows in eina_file_mkstemp()
umask() sets the permissions of the file to read-only on Windows
(see umask documentation on MSDN).
This breaks the creation of .edj file (epp needs to modify the
created file).
Anyway, on Windows, permissions should be given to anybody.

@fix

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2014-09-23 16:41:32 +02:00
Stefan Schmidt 61478af3a6 eina_file: Try to use XDG_RUNTIME_DIR for tmp dir first
Instead using $TMPDIR and falling back to /tmp we now try $XDG_RUNTIME_DIR
first.

"$XDG_RUNTIME_DIR defines the base directory relative to which user-specific
non-essential runtime files and other file objects (such as sockets, named
pipes, ...) should be stored. The directory MUST be owned by the user, and
he MUST be the only one having read and write access to it. Its Unix access
mode MUST be 0700."

While improving our security by isolating these files from other users this
has the potential to break things. I have not seen any breakage in testing
but keep this commit in mind if something strange happens on your system.
2014-09-12 09:12:52 +02:00
Andrii Kroitor 38147da036 eina_file: fixing wrong return value on access problems in file copy process
Summary:
when dest directory is protected from writing success value was returned
@fix

Reviewers: seoz, cedric, Hermet

Reviewed By: Hermet

Subscribers: cedric, reutskiy.v.v

Differential Revision: https://phab.enlightenment.org/D1366
2014-08-27 19:47:16 +09:00
Daniel Kolesa 987cde5f35 Revert "eina: new API: eina_file_path_basename"
This reverts commit 68282f8c42.

This is actually not needed because of presence of basename in Evil.
2014-07-23 19:38:08 +01:00
Daniel Kolesa 68282f8c42 eina: new API: eina_file_path_basename 2014-07-23 17:04:04 +01:00
Cedric BAIL 72aca66f8d eina: win32 and linux version code are the same. Sharing code is better. 2014-07-14 15:46:54 +02:00
ChunEon Park cc68ef1f22 eina - fixed typo 2014-07-07 20:22:06 +09:00
ChunEon Park 328d28a7f4 eina/file - revert 18be4c50d9
I realized that's not a bug in eina but user usage was inccorect.
revert the patch

@fix
2014-05-31 18:34:48 +09:00
Jean-Philippe Andre e50bcc937c Eina: Fix mistake in a previous patch
Suffix length was not computed properly.
Also, the change on eina_mkstemps was a @feature:
add file extension support when creating temporary files
2014-04-02 14:53:00 +09:00