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:
parent
d9bef3e237
commit
be19606501
Notes:
sideshowbarker
2024-07-19 11:28:01 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/be196065018
1 changed files with 4 additions and 2 deletions
|
@ -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) {
|
||||
// NOTE: This is primarily an optimization, so it's not the end if it fails.
|
||||
ftruncate(dst_fd, src_stat.st_size);
|
||||
if (ftruncate(dst_fd, src_stat.st_size) < 0) {
|
||||
perror("cp: ftruncate");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
|
Loading…
Add table
Reference in a new issue