[PATCH] D31831: posix_fallocate isn't support on all filesystems

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue May 2 09:02:38 PDT 2017


LGTM with an expanded comment about which filesystems don't support
posix_fallocate.

Sid Manning via Phabricator <reviews at reviews.llvm.org> writes:

> sidneym updated this revision to Diff 97457.
> sidneym added a comment.
>
> Removed duplicated code.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D31831
>
> Files:
>   lib/Support/Unix/Path.inc
>
>
> Index: lib/Support/Unix/Path.inc
> ===================================================================
> --- lib/Support/Unix/Path.inc
> +++ lib/Support/Unix/Path.inc
> @@ -422,13 +422,13 @@
>    // If we have posix_fallocate use it. Unlike ftruncate it always allocates
>    // space, so we get an error if the disk is full.
>    if (int Err = ::posix_fallocate(FD, 0, Size))
> -    return std::error_code(Err, std::generic_category());
> -#else
> +    if (Err != EOPNOTSUPP)
> +      return std::error_code(Err, std::generic_category());
> +#endif
>    // Use ftruncate as a fallback. It may or may not allocate space. At least on
>    // OS X with HFS+ it does.
>    if (::ftruncate(FD, Size) == -1)
>      return std::error_code(errno, std::generic_category());
> -#endif
>  
>    return std::error_code();
>  }
>
>
> Index: lib/Support/Unix/Path.inc
> ===================================================================
> --- lib/Support/Unix/Path.inc
> +++ lib/Support/Unix/Path.inc
> @@ -422,13 +422,13 @@
>    // If we have posix_fallocate use it. Unlike ftruncate it always allocates
>    // space, so we get an error if the disk is full.
>    if (int Err = ::posix_fallocate(FD, 0, Size))
> -    return std::error_code(Err, std::generic_category());
> -#else
> +    if (Err != EOPNOTSUPP)
> +      return std::error_code(Err, std::generic_category());
> +#endif
>    // Use ftruncate as a fallback. It may or may not allocate space. At least on
>    // OS X with HFS+ it does.
>    if (::ftruncate(FD, Size) == -1)
>      return std::error_code(errno, std::generic_category());
> -#endif
>  
>    return std::error_code();
>  }


More information about the llvm-commits mailing list