fix full allocation failure on APFS
This commit is contained in:
parent
9f6631bfbe
commit
205fe5e7ea
|
@ -1,4 +1,6 @@
|
|||
|
||||
* fix full allocation failure on APFS
|
||||
|
||||
1.1.5 release
|
||||
|
||||
* fix infinite loop when parsing certain invalid magnet links
|
||||
|
|
26
src/file.cpp
26
src/file.cpp
|
@ -2115,17 +2115,23 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
|||
fstore_t f = {F_ALLOCATECONTIG, F_PEOFPOSMODE, 0, s, 0};
|
||||
if (fcntl(native_handle(), F_PREALLOCATE, &f) < 0)
|
||||
{
|
||||
if (errno != ENOSPC)
|
||||
// It appears Apple's new filesystem (APFS) does not
|
||||
// support this control message and fails with EINVAL
|
||||
// if so, just skip it
|
||||
if (errno != EINVAL)
|
||||
{
|
||||
ec.assign(errno, system_category());
|
||||
return false;
|
||||
}
|
||||
// ok, let's try to allocate non contiguous space then
|
||||
f.fst_flags = F_ALLOCATEALL;
|
||||
if (fcntl(native_handle(), F_PREALLOCATE, &f) < 0)
|
||||
{
|
||||
ec.assign(errno, system_category());
|
||||
return false;
|
||||
if (errno != ENOSPC)
|
||||
{
|
||||
ec.assign(errno, system_category());
|
||||
return false;
|
||||
}
|
||||
// ok, let's try to allocate non contiguous space then
|
||||
f.fst_flags = F_ALLOCATEALL;
|
||||
if (fcntl(native_handle(), F_PREALLOCATE, &f) < 0)
|
||||
{
|
||||
ec.assign(errno, system_category());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // F_PREALLOCATE
|
||||
|
|
Loading…
Reference in New Issue