Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] [package/config] Change behaviour of symlink .config
@ 2011-06-28 12:07 Benoit Mauduit
  2011-06-28 13:51 ` [Buildroot] [PATCHv2] " Benoît Mauduit
  2011-06-28 14:18 ` Thomas Petazzoni
  0 siblings, 2 replies; 6+ messages in thread
From: Benoit Mauduit @ 2011-06-28 12:07 UTC (permalink / raw)
  To: buildroot

This patch change the bahaviour with .config management.

The default behaviour is modified only if .config is a symbolic link.
In this case, the target pointed by the link will be overwritten, and
the old .config is save to .config.old.

This can be useful when we want to save and use the config file
outside the Buildroot directory.

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [Buildroot] [PATCH] [package/config] Change behaviour of symlink .config
@ 2011-06-28 12:07 Benoit Mauduit
  0 siblings, 0 replies; 6+ messages in thread
From: Benoit Mauduit @ 2011-06-28 12:07 UTC (permalink / raw)
  To: buildroot

If .config is a symlink, the target will be modified and the old
.config is saved to .config.old.
---
 package/config/confdata.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/package/config/confdata.c b/package/config/confdata.c
index c9f13ee..c00639f 100644
--- a/package/config/confdata.c
+++ b/package/config/confdata.c
@@ -588,7 +588,20 @@ int conf_write(const char *name)
 	} else
 		basename = conf_get_configname();
 
-	sprintf(newname, "%s%s", dirname, basename);
+	sprintf(tmpname, "%s%s", dirname, basename);
+
+	realpath(tmpname, newname);
+
+	if (strcmp(tmpname, newname)) {
+		printf(_("#\n"
+		         "# Warning: Symbolic link detected,"
+		         " the target will be overwritten\n"
+		         "#\n")
+		       );
+
+		tmpname[0] = '\0';
+	}
+
 	env = getenv("KCONFIG_OVERWRITECONFIG");
 	if (!env || !*env) {
 		sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
-- 
1.7.5.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-06-28 15:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-28 12:07 [Buildroot] [PATCH] [package/config] Change behaviour of symlink .config Benoit Mauduit
2011-06-28 13:51 ` [Buildroot] [PATCHv2] " Benoît Mauduit
2011-06-28 13:51   ` [Buildroot] [PATCH] " Benoît Mauduit
2011-06-28 14:18 ` Thomas Petazzoni
2011-06-28 15:42   ` Benoît Mauduit
  -- strict thread matches above, loose matches on Subject: below --
2011-06-28 12:07 Benoit Mauduit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox