Lines Matching defs:dir
30 char dir[512] = { '\0' };
43 strlcpy(dir, home, sizeof(dir));
46 strlcat(dir, uml_dir, sizeof(dir));
47 len = strlen(dir);
48 if (len > 0 && dir[len - 1] != '/')
49 strlcat(dir, "/", sizeof(dir));
52 uml_dir = malloc(strlen(dir) + 1);
58 strcpy(uml_dir, dir);
76 * Unlinks the files contained in @dir and then removes @dir.
81 static int remove_files_and_dir(char *dir)
89 directory = opendir(dir);
100 len = strlen(dir) + strlen("/") + strlen(ent->d_name) + 1;
106 sprintf(file, "%s/%s", dir, ent->d_name);
113 if (rmdir(dir) < 0 && errno != ENOENT) {
136 static inline int is_umdir_used(char *dir)
140 size_t filelen = strlen(dir) + sizeof("/pid") + 1;
146 snprintf(file, filelen, "%s/pid", dir);
192 * Try to remove the directory @dir unless it's in use.
193 * Precondition: @dir exists.
197 static int umdir_take_if_dead(char *dir)
200 if (is_umdir_used(dir))
203 ret = remove_files_and_dir(dir);
394 char *dir, err;
396 dir = malloc(strlen(uml_dir) + UMID_LEN + 1);
397 if (!dir)
400 sprintf(dir, "%s%s", uml_dir, umid);
401 err = remove_files_and_dir(dir);
406 free(dir);