From 3c63f88d2f69003ab593cbf1fe3f371b24b57b2e Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Thu, 11 Dec 2003 01:55:22 +0000
Subject: [PATCH] Remove remnants of mkdir_parent on log file and pid file
 create. Just log open failure and continue.

---
 src/common/daemonize.c |  2 --
 src/common/log.c       |  1 -
 src/common/safeopen.c  | 33 ---------------------------------
 src/common/safeopen.h  | 10 ----------
 4 files changed, 46 deletions(-)

diff --git a/src/common/daemonize.c b/src/common/daemonize.c
index e4603c41acd..53d25073ee3 100644
--- a/src/common/daemonize.c
+++ b/src/common/daemonize.c
@@ -36,7 +36,6 @@
 #include "src/common/fd.h"
 #include "src/common/log.h"
 #include "src/common/macros.h"
-#include "src/common/safeopen.h"
 #include "src/common/xassert.h"
 
 /* closeall FDs >= a specified value */
@@ -158,7 +157,6 @@ create_pidfile(const char *pidfile)
 	xassert(pidfile != NULL);
 	xassert(pidfile[0] == '/');
 
-	(void) mkdir_parent(pidfile, 0755);
 	if (!(fp = fopen(pidfile, "w"))) {
 		error("Unable to open pidfile `%s': %m", pidfile);
 		return -1;
diff --git a/src/common/log.c b/src/common/log.c
index 2dee8d415ba..3c66406fb67 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -183,7 +183,6 @@ _log_init(char *prog, log_options_t opt, log_facility_t fac, char *logfile )
 	if (logfile && (log->opt.logfile_level > LOG_LEVEL_QUIET)) {
 		FILE *fp; 
 
-		(void) mkdir_parent(logfile, 0700);
 		fp = safeopen(logfile, "a", SAFEOPEN_LINK_OK);
 
 		if (!fp) {
diff --git a/src/common/safeopen.c b/src/common/safeopen.c
index 613513eda70..5221b66ce7e 100644
--- a/src/common/safeopen.c
+++ b/src/common/safeopen.c
@@ -58,36 +58,3 @@ FILE * safeopen(const char *path, const char *mode, int flags)
 
 }
 
-int
-mkdir_parent(const char *path_name, mode_t mode)
-{
-	char *dir_path, *tmp_ptr;
-	int i, rc = 0;
-
-	xassert(path_name);
-	xassert(path_name[0] == '/');
-
-	/* copy filename and strip off final element */
-	dir_path = xstrdup(path_name);
-	tmp_ptr  = strrchr(dir_path, (int)'/');
-	tmp_ptr[0] = (char) 0;
-
-	/* now create the parent directories */
-	for (i=1; ; i++) {
-		if (dir_path[i] == (char) 0) {
-			if (mkdir(dir_path, mode) && (errno != EEXIST))
-				rc = -1;
-			break;
-		}
-		if (dir_path[i] == '/') {
-			dir_path[i] = (char) 0;
-			if (mkdir(dir_path, mode) && (errno != EEXIST))
-				rc = -1;
-			dir_path[i] = '/';
-		}
-	}
-
-	xfree(dir_path);
-	return rc;
-}
-
diff --git a/src/common/safeopen.h b/src/common/safeopen.h
index 0f7fe1d5c02..f5815218ed1 100644
--- a/src/common/safeopen.h
+++ b/src/common/safeopen.h
@@ -24,14 +24,4 @@
  */
 FILE *safeopen(const char *path, const char *mode, int flags);
 
-/*
- * create parent directories as needed so that a specified 
- * file or directory can later be create
- * path_name IN - path name of the file or directory to be later 
- *                created, only its parents are created
- * mode IN      - permission mode to be used in creating directories
- * RET          - zero on success, -1 on failure with errno set
- */
-extern int mkdir_parent(const char *path_name, mode_t mode);
-
 #endif /* _SAFEOPEN_H */
-- 
GitLab