Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144301470
D40882.id124217.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
701 B
Referenced Files
None
Subscribers
None
D40882.id124217.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,8 @@
}
#endif
} else {
- raw_cat(fd);
+ if (in_kernel_copy(fd) == -1)
+ raw_cat(fd);
if (fd != STDIN_FILENO)
close(fd);
}
@@ -382,6 +384,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
Sun, Feb 8, 5:46 PM (10 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28480592
Default Alt Text
D40882.id124217.diff (701 B)
Attached To
Mode
D40882: copy_file_range() support for cat(1)
Attached
Detach File
Event Timeline
Log In to Comment