Browse Source

automatically append / to base disk paths

Samuel Thibault 12 years ago
parent
commit
d4df9bad9c

+ 4 - 10
src/core/disk_ops/disk_stdio.c

@@ -50,16 +50,13 @@ starpu_stdio_alloc (void *base, size_t size)
 	int id = -1;
 
 	/* create template for mkstemp */
-	unsigned int sizeBase = 16;
-	while(sizeBase < (strlen(base)+7))
-		sizeBase *= 2;
-
-	char * baseCpy = malloc(sizeBase*sizeof(char));
+	char * baseCpy = malloc(strlen(base)+8);
 	STARPU_ASSERT(baseCpy != NULL);
 
 	char * tmp = "STARPU_XXXXXX";
 
 	strcpy(baseCpy, (char *) base);
+	strcat(baseCpy,"/");
 	strcat(baseCpy,tmp);
 
 #ifdef STARPU_HAVE_WINDOWS
@@ -134,13 +131,10 @@ starpu_stdio_open (void *base, void *pos, size_t size)
 	STARPU_ASSERT(obj != NULL);
 
 	/* create template */
-	unsigned int sizeBase = 16;
-	while(sizeBase < (strlen(base)+strlen(pos)+1))
-		sizeBase *= 2;
-	
-	char * baseCpy = malloc(sizeBase*sizeof(char));
+	char * baseCpy = malloc(strlen(base)+1+strlen(pos)+1);
 	STARPU_ASSERT(baseCpy != NULL);
 	strcpy(baseCpy,(char *) base);
+	strcat(baseCpy,(char *) "/");
 	strcat(baseCpy,(char *) pos);
 
 	int id = open(baseCpy, O_RDWR);

+ 2 - 1
src/core/disk_ops/unistd/disk_unistd_global.c

@@ -111,12 +111,13 @@ starpu_unistd_global_open (struct starpu_unistd_global_obj * obj, void *base, vo
 {
 	/* create template */
 	unsigned int sizeBase = 16;
-	while(sizeBase < (strlen(base)+strlen(pos)+1))
+	while(sizeBase < (strlen(base)+1+strlen(pos)+1))
 		sizeBase *= 2;
 	
 	char * baseCpy = malloc(sizeBase*sizeof(char));
 	STARPU_ASSERT(baseCpy != NULL);
 	strcpy(baseCpy,(char *) base);
+	strcat(baseCpy,(char *) "/");
 	strcat(baseCpy,(char *) pos);
 
 	int id = open(baseCpy, obj->flags);

+ 1 - 1
tests/disk/disk_compute.c

@@ -45,7 +45,7 @@ int main(int argc, char **argv)
 	int pid = getpid();
 	snprintf(pid_str, 16, "%d", pid);
 
-	char * base = "/tmp/";
+	char * base = "/tmp";
 
 	char * name_file_start = malloc(128*sizeof(char));
 	strcpy(name_file_start, "STARPU_DISK_COMPUTE_DATA_");

+ 1 - 1
tests/disk/disk_copy.c

@@ -41,7 +41,7 @@ int main(int argc, char **argv)
 	if (ret == -ENODEV) goto enodev;
 
 	/* register a disk */
-	int new_dd = starpu_disk_register(&starpu_disk_unistd_ops, (void *) "/tmp/", 1024*1024*200);
+	int new_dd = starpu_disk_register(&starpu_disk_unistd_ops, (void *) "/tmp", 1024*1024*200);
 	/* can't write on /tmp/ */
 	if (new_dd == -ENOENT) goto enoent;