Page MenuHomeFreeBSD

D40882.id124213.diff
No OneTemporary

D40882.id124213.diff

diff --git a/bin/cat/cat.c b/bin/cat/cat.c
--- a/bin/cat/cat.c
+++ b/bin/cat/cat.c
@@ -84,6 +84,7 @@
#ifndef BOOTSTRAP_CAT
static void cook_cat(FILE *);
#endif
+static int in_kernel_copy(int);
static void raw_cat(int);
#ifndef NO_UDOM_SUPPORT
@@ -280,7 +281,9 @@
}
#endif
} else {
- raw_cat(fd);
+ if (in_kernel_copy(fd) == -1) {
+ raw_cat(fd);
+ }
if (fd != STDIN_FILENO)
close(fd);
}
@@ -382,6 +385,20 @@
}
#endif /* BOOTSTRAP_CAT */
+static int
+in_kernel_copy(int rfd)
+{
+ int ret, wfd;
+
+ wfd = fileno(stdout);
+ ret = 1;
+
+ while (ret > 0)
+ ret = copy_file_range(rfd, NULL, wfd, NULL, SSIZE_MAX, 0);
+
+ return (ret);
+}
+
static void
raw_cat(int rfd)
{

File Metadata

Mime Type
text/plain
Expires
Mon, Feb 9, 7:36 AM (19 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28554098
Default Alt Text
D40882.id124213.diff (709 B)

Event Timeline