OSDN Git Service

Don't let missing Treble property context files affect errno.
authorElliott Hughes <enh@google.com>
Tue, 11 Apr 2017 20:38:36 +0000 (13:38 -0700)
committerElliott Hughes <enh@google.com>
Wed, 12 Apr 2017 00:05:01 +0000 (17:05 -0700)
commita7afa0285b3786ecc55e4738ec9f23effb3699bc
treedbe9b746ff0e84eea4ee43a386edd791e37826aa
parent993b08366dbe01cea7269dfe481b6ac672681035
Don't let missing Treble property context files affect errno.

User code on a non-treble device was starting with errno == ENOENT rather
than 0 because of this treble support:

  openat(AT_FDCWD, "/property_contexts", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
  faccessat(AT_FDCWD, "/system/etc/selinux/plat_property_contexts", R_OK) = -1 ENOENT (No such file or directory)

This caused us to fail some toybox tests by reporting bogus errno values
where errno should have been left unset:

  PASS: date -d @0
  FAIL: date -d @0x123
  echo -ne '' | TZ=UTC date -d @0x123 2>&1
  --- expected
  +++ actual
  @@ -1 +1 @@
  -date: bad date '@0x123'
  +date: bad date '@0x123': No such file or directory
  PASS: date -d 06021234
  PASS: date -d 060212341982
  FAIL: date -d 123
  echo -ne '' | TZ=UTC date -d 123 2>&1
  --- expected
  +++ actual
  @@ -1 +1 @@
  -date: bad date '123'
  +date: bad date '123': No such file or directory
  PASS: date -d 1110143115.30
  PASS: date -d 111014312015.30
  PASS: date Unix time missing @

Bug: http://b/37248982
Test: ran tests

(cherry picked from commit 7ade61cae297c112e7288f173fb529673010926a)

Change-Id: I4c680da14f3df16dc5a9884071e48f3221ad3b3b
libc/bionic/system_properties.cpp