#include <sys/param.h>
+/* Modified by which_tmpdir, which is called during early boot */
static char *default_tmpdir = "/tmp";
+
+/*
+ * Modified when creating the physical memory file and when checking
+ * the tmp filesystem for usability, both happening during early boot.
+ */
static char *tempdir = NULL;
static void __init find_tempdir(void)
int i;
char *dir = NULL;
- if(tempdir != NULL) return; /* We've already been called */
+ if(tempdir != NULL) /* We've already been called */
+ return;
for(i = 0; dirs[i]; i++){
dir = getenv(dirs[i]);
if((dir != NULL) && (*dir != '\0'))
return 1;
}
+/* which_tmpdir is called only during early boot */
static int checked_tmpdir = 0;
/* Look for a tmpfs mounted at /dev/shm. I couldn't find a cleaner
else if(found < 0)
printf("read returned errno %d\n", -found);
+out:
+ close(fd);
+
return;
found:
if(strncmp(buf, "tmpfs", strlen("tmpfs"))){
printf("not tmpfs\n");
- return;
+ goto out;
}
printf("OK\n");
default_tmpdir = "/dev/shm";
+ goto out;
}
/*
} else {
free(tempname);
}
- return(fd);
+ return fd;
out:
free(tempname);
return -1;
exit(1);
}
- return(fd);
+ return fd;
}
int create_mem_file(unsigned long long len)
errno = -err;
perror("exec_close");
}
- return(fd);
+ return fd;
}