ext2simg: fix same_file() with symlinks

Fix same_file() to use stat() instead of lstat() when checking the
paths, so that symlinks are dereferenced.  This is needed to be
consistent with how the paths are actually accessed later.  Otherwise,
not all cases where the input and output file are the same are detected.

Also just use the stat() result to check whether the output file exists,
instead of using a separate call to access().

Fixes: db6f320912cf ("AOSP: android: add the ext2simg tool")
Change-Id: Ie36981f9dbc19494732f518488a75fb92c0f0343
Signed-off-by: Eric Biggers <ebiggers@google.com>
1 file changed