From: Himal <himalr@proton.me>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [PATCH] libiberty: Handle Windows nul device in unlink-if-ordinary.c [PR108276]
Date: Wed, 04 Jan 2023 03:09:45 +0000 [thread overview]
Message-ID: <fNaJU0FQkpY1sbMSTBhtyL9Fe3rKjTMaPdqQoq0VZhJBQxB1UtH_QU19Rai4usWKkETmSjqNT7cW5JaJxPnLy6iDTYpq4LHcEZsk2twCHAE=@proton.me> (raw)
libiberty/ChangeLog:
* unlink-if-ordinary.c (unlink_if_ordinary):
Handle Windows nul device
---
libiberty/unlink-if-ordinary.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libiberty/unlink-if-ordinary.c b/libiberty/unlink-if-ordinary.c
index 84328b216..ae9090e54 100644
--- a/libiberty/unlink-if-ordinary.c
+++ b/libiberty/unlink-if-ordinary.c
@@ -62,11 +62,18 @@ was made to unlink the file because it is special.
int
unlink_if_ordinary (const char *name)
{
+/* MS-Windows 'stat' function (and in turn, S_ISREG)
+ reports the null device as a regular file. */
+#ifdef _WIN32
+ if (stricmp (name, "nul") == 0)
+ return 1;
+#else
struct stat st;
if (lstat (name, &st) == 0
&& (S_ISREG (st.st_mode) || S_ISLNK (st.st_mode)))
return unlink (name);
+#endif
return 1;
}
--
2.39.0
next reply other threads:[~2023-01-04 3:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-04 3:09 Himal [this message]
2023-01-06 8:23 ` [PATCH] Handle Windows nul device in unlink-if-ordinary.c anothername27-unity
2023-01-06 8:31 ` anothername27-unity
2023-03-11 20:18 ` Jeff Law
2023-03-13 5:15 ` Himal
2023-04-29 18:10 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='fNaJU0FQkpY1sbMSTBhtyL9Fe3rKjTMaPdqQoq0VZhJBQxB1UtH_QU19Rai4usWKkETmSjqNT7cW5JaJxPnLy6iDTYpq4LHcEZsk2twCHAE=@proton.me' \
--to=himalr@proton.me \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).