Skip to content

Commit

Permalink
syscall: restart open, ioctl, accept and connect after interrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
mosmeh committed Nov 9, 2024
1 parent 561670f commit 10dbc9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion kernel/syscall/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ int sys_open(const char* user_pathname, int flags, unsigned mode) {
return rc;

struct file* file = vfs_open(pathname, flags, (mode & 0777) | S_IFREG);
if (PTR_ERR(file) == -EINTR)
return -ERESTARTSYS;
if (IS_ERR(file))
return PTR_ERR(file);
rc = task_alloc_file_descriptor(-1, file);
Expand Down Expand Up @@ -422,7 +424,10 @@ int sys_ioctl(int fd, int request, void* user_argp) {
struct file* file = task_get_file(fd);
if (IS_ERR(file))
return PTR_ERR(file);
return file_ioctl(file, request, user_argp);
int rc = file_ioctl(file, request, user_argp);
if (rc == -EINTR)
return -ERESTARTSYS;
return rc;
}

int sys_mkdir(const char* user_pathname, mode_t mode) {
Expand Down
7 changes: 6 additions & 1 deletion kernel/syscall/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ int sys_accept4(int sockfd, struct sockaddr* user_addr, socklen_t* user_addrlen,
}

struct unix_socket* connector = unix_socket_accept(file);
if (PTR_ERR(connector) == -EINTR)
return -ERESTARTSYS;
if (IS_ERR(connector))
return PTR_ERR(connector);
struct file* connector_file = inode_open(&connector->inode, O_RDWR, 0);
Expand Down Expand Up @@ -137,7 +139,10 @@ int sys_connect(int sockfd, const struct sockaddr* user_addr,
if (IS_ERR(addr_file))
return PTR_ERR(addr_file);

return unix_socket_connect(file, addr_file->inode);
int rc = unix_socket_connect(file, addr_file->inode);
if (rc == -EINTR)
return -ERESTARTSYS;
return rc;
}

int sys_shutdown(int sockfd, int how) {
Expand Down

0 comments on commit 10dbc9d

Please sign in to comment.