diff options
author | Tor Lillqvist <tlillqvist@suse.com> | 2012-01-24 19:41:04 +0200 |
---|---|---|
committer | Tor Lillqvist <tlillqvist@suse.com> | 2012-01-24 21:35:01 +0200 |
commit | e580fd501b67b9e0a56a712ffb24ec3c244a135b (patch) | |
tree | dda1e0ce1cefda2a9c5cead7d65e70979524c353 /sal/android | |
parent | 2175e21fb94ecb9a266b656c0efa9f7197072006 (diff) |
Fill in more struct stat fields in lo_apk_lstat()
Set uid and gid to that of the process, atime to current time, mtime
and ctime to the modification timestamp of the archive entry.
Diffstat (limited to 'sal/android')
-rw-r--r-- | sal/android/lo-bootstrap.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/sal/android/lo-bootstrap.c b/sal/android/lo-bootstrap.c index aaf823703231..d28c8e999a1b 100644 --- a/sal/android/lo-bootstrap.c +++ b/sal/android/lo-bootstrap.c @@ -1076,9 +1076,15 @@ new_stat(const char *path, int mode, int fake_ino) { + struct tm tm; + memset(statp, 0, sizeof(*statp)); statp->st_mode = mode | S_IRUSR | S_IRGRP | S_IROTH; statp->st_nlink = 1; + + statp->st_uid = getuid(); + statp->st_gid = getgid(); + if (entry != NULL) statp->st_size = entry->uncompressed_size; else @@ -1088,11 +1094,26 @@ new_stat(const char *path, statp->st_blocks = 0; else statp->st_blocks = (statp->st_size - 1) / statp->st_blksize + 1; - /* Leave timestamps at zero for now? */ + + statp->st_atime = time(NULL); + + memset(&tm, 0, sizeof(tm)); + tm.tm_sec = (letoh16(entry->lastmod_time) & 0x1F) * 2; + tm.tm_min = (letoh16(entry->lastmod_time) >> 5) & 0x3F; + tm.tm_hour = (letoh16(entry->lastmod_time) >> 11) & 0x1F; + tm.tm_mday = letoh16(entry->lastmod_date) & 0x1F; + tm.tm_mon = ((letoh16(entry->lastmod_date) >> 5) & 0x0F) - 1; + tm.tm_year = ((letoh16(entry->lastmod_date) >> 9) & 0x7F) + 80; + + statp->st_mtime = mktime(&tm); + statp->st_ctime = statp->st_mtime; + statp->st_ino = fake_ino; (void) path; - /* LOGI("lo_apk_lstat(%s) = { st_mode=%o, st_size=%lld, st_ino=%lld }", path, statp->st_mode, statp->st_size, statp->st_ino); */ + /* LOGI("lo_apk_lstat(%s) = { mode=%o, size=%lld, ino=%lld mtime=%.24s }", + path, statp->st_mode, statp->st_size, statp->st_ino, + ctime((const time_t *) &statp->st_mtime)); */ return 0; } |