ostreedev / ostree

Operating system and container binary deployment and upgrades
https://ostreedev.github.io/ostree/
Other
1.27k stars 291 forks source link

Add work-around for TEMP_FAILURE_RETRY to support musl #731

Open misery opened 7 years ago

misery commented 7 years ago

Macro TEMP_FAILURE_RETRY is not available on musl as it is stuff from glibc.

Some projects uses an #ifdef for this

/* taken from glibc unistd.h and fixes musl */
#ifndef TEMP_FAILURE_RETRY
#define TEMP_FAILURE_RETRY(expression) \
  (__extension__                                                              \
    ({ long int __result;                                                     \
       do __result = (long int) (expression);                                 \
       while (__result == -1L && errno == EINTR);                             \
       __result; }))
#endif

http://www.musl-libc.org/

cgwalters commented 7 years ago

Ug. Honestly we're not really consistent about even using it unfortunately.

But I'm okay sticking that in...probably libglnx.

That said, has musl rejected adding it, or has it not been proposed?

misery commented 7 years ago

Well, I don't know why musl do not have it.

I created a flatpak (and ostree) package for AlpineLinux (musl based). So I need a fix for it. ;-)

https://github.com/alpinelinux/aports/pull/1005

ricardosalveti commented 5 years ago

TEMP_FAILURE_RETRY seems to be used in several places in the current codebase, and not only in glnx.

From what I saw TEMP_FAILURE_RETRY will not be available in musl because it is glibc specific.

misery commented 5 years ago
$ rg TEMP_FAILURE_RETRY
tests/test-repo-finder-mount.c
278:  if (TEMP_FAILURE_RETRY (symlinkat (symlink_target_path, repos_dfd, repo_name)) != 0)

src/libotutil/ot-fs-utils.c
54:  if (TEMP_FAILURE_RETRY (len = readlinkat (dfd, path, targetbuf, sizeof (targetbuf) - 1)) < 0)

src/ostree/ot-builtin-create-usb.c
259:              int ret = TEMP_FAILURE_RETRY (symlinkat (relative_dest_repo_path, mount_root_dfd, symlink_path));

src/libostree/ostree-sysroot.c
1840:        if (TEMP_FAILURE_RETRY (waitpid (mount_child, &estatus, 0)) < 0)

src/libostree/ostree-sysroot-deploy.c
79:  if (TEMP_FAILURE_RETRY (symlinkat (oldpath, parent_dfd, temppath)) < 0)
1310:      ssize_t bytes_read = TEMP_FAILURE_RETRY (read (sock_watchdog, &c, sizeof (c)));
1324:      int r = TEMP_FAILURE_RETRY (poll (pfds, 1, timeout_ms));
1334:          (void) TEMP_FAILURE_RETRY (ioctl (rootfs_dfd, FITHAW, 0));
1355:      ssize_t bytes_read = TEMP_FAILURE_RETRY (read (sock_parent, &c, sizeof (c)));
1368:          if (TEMP_FAILURE_RETRY (waitpid (pid, &wstatus, 0)) < 0)
1386:              if (TEMP_FAILURE_RETRY (syncfs (rootfs_dfd)) != 0)
1397:      if (TEMP_FAILURE_RETRY (ioctl (rootfs_dfd, FITHAW, 0)) != 0)

src/libostree/ostree-repo.c
278:  res = TEMP_FAILURE_RETRY (fcntl (fd, (flags & LOCK_NB) ? F_OFD_SETLK : F_OFD_SETLKW, &fl));
288:        res = TEMP_FAILURE_RETRY (flock (fd, flags));
311:  res = TEMP_FAILURE_RETRY (fcntl (fd, (flags & LOCK_NB) ? F_OFD_SETLK : F_OFD_SETLKW, &fl));
321:        res = TEMP_FAILURE_RETRY (flock (fd, LOCK_UN | flags));
354:      lock->fd = TEMP_FAILURE_RETRY (openat (self->repo_dir_fd, ".lock",
2750:  if (TEMP_FAILURE_RETRY (fstatvfs (self->repo_dir_fd, &stvfsbuf)) < 0)
3830:  if ((res = TEMP_FAILURE_RETRY (fstatat (objdir_fd, loose_path_buf, &stbuf, AT_SYMLINK_NOFOLLOW))) < 0
3834:      res = TEMP_FAILURE_RETRY (fstatat (objdir_fd, loose_path_buf, &stbuf, AT_SYMLINK_NOFOLLOW));
4087:      if (TEMP_FAILURE_RETRY (fstatat (dfd, loose_path_buf, &stbuf, AT_SYMLINK_NOFOLLOW)) < 0)
4376:  res = TEMP_FAILURE_RETRY (fstatat (self->objects_dir_fd, loose_path, &stbuf, AT_SYMLINK_NOFOLLOW));
4378:    res = TEMP_FAILURE_RETRY (fstatat (self->commit_stagedir.fd, loose_path, &stbuf, AT_SYMLINK_NOFOLLOW));

src/libostree/ostree-repo-pull.c
2352:  if (TEMP_FAILURE_RETRY (fstatvfs (pull_data->repo->repo_dir_fd, &stvfsbuf)) < 0)

src/libostree/ostree-repo-checkout.c
83:      if (TEMP_FAILURE_RETRY (fsync (tmpf.fd)) < 0)
158:      if (TEMP_FAILURE_RETRY (fchown (outfd, g_file_info_get_attribute_uint32 (file_info, "unix::uid"),
175:  if (TEMP_FAILURE_RETRY (fchmod (outfd, file_mode)) < 0)
303:          if (TEMP_FAILURE_RETRY (fchownat (destination_dfd, destination_name,
704:                  if (TEMP_FAILURE_RETRY (fstatat (destination_dfd, destination_name, &stbuf, AT_SYMLINK_NOFOLLOW)) != 0)
963:    if (TEMP_FAILURE_RETRY (mkdirat (destination_parent_fd, destination_name, 0700)) < 0)
1079:      if (TEMP_FAILURE_RETRY (fchmod (destination_dfd, canonical_mode)) < 0)
1085:      if (TEMP_FAILURE_RETRY (fchown (destination_dfd, uid, gid)) < 0)
1097:      if (TEMP_FAILURE_RETRY (futimens (destination_dfd, times)) < 0)

src/libostree/ostree-repo-commit.c
138:  if (TEMP_FAILURE_RETRY (fsetxattr (fd, "user.ostreemeta",
250:      if (TEMP_FAILURE_RETRY (fchown (tmpf->fd, uid, gid)) < 0)
253:      if (TEMP_FAILURE_RETRY (fchmod (tmpf->fd, mode)) < 0)
302:      if (TEMP_FAILURE_RETRY (futimens (tmpf->fd, times)) < 0)
789:      size = TEMP_FAILURE_RETRY (readlinkat (dfd, loose_path_buf, target_buf, sizeof (target_buf)));
1609:  if (TEMP_FAILURE_RETRY (fstatvfs (self->repo_dir_fd, &stvfsbuf)) < 0)
4300:              if (TEMP_FAILURE_RETRY (fsetxattr (tmp_dest.fd, "user.ostreemeta",
akiernan commented 5 years ago

I just opened https://gitlab.gnome.org/GNOME/libglnx/merge_requests/9 for this