logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0004-Revert-Handle-EINTR-when-doing-I-O-on-files-or-socke.patch (8419B)


  1. From bbe8e2f75800633c251adbb34f7f9a1632a0d22a Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Sun, 2 Feb 2025 01:34:54 -0800
  4. Subject: [PATCH] Revert "Handle EINTR when doing I/O on files or sockets"
  5. This reverts commit 0c9646573f140d415cf790310ed17c2ab89f64a3.
  6. ---
  7. bind-mount.c | 2 +-
  8. bubblewrap.c | 26 +++++++++++++-------------
  9. network.c | 6 +++---
  10. utils.c | 16 ++++++++--------
  11. 4 files changed, 25 insertions(+), 25 deletions(-)
  12. diff --git a/bind-mount.c b/bind-mount.c
  13. index a2e1ac6..c1aa9ce 100644
  14. --- a/bind-mount.c
  15. +++ b/bind-mount.c
  16. @@ -405,7 +405,7 @@ bind_mount (int proc_fd,
  17. if (resolved_dest == NULL)
  18. return BIND_MOUNT_ERROR_REALPATH_DEST;
  19. - dest_fd = TEMP_FAILURE_RETRY (open (resolved_dest, O_PATH | O_CLOEXEC));
  20. + dest_fd = open (resolved_dest, O_PATH | O_CLOEXEC);
  21. if (dest_fd < 0)
  22. {
  23. if (failing_path != NULL)
  24. diff --git a/bubblewrap.c b/bubblewrap.c
  25. index bc53891..4848713 100644
  26. --- a/bubblewrap.c
  27. +++ b/bubblewrap.c
  28. @@ -608,7 +608,7 @@ do_init (int event_fd, pid_t initial_pid)
  29. for (lock = lock_files; lock != NULL; lock = lock->next)
  30. {
  31. - int fd = TEMP_FAILURE_RETRY (open (lock->path, O_RDONLY | O_CLOEXEC));
  32. + int fd = open (lock->path, O_RDONLY | O_CLOEXEC);
  33. if (fd == -1)
  34. die_with_error ("Unable to open lock file %s", lock->path);
  35. @@ -619,7 +619,7 @@ do_init (int event_fd, pid_t initial_pid)
  36. .l_len = 0
  37. };
  38. - if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &l)) < 0)
  39. + if (fcntl (fd, F_SETLK, &l) < 0)
  40. die_with_error ("Unable to lock file %s", lock->path);
  41. /* Keep fd open to hang on to lock */
  42. @@ -636,7 +636,7 @@ do_init (int event_fd, pid_t initial_pid)
  43. pid_t child;
  44. int status;
  45. - child = TEMP_FAILURE_RETRY (wait (&status));
  46. + child = wait (&status);
  47. if (child == initial_pid)
  48. {
  49. initial_exit_status = propagate_exit_status (status);
  50. @@ -647,7 +647,7 @@ do_init (int event_fd, pid_t initial_pid)
  51. int res UNUSED;
  52. val = initial_exit_status + 1;
  53. - res = TEMP_FAILURE_RETRY (write (event_fd, &val, 8));
  54. + res = write (event_fd, &val, 8);
  55. /* Ignore res, if e.g. the parent died and closed event_fd
  56. we don't want to error out here */
  57. }
  58. @@ -1071,10 +1071,10 @@ privileged_op (int privileged_op_socket,
  59. if (arg2 != NULL)
  60. strcpy ((char *) buffer + arg2_offset, arg2);
  61. - if (TEMP_FAILURE_RETRY (write (privileged_op_socket, buffer, buffer_size)) != (ssize_t)buffer_size)
  62. + if (write (privileged_op_socket, buffer, buffer_size) != (ssize_t)buffer_size)
  63. die ("Can't write to privileged_op_socket");
  64. - if (TEMP_FAILURE_RETRY (read (privileged_op_socket, buffer, 1)) != 1)
  65. + if (read (privileged_op_socket, buffer, 1) != 1)
  66. die ("Can't read from privileged_op_socket");
  67. return;
  68. @@ -2824,7 +2824,7 @@ namespace_ids_read (pid_t pid)
  69. NsInfo *info;
  70. dir = xasprintf ("%d/ns", pid);
  71. - ns_fd = TEMP_FAILURE_RETRY (openat (proc_fd, dir, O_PATH));
  72. + ns_fd = openat (proc_fd, dir, O_PATH);
  73. if (ns_fd < 0)
  74. die_with_error ("open /proc/%s/ns failed", dir);
  75. @@ -3046,7 +3046,7 @@ main (int argc,
  76. /* We need to read stuff from proc during the pivot_root dance, etc.
  77. Lets keep a fd to it open */
  78. - proc_fd = TEMP_FAILURE_RETRY (open ("/proc", O_PATH));
  79. + proc_fd = open ("/proc", O_PATH);
  80. if (proc_fd == -1)
  81. die_with_error ("Can't open /proc");
  82. @@ -3213,7 +3213,7 @@ main (int argc,
  83. /* Let child run now that the uid maps are set up */
  84. val = 1;
  85. - res = TEMP_FAILURE_RETRY (write (child_wait_fd, &val, 8));
  86. + res = write (child_wait_fd, &val, 8);
  87. /* Ignore res, if e.g. the child died and closed child_wait_fd we don't want to error out here */
  88. close (child_wait_fd);
  89. @@ -3393,12 +3393,12 @@ main (int argc,
  90. op = read_priv_sec_op (unpriv_socket, buffer, sizeof (buffer),
  91. &flags, &perms, &size_arg, &arg1, &arg2);
  92. privileged_op (-1, op, flags, perms, size_arg, arg1, arg2);
  93. - if (TEMP_FAILURE_RETRY (write (unpriv_socket, buffer, 1)) != 1)
  94. + if (write (unpriv_socket, buffer, 1) != 1)
  95. die ("Can't write to op_socket");
  96. }
  97. while (op != PRIV_SEP_OP_DONE);
  98. - TEMP_FAILURE_RETRY (waitpid (child, &status, 0));
  99. + waitpid (child, &status, 0);
  100. /* Continue post setup */
  101. }
  102. }
  103. @@ -3422,7 +3422,7 @@ main (int argc,
  104. * We're aiming to make /newroot the real root, and get rid of /oldroot. To do
  105. * that we need a temporary place to store it before we can unmount it.
  106. */
  107. - { cleanup_fd int oldrootfd = TEMP_FAILURE_RETRY (open ("/", O_DIRECTORY | O_RDONLY));
  108. + { cleanup_fd int oldrootfd = open ("/", O_DIRECTORY | O_RDONLY);
  109. if (oldrootfd < 0)
  110. die_with_error ("can't open /");
  111. if (chdir ("/newroot") != 0)
  112. @@ -3470,7 +3470,7 @@ main (int argc,
  113. {
  114. cleanup_fd int sysctl_fd = -1;
  115. - sysctl_fd = TEMP_FAILURE_RETRY (openat (proc_fd, "sys/user/max_user_namespaces", O_WRONLY));
  116. + sysctl_fd = openat (proc_fd, "sys/user/max_user_namespaces", O_WRONLY);
  117. if (sysctl_fd < 0)
  118. die_with_error ("cannot open /proc/sys/user/max_user_namespaces");
  119. diff --git a/network.c b/network.c
  120. index 373d606..f6d58a6 100644
  121. --- a/network.c
  122. +++ b/network.c
  123. @@ -53,8 +53,8 @@ rtnl_send_request (int rtnl_fd,
  124. struct sockaddr_nl dst_addr = { AF_NETLINK, 0 };
  125. ssize_t sent;
  126. - sent = TEMP_FAILURE_RETRY (sendto (rtnl_fd, (void *) header, header->nlmsg_len, 0,
  127. - (struct sockaddr *) &dst_addr, sizeof (dst_addr)));
  128. + sent = sendto (rtnl_fd, (void *) header, header->nlmsg_len, 0,
  129. + (struct sockaddr *) &dst_addr, sizeof (dst_addr));
  130. if (sent < 0)
  131. return -1;
  132. @@ -71,7 +71,7 @@ rtnl_read_reply (int rtnl_fd,
  133. while (1)
  134. {
  135. - received = TEMP_FAILURE_RETRY (recv (rtnl_fd, buffer, sizeof (buffer), 0));
  136. + received = recv (rtnl_fd, buffer, sizeof (buffer), 0);
  137. if (received < 0)
  138. return -1;
  139. diff --git a/utils.c b/utils.c
  140. index 8ab89bb..ffe0a0d 100644
  141. --- a/utils.c
  142. +++ b/utils.c
  143. @@ -378,7 +378,7 @@ fdwalk (int proc_fd, int (*cb)(void *data,
  144. int res = 0;
  145. DIR *d;
  146. - dfd = TEMP_FAILURE_RETRY (openat (proc_fd, "self/fd", O_DIRECTORY | O_RDONLY | O_NONBLOCK | O_CLOEXEC | O_NOCTTY));
  147. + dfd = openat (proc_fd, "self/fd", O_DIRECTORY | O_RDONLY | O_NONBLOCK | O_CLOEXEC | O_NOCTTY);
  148. if (dfd == -1)
  149. return res;
  150. @@ -460,7 +460,7 @@ write_file_at (int dfd,
  151. bool res;
  152. int errsv;
  153. - fd = TEMP_FAILURE_RETRY (openat (dfd, path, O_RDWR | O_CLOEXEC, 0));
  154. + fd = openat (dfd, path, O_RDWR | O_CLOEXEC, 0);
  155. if (fd == -1)
  156. return -1;
  157. @@ -485,7 +485,7 @@ create_file (const char *path,
  158. int res;
  159. int errsv;
  160. - fd = TEMP_FAILURE_RETRY (creat (path, mode));
  161. + fd = creat (path, mode);
  162. if (fd == -1)
  163. return -1;
  164. @@ -566,11 +566,11 @@ copy_file (const char *src_path,
  165. int res;
  166. int errsv;
  167. - sfd = TEMP_FAILURE_RETRY (open (src_path, O_CLOEXEC | O_RDONLY));
  168. + sfd = open (src_path, O_CLOEXEC | O_RDONLY);
  169. if (sfd == -1)
  170. return -1;
  171. - dfd = TEMP_FAILURE_RETRY (creat (dst_path, mode));
  172. + dfd = creat (dst_path, mode);
  173. if (dfd == -1)
  174. {
  175. errsv = errno;
  176. @@ -647,7 +647,7 @@ load_file_at (int dfd,
  177. char *data;
  178. int errsv;
  179. - fd = TEMP_FAILURE_RETRY (openat (dfd, path, O_CLOEXEC | O_RDONLY));
  180. + fd = openat (dfd, path, O_CLOEXEC | O_RDONLY);
  181. if (fd == -1)
  182. return NULL;
  183. @@ -777,7 +777,7 @@ send_pid_on_socket (int sockfd)
  184. cred.gid = getegid ();
  185. memcpy (CMSG_DATA (cmsg), &cred, sizeof (cred));
  186. - if (TEMP_FAILURE_RETRY (sendmsg (sockfd, &msg, 0)) < 0)
  187. + if (sendmsg (sockfd, &msg, 0) < 0)
  188. die_with_error ("Can't send pid");
  189. }
  190. @@ -807,7 +807,7 @@ read_pid_from_socket (int sockfd)
  191. msg.msg_control = control_buf_rcv;
  192. msg.msg_controllen = sizeof (control_buf_rcv);
  193. - if (TEMP_FAILURE_RETRY (recvmsg (sockfd, &msg, 0)) < 0)
  194. + if (recvmsg (sockfd, &msg, 0) < 0)
  195. die_with_error ("Can't read pid from socket");
  196. if (msg.msg_controllen <= 0)
  197. --
  198. 2.44.0