On 2021/08/17 09:14, Paco Esteban wrote:
> Hi ports@,
> 
> This is an update of x11/kitty to 0.23.0
> It works for me and all tests pass on amd64.
> 
> About the port itself, I removed most of the patches that seem to be
> included upstream.  I have a doubt about a new one I had to introduce.
> We don't seem to have a function called posix_fallocate, which is used
> to guarantee disk space available.  The closest thing I could find is
> ftruncate(2), which is not exactly the same but it was used on the same
> file under certain conditions.  This is probably the wrong move, so I'm
> open to suggestions here.  I also created a tmp folder in pre-test to
> avoid some tests failing because of filesystems permissions.

The posix_fallocate -> ftruncate move seems sane, another
approach would be to emulate shm_open SHM_ANON, see
https://github.com/lassik/shm_open_anon for clues, otherwise implement
memfd_create, which would have some uses in X too).


> + int createAnonymousFile(off_t size) {
> +-    int ret, fd = -1, shm_anon = 0;
> ++    int ret, fd = -1;
> + #ifdef HAS_MEMFD_CREATE
> +     fd = glfw_memfd_create("glfw-shared", MFD_CLOEXEC | MFD_ALLOW_SEALING);
> +     if (fd < 0) return -1;
> +@@ -383,10 +383,6 @@ int createAnonymousFile(off_t size) {
> +     // There is also no need to check for the return value, we couldn’t do
> +     // anything with it anyway.
> +     fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
> +-#elif defined(SHM_ANON)
> +-    fd = shm_open(SHM_ANON, O_RDWR | O_CLOEXEC, 0600);
> +-    if (fd < 0) return -1;
> +-    shm_anon = 1;
> + #else
> +     static const char template[] = "/glfw-shared-XXXXXX";
> +     const char* path;
> +@@ -410,8 +406,7 @@ int createAnonymousFile(off_t size) {
> +     if (fd < 0)
> +         return -1;
> + #endif
> +-    // posix_fallocate does not work on SHM descriptors
> +-    ret = shm_anon ? ftruncate(fd, size) : posix_fallocate(fd, 0, size);
> ++    ret = ftruncate(fd, size);
> +     if (ret != 0)
> +     {
> +         close(fd);

Reply via email to