@@ -222,6 +222,11 @@ static int expand_files(struct files_struct *files, unsigned int nr)
return expanded;
}
+static inline bool fd_is_open(unsigned int fd, struct files_struct *files)
+{
+ return !idr_tag_get(&files->fd_idr, fd, IDR_FREE);
+}
+
static inline void __set_close_on_exec(unsigned int fd, struct fdtable *fdt)
{
__set_bit(fd, fdt->close_on_exec);
@@ -778,7 +783,7 @@ static int do_dup2(struct files_struct *files,
*/
fdt = files_fdtable(files);
tofree = idr_find(&files->fd_idr, fd);
- if (!tofree && fd_is_open(fd, fdt))
+ if (!tofree && fd_is_open(fd, files))
goto Ebusy;
get_file(file);
if (tofree) {
@@ -34,11 +34,6 @@ static inline bool close_on_exec(unsigned int fd, const struct fdtable *fdt)
return test_bit(fd, fdt->close_on_exec);
}
-static inline bool fd_is_open(unsigned int fd, const struct fdtable *fdt)
-{
- return test_bit(fd, fdt->open_fds);
-}
-
/*
* Open file table structure
*/