1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:47:45 +00:00

cp: Fail immediately if there's not enough space for the destination

Instead of writing until we run out of space, just fail immediately.
This commit is contained in:
Andreas Kling 2019-11-02 23:47:22 +01:00
parent d9bef3e237
commit be19606501

View file

@ -90,8 +90,10 @@ bool copy_file(String src_path, String dst_path, struct stat src_stat, int src_f
} }
if (src_stat.st_size > 0) { if (src_stat.st_size > 0) {
// NOTE: This is primarily an optimization, so it's not the end if it fails. if (ftruncate(dst_fd, src_stat.st_size) < 0) {
ftruncate(dst_fd, src_stat.st_size); perror("cp: ftruncate");
return false;
}
} }
for (;;) { for (;;) {