mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 19:11:46 +01:00
MDEV-14132 follow-up fix: Validate the posix_fallocate() argument
os_file_set_size(): Sometimes the file already is large enough. Avoid calling posix_fallocate() with a non-positive argument. Also, add a missing space to an error message.
This commit is contained in:
parent
057a6cf768
commit
5f5ffdc76b
1 changed files with 4 additions and 2 deletions
|
@ -5382,14 +5382,16 @@ fallback:
|
||||||
int err;
|
int err;
|
||||||
do {
|
do {
|
||||||
os_offset_t current_size = os_file_get_size(file);
|
os_offset_t current_size = os_file_get_size(file);
|
||||||
err = posix_fallocate(file, current_size, size - current_size);
|
err = current_size >= size
|
||||||
|
? 0 : posix_fallocate(file, current_size,
|
||||||
|
size - current_size);
|
||||||
} while (err == EINTR
|
} while (err == EINTR
|
||||||
&& srv_shutdown_state == SRV_SHUTDOWN_NONE);
|
&& srv_shutdown_state == SRV_SHUTDOWN_NONE);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
ib::error() <<
|
ib::error() <<
|
||||||
"preallocating " << size << " bytes for" <<
|
"preallocating " << size << " bytes for" <<
|
||||||
"file " << name << "failed with error " << err;
|
"file " << name << " failed with error " << err;
|
||||||
}
|
}
|
||||||
errno = err;
|
errno = err;
|
||||||
return(!err);
|
return(!err);
|
||||||
|
|
Loading…
Add table
Reference in a new issue