From 3079ef01ce4da0f70b7c53551c8f1ea0699576d7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 6 Mar 2019 20:28:00 +0100 Subject: [PATCH] Userland: /bin/cp needs to handle open(dst) failing with EISDIR. --- Userland/cp.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Userland/cp.cpp b/Userland/cp.cpp index b7810fdbcf..d835eb38e0 100644 --- a/Userland/cp.cpp +++ b/Userland/cp.cpp @@ -36,18 +36,10 @@ int main(int argc, char** argv) int dst_fd = open(dst_path.characters(), O_WRONLY | O_CREAT); if (dst_fd < 0) { - perror("open dst"); - return 1; - } - - struct stat dst_stat; - rc = fstat(dst_fd, &dst_stat); - if (rc < 0) { - perror("stat dst"); - return 1; - } - - if (S_ISDIR(dst_stat.st_mode)) { + if (errno != EISDIR) { + perror("open dst"); + return 1; + } StringBuilder builder; builder.append(dst_path); builder.append('/');