Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144345736
D40882.id124261.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
856 B
Referenced Files
None
Subscribers
None
D40882.id124261.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
@@ -83,6 +83,7 @@
static void scanfiles(char *argv[], int cooked);
#ifndef BOOTSTRAP_CAT
static void cook_cat(FILE *);
+static int in_kernel_copy(int);
#endif
static void raw_cat(int);
@@ -280,7 +281,16 @@
}
#endif
} else {
+#ifndef BOOTSTRAP_CAT
+ if (in_kernel_copy(fd) == -1) {
+ if (errno == EINVAL)
+ raw_cat(fd);
+ else
+ err(1, "stdout");
+ }
+#else
raw_cat(fd);
+#endif
if (fd != STDIN_FILENO)
close(fd);
}
@@ -380,6 +390,20 @@
if (ferror(stdout))
err(1, "stdout");
}
+
+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);
+}
#endif /* BOOTSTRAP_CAT */
static void
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 8, 11:24 PM (1 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28510092
Default Alt Text
D40882.id124261.diff (856 B)
Attached To
Mode
D40882: copy_file_range() support for cat(1)
Attached
Detach File
Event Timeline
Log In to Comment