linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix menuconfig if saving on different fs
@ 2003-05-26 19:35 Michael Buesch
  2003-05-28 16:41 ` Roman Zippel
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Buesch @ 2003-05-26 19:35 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux kernel mailing list, Roman Zippel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

This patch fixes the behaviour of make menuconfig, if the
file in the "Save Configuration to Alternate File" menu is
on a different file-system, than the source tree.
Without this patch saving the config to /boot/xyz fails, if
boot is on an own filesystem.

patch against 2.5.69-bk19

Linus, please apply.

- -- 
Regards Michael Büsch
http://www.8ung.at/tuxsoft
 21:27:43 up  5:37,  4 users,  load average: 2.04, 1.35, 1.14



diff -urN -X /home/mb/dontdiff linux-2.5.69-bk19.vanilla/scripts/kconfig/confdata.c linux-2.5.69-bk19/scripts/kconfig/confdata.c
- --- linux-2.5.69-bk19.vanilla/scripts/kconfig/confdata.c	2003-05-26 20:24:44.000000000 +0200
+++ linux-2.5.69-bk19/scripts/kconfig/confdata.c	2003-05-26 21:23:47.000000000 +0200
@@ -1,6 +1,9 @@
 /*
  * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
  * Released under the terms of the GNU GPL v2.0.
+ *
+ * May 26, 2003 Michael Buesch <fsdeveloper@yahoo.de>:
+ *	fixed behaviour of conf_write() if "name" is on different file system.
  */
 
 #include <sys/stat.h>
@@ -239,7 +242,7 @@
 
 int conf_write(const char *name)
 {
- -	FILE *out, *out_h;
+	FILE *out, *out_h, *out_new;
 	struct symbol *sym;
 	struct menu *menu;
 	char oldname[128];
@@ -369,8 +372,30 @@
 
 	sprintf(oldname, "%s.old", name);
 	rename(name, oldname);
- -	if (rename(".tmpconfig", name))
- -		return 1;
+
+	if (rename(".tmpconfig", name)) {
+		if (errno == EXDEV) {
+			out = fopen(".tmpconfig", "r");
+			if (!out)
+				return 1;
+			out_new = fopen(name, "w");
+			if (!out_new) {
+				fclose(out);
+				return 1;
+			}
+			while ((l = fgetc(out)) != EOF) {
+				if (fputc(l, out_new) == EOF) {
+					fclose(out);
+					fclose(out_new);
+					return 1;
+				}
+			}
+			fclose(out);
+			fclose(out_new);
+			unlink(".tmpconfig");
+		} else
+			return 1;
+	}
 
 	sym_change_count = 0;
 


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+0mx9oxoigfggmSgRAsKRAKCHoEFbU386aVjO65KIpBVkMLtF4ACcDj+s
rng5t4l/ClMytEjyal72uXs=
=ciX7
-----END PGP SIGNATURE-----


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

* Re: [PATCH] fix menuconfig if saving on different fs
  2003-05-26 19:35 [PATCH] fix menuconfig if saving on different fs Michael Buesch
@ 2003-05-28 16:41 ` Roman Zippel
  0 siblings, 0 replies; 2+ messages in thread
From: Roman Zippel @ 2003-05-28 16:41 UTC (permalink / raw)
  To: Michael Buesch; +Cc: linux kernel mailing list

Hi,

On Mon, 26 May 2003, Michael Buesch wrote:

> +			while ((l = fgetc(out)) != EOF) {
> +				if (fputc(l, out_new) == EOF) {
> +					fclose(out);
> +					fclose(out_new);
> +					return 1;
> +				}

I don't really like this file copy, I'd rather create the file in the 
destination directory. I fixed this here a bit different.

bye, Roman


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

end of thread, other threads:[~2003-05-28 16:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-26 19:35 [PATCH] fix menuconfig if saving on different fs Michael Buesch
2003-05-28 16:41 ` Roman Zippel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).