From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30309 invoked by alias); 20 Mar 2013 02:36:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 30290 invoked by uid 89); 20 Mar 2013 02:36:42 -0000 X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.1 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 20 Mar 2013 02:36:39 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1UI8tJ-00025k-3D from Yao_Qi@mentor.com ; Tue, 19 Mar 2013 19:36:37 -0700 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 19 Mar 2013 19:36:34 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.1.289.1; Tue, 19 Mar 2013 19:36:32 -0700 Message-ID: <51492077.30307@codesourcery.com> Date: Wed, 20 Mar 2013 02:48:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Doug Evans CC: gdb-patches , Eli Zaretskii Subject: Re: [PATCH 3/3] Don't use unportable macros References: <83ip4s4ixc.fsf@gnu.org> <1363407692-18959-1-git-send-email-yao@codesourcery.com> <1363407692-18959-4-git-send-email-yao@codesourcery.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-SW-Source: 2013-03/txt/msg00726.txt.bz2 On 03/20/2013 12:31 AM, Doug Evans wrote: >> /* Create DIRNAME. */ >> - if (mkdir (dirname, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) >> - && errno != EEXIST) >> + if (mkdir (dirname, S_IRUSR | S_IWUSR | S_IXUSR) && errno != EEXIST) >> error (_("Unable to open directory '%s' for saving trace data (%s)"), >> dirname, safe_strerror (errno)); > > It feels like one would want to use mode 0755 by default on *nix. > Why not store the mode in a local, and have a sequence of #ifdef's > like remote-fileio.c? OK. Done. The directory mode now is 755. On 03/20/2013 01:19 AM, Eli Zaretskii wrote: > > This is why I suggested an alternative and much smaller and more > elegant solution. Also define a macro 'mkdir' in this patch, as Eli suggested before. Is it OK? -- Yao (齐尧) gdb: 2013-03-20 Yao Qi * ctf.c: Include "gdb_stat.h". [USE_WIN32API]: New macro 'mkdir'. (ctf_start): Use permission bits macros if they are defined. --- gdb/ctf.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gdb/ctf.c b/gdb/ctf.c index 455bfde..f058dc9 100644 --- a/gdb/ctf.c +++ b/gdb/ctf.c @@ -24,6 +24,7 @@ #include "tracepoint.h" #include "regcache.h" #include "exec.h" +#include "gdb_stat.h" #include @@ -294,6 +295,10 @@ ctf_target_save (struct trace_file_writer *self, return 0; } +#ifdef USE_WIN32API +#define mkdir(pathname, mode) _mkdir (pathname) +#endif + /* This is the implementation of trace_file_write_ops method start. It creates the directory DIRNAME, metadata and datastream in the directory. */ @@ -306,10 +311,21 @@ ctf_start (struct trace_file_writer *self, const char *dirname) struct ctf_trace_file_writer *writer = (struct ctf_trace_file_writer *) self; int i; + mode_t hmode = S_IRUSR | S_IWUSR | S_IXUSR +#ifdef S_IRGRP + | S_IRGRP +#endif +#ifdef S_IXGRP + | S_IXGRP +#endif + | S_IROTH /* Defined in common/gdb_stat.h if not defined. */ +#ifdef S_IXOTH + | S_IXOTH +#endif + ; /* Create DIRNAME. */ - if (mkdir (dirname, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) - && errno != EEXIST) + if (mkdir (dirname, hmode) && errno != EEXIST) error (_("Unable to open directory '%s' for saving trace data (%s)"), dirname, safe_strerror (errno)); -- 1.7.7.6