Handle case where posix_fallocate is not supported for a filesystem.
2017-12-02 Vladimir Kondratyev <vladimir@kondratyev.su> Cary Coutant <ccoutant@gmail.com> gold/ PR gold/22540 * output.cc (gold_fallocate): Trivial return for len == 0. Add fallback options when posix_fallocate and fallocate return not-supported errors.
This commit is contained in:
parent
158600eb98
commit
222b39c283
@ -1,3 +1,11 @@
|
|||||||
|
2017-12-02 Vladimir Kondratyev <vladimir@kondratyev.su>
|
||||||
|
Cary Coutant <ccoutant@gmail.com>
|
||||||
|
|
||||||
|
PR gold/22540
|
||||||
|
* output.cc (gold_fallocate): Trivial return for len == 0.
|
||||||
|
Add fallback options when posix_fallocate and fallocate return
|
||||||
|
not-supported errors.
|
||||||
|
|
||||||
2017-12-01 Cary Coutant <ccoutant@gmail.com>
|
2017-12-01 Cary Coutant <ccoutant@gmail.com>
|
||||||
|
|
||||||
PR gold/21090
|
PR gold/21090
|
||||||
|
@ -127,14 +127,26 @@ namespace gold
|
|||||||
static int
|
static int
|
||||||
gold_fallocate(int o, off_t offset, off_t len)
|
gold_fallocate(int o, off_t offset, off_t len)
|
||||||
{
|
{
|
||||||
|
if (len <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
#ifdef HAVE_POSIX_FALLOCATE
|
#ifdef HAVE_POSIX_FALLOCATE
|
||||||
if (parameters->options().posix_fallocate())
|
if (parameters->options().posix_fallocate())
|
||||||
return ::posix_fallocate(o, offset, len);
|
{
|
||||||
|
int err = ::posix_fallocate(o, offset, len);
|
||||||
|
if (err != EINVAL && err != ENOSYS && err != EOPNOTSUPP)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
#endif // defined(HAVE_POSIX_FALLOCATE)
|
#endif // defined(HAVE_POSIX_FALLOCATE)
|
||||||
|
|
||||||
#ifdef HAVE_FALLOCATE
|
#ifdef HAVE_FALLOCATE
|
||||||
if (::fallocate(o, 0, offset, len) == 0)
|
{
|
||||||
return 0;
|
int err = ::fallocate(o, 0, offset, len);
|
||||||
|
if (err != EINVAL && err != ENOSYS && err != EOPNOTSUPP)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
#endif // defined(HAVE_FALLOCATE)
|
#endif // defined(HAVE_FALLOCATE)
|
||||||
|
|
||||||
if (::ftruncate(o, offset + len) < 0)
|
if (::ftruncate(o, offset + len) < 0)
|
||||||
return errno;
|
return errno;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user