diff options
author | Elliott Hughes <enh@google.com> | 2013-09-18 19:25:28 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-09-19 11:17:42 -0700 |
commit | cf178bf7d0300edfeec31528a744aa38a7177c0e (patch) | |
tree | 84fc277fa849dbd5e6af543a70c8fce1d1544d88 /libc/tzcode | |
parent | 4a509d898e24cefe0f7f0edf927b11ce7c304c81 (diff) | |
download | android_bionic-cf178bf7d0300edfeec31528a744aa38a7177c0e.tar.gz android_bionic-cf178bf7d0300edfeec31528a744aa38a7177c0e.tar.bz2 android_bionic-cf178bf7d0300edfeec31528a744aa38a7177c0e.zip |
Use $ANDROID_DATA and $ANDROID_ROOT to find the tzdata.
This lets us run binaries linked against bionic on an x86 host.
Change-Id: Icd60cf99a90d747c77304c05b4f764e4d26af985
Diffstat (limited to 'libc/tzcode')
-rw-r--r-- | libc/tzcode/localtime.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libc/tzcode/localtime.c b/libc/tzcode/localtime.c index b23eca468..f37454104 100644 --- a/libc/tzcode/localtime.c +++ b/libc/tzcode/localtime.c @@ -2114,7 +2114,15 @@ static int to_int(unsigned char* s) { return (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]; } -static int __bionic_open_tzdata_path(const char* path, const char* olson_id, int* data_size) { +static int __bionic_open_tzdata_path(const char* path_prefix_variable, const char* path_suffix, + const char* olson_id, int* data_size) { + const char* path_prefix = getenv(path_prefix_variable); + if (path_prefix == NULL) { + fprintf(stderr, "%s: %s not set!\n", __FUNCTION__, path_prefix_variable); + return -1; + } + char path[PATH_MAX]; + snprintf(path, sizeof(path), "%s/%s", path_prefix, path_suffix); int fd = TEMP_FAILURE_RETRY(open(path, OPEN_MODE)); if (fd == -1) { XLOG(("%s: could not open \"%s\": %s\n", __FUNCTION__, path, strerror(errno))); @@ -2202,10 +2210,9 @@ static int __bionic_open_tzdata_path(const char* path, const char* olson_id, int } static int __bionic_open_tzdata(const char* olson_id, int* data_size) { - // TODO: use $ANDROID_DATA and $ANDROID_ROOT like libcore, to support bionic on the host. - int fd = __bionic_open_tzdata_path("/data/misc/zoneinfo/tzdata", olson_id, data_size); + int fd = __bionic_open_tzdata_path("ANDROID_DATA", "/misc/zoneinfo/tzdata", olson_id, data_size); if (fd < 0) { - fd = __bionic_open_tzdata_path("/system/usr/share/zoneinfo/tzdata", olson_id, data_size); + fd = __bionic_open_tzdata_path("ANDROID_ROOT", "/usr/share/zoneinfo/tzdata", olson_id, data_size); if (fd == -2) { // The first thing that 'recovery' does is try to format the current time. It doesn't have // any tzdata available, so we must not abort here --- doing so breaks the recovery image! |