From patchwork Wed Jan 4 03:09:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Himal X-Patchwork-Id: 38731 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4939625wrt; Tue, 3 Jan 2023 19:10:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXsZ9Eov9WxJrbuFsHDjNYtkiFFcZrYGGzPSIiH+4aTGn7kJuVzspoyzPxGpeqJRTFPKISAu X-Received: by 2002:aa7:dcc9:0:b0:472:1436:73ab with SMTP id w9-20020aa7dcc9000000b00472143673abmr37026103edu.28.1672801847174; Tue, 03 Jan 2023 19:10:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672801847; cv=none; d=google.com; s=arc-20160816; b=mUbcvzfVUNuq0cg4TcDrAOclX1+EUu9p2Pl+tqMuiHNaoy/BCK9/yeXROqgGL057KT 7oE4FdULh5CQNA/66OdumdsmGXALQ4ctiF0WMuS6NaT6S8E7/428wzQ3Veg4tyunWhdI Cl+edrYR00OZxqGjai3frTs+wy5GS9HLqHwEiRZ1gWu8oZ6L1/g+fhzeIn8kw9spkNrr xyQq0tvWGawFPtbzLkC0Nivrmpp8jrRF7v2qFpHZqKhlgmTvFPFVjOKIgO+rnKatLHZC VyxdCFAnPo3XONE6tuH5H7rhVGW87Ieel/Cv6HTGzakWsU0Qk0LmajmYcmHqSrJGulL0 7vDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:feedback-id:message-id :subject:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=z6CL2CWP3SlD14fqCjS7UIC2VjSBQEbRCU0R5QzVDis=; b=eJ5zqg4kbi+TDBYOIbVJso5zQ7XhqFIlJ0u6p2KxHUwm96YGEAU+jsbTMjdp0EsKoe K4QCT1YIcS5QiTXWXAMwhpgQwNqS6LLpLzaWlzFYUC1X9kPI33uK0y9nktuiBiDlphMb V07K7NwO8KqKg4MFGaCPnUGPmktEcf1tPBpYV44X0i1hy9+uQlr5LDtUk35UWXRGPIhF 2EGjOFVg51cbuNK1D2AXq7/xrSSJWOCacb5cx3Tc5IRvXhevrhfKftA3BmDGXqwpn91V uqHiGXUpW5D5NY9ATX2uZcCJYDBS8B04hCi9FFWL34pwlKs3FQ7G+iGjk7L//riPAbaF 8scA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="cJ/TVeoA"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f24-20020a50ee98000000b0048a9b9c8d4csi11982954edr.375.2023.01.03.19.10.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 19:10:47 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="cJ/TVeoA"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 01443385840D for ; Wed, 4 Jan 2023 03:10:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01443385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672801846; bh=z6CL2CWP3SlD14fqCjS7UIC2VjSBQEbRCU0R5QzVDis=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=cJ/TVeoAoK+STkomhplC2CSvRhXydTFQQkthkKCtJFf4AUkFC0VXo1k+7SuHgzOpG CGv7I38UHz5yH2DXCQSvehAGtaWl3q4RVWrNC2iGiAkXW5AZmAqXweMYl5Uk6EhNsP H7iIO4C1lirwC/OL6dQJdaWT6XGfyMn+Rm0Sdvi8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-40135.protonmail.ch (mail-40135.protonmail.ch [185.70.40.135]) by sourceware.org (Postfix) with ESMTPS id 95B4F3858D1E for ; Wed, 4 Jan 2023 03:10:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 95B4F3858D1E Date: Wed, 04 Jan 2023 03:09:45 +0000 To: "gcc-patches@gcc.gnu.org" Subject: [PATCH] libiberty: Handle Windows nul device in unlink-if-ordinary.c [PR108276] Message-ID: Feedback-ID: 48786361:user:proton MIME-Version: 1.0 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Himal via Gcc-patches From: Himal Reply-To: Himal Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754059869632055907?= X-GMAIL-MSGID: =?utf-8?q?1754059869632055907?= libiberty/ChangeLog:         * unlink-if-ordinary.c (unlink_if_ordinary): Handle Windows nul device --- libiberty/unlink-if-ordinary.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.39.0 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; }