From patchwork Fri Aug 18 22:20:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Porcel X-Patchwork-Id: 9910037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 93E1160385 for ; Fri, 18 Aug 2017 22:21:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 868C928D81 for ; Fri, 18 Aug 2017 22:21:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 786C728D90; Fri, 18 Aug 2017 22:21:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19AED28D81 for ; Fri, 18 Aug 2017 22:21:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbdHRWVp (ORCPT ); Fri, 18 Aug 2017 18:21:45 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:35751 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752167AbdHRWVn (ORCPT ); Fri, 18 Aug 2017 18:21:43 -0400 Received: by mail-wr0-f196.google.com with SMTP id p8so8332590wrf.2 for ; Fri, 18 Aug 2017 15:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OSq9SqmknBYv5fF4T+qWm+pfdfDRMrYpmqKkQsFKoAI=; b=k838vSA1fdM+C50g3xllYQRkPcRau56lU8Yyuovm9tAz2CQ5ediepe7Wz0U0DNw+Wq 7uCTlBqOfYOBFxu584++wIxrtQsxSG9G23BgUvXV0Lj6T960TrMTLaYUGRFCvwP+Hnqj /uSSi2J//QdxWLQleI1lWRgK/JIXTE61abquZMFwAKmVmSAhNC9hm8EcvNDM3EI/bhKJ iOS4fHgt66TC+iDLrskNGpqqxfsJy7ev0Ses9srgwTNdh43f7WzHQVb3cMAFbEhzHXKb Y0BOn5Pn2bnukvlTDnuOYPUbS7AFRpPwRGTlVH+PbGcnW8XYP5LIlOH74uBHuY2mkBAN 6n+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OSq9SqmknBYv5fF4T+qWm+pfdfDRMrYpmqKkQsFKoAI=; b=UnZi7lU43YJ+KUxv/H3iCzbWxrv9nDkdGOlsFS6Vl7B7ntbJ6jdlK2lmBq5CZQP746 Gskg3Jpo7vB2X810xP1H9Sc/4Z+6QEJR9z7veKFl6I6N1kOq2L68LcYapKBN9z1SMC/r IqAg6E0dCGoqAZvaDd8s+cfYJUhje510Fbcnnv9sZll8WhFw4x6TMilkffgjy5Z3wS2b Bw24g2I/2swdlpUn6v4GFDuqcp2uXw7hrF4s8IBNwfMSTO/0tb2xhur6y/6DD+ZK7Cye 5ztKdctYfsWObMKHr3IEv30AS4bS3xYY6L3m0Ixz1Oqef9WDVbJkAP2/Ego0Qzws0N7L RExQ== X-Gm-Message-State: AHYfb5jnKL/Cv0WRWMGl/LAegghwBDe32RlRvFu5M/mAUJ/wBtnVFS75 ke3k5EYRBHQ0oLBNbRY= X-Received: by 10.223.167.9 with SMTP id c9mr6974432wrd.180.1503094902424; Fri, 18 Aug 2017 15:21:42 -0700 (PDT) Received: from localhost (htr06-1-82-227-229-91.fbx.proxad.net. [82.227.229.91]) by smtp.gmail.com with ESMTPSA id z7sm5314814wrg.74.2017.08.18.15.21.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Aug 2017 15:21:41 -0700 (PDT) From: Nicolas Porcel To: linux-kbuild@vger.kernel.org Cc: Nicolas Porcel Subject: [PATCH 2/2] kconfig: support out of tree KCONFIG_CONFIG Date: Sat, 19 Aug 2017 00:20:52 +0200 Message-Id: <20170818222052.22375-3-nicolasporcel06@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170818222052.22375-1-nicolasporcel06@gmail.com> References: <20170818222052.22375-1-nicolasporcel06@gmail.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If KCONFIG_CONFIG is on a different file system than the kernel source, oldconfig/defconfig will fail due to the use of rename in conf_write. It will also fail if the kernel source directory is not writable. This patch changes the behavior of conf_write to be more intuitive. When no argument is passed to conf_write, KCONFIG_CONFIG is used instead for the config path. The consequence is that the .tmpconfig.%(pid) is written in the same directory as KCONFIG_CONFIG. Some defaulting logic has been added, allowing the use of a directory for KCONFIG_CONFIG. In that case, the .config file will be written in this directory. Signed-off-by: Nicolas Porcel --- scripts/kconfig/confdata.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 297b079ae4d9..3c2b7155a385 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -743,32 +743,37 @@ int conf_write(const char *name) FILE *out; struct symbol *sym; struct menu *menu; + struct stat st; const char *basename; const char *str; char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1]; char *env; + char *slash; + + const char *configname = conf_get_configname(); dirname[0] = 0; - if (name && name[0]) { - struct stat st; - char *slash; - - if (!stat(name, &st) && S_ISDIR(st.st_mode)) { - strcpy(dirname, name); - strcat(dirname, "/"); - basename = conf_get_configname(); - } else if ((slash = strrchr(name, '/'))) { + if (!name || !name[0]) + name = configname; + + if (!stat(name, &st) && S_ISDIR(st.st_mode)) { + strcpy(dirname, name); + strcat(dirname, "/"); + if (name == configname || strchr(configname, '/')) + basename = ".config"; + else + basename = configname; + } else { + slash = strrchr(name, '/'); + if (slash) { int size = slash - name + 1; + memcpy(dirname, name, size); dirname[size] = 0; - if (slash[1]) - basename = slash + 1; - else - basename = conf_get_configname(); + basename = slash + 1; } else basename = name; - } else - basename = conf_get_configname(); + } sprintf(newname, "%s%s", dirname, basename); env = getenv("KCONFIG_OVERWRITECONFIG");