Blob Blame History Raw
From 74f8dd6193fe1ae1e475452a76f9c4daaf602a63 Mon Sep 17 00:00:00 2001
Message-Id: <74f8dd6193fe1ae1e475452a76f9c4daaf602a63.1431444153.git.aquini@redhat.com>
From: Rafael Aquini <aquini@redhat.com>
Date: Tue, 12 May 2015 11:22:30 -0400
Subject: [PATCH] memkind-pmtt: stop nuking sysconfdir and contents

memkind-pmtt tool should not be nuking the sysconfdir -- /etc/memkind --
in order to not overlap content ownership with package managers such RPM
as well as to avoid crazy havocs of racy file and dir unlinks with concurrent
usage from the libs or other parses via parallel memkind-pmtt invocations.

This patch removes the sysconfdir nuking points for the memkind-pmtt tool and
its sysv init script as well as it delegates the 'MEMKIND_FILE' file deletion
control only to the sysv init script for procedural consistency.

Signed-off-by: Rafael Aquini <aquini@redhat.com>
---
 init.d/memkind     | 8 --------
 src/memkind_pmtt.c | 7 -------
 2 files changed, 15 deletions(-)

diff --git a/init.d/memkind b/init.d/memkind
index 1be0954..2ba6745 100755
--- a/init.d/memkind
+++ b/init.d/memkind
@@ -90,14 +90,6 @@ stop() {
     if [ $err -eq 0 ] && [ ! -f $MEMKIND_FILE ]
     then
         echo_success "deleted file: $MEMKIND_FILE"
-        rmdir $MEMKIND_DIR
-        err=$?
-        if [ $err -eq 0 ] && [ ! -d $MEMKIND_DIR ]
-        then
-            echo_success "deleted directory: $MEMKIND_DIR"
-        else
-            echo_failure "could not delete directory: $MEMKIND_DIR"
-        fi
     else
         echo_failure "could not delete file: $MEMKIND_FILE"
     fi
diff --git a/src/memkind_pmtt.c b/src/memkind_pmtt.c
index ebabafd..9d9296c 100644
--- a/src/memkind_pmtt.c
+++ b/src/memkind_pmtt.c
@@ -220,7 +220,6 @@ int memkind_pmtt(char *pmtt_path, char *bandwidth_path)
         err = errno ? -errno : 1;
         goto exit;
     }
-    unlink(bandwidth_path);
     fd = open(bandwidth_path, O_CREAT | O_EXCL | O_WRONLY, 0644);
     if (fd == -1) {
         fprintf(stderr, "ERROR: <memkind_pmtt> opening %s for writing\n", bandwidth_path);
@@ -252,12 +251,6 @@ exit:
     if (bandwidth != NULL) {
         free(bandwidth);
     }
-    if (err) {
-        unlink(bandwidth_path);
-        if(*dir) {
-            rmdir(dir);
-        }
-    }
     return err;
 }
 
-- 
2.1.0