diff options
author | Anton Kling <anton@kling.gg> | 2024-12-11 18:47:33 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-12-12 15:48:20 +0100 |
commit | 633feeea57c298306d8664c9c2768ab46fb7c6f4 (patch) | |
tree | d91cd1c19d3e850b978c7ada526246e3b35e6608 /kernel | |
parent | bc828883c51c3c0f35872019f4db632e4ce82dc5 (diff) |
signal: Remove old way of sending signals and instead use procfs
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cpu/syscall.c | 36 | ||||
-rw-r--r-- | kernel/fs/ext2.c | 4 | ||||
-rw-r--r-- | kernel/fs/procfs.c | 7 | ||||
-rw-r--r-- | kernel/fs/shm.c | 3 | ||||
-rw-r--r-- | kernel/fs/tmpfs.c | 4 | ||||
-rw-r--r-- | kernel/fs/vfs.c | 2 | ||||
-rw-r--r-- | kernel/fs/vfs.h | 2 | ||||
-rw-r--r-- | kernel/queue.c | 9 | ||||
-rw-r--r-- | kernel/socket.c | 9 |
9 files changed, 16 insertions, 60 deletions
diff --git a/kernel/cpu/syscall.c b/kernel/cpu/syscall.c index 31f1fc5..de765b4 100644 --- a/kernel/cpu/syscall.c +++ b/kernel/cpu/syscall.c @@ -173,17 +173,6 @@ int syscall_isatty(int fd) { return 1; } -int syscall_kill(int fd, int sig) { - vfs_fd_t *fd_ptr = get_vfs_fd(fd, NULL); - if (!fd_ptr) { - return -EBADF; - } - if (!fd_ptr->inode->send_signal) { - return -EBADF; - } - return process_signal(fd_ptr, sig); -} - int syscall_lseek(int fd, int offset, int whence) { return vfs_lseek(fd, offset, whence); } @@ -223,29 +212,6 @@ int syscall_open(const char *file, int flags, mode_t mode) { return vfs_open(_file, _flags, _mode); } -int syscall_open_process(int pid) { - // TODO: Permission check - process_t *process = (process_t *)ready_queue; - for (; process; process = process->next) { - if (pid == process->pid) { - break; - } - } - if (!process) { - return -ESRCH; - } - - vfs_inode_t *inode = vfs_create_inode( - process->pid, 0 /*type*/, 0 /*has_data*/, 0 /*can_write*/, 1 /*is_open*/, - 0, process /*internal_object*/, 0 /*file_size*/, NULL /*open*/, - NULL /*create_file*/, NULL /*read*/, NULL /*write*/, NULL /*close*/, - NULL /*create_directory*/, NULL /*get_vm_object*/, NULL /*truncate*/, - NULL /*stat*/, process_signal, NULL /*connect*/); - int rc = vfs_create_fd(0, 0, 0, inode, NULL); - assert(rc >= 0); - return rc; -} - int syscall_poll(SYS_POLL_PARAMS *args) { struct pollfd *fds = args->fds; size_t nfds = args->nfds; @@ -654,14 +620,12 @@ int (*syscall_functions[])() = { (void(*))syscall_mkdir, (void(*))syscall_recvfrom, (void(*))syscall_sendto, - (void(*))syscall_kill, (void(*))syscall_sigaction, (void(*))syscall_chdir, (void(*))syscall_getcwd, (void(*))syscall_isatty, (void(*))syscall_randomfill, (void(*))syscall_munmap, - (void(*))syscall_open_process, (void(*))syscall_lseek, (void(*))syscall_connect, (void(*))syscall_setsockopt, diff --git a/kernel/fs/ext2.c b/kernel/fs/ext2.c index fe09834..0f8e344 100644 --- a/kernel/fs/ext2.c +++ b/kernel/fs/ext2.c @@ -745,7 +745,7 @@ vfs_inode_t *ext2_open(const char *path) { inode_num, type, NULL, NULL, 1 /*is_open*/, 0, NULL /*internal_object*/, file_size, ext2_open, ext2_create_file, ext2_read, ext2_write, ext2_close, ext2_create_directory, NULL /*get_vm_object*/, ext2_truncate /*truncate*/, - ext2_stat, NULL /*send_signal*/, NULL /*connect*/); + ext2_stat, NULL /*connect*/); } u64 end_of_last_entry_position(int dir_inode, u64 *entry_offset, @@ -960,7 +960,7 @@ vfs_inode_t *ext2_mount(void) { 0 /*is_open*/, 0, NULL /*internal_object*/, 0 /*file_size*/, ext2_open, ext2_create_file, ext2_read, ext2_write, ext2_close, ext2_create_directory, NULL /*get_vm_object*/, ext2_truncate /*truncate*/, - ext2_stat, NULL /*send_signal*/, NULL /*connect*/); + ext2_stat, NULL /*connect*/); if (!inode) { goto ext2_mount_error; } diff --git a/kernel/fs/procfs.c b/kernel/fs/procfs.c index f6a4fef..69022d4 100644 --- a/kernel/fs/procfs.c +++ b/kernel/fs/procfs.c @@ -134,7 +134,7 @@ vfs_inode_t *open_process(u64 pid, int id) { 0 /*is_open*/, 0, process /*internal_object*/, 0 /*file_size*/, procfs_open, NULL /*create_file*/, process_read, process_write, process_close, NULL /*create_directory*/, NULL /*get_vm_object*/, - NULL /*truncate*/, NULL /*stat*/, NULL /*send_signal*/, NULL /*connect*/); + NULL /*truncate*/, NULL /*stat*/, NULL /*connect*/); if (!inode) { return NULL; } @@ -152,8 +152,7 @@ vfs_inode_t *procfs_open(const char *p) { 0 /*is_open*/, 0, NULL /*internal_object*/, 0 /*file_size*/, procfs_open, NULL /*create_file*/, procfs_read, NULL /* write */, procfs_close, NULL /*create_directory*/, NULL /*get_vm_object*/, - NULL /*truncate*/, NULL /*stat*/, NULL /*send_signal*/, - NULL /*connect*/); + NULL /*truncate*/, NULL /*stat*/, NULL /*connect*/); } int got_num; @@ -180,6 +179,6 @@ vfs_inode_t *procfs_mount(void) { 0 /*is_open*/, 0, NULL /*internal_object*/, 0 /*file_size*/, procfs_open, NULL /*create_file*/, procfs_read, NULL /* write */, procfs_close, NULL /*create_directory*/, NULL /*get_vm_object*/, NULL /*truncate*/, - NULL /*stat*/, NULL /*send_signal*/, NULL /*connect*/); + NULL /*stat*/, NULL /*connect*/); return inode; } diff --git a/kernel/fs/shm.c b/kernel/fs/shm.c index 5e44b97..be80de5 100644 --- a/kernel/fs/shm.c +++ b/kernel/fs/shm.c @@ -101,8 +101,7 @@ int shm_open(const char *name, int oflag, mode_t mode) { 0 /*inode_num*/, 0 /*type*/, NULL, NULL, 1 /*is_open*/, 0, internal_object, 0 /*file_size*/, NULL /*open*/, NULL /*create_file*/, shm_read, shm_write, shm_close, NULL /*create_directory*/, - shm_get_vm_object, shm_ftruncate, NULL /*stat*/, NULL /*send_signal*/, - NULL /*connect*/); + shm_get_vm_object, shm_ftruncate, NULL /*stat*/, NULL /*connect*/); vfs_fd_t *fd_ptr; int fd = vfs_create_fd(oflag, mode, 0 /*is_tty*/, inode, &fd_ptr); diff --git a/kernel/fs/tmpfs.c b/kernel/fs/tmpfs.c index f979d92..3040622 100644 --- a/kernel/fs/tmpfs.c +++ b/kernel/fs/tmpfs.c @@ -62,7 +62,7 @@ void dual_pipe(int fd[2]) { internal_object, 0 /*file_size*/, NULL /*open*/, NULL /*create_file*/, tmp_read, tmp_write, tmp_close, NULL /*create_directory*/, NULL /*get_vm_object*/, NULL /*truncate*/, NULL /*stat*/, - NULL /*send_signal*/, NULL /*connect*/); + NULL /*connect*/); assert(inode); fd[i] = @@ -93,7 +93,7 @@ void pipe(int fd[2]) { internal_object, 0 /*file_size*/, NULL /*open*/, NULL /*create_file*/, tmp_read, tmp_write, tmp_close, NULL /*create_directory*/, NULL /*get_vm_object*/, NULL /*truncate*/, NULL /*stat*/, - NULL /*send_signal*/, NULL /*connect*/); + NULL /*connect*/); assert(inode); fd[i] = vfs_create_fd(O_RDWR, 0, 0 /*is_tty*/, inode, &fd_ptrs[i]); diff --git a/kernel/fs/vfs.c b/kernel/fs/vfs.c index 7e23870..f8655bd 100644 --- a/kernel/fs/vfs.c +++ b/kernel/fs/vfs.c @@ -38,7 +38,6 @@ vfs_inode_t *vfs_create_inode( vfs_vm_object_t *(*get_vm_object)(u64 length, u64 offset, vfs_fd_t *fd), int (*truncate)(vfs_fd_t *fd, size_t length), int (*stat)(vfs_fd_t *fd, struct stat *buf), - int (*send_signal)(vfs_fd_t *fd, int signal), int (*connect)(vfs_fd_t *fd, const struct sockaddr *addr, socklen_t addrlen)) { vfs_inode_t *r = kcalloc(1, sizeof(inode_t)); @@ -59,7 +58,6 @@ vfs_inode_t *vfs_create_inode( r->get_vm_object = get_vm_object; r->truncate = truncate; r->stat = stat; - r->send_signal = send_signal; r->connect = connect; return r; } diff --git a/kernel/fs/vfs.h b/kernel/fs/vfs.h index 98220d3..518f304 100644 --- a/kernel/fs/vfs.h +++ b/kernel/fs/vfs.h @@ -63,7 +63,6 @@ struct vfs_inode { vfs_vm_object_t *(*get_vm_object)(u64 length, u64 offset, vfs_fd_t *fd); int (*truncate)(vfs_fd_t *fd, size_t length); int (*stat)(vfs_fd_t *fd, struct stat *buf); - int (*send_signal)(vfs_fd_t *fd, int signal); int (*connect)(vfs_fd_t *fd, const struct sockaddr *addr, socklen_t addrlen); }; @@ -102,7 +101,6 @@ vfs_inode_t *vfs_create_inode( vfs_vm_object_t *(*get_vm_object)(u64 length, u64 offset, vfs_fd_t *fd), int (*truncate)(vfs_fd_t *fd, size_t length), int (*stat)(vfs_fd_t *fd, struct stat *buf), - int (*send_signal)(vfs_fd_t *fd, int signal), int (*connect)(vfs_fd_t *fd, const struct sockaddr *addr, socklen_t addrlen)); #endif diff --git a/kernel/queue.c b/kernel/queue.c index e1b2943..7aa9a56 100644 --- a/kernel/queue.c +++ b/kernel/queue.c @@ -73,11 +73,10 @@ int queue_create(void) { relist_init(&list->entries); list->process = current_task; - vfs_inode_t *inode = - vfs_create_inode(0, 0, queue_has_data, NULL, 1 /*is_open*/, OBJECT_QUEUE, - list /*internal_object*/, 0, NULL, NULL, NULL, NULL, - queue_close, NULL, NULL /*get_vm_object*/, NULL, NULL, - NULL /*send_signal*/, NULL /*connect*/); + vfs_inode_t *inode = vfs_create_inode( + 0, 0, queue_has_data, NULL, 1 /*is_open*/, OBJECT_QUEUE, + list /*internal_object*/, 0, NULL, NULL, NULL, NULL, queue_close, NULL, + NULL /*get_vm_object*/, NULL, NULL, NULL /*connect*/); assert(inode); return vfs_create_fd(0, 0, 0, inode, NULL); } diff --git a/kernel/socket.c b/kernel/socket.c index 7ed6769..57f869a 100644 --- a/kernel/socket.c +++ b/kernel/socket.c @@ -634,7 +634,7 @@ int accept(int socket, struct sockaddr *address, socklen_t *address_len) { OBJECT_TCP, connection, 0 /*file_size*/, NULL /*open*/, NULL /*create_file*/, tcp_read, tcp_write, tcp_close /*close*/, NULL /*create_directory*/, NULL /*get_vm_object*/, NULL /*truncate*/, - NULL /*stat*/, NULL /*send_signal*/, NULL /*connect*/); + NULL /*stat*/, NULL /*connect*/); inode->_is_open = tcp_is_open; assert(inode); return vfs_create_fd(O_RDWR, 0, 0 /*is_tty*/, inode, NULL); @@ -782,8 +782,7 @@ int tcp_create_fd(int is_nonblock) { 0 /*inode_num*/, FS_TYPE_UNIX_SOCKET, NULL, always_can_write, 1, OBJECT_TCP, con, 0 /*file_size*/, NULL /*open*/, NULL /*create_file*/, tcp_read, tcp_write, NULL /*close*/, NULL /*create_directory*/, - NULL /*get_vm_object*/, NULL /*truncate*/, NULL /*stat*/, - NULL /*send_signal*/, tcp_connect); + NULL /*get_vm_object*/, NULL /*truncate*/, NULL /*stat*/, tcp_connect); if (!inode) { kfree(con); return -ENOMEM; @@ -825,7 +824,7 @@ int socket(int domain, int type, int protocol) { 0 /*file_size*/, NULL /*open*/, NULL /*create_file*/, socket_read, socket_write, socket_close, NULL /*create_directory*/, NULL /*get_vm_object*/, NULL /*truncate*/, NULL /*stat*/, - NULL /*send_signal*/, NULL /*connect*/); + NULL /*connect*/); if (!inode) { rc = -ENOMEM; goto socket_error; @@ -855,7 +854,7 @@ int socket(int domain, int type, int protocol) { OBJECT_UNIX, new_socket, 0 /*file_size*/, NULL /*open*/, NULL /*create_file*/, NULL, NULL, NULL /*close*/, NULL /*create_directory*/, NULL /*get_vm_object*/, NULL /*truncate*/, - NULL /*stat*/, NULL /*send_signal*/, udp_connect); + NULL /*stat*/, udp_connect); if (!inode) { rc = -ENOMEM; goto socket_error; |