diff options
Diffstat (limited to 'xlators/protocol/server/src/server-helpers.c')
-rw-r--r-- | xlators/protocol/server/src/server-helpers.c | 213 |
1 files changed, 0 insertions, 213 deletions
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 617a12a01..11c489e88 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -46,149 +46,6 @@ server_decode_groups (call_frame_t *frame, rpcsvc_request_t *req) return 0; } -/* server_loc_fill - derive a loc_t for a given inode number - * - * NOTE: make sure that @loc is empty, because any pointers it holds with reference will - * be leaked after returning from here. - */ -int -server_loc_fill (loc_t *loc, server_state_t *state, - ino_t ino, ino_t par, - const char *name, const char *path) -{ - inode_t *inode = NULL; - inode_t *parent = NULL; - int32_t ret = -1; - char *dentry_path = NULL; - - - GF_VALIDATE_OR_GOTO ("server", loc, out); - GF_VALIDATE_OR_GOTO ("server", state, out); - GF_VALIDATE_OR_GOTO ("server", path, out); - - /* anything beyond this point is success */ - ret = 0; - loc->ino = ino; - inode = loc->inode; - if (inode == NULL) { - if (ino) - inode = inode_search (state->itable, ino, NULL); - - if ((inode == NULL) && - (par && name)) - inode = inode_search (state->itable, par, name); - - loc->inode = inode; - if (inode) - loc->ino = inode->ino; - } - - parent = loc->parent; - if (parent == NULL) { - if (inode) - parent = inode_parent (inode, par, name); - else - parent = inode_search (state->itable, par, NULL); - loc->parent = parent; - } - - if (name && parent) { - ret = inode_path (parent, name, &dentry_path); - if (ret < 0) { - gf_log (state->conn->bound_xl->name, GF_LOG_DEBUG, - "failed to build path for %"PRId64"/%s: %s", - parent->ino, name, strerror (-ret)); - } - } else if (inode) { - ret = inode_path (inode, NULL, &dentry_path); - if (ret < 0) { - gf_log (state->conn->bound_xl->name, GF_LOG_DEBUG, - "failed to build path for %"PRId64": %s", - inode->ino, strerror (-ret)); - } - } - - if (dentry_path) { - if (strcmp (dentry_path, path)) { - gf_log (state->conn->bound_xl->name, GF_LOG_DEBUG, - "paths differ for inode(%"PRId64"): " - "client path = %s. dentry path = %s", - ino, path, dentry_path); - } - - loc->path = dentry_path; - loc->name = strrchr (loc->path, '/'); - if (loc->name) - loc->name++; - } else { - loc->path = gf_strdup (path); - loc->name = strrchr (loc->path, '/'); - if (loc->name) - loc->name++; - } - -out: - return ret; -} - -/* - * stat_to_str - convert struct iatt to a ASCII string - * @stbuf: struct iatt pointer - * - * not for external reference - */ -char * -stat_to_str (struct iatt *stbuf) -{ - int ret = 0; - char *tmp_buf = NULL; - - uint64_t dev = stbuf->ia_gen; - uint64_t ino = stbuf->ia_ino; - uint32_t mode = st_mode_from_ia (stbuf->ia_prot, stbuf->ia_type); - uint32_t nlink = stbuf->ia_nlink; - uint32_t uid = stbuf->ia_uid; - uint32_t gid = stbuf->ia_gid; - uint64_t rdev = stbuf->ia_rdev; - uint64_t size = stbuf->ia_size; - uint32_t blksize = stbuf->ia_blksize; - uint64_t blocks = stbuf->ia_blocks; - uint32_t atime = stbuf->ia_atime; - uint32_t mtime = stbuf->ia_mtime; - uint32_t ctime = stbuf->ia_ctime; - - uint32_t atime_nsec = stbuf->ia_atime_nsec; - uint32_t mtime_nsec = stbuf->ia_mtime_nsec; - uint32_t ctime_nsec = stbuf->ia_ctime_nsec; - - - ret = gf_asprintf (&tmp_buf, - GF_STAT_PRINT_FMT_STR, - dev, - ino, - mode, - nlink, - uid, - gid, - rdev, - size, - blksize, - blocks, - atime, - atime_nsec, - mtime, - mtime_nsec, - ctime, - ctime_nsec); - if (-1 == ret) { - gf_log ("protocol/server", GF_LOG_DEBUG, - "asprintf failed while setting up stat buffer string"); - return NULL; - } - return tmp_buf; -} - - void server_loc_wipe (loc_t *loc) { @@ -279,34 +136,6 @@ free_state (server_state_t *state) } -call_frame_t * -server_copy_frame (call_frame_t *frame) -{ - call_frame_t *new_frame = NULL; - server_state_t *state = NULL, *new_state = NULL; - - state = frame->root->state; - - new_frame = copy_frame (frame); - - new_state = GF_CALLOC (1, sizeof (server_state_t), gf_server_mt_state_t); - - new_frame->root->op = frame->root->op; - new_frame->root->type = frame->root->type; - new_frame->root->trans = state->conn; - new_frame->root->state = new_state; - - new_state->itable = state->itable; - new_state->conn = state->conn; - //new_state->conn = xprt_ref (state->conn); - - new_state->resolve.fd_no = -1; - new_state->resolve2.fd_no = -1; - - return new_frame; -} - - int gf_add_locker (struct _lock_table *table, const char *volume, loc_t *loc, fd_t *fd, pid_t pid) @@ -408,48 +237,6 @@ gf_del_locker (struct _lock_table *table, const char *volume, return ret; } - -int -gf_direntry_to_bin (dir_entry_t *head, char *buffer) -{ - dir_entry_t *trav = NULL; - uint32_t len = 0; - uint32_t this_len = 0; - size_t buflen = -1; - char *ptr = NULL; - char *tmp_buf = NULL; - - trav = head->next; - while (trav) { - len += strlen (trav->name); - len += 1; - len += strlen (trav->link); - len += 1; /* for '\n' */ - len += 256; // max possible for statbuf; - trav = trav->next; - } - - ptr = buffer; - trav = head->next; - while (trav) { - tmp_buf = stat_to_str (&trav->buf); - /* tmp_buf will have \n before \0 */ - - this_len = sprintf (ptr, "%s/%s%s\n", - trav->name, tmp_buf, - trav->link); - - GF_FREE (tmp_buf); - trav = trav->next; - ptr += this_len; - } - - buflen = strlen (buffer); - - return buflen; -} - - static struct _lock_table * gf_lock_table_new (void) { |