open: add close_range()
[linux-block.git] / fs / open.c
index 6cd48a61cda3b969c0717c30c8bed879efa3d8cc..073ea3c45347ce125db61cbab3e6d4fa30d05fb0 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -1310,6 +1310,26 @@ SYSCALL_DEFINE1(close, unsigned int, fd)
        return retval;
 }
 
+/**
+ * close_range() - Close all file descriptors in a given range.
+ *
+ * @fd:     starting file descriptor to close
+ * @max_fd: last file descriptor to close
+ * @flags:  reserved for future extensions
+ *
+ * This closes a range of file descriptors. All file descriptors
+ * from @fd up to and including @max_fd are closed.
+ * Currently, errors to close a given file descriptor are ignored.
+ */
+SYSCALL_DEFINE3(close_range, unsigned int, fd, unsigned int, max_fd,
+               unsigned int, flags)
+{
+       if (flags)
+               return -EINVAL;
+
+       return __close_range(current->files, fd, max_fd);
+}
+
 /*
  * This routine simulates a hangup on the tty, to arrange that users
  * are given clean terminals at login time.