From f7566e9585a438f9e78105052ef3606193c65928 Mon Sep 17 00:00:00 2001 From: Ksawlii Date: Tue, 19 Nov 2024 12:59:13 +0100 Subject: [PATCH] Revert "file: Rename __close_fd to close_fd and remove the files parameter" This reverts commit b0d8979a5d84d0b098f26d6803a0c55da257a649. --- fs/file.c | 10 ++++++---- fs/open.c | 2 +- include/linux/fdtable.h | 3 ++- include/linux/syscalls.h | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/fs/file.c b/fs/file.c index fdb84a647..48d0306e4 100755 --- a/fs/file.c +++ b/fs/file.c @@ -659,9 +659,11 @@ out_unlock: return file; } -int close_fd(unsigned fd) +/* + * The same warnings as for __alloc_fd()/__fd_install() apply here... + */ +int __close_fd(struct files_struct *files, unsigned fd) { - struct files_struct *files = current->files; struct file *file; file = pick_file(files, fd); @@ -670,7 +672,7 @@ int close_fd(unsigned fd) return filp_close(file, files); } -EXPORT_SYMBOL(close_fd); /* for ksys_close() */ +EXPORT_SYMBOL(__close_fd); /* for ksys_close() */ /** * __close_range() - Close all file descriptors in a given range. @@ -1085,7 +1087,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags) struct files_struct *files = current->files; if (!file) - return close_fd(fd); + return __close_fd(files, fd); if (fd >= rlimit(RLIMIT_NOFILE)) return -EBADF; diff --git a/fs/open.c b/fs/open.c index cf044b289..beb65d11a 100755 --- a/fs/open.c +++ b/fs/open.c @@ -1383,7 +1383,7 @@ EXPORT_SYMBOL(filp_close); */ SYSCALL_DEFINE1(close, unsigned int, fd) { - int retval = close_fd(fd); + int retval = __close_fd(current->files, fd); /* can't restart close syscall because file table entry was cleared */ if (unlikely(retval == -ERESTARTSYS || diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index 4ed3589f9..d26b884fc 100755 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h @@ -124,7 +124,8 @@ int iterate_fd(struct files_struct *, unsigned, int (*)(const void *, struct file *, unsigned), const void *); -extern int close_fd(unsigned int fd); +extern int __close_fd(struct files_struct *files, + unsigned int fd); extern int __close_range(unsigned int fd, unsigned int max_fd, unsigned int flags); extern int close_fd_get_file(unsigned int fd, struct file **res); extern int unshare_fd(unsigned long unshare_flags, unsigned int max_fds, diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 212ec79e6..61d0315a4 100755 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -1321,16 +1321,16 @@ static inline long ksys_ftruncate(unsigned int fd, loff_t length) return do_sys_ftruncate(fd, length, 1); } -extern int close_fd(unsigned int fd); +extern int __close_fd(struct files_struct *files, unsigned int fd); /* * In contrast to sys_close(), this stub does not check whether the syscall * should or should not be restarted, but returns the raw error codes from - * close_fd(). + * __close_fd(). */ static inline int ksys_close(unsigned int fd) { - return close_fd(fd); + return __close_fd(current->files, fd); } extern long do_sys_truncate(const char __user *pathname, loff_t length);