From patchwork Wed Jul 15 18:04:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Robinson X-Patchwork-Id: 35737 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6FI4T2Q023734 for ; Wed, 15 Jul 2009 18:04:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755932AbZGOSE2 (ORCPT ); Wed, 15 Jul 2009 14:04:28 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755885AbZGOSE2 (ORCPT ); Wed, 15 Jul 2009 14:04:28 -0400 Received: from mail-bw0-f228.google.com ([209.85.218.228]:45817 "EHLO mail-bw0-f228.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755747AbZGOSE1 (ORCPT ); Wed, 15 Jul 2009 14:04:27 -0400 Received: by bwz28 with SMTP id 28so1580697bwz.37 for ; Wed, 15 Jul 2009 11:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=mIcguxT+dYVeBDPrAbWO8VzlWHLsyB9tAnRVdbFaHBc=; b=I8UuLfKqTYnlonFcvgCEcjaklnJByQahIRz1uN6zDbyvgsPKY0tZGSL1Ef3h+MRIi8 BUeeFxrhbB2sARecPgRsstESF2b3rwpKHifwwyJilW95ASUck4Tdl1QaQbty4bElsSvk 0IMGD4XB81l+AQtaDk7JDTZDJPZHPwroD5+nU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=GRSCSdRxeK8IO5vXKyxsI6J8MbwXq7fPTvMubMaOmLaFlwuMmhA+mtCsBzbz7Z32Ez apzVjO1rAqURQU6HIdarPW+EioQ2huYMb4vzb3LKxVV3f4TFqlbNQmma3aHA2WtGkoNZ QVl7O4yS98dKrzpiRKVfxUflE4YYr/POyv94Q= MIME-Version: 1.0 Received: by 10.103.214.4 with SMTP id r4mr4261952muq.35.1247681064859; Wed, 15 Jul 2009 11:04:24 -0700 (PDT) In-Reply-To: References: <20090526152540.GA28341@sepie.suse.cz> <20090703144547.GA20980@sepie.suse.cz> <1247675954.3968.140.camel@quest> Date: Wed, 15 Jul 2009 20:04:24 +0200 Message-ID: Subject: Re: [PATCH] kbuild: generate modules.builtin From: Andreas Robinson To: Kay Sievers Cc: Scott James Remnant , Michal Marek , linux-modules@vger.kernel.org, Sam Ravnborg , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Guys, is this patch what you need on the m-i-t end? (Sorry for sending it as an attachment. I'm restricted to webmail at the moment and can't prevent gmail from adding line breaks.) Cheers, Andreas From d60a4a56f5d484a6076c606a111510ce40a4ccd8 Mon Sep 17 00:00:00 2001 From: Andreas Robinson Date: Wed, 15 Jul 2009 19:48:59 +0200 Subject: [PATCH] modprobe: warn when trying to insert a built-in module The previous behaviour was to fail with "module foo not found". Signed-off-by: Andreas Robinson --- modprobe.c | 34 ++++++++++++++++++++++++++++++++-- 1 files changed, 32 insertions(+), 2 deletions(-) diff --git a/modprobe.c b/modprobe.c index 21a3111..a0943fe 100644 --- a/modprobe.c +++ b/modprobe.c @@ -1049,6 +1049,29 @@ static char *gather_options(char *argv[]) return optstring; } +/* Check whether a module is built into the kernel */ +static int is_builtin(const char *modname, const char *dirname) +{ + char *filename; + FILE *file; + char *line; + int found = 0; + + nofail_asprintf(&filename, "%s/modules.builtin", dirname); + file = fopen(filename, "r"); + if (file) { + while ((line = getline_wrapped(file, NULL)) != NULL && !found) { + char *p = line; + char *builtin = underscores(strsep_skipspace(&p, "\t ")); + found = streq(modname, builtin); + free(line); + } + fclose(file); + } + free(filename); + return found; +} + /* Do an install/remove command: replace $CMDLINE_OPTS if it's specified. */ static void do_command(const char *modname, const char *command, @@ -1256,6 +1279,7 @@ static int handle_module(const char *modname, struct module_options *modoptions, struct module_command *commands, const char *cmdline_opts, + const char *dirname, errfn_t error, modprobe_flags_t flags) { @@ -1271,6 +1295,11 @@ static int handle_module(const char *modname, return 0; } + if (is_builtin(modname, dirname)) { + warn("Module %s is built into the kernel.\n", modname); + return 0; + } + if (!quiet) error("Module %s not found.\n", modname); return 1; @@ -1350,7 +1379,7 @@ int do_modprobe(char *modname, read_depends(dirname, aliases->module, &list); failed |= handle_module(aliases->module, &list, newname, opts, modoptions, - commands, cmdline_opts, err, flags); + commands, cmdline_opts, dirname, err, flags); aliases = aliases->next; INIT_LIST_HEAD(&list); @@ -1361,7 +1390,8 @@ int do_modprobe(char *modname, return failed; failed |= handle_module(modname, &list, newname, cmdline_opts, - modoptions, commands, cmdline_opts, error, flags); + modoptions, commands, cmdline_opts, dirname, error, + flags); } return failed; } -- 1.6.0.4