From 47a44efc3354a34af2ce9f4f6aafb6b7af417f37 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Tue, 31 Mar 2009 16:26:58 +0000 Subject: [PATCH] Fixed some bugs, and tested to work. --- fd_fusemount.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/fd_fusemount.c b/fd_fusemount.c index 5c43cf4..73ed928 100644 --- a/fd_fusemount.c +++ b/fd_fusemount.c @@ -20,7 +20,7 @@ void receive_argument(int control_channel_fd, char *source) { } } -int get_magic_fd (char *data) { +int set_magic_fd (char *data, int new_fd) { char *ptr; int fd; @@ -34,7 +34,17 @@ int get_magic_fd (char *data) { return -1; if (*(ptr+3)!='\0') { + char *new_data = (char *) malloc(arg_length); + char *head = (char *) malloc(arg_length); + char *tail = (char *) malloc(arg_length); sscanf(ptr+3,"%d",&fd); + strncpy(head, data, ptr - data); + tail = strchr(ptr+3,','); + sprintf(new_data,"%sfd=%d,%s",head,new_fd,tail); + strcpy(data,new_data); + free(new_data); + free(head); + free(tail); return fd; } else @@ -87,21 +97,17 @@ int main(int argc, char *argv[]) { receive_argument(control_channel_fd, target); receive_argument(control_channel_fd, filesystemtype); receive_argument(control_channel_fd, data); - - magic_fd = get_magic_fd (data); - - if (magic_fd < 3) { - printf("Got fd %d in fusemount\n",magic_fd); - exit(1); - } mount_fd = receive_fd (control_channel_fd); - if (mount_fd != magic_fd) { - printf("mount_fd (%d) != magic_fd (%d)\n", mount_fd, magic_fd); + if (mount_fd < 2) { + printf("mount_fd = %d\n", mount_fd); exit(1); } + set_magic_fd(data, mount_fd); + + check_source(source); check_target(target); check_fstype(filesystemtype); @@ -109,7 +115,7 @@ int main(int argc, char *argv[]) { sprintf(slice_target,"/vservers/%s/%s", target); if (!mount(source, slice_target, filesystemtype, mountflags, data)) { - send_fd(control_channel_fd, magic_fd); + send_fd(control_channel_fd, mount_fd); } else { printf ("Error executing mount\n"); -- 2.43.0