Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144412267
D40882.id124213.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
709 B
Referenced Files
None
Subscribers
None
D40882.id124213.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D40882: copy_file_range() support for cat(1)
Attached
Detach File
Event Timeline
Log In to Comment