Files
android_bootable_recovery/libblkid/include/all-io.h
Ethan Yonker c798c9cd24 Merge up to AOSP marshmallow-release
In order to maintain compatibility with older trees, we now have
minadbd.old and minui.old. I had to use a TARGET_GLOBAL_CFLAG to
handle ifdef issues in minui/minui.d because healthd includes
minui/minui.h and there was no other alternative to make minui.h
compatible with older trees without having to modify healthd rules
which is outside of TWRP.

Note that the new minui does not currently have support for qcom
overlay graphics. Support for this graphics mode will likely be
added in a later patch set. If you are building in a 6.0 tree and
have a device that needs qcom overlay graphics, be warned, as off
mode charging may not work properly. A dead battery in this case
could potentially brick your device if it is unable to charge as
healthd handles charging duties.

Update rules for building toolbox and add rules for making toybox

Use permissive.sh in init.rc which will follow symlinks so we do
not have to worry about what binary is supplying the setenforce
functionality (toolbox, toybox, or busybox).

Fix a few warnings in the main recovery binary source code.

Fix a few includes that were missing that prevented compiling in
6.0

Change-Id: Ia67aa2107d260883da5e365475a19bea538e8b97
2015-10-09 11:15:29 -05:00

85 lines
1.6 KiB
C

/*
* No copyright is claimed. This code is in the public domain; do with
* it what you wish.
*
* Written by Karel Zak <kzak@redhat.com>
* Petr Uzel <petr.uzel@suse.cz>
*/
#ifndef UTIL_LINUX_ALL_IO_H
#define UTIL_LINUX_ALL_IO_H
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "c.h"
static inline int write_all(int fd, const void *buf, size_t count)
{
while (count) {
ssize_t tmp;
errno = 0;
tmp = write(fd, buf, count);
if (tmp > 0) {
count -= tmp;
if (count)
buf = (void *) ((char *) buf + tmp);
} else if (errno != EINTR && errno != EAGAIN)
return -1;
if (errno == EAGAIN) /* Try later, *sigh* */
usleep(250000);
}
return 0;
}
static inline int fwrite_all(const void *ptr, size_t size,
size_t nmemb, FILE *stream)
{
while (nmemb) {
size_t tmp;
errno = 0;
tmp = fwrite(ptr, size, nmemb, stream);
if (tmp > 0) {
nmemb -= tmp;
if (nmemb)
ptr = (void *) ((char *) ptr + (tmp * size));
} else if (errno != EINTR && errno != EAGAIN)
return -1;
if (errno == EAGAIN) /* Try later, *sigh* */
usleep(250000);
}
return 0;
}
static inline ssize_t read_all(int fd, char *buf, size_t count)
{
ssize_t ret;
ssize_t c = 0;
int tries = 0;
memset(buf, 0, count);
while (count > 0) {
ret = read(fd, buf, count);
if (ret <= 0) {
if ((errno == EAGAIN || errno == EINTR || ret == 0) &&
(tries++ < 5)) {
usleep(250000);
continue;
}
return c ? c : -1;
}
if (ret > 0)
tries = 0;
count -= ret;
buf += ret;
c += ret;
}
return c;
}
#endif /* UTIL_LINUX_ALL_IO_H */