AOSP: android/perms.c: clean up error handling

There are a number of error conditions which, due to the way
ext2fs_dir_iterate2 operates, would not be propagated to the upper
layers of the call stack. As a result, certain error conditions,
such as not having enough room to allocate blocks for SELinux
labels, would fail silently, instead of causing a compile
failure.

As suggested in
https://android-review.googlesource.com/c/platform/external/e2fsprogs/+/324363
, add a error field to the caller's private data structure, and use the
bit in the field to indicate an error condition. Now, certain errors
which were silently ignored will cause a compile failure when compiling
Android.

Test: Artifically modify selabel_lookup() to return a failure, and
      verify Android doesn't compile.
Test: Verify Android compiles under normal circumstances.
Test: Artifically modify ino_add_xattr() to return a failure, and
      verify Android doesn't compile.
Bug: 117502873
Bug: 117567573
Bug: 117473440

Signed-off-by: Theodore Ts'o <tytso@mit.edu>

Change-Id: Icdb0105a77e98c3428f20d3c59bf824dcad5db8d
From AOSP commit: 7ca13b8b2953f93536ea09eb2ff19bd7cc85b3c1
1 file changed