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>
Tue, 11 Apr 2017 20:38:36 +0000 (13:38 -0700)
commit7ade61cae297c112e7288f173fb529673010926a
tree6a89998346f43262f68dd32872ba77f3f245e179
parent2d389ffee98b6f480f4340ec408d37457e02fbd7
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
Change-Id: Iacf08c89dbe207ec53a7837e6ac7f78f5541ef35
libc/bionic/system_properties.cpp