Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
lib/utils/DebugDump.cpp | 43 ++++++++++++++++++++++---------------------
1 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/lib/utils/DebugDump.cpp b/lib/utils/DebugDump.cpp
index 8987b43..37e21c7 100644
--- a/lib/utils/DebugDump.cpp
+++ b/lib/utils/DebugDump.cpp
@@ -34,7 +34,8 @@ static bool isdigit_str(const char *str)
return true;
}
-static char* RemoveBackSlashes(const char *pDir)
+// doesn't it only slash?
+static char* rm_backslashes(const char *pDir)
{
unsigned len = strlen(pDir);
while (len != 0 && pDir[len-1] == '/')
@@ -42,7 +43,7 @@ static char* RemoveBackSlashes(const char *pDir)
return xstrndup(pDir, len);
}
-static bool ExistFileDir(const char *pPath)
+static bool exist_file_dir(const char *pPath)
{
struct stat buf;
if (stat(pPath, &buf) == 0)
@@ -55,7 +56,7 @@ static bool ExistFileDir(const char *pPath)
return false;
}
-static char *LoadTextFile(const char *path);
+static char *loadtxt_file(const char *path);
static void dd_lock(dump_dir_t *dd);
static void dd_unlock(dump_dir_t *dd);
@@ -85,8 +86,8 @@ int dd_opendir(dump_dir_t *dd, const char *dir)
if (dd->opened)
error_msg_and_die("CDebugDump is already opened");
- dd->dd_dir = RemoveBackSlashes(dir);
- if (!dd->dd_dir || !ExistFileDir(dd->dd_dir))
+ dd->dd_dir = rm_backslashes(dir);
+ if (!dd->dd_dir || !exist_file_dir(dd->dd_dir))
{
error_msg("'%s' does not exist", dd->dd_dir);
return 0;
@@ -109,12 +110,12 @@ int dd_opendir(dump_dir_t *dd, const char *dir)
int dd_exist(dump_dir_t *dd, const char *path)
{
char *full_path = concat_path_file(dd->dd_dir, path);
- int ret = ExistFileDir(full_path);
+ int ret = exist_file_dir(full_path);
free(full_path);
return ret;
}
-static bool GetAndSetLock(const char* pLockFile, const char* pPID)
+static bool get_and_set_lock(const char* pLockFile, const char* pPID)
{
while (symlink(pPID, pLockFile) != 0)
{
@@ -232,7 +233,7 @@ static void dd_lock(dump_dir_t *dd)
char pid_buf[sizeof(long)*3 + 2];
sprintf(pid_buf, "%lu", (long)getpid());
- while ((dd->locked = GetAndSetLock(lock_buf, pid_buf)) != true)
+ while ((dd->locked = get_and_set_lock(lock_buf, pid_buf)) != true)
{
sleep(1); /* was 0.5 seconds */
}
@@ -273,8 +274,8 @@ int dd_create(dump_dir_t *dd, const char *dir, uid_t uid)
if (dd->opened)
error_msg_and_die("DebugDump is already opened");
- dd->dd_dir = RemoveBackSlashes(dir);
- if (ExistFileDir(dd->dd_dir))
+ dd->dd_dir = rm_backslashes(dir);
+ if (exist_file_dir(dd->dd_dir))
{
error_msg("'%s' already exists", dd->dd_dir);
return 0;
@@ -338,7 +339,7 @@ int dd_create(dump_dir_t *dd, const char *dir, uid_t uid)
}
dd_savetxt(dd, FILENAME_KERNEL, buf.release);
dd_savetxt(dd, FILENAME_ARCHITECTURE, buf.machine);
- char *release = LoadTextFile("/etc/redhat-release");
+ char *release = loadtxt_file("/etc/redhat-release");
strchrnul(release, '\n')[0] = '\0';
dd_savetxt(dd, FILENAME_RELEASE, release);
free(release);
@@ -352,9 +353,9 @@ int dd_create(dump_dir_t *dd, const char *dir, uid_t uid)
return 1;
}
-static bool DeleteFileDir(const char *pDir)
+static bool delete_file_dir(const char *pDir)
{
- if (!ExistFileDir(pDir))
+ if (!exist_file_dir(pDir))
return true;
DIR *d = opendir(pDir);
@@ -379,7 +380,7 @@ static bool DeleteFileDir(const char *pDir)
free(full_path);
return false;
}
- DeleteFileDir(full_path);
+ delete_file_dir(full_path);
}
free(full_path);
}
@@ -395,15 +396,15 @@ static bool DeleteFileDir(const char *pDir)
void dd_delete(dump_dir_t *dd)
{
- if (!ExistFileDir(dd->dd_dir))
+ if (!exist_file_dir(dd->dd_dir))
{
return;
}
- DeleteFileDir(dd->dd_dir);
+ delete_file_dir(dd->dd_dir);
}
-static char *LoadTextFile(const char *pPath)
+static char *loadtxt_file(const char *pPath)
{
FILE *fp = fopen(pPath, "r");
if (!fp)
@@ -426,7 +427,7 @@ static char *LoadTextFile(const char *pPath)
return strbuf_free_nobuf(buf_content);
}
-static bool SaveBinaryFile(const char *pPath, const char* pData, unsigned size, uid_t
uid, gid_t gid)
+static bool savebin_file(const char *pPath, const char* pData, unsigned size, uid_t uid,
gid_t gid)
{
/* "Why 0640?!" See ::Create() for security analysis */
unlink(pPath);
@@ -457,7 +458,7 @@ char* dd_loadtxt(const dump_dir_t *dd, const char *name)
error_msg_and_die("DebugDump is not opened");
char *full_path = concat_path_file(dd->dd_dir, name);
- char *ret = LoadTextFile(full_path);
+ char *ret = loadtxt_file(full_path);
free(full_path);
return ret;
@@ -469,7 +470,7 @@ void dd_savetxt(dump_dir_t *dd, const char *name, const char *data)
error_msg_and_die("DebugDump is not opened");
char *full_path = concat_path_file(dd->dd_dir, name);
- SaveBinaryFile(full_path, data, strlen(data), dd->uid, dd->gid);
+ savebin_file(full_path, data, strlen(data), dd->uid, dd->gid);
free(full_path);
}
@@ -479,7 +480,7 @@ void dd_savebin(dump_dir_t* dd, const char* name, const char* data,
unsigned siz
error_msg_and_die("DebugDump is not opened");
char *full_path = concat_path_file(dd->dd_dir, name);
- SaveBinaryFile(full_path, data, size, dd->uid, dd->gid);
+ savebin_file(full_path, data, size, dd->uid, dd->gid);
free(full_path);
}
--
1.7.1