[Wayland] Fall back to ftruncate if posix_fallocate isn't supported by filesystem. diff --git widget/gtk/WindowSurfaceWayland.cpp widget/gtk/WindowSurfaceWayland.cpp index 9a73326399bd5..9e42a7f1c5d18 100644 --- widget/gtk/WindowSurfaceWayland.cpp +++ widget/gtk/WindowSurfaceWayland.cpp @@ -221,7 +221,9 @@ static int WaylandAllocateShmMemory(int aSize) { do { ret = posix_fallocate(fd, 0, aSize); } while (ret == EINTR); - if (ret != 0) { + if (ret == 0) { + return fd; + } else if (ret != ENODEV && ret != EINVAL && ret != EOPNOTSUPP) { NS_WARNING( nsPrintfCString("posix_fallocate() fails to allocate shm memory: %s", strerror(ret)) @@ -229,7 +231,7 @@ static int WaylandAllocateShmMemory(int aSize) { close(fd); return -1; } -#else +#endif do { ret = ftruncate(fd, aSize); } while (ret < 0 && errno == EINTR); @@ -240,7 +242,6 @@ static int WaylandAllocateShmMemory(int aSize) { close(fd); fd = -1; } -#endif return fd; } @@ -253,7 +254,7 @@ static bool WaylandReAllocateShmMemory(int aFd, int aSize) { do { errno = posix_fallocate(aFd, 0, aSize); } while (errno == EINTR); - if (errno != 0) { + if (errno != 0 && errno != ENODEV && errno != EINVAL && errno != EOPNOTSUPP) { return false; } #endif