summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/compat.c')
-rw-r--r--libglusterfs/src/compat.c73
1 files changed, 38 insertions, 35 deletions
diff --git a/libglusterfs/src/compat.c b/libglusterfs/src/compat.c
index 42c20f527..eb6d8d4b7 100644
--- a/libglusterfs/src/compat.c
+++ b/libglusterfs/src/compat.c
@@ -1,20 +1,11 @@
/*
- Copyright (c) 2006-2010 Gluster, Inc. <http://www.gluster.com>
+ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
This file is part of GlusterFS.
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
*/
#ifndef _CONFIG_H
@@ -121,7 +112,7 @@ make_export_path (const char *real_path, char **path)
ret = solaris_getxattr ("/", GFID_XATTR_KEY, gfid, 16);
/* Return value of getxattr */
if (ret == 16) {
- if (!__is_root_gfid (gfid)){
+ if (__is_root_gfid (gfid)){
strcat (export_path, "/");
ret = 0;
goto done;
@@ -135,7 +126,7 @@ make_export_path (const char *real_path, char **path)
strcat (export_path, dup);
ret = solaris_getxattr (export_path, GFID_XATTR_KEY, gfid, 16);
if (ret == 16) {
- if (!__is_root_gfid (gfid)) {
+ if (__is_root_gfid (gfid)) {
ret = 0;
goto done;
}
@@ -151,8 +142,7 @@ done:
*path = export_path;
}
out:
- if (freeptr)
- GF_FREE (freeptr);
+ GF_FREE (freeptr);
if (ret && export_path)
GF_FREE (export_path);
@@ -181,7 +171,7 @@ solaris_xattr_resolve_path (const char *real_path, char **path)
if (lstat (export_path, &statbuf)) {
ret = mkdir (export_path, 0777);
if (ret && (errno != EEXIST)) {
- gf_log ("", GF_LOG_DEBUG, "mkdir failed,"
+ gf_log (THIS->name, GF_LOG_DEBUG, "mkdir failed,"
" errno: %d", errno);
goto out;
}
@@ -195,7 +185,7 @@ solaris_xattr_resolve_path (const char *real_path, char **path)
if (ret) {
ret = mknod (xattr_path, S_IFREG|O_WRONLY, 0);
if (ret && (errno != EEXIST)) {
- gf_log ("", GF_LOG_WARNING,"Failed to create "
+ gf_log (THIS->name, GF_LOG_WARNING,"Failed to create "
"mapped file %s, error %d", xattr_path,
errno);
goto out;
@@ -204,8 +194,7 @@ solaris_xattr_resolve_path (const char *real_path, char **path)
*path = gf_strdup (xattr_path);
}
out:
- if (export_path)
- GF_FREE (export_path);
+ GF_FREE (export_path);
if (*path)
return 0;
else
@@ -239,8 +228,7 @@ solaris_setxattr(const char *path, const char* key, const char *value,
path, errno);
ret = -1;
}
- if (mapped_path)
- GF_FREE (mapped_path);
+ GF_FREE (mapped_path);
return ret;
}
@@ -306,8 +294,7 @@ solaris_listxattr(const char *path, char *list, size_t size)
close (attrdirfd);
}
out:
- if (mapped_path)
- GF_FREE (mapped_path);
+ GF_FREE (mapped_path);
return len;
}
@@ -389,8 +376,7 @@ solaris_removexattr(const char *path, const char* key)
ret = -1;
}
- if (mapped_path)
- GF_FREE (mapped_path);
+ GF_FREE (mapped_path);
return ret;
}
@@ -430,8 +416,7 @@ solaris_getxattr(const char *path,
errno = ENODATA;
ret = -1;
}
- if (mapped_path)
- GF_FREE (mapped_path);
+ GF_FREE (mapped_path);
return ret;
}
@@ -490,21 +475,20 @@ int solaris_unlink (const char *path)
if (!ret && mapped_path) {
if (lstat(path, &stbuf)) {
- gf_log ("",GF_LOG_WARNING, "Stat failed on mapped"
+ gf_log (THIS->name, GF_LOG_WARNING, "Stat failed on mapped"
" file %s with error %d", mapped_path, errno);
goto out;
}
if (stbuf.st_nlink == 1) {
if(remove (mapped_path))
- gf_log ("", GF_LOG_WARNING, "Failed to remove mapped "
+ gf_log (THIS->name, GF_LOG_WARNING, "Failed to remove mapped "
"file %s. Errno %d", mapped_path, errno);
}
}
out:
- if (mapped_path)
- GF_FREE (mapped_path);
+ GF_FREE (mapped_path);
return unlink (path);
}
@@ -520,7 +504,7 @@ solaris_rename (const char *old_path, const char *new_path)
if (!ret && mapped_path) {
if (!remove (mapped_path))
- gf_log ("", GF_LOG_WARNING, "Failed to remove mapped "
+ gf_log (THIS->name, GF_LOG_WARNING, "Failed to remove mapped "
"file %s. Errno %d", mapped_path, errno);
GF_FREE (mapped_path);
}
@@ -528,6 +512,25 @@ solaris_rename (const char *old_path, const char *new_path)
return rename(old_path, new_path);
}
+
+char *
+mkdtemp (char *tempstring)
+{
+ char *new_string = NULL;
+ int ret = 0;
+
+ new_string = mkstemp (tempstring);
+ if (!new_string)
+ goto out;
+
+ ret = mkdir (new_string, 0700);
+ if (ret < 0)
+ new_string = NULL;
+
+out:
+ return new_string;
+}
+
#endif /* GF_SOLARIS_HOST_OS */
#ifndef HAVE_STRNLEN