git://git.onelab.eu
/
vsys-scripts.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cleanup
[vsys-scripts.git]
/
fd_fusemount.c
diff --git
a/fd_fusemount.c
b/fd_fusemount.c
index
73ed928
..
5c29c98
100644
(file)
--- a/
fd_fusemount.c
+++ b/
fd_fusemount.c
@@
-11,11
+11,14
@@
unsigned int rcvbuf = 16*1024*1024;
unsigned int arg_length = 128;
unsigned int mountflags = MS_NODEV | MS_NOSUID;
unsigned int arg_length = 128;
unsigned int mountflags = MS_NODEV | MS_NOSUID;
+FILE *logfd;
+
void receive_argument(int control_channel_fd, char *source) {
int received;
received=recv(control_channel_fd, source, arg_length, 0);
if (received<arg_length) {
void receive_argument(int control_channel_fd, char *source) {
int received;
received=recv(control_channel_fd, source, arg_length, 0);
if (received<arg_length) {
- printf("Error receiving arguments over the control buffer\n");
+ fprintf(logfd,"Error receiving arguments over the control buffer\n");
+ close(logfd);
exit(1);
}
}
exit(1);
}
}
@@
-36,15
+39,14
@@
int set_magic_fd (char *data, int new_fd) {
if (*(ptr+3)!='\0') {
char *new_data = (char *) malloc(arg_length);
char *head = (char *) malloc(arg_length);
if (*(ptr+3)!='\0') {
char *new_data = (char *) malloc(arg_length);
char *head = (char *) malloc(arg_length);
- char *tail
= (char *) malloc(arg_length)
;
+ char *tail;
sscanf(ptr+3,"%d",&fd);
strncpy(head, data, ptr - data);
tail = strchr(ptr+3,',');
sscanf(ptr+3,"%d",&fd);
strncpy(head, data, ptr - data);
tail = strchr(ptr+3,',');
- sprintf(new_data,"%sfd=%d
,
%s",head,new_fd,tail);
+ sprintf(new_data,"%sfd=%d%s",head,new_fd,tail);
strcpy(data,new_data);
strcpy(data,new_data);
- free(new_data);
free(head);
free(head);
- free(
tail
);
+ free(
new_data
);
return fd;
}
else
return fd;
}
else
@@
-54,7
+56,8
@@
int set_magic_fd (char *data, int new_fd) {
void check_source(char *source) {
source[arg_length-1]='\0';
if (strchr(source,'/') || strstr(source,"..")) {
void check_source(char *source) {
source[arg_length-1]='\0';
if (strchr(source,'/') || strstr(source,"..")) {
- printf("Tried mounting with source = %s\n", source);
+ fprintf(logfd, "Tried mounting with source = %s\n", source);
+ close(logfd);
exit(1);
}
}
exit(1);
}
}
@@
-62,20
+65,23
@@
void check_source(char *source) {
void check_target(char *target) {
target[arg_length-1]='\0';
if (strstr(target,"..")) {
void check_target(char *target) {
target[arg_length-1]='\0';
if (strstr(target,"..")) {
- printf("Tried mounting with target = %s\n", target);
+ fprintf(logfd,"Tried mounting with target = %s\n", target);
+ close(logfd);
exit(1);
}
}
void check_fstype(char *filesystemtype) {
if (strncmp(filesystemtype,"fuse",4)) {
exit(1);
}
}
void check_fstype(char *filesystemtype) {
if (strncmp(filesystemtype,"fuse",4)) {
- printf("Tried mounting filesystem type %s\n", filesystemtype);
+ fprintf(logfd,"Tried mounting filesystem type %s\n", filesystemtype);
+ close(logfd);
+ exit(1);
}
}
int main(int argc, char *argv[]) {
int control_channel_fd, magic_fd, mount_fd;
}
}
int main(int argc, char *argv[]) {
int control_channel_fd, magic_fd, mount_fd;
- char source[128],target[128],filesystemtype[128],data[128],slice_target[
256
];
+ char source[128],target[128],filesystemtype[128],data[128],slice_target[
1024
];
int received;
int received;
@@
-85,6
+91,9
@@
int main(int argc, char *argv[]) {
}
char *slice_name = argv[1];
}
char *slice_name = argv[1];
+
+ logfd=fopen("/tmp/fuselog","w");
+ if (!logfd) {logfd = stderr;}
sscanf(argv[2],"%d", &control_channel_fd);
sscanf(argv[2],"%d", &control_channel_fd);
@@
-112,7
+121,9
@@
int main(int argc, char *argv[]) {
check_target(target);
check_fstype(filesystemtype);
check_target(target);
check_fstype(filesystemtype);
- sprintf(slice_target,"/vservers/%s/%s", target);
+ sprintf(slice_target,"/vservers/%s/%s", slice_name, target);
+
+ fprintf(logfd, "Mount fd: %d Source: %s slice_target: %s fstype: %s mountflags: %d data: %s\n", mount_fd, source, slice_target, filesystemtype, mountflags, data);
if (!mount(source, slice_target, filesystemtype, mountflags, data)) {
send_fd(control_channel_fd, mount_fd);
if (!mount(source, slice_target, filesystemtype, mountflags, data)) {
send_fd(control_channel_fd, mount_fd);
@@
-122,5
+133,6
@@
int main(int argc, char *argv[]) {
exit(1);
}
exit(1);
}
+ close(logfd);
return 0;
}
return 0;
}