| int copy_fd(int ifd, int ofd) |
| ssize_t len = xread(ifd, buffer, sizeof(buffer)); |
| return error("copy-fd: read returned %s", |
| int written = xwrite(ofd, buf, len); |
| return error("copy-fd: write returned 0"); |
| return error("copy-fd: write returned %s", |
| int copy_file(const char *dst, const char *src, int mode) |
| mode = (mode & 0111) ? 0777 : 0666; |
| if ((fdi = open(src, O_RDONLY)) < 0) |
| if ((fdo = open(dst, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0) { |
| status = copy_fd(fdi, fdo); |
| return error("%s: close error: %s", dst, strerror(errno)); |
| if (!status && adjust_shared_perm(dst)) |