/* * Parse a single mount parameter. */ static int afs_parse_param(struct fs_context *fc, struct fs_parameter *param) { struct fs_parse_result result; struct afs_fs_context *ctx = fc->fs_private; int opt; opt = fs_parse(fc, &afs_fs_parameters, param, &result); if (opt < 0) return opt; switch (opt) { case Opt_source: return afs_parse_source(fc, param); case Opt_autocell: ctx->autocell = true; break; case Opt_dyn: ctx->dyn_root = true; break; default: return -EINVAL; } _leave(" = 0"); return 0; }
/* * FreeSWITCH specific wrapper around socket_recv(). * Return value: * Returns 0 on success, or -1 on fatal socket error. */ int fs_recv(char **buf) { char *temp; fd_set *m_sock_fds_t = pthread_getspecific(m_sock_fds); struct socket_in *fs_t = pthread_getspecific(fs_s); if(socket_recv(fs_t, *buf, "\n\n") == -1) { switch(errno) { case EBADF: case ECONNRESET: case ENOTCONN: case ENOTSOCK: case EFAULT: return -1; } } do { size_t buf_len, content_len = 0; char *cbuf; /* * Default copy address of buf to temp. If we find content-length * then we'll free it and overwrite. */ temp = *buf; /* If there is a content-len header, get the full message. */ if((cbuf = strstr(temp, "Content-Length: ")) != NULL) { struct socket_buf *b = &fs_t->buffer; content_len = atoi(cbuf+16); buf_len = strlen(*buf)+2; /* Create some memory and get the rest of the buffer. */ temp = calloc(buf_len+content_len+b->offset+1, sizeof(*temp)); memcpy(temp, *buf, buf_len-2); memset(temp+buf_len-2, '\n', 2); memcpy(temp+buf_len, b->buf, b->offset); socket_recv_bytes(fs_t, temp+buf_len+b->offset, content_len); /* Zero out our buffer. */ memset(b, 0, sizeof(*b)); } if(fs_parse(temp) == -1) { /* The socket had a fatal error so we close it down. */ FD_CLR(fs_t->fd, m_sock_fds_t); socket_close(fs_t); return -1; } if(content_len > 0) free(temp); } while(socket_next_chunk(fs_t, *buf, "\n\n") != 0); return 0; }