summaryrefslogtreecommitdiffstats
path: root/xlators/features/path-convertor/src/path.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/features/path-convertor/src/path.c')
-rw-r--r--xlators/features/path-convertor/src/path.c184
1 files changed, 95 insertions, 89 deletions
diff --git a/xlators/features/path-convertor/src/path.c b/xlators/features/path-convertor/src/path.c
index d58f0f3cb..5c52e0a8d 100644
--- a/xlators/features/path-convertor/src/path.c
+++ b/xlators/features/path-convertor/src/path.c
@@ -1,22 +1,12 @@
/*
- Copyright (c) 2008-2009 Gluster, Inc. <http://www.gluster.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 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
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
-*/
+ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+ 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.
+*/
/* TODO: add gf_log to all the cases returning errors */
#ifndef _CONFIG_H
@@ -35,6 +25,7 @@
#include <errno.h>
#include "glusterfs.h"
#include "xlator.h"
+#include "path-mem-types.h"
typedef struct path_private
{
@@ -51,7 +42,7 @@ static char *
name_this_to_that (xlator_t *xl, const char *path, const char *name)
{
path_private_t *priv = xl->private;
- char priv_path[ZR_PATH_MAX] = {0,};
+ char priv_path[PATH_MAX] = {0,};
char *tmp_name = NULL;
int32_t path_len = strlen (path);
int32_t name_len = strlen (name) - ZR_FILE_CONTENT_STRLEN;
@@ -63,7 +54,9 @@ name_this_to_that (xlator_t *xl, const char *path, const char *name)
if (priv->end_off && (total_len > priv->end_off)) {
j = priv->start_off;
- tmp_name = CALLOC (1, (total_len + ZR_FILE_CONTENT_STRLEN));
+ tmp_name = GF_CALLOC (1, (total_len +
+ ZR_FILE_CONTENT_STRLEN),
+ gf_path_mt_char);
ERR_ABORT (tmp_name);
/* Get the complete path for the file first */
@@ -104,7 +97,7 @@ path_this_to_that (xlator_t *xl, const char *path)
int32_t i = 0, j = 0;
if (priv->end_off && (path_len > priv->start_off)) {
- priv_path = CALLOC (1, path_len);
+ priv_path = GF_CALLOC (1, path_len, gf_path_mt_char);
ERR_ABORT (priv_path);
if (priv->start_off && (path_len > priv->start_off))
@@ -134,9 +127,9 @@ path_create_cbk (call_frame_t *frame,
int32_t op_errno,
fd_t *fd,
inode_t *inode,
- struct stat *buf,
- struct stat *preparent,
- struct stat *postparent)
+ struct iatt *buf,
+ struct iatt *preparent,
+ struct iatt *postparent)
{
STACK_UNWIND (frame, op_ret, op_errno, fd, inode, buf);
return 0;
@@ -187,7 +180,7 @@ path_readlink_cbk (call_frame_t *frame,
int32_t op_ret,
int32_t op_errno,
const char *buf,
- struct stat *sbuf)
+ struct iatt *sbuf)
{
STACK_UNWIND (frame, op_ret, op_errno, buf, sbuf);
return 0;
@@ -200,9 +193,9 @@ path_lookup_cbk (call_frame_t *frame,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
- struct stat *buf,
+ struct iatt *buf,
dict_t *xattr,
- struct stat *postparent)
+ struct iatt *postparent)
{
STACK_UNWIND (frame, op_ret, op_errno, inode, buf, xattr);
return 0;
@@ -216,9 +209,9 @@ path_symlink_cbk (call_frame_t *frame,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
- struct stat *buf,
- struct stat *preparent,
- struct stat *postparent)
+ struct iatt *buf,
+ struct iatt *preparent,
+ struct iatt *postparent)
{
STACK_UNWIND (frame, op_ret, op_errno, inode, buf);
return 0;
@@ -231,9 +224,9 @@ path_mknod_cbk (call_frame_t *frame,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
- struct stat *buf,
- struct stat *preparent,
- struct stat *postparent)
+ struct iatt *buf,
+ struct iatt *preparent,
+ struct iatt *postparent)
{
STACK_UNWIND (frame, op_ret, op_errno, inode, buf);
return 0;
@@ -247,9 +240,9 @@ path_mkdir_cbk (call_frame_t *frame,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
- struct stat *buf,
- struct stat *preparent,
- struct stat *postparent)
+ struct iatt *buf,
+ struct iatt *preparent,
+ struct iatt *postparent)
{
STACK_UNWIND (frame, op_ret, op_errno, inode, buf);
return 0;
@@ -262,9 +255,9 @@ path_link_cbk (call_frame_t *frame,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
- struct stat *buf,
- struct stat *preparent,
- struct stat *postparent)
+ struct iatt *buf,
+ struct iatt *preparent,
+ struct iatt *postparent)
{
STACK_UNWIND (frame, op_ret, op_errno, inode, buf);
return 0;
@@ -289,11 +282,11 @@ path_rename_buf_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- struct stat *buf,
- struct stat *preoldparent,
- struct stat *postoldparent,
- struct stat *prenewparent,
- struct stat *postnewparent)
+ struct iatt *buf,
+ struct iatt *preoldparent,
+ struct iatt *postoldparent,
+ struct iatt *prenewparent,
+ struct iatt *postnewparent)
{
STACK_UNWIND (frame, op_ret, op_errno, buf);
return 0;
@@ -307,7 +300,7 @@ path_common_buf_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- struct stat *buf)
+ struct iatt *buf)
{
STACK_UNWIND (frame, op_ret, op_errno, buf);
return 0;
@@ -327,8 +320,8 @@ path_common_dict_cbk (call_frame_t *frame,
int32_t
path_common_remove_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,struct stat *preparent,
- struct stat *postparent)
+ int32_t op_ret, int32_t op_errno,struct iatt *preparent,
+ struct iatt *postparent)
{
STACK_UNWIND (frame, op_ret, op_errno);
return 0;
@@ -336,8 +329,8 @@ path_common_remove_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t
path_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,struct stat *prebuf,
- struct stat *postbuf)
+ int32_t op_ret, int32_t op_errno,struct iatt *prebuf,
+ struct iatt *postbuf)
{
STACK_UNWIND (frame, op_ret, op_errno, prebuf, postbuf);
return 0;
@@ -378,7 +371,7 @@ path_lookup (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -405,7 +398,7 @@ path_stat (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -434,7 +427,7 @@ path_readlink (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -465,7 +458,7 @@ path_mknod (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -494,7 +487,7 @@ path_mkdir (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -521,7 +514,7 @@ path_unlink (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -548,7 +541,7 @@ path_rmdir (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -577,7 +570,7 @@ path_symlink (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -615,11 +608,11 @@ path_rename (call_frame_t *frame,
oldloc->path = oldloc_path;
if (tmp_oldloc_path != oldloc_path)
- FREE (tmp_oldloc_path);
+ GF_FREE (tmp_oldloc_path);
newloc->path = newloc_path;
if (tmp_newloc_path != newloc_path)
- FREE (tmp_newloc_path);
+ GF_FREE (tmp_newloc_path);
return 0;
}
@@ -657,11 +650,11 @@ path_link (call_frame_t *frame,
oldloc->path = oldloc_path;
if (tmp_oldloc_path != oldloc_path)
- FREE (tmp_oldloc_path);
+ GF_FREE (tmp_oldloc_path);
newloc->path = newloc_path;
if (tmp_newloc_path != newloc_path)
- FREE (tmp_newloc_path);
+ GF_FREE (tmp_newloc_path);
return 0;
}
@@ -672,8 +665,8 @@ path_setattr_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- struct stat *preop,
- struct stat *postop)
+ struct iatt *preop,
+ struct iatt *postop)
{
STACK_UNWIND (frame, op_ret, op_errno, preop, postop);
return 0;
@@ -683,7 +676,7 @@ int32_t
path_setattr (call_frame_t *frame,
xlator_t *this,
loc_t *loc,
- struct stat *stbuf,
+ struct iatt *stbuf,
int32_t valid)
{
char *loc_path = (char *)loc->path;
@@ -704,7 +697,7 @@ path_setattr (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -734,7 +727,7 @@ path_truncate (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -768,7 +761,7 @@ path_open (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -801,7 +794,7 @@ path_create (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -843,10 +836,9 @@ path_setxattr (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
- if (tmp_name)
- FREE (tmp_name);
+ GF_FREE (tmp_name);
return 0;
}
@@ -880,10 +872,10 @@ path_getxattr (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
if (tmp_name != name)
- FREE (tmp_name);
+ GF_FREE (tmp_name);
return 0;
}
@@ -917,10 +909,10 @@ path_removexattr (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
if (tmp_name != name)
- FREE (tmp_name);
+ GF_FREE (tmp_name);
return 0;
}
@@ -949,7 +941,7 @@ path_opendir (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -978,7 +970,7 @@ path_access (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -1020,7 +1012,7 @@ path_checksum (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -1047,14 +1039,14 @@ path_entrylk (call_frame_t *frame, xlator_t *this,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
int32_t
path_inodelk (call_frame_t *frame, xlator_t *this,
- const char *volume, loc_t *loc, int32_t cmd, struct flock *lock)
+ const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *lock)
{
char *loc_path = (char *)loc->path;
char *tmp_path = NULL;
@@ -1073,7 +1065,7 @@ path_inodelk (call_frame_t *frame, xlator_t *this,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
@@ -1105,11 +1097,29 @@ path_xattrop (call_frame_t *frame,
loc->path = loc_path;
if (tmp_path != loc_path)
- FREE (tmp_path);
+ GF_FREE (tmp_path);
return 0;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_path_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
int32_t
init (xlator_t *this)
@@ -1128,7 +1138,7 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- priv = CALLOC (1, sizeof (*priv));
+ priv = GF_CALLOC (1, sizeof (*priv), gf_path_mt_path_private_t);
ERR_ABORT (priv);
if (dict_get (options, "start-offset")) {
priv->start_off = data_to_int32 (dict_get (options,
@@ -1141,7 +1151,8 @@ init (xlator_t *this)
if (dict_get (options, "regex")) {
int32_t ret = 0;
- priv->preg = CALLOC (1, sizeof (regex_t));
+ priv->preg = GF_CALLOC (1, sizeof (regex_t),
+ gf_path_mt_regex_t);
ERR_ABORT (priv->preg);
ret = regcomp (priv->preg,
data_to_str (dict_get (options, "regex")),
@@ -1149,7 +1160,7 @@ init (xlator_t *this)
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"Failed to compile the 'option regex'");
- FREE (priv);
+ GF_FREE (priv);
return -1;
}
if (dict_get (options, "replace-with")) {
@@ -1196,11 +1207,6 @@ struct xlator_fops fops = {
.setattr = path_setattr,
};
-
-struct xlator_mops mops = {
-};
-
-
struct xlator_cbks cbks = {
};