lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070331073935.GA11383@uranus.ravnborg.org>
Date:	Sat, 31 Mar 2007 09:39:35 +0200
From:	Sam Ravnborg <sam@...nborg.org>
To:	Jan Beulich <jbeulich@...ell.com>,
	Roman Zippel <zippel@...ux-m68k.org>
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH 1/2] kconfig: factor out code in conf_spilt_config

>From e9fcc3bf8d1c71df1ae650d5291c5d4b15d71656 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@...tun.ravnborg.org>
Date: Sat, 31 Mar 2007 09:15:12 +0200
Subject: [PATCH] kconfig: factor out code in conf_spilt_config

This patch simply factor out code and
do not introduce any functional changes.

Signed-off-by: Sam Ravnborg <sam@...nborg.org>
---
 scripts/kconfig/confdata.c |   75 ++++++++++++++++++++++++--------------------
 1 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 664fe29..ff6b39b 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -533,13 +533,48 @@ int conf_write(const char *name)
 	return 0;
 }
 
+/* Touch the file specified (adding .h to the name) */
+static int touch_file(const char *file)
+{
+	struct stat sb;
+	int fd;
+	char *d;
+	char name[128];
+
+	strcpy(name, file);
+	strcat(name, ".h");
+
+	/* Open existing file */
+	fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+	if (fd == -1) {
+		if (errno != ENOENT)
+			return 1;
+		/*
+		 * Create directory components,
+		 * unless they exist already.
+		 */
+		d = name;
+		while ((d = strchr(d, '/'))) {
+			*d = 0;
+			if (stat(name, &sb) && mkdir(name, 0755))
+				return 1;
+			*d++ = '/';
+		}
+		/* Directories created, now create file. */
+		fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+		if (fd == -1)
+			return 1;
+	}
+	close(fd);
+	return 0;
+}
+
 int conf_split_config(void)
 {
 	char *name, path[128];
 	char *s, *d, c;
 	struct symbol *sym;
-	struct stat sb;
-	int res, i, fd;
+	int res, i;
 
 	name = getenv("KCONFIG_AUTOCONFIG");
 	if (!name)
@@ -601,45 +636,17 @@ int conf_split_config(void)
 		 *	different from 'no').
 		 */
 
-		/* Replace all '_' and append ".h" */
+		/* Replace all '_' with '/' */
 		s = sym->name;
 		d = path;
 		while ((c = *s++)) {
 			c = tolower(c);
 			*d++ = (c == '_') ? '/' : c;
 		}
-		strcpy(d, ".h");
-
-		/* Assume directory path already exists. */
-		fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
-		if (fd == -1) {
-			if (errno != ENOENT) {
-				res = 1;
-				break;
-			}
-			/*
-			 * Create directory components,
-			 * unless they exist already.
-			 */
-			d = path;
-			while ((d = strchr(d, '/'))) {
-				*d = 0;
-				if (stat(path, &sb) && mkdir(path, 0755)) {
-					res = 1;
-					goto out;
-				}
-				*d++ = '/';
-			}
-			/* Try it again. */
-			fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
-			if (fd == -1) {
-				res = 1;
-				break;
-			}
-		}
-		close(fd);
+		*d = '\0';
+		if (touch_file(path))
+			return 1;
 	}
-out:
 	if (chdir("../.."))
 		return 1;
 
-- 
1.5.1.rc3.gaa453

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ