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:
parent
d9bef3e237
commit
be19606501
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) {
|
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 (;;) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue