diff options
author | Timo Teräs <timo.teras@iki.fi> | 2012-02-23 17:04:51 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2012-02-23 17:04:51 +0200 |
commit | 7392acb95ea7be1317892aad1b69a01382ee3f5c (patch) | |
tree | b97a25dce86bedc25f07f0f0275b67519c0521a2 /src/io.c | |
parent | a9a84215c70c746b2f6a6b3c58c338730100666c (diff) | |
download | apk-tools-7392acb95ea7be1317892aad1b69a01382ee3f5c.tar.gz apk-tools-7392acb95ea7be1317892aad1b69a01382ee3f5c.tar.bz2 apk-tools-7392acb95ea7be1317892aad1b69a01382ee3f5c.tar.xz apk-tools-7392acb95ea7be1317892aad1b69a01382ee3f5c.zip |
db: keep architecture in $ROOT/etc/apk/arch
This we use proper arch in case modifying chroot installation.
Diffstat (limited to 'src/io.c')
-rw-r--r-- | src/io.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -486,6 +486,36 @@ err_fd: return APK_BLOB_NULL; } +int apk_blob_to_file(int atfd, const char *file, apk_blob_t b, unsigned int flags) +{ + int fd, r, len; + + fd = openat(atfd, file, O_CREAT | O_WRONLY | O_CLOEXEC, 0644); + if (fd < 0) + return -errno; + + len = b.len; + r = write(fd, b.ptr, len); + if ((r == len) && + (flags & APK_BTF_ADD_EOL) && (b.len == 0 || b.ptr[b.len-1] != '\n')) { + len = 1; + r = write(fd, "\n", len); + } + + if (r < 0) + r = -errno; + else if (r != len) + r = -ENOSPC; + else + r = 0; + close(fd); + + if (r != 0) + unlinkat(atfd, file, 0); + + return r; +} + int apk_file_get_info(int atfd, const char *filename, unsigned int flags, struct apk_file_info *fi) { |