Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <unistd.h> |
| 3 | #include <stdlib.h> |
| 4 | #include <string.h> |
| 5 | #include <errno.h> |
| 6 | #include <signal.h> |
| 7 | #include <dirent.h> |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 8 | #include <sys/fcntl.h> |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 9 | #include <sys/stat.h> |
| 10 | #include <sys/param.h> |
| 11 | #include "init.h" |
| 12 | #include "os.h" |
| 13 | #include "user.h" |
| 14 | #include "mode.h" |
| 15 | |
| 16 | #define UML_DIR "~/.uml/" |
| 17 | |
| 18 | #define UMID_LEN 64 |
| 19 | |
| 20 | /* Changed by set_umid, which is run early in boot */ |
| 21 | char umid[UMID_LEN] = { 0 }; |
| 22 | |
| 23 | /* Changed by set_uml_dir and make_uml_dir, which are run early in boot */ |
| 24 | static char *uml_dir = UML_DIR; |
| 25 | |
| 26 | static int __init make_uml_dir(void) |
| 27 | { |
| 28 | char dir[512] = { '\0' }; |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 29 | int len, err; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 30 | |
| 31 | if(*uml_dir == '~'){ |
| 32 | char *home = getenv("HOME"); |
| 33 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 34 | err = -ENOENT; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 35 | if(home == NULL){ |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 36 | printk("make_uml_dir : no value in environment for " |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 37 | "$HOME\n"); |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 38 | goto err; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 39 | } |
| 40 | strlcpy(dir, home, sizeof(dir)); |
| 41 | uml_dir++; |
| 42 | } |
| 43 | strlcat(dir, uml_dir, sizeof(dir)); |
| 44 | len = strlen(dir); |
| 45 | if (len > 0 && dir[len - 1] != '/') |
| 46 | strlcat(dir, "/", sizeof(dir)); |
| 47 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 48 | err = -ENOMEM; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 49 | uml_dir = malloc(strlen(dir) + 1); |
| 50 | if (uml_dir == NULL) { |
| 51 | printf("make_uml_dir : malloc failed, errno = %d\n", errno); |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 52 | goto err; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 53 | } |
| 54 | strcpy(uml_dir, dir); |
| 55 | |
| 56 | if((mkdir(uml_dir, 0777) < 0) && (errno != EEXIST)){ |
| 57 | printf("Failed to mkdir '%s': %s\n", uml_dir, strerror(errno)); |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 58 | err = -errno; |
| 59 | goto err_free; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 60 | } |
| 61 | return 0; |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 62 | |
| 63 | err_free: |
| 64 | free(uml_dir); |
| 65 | err: |
| 66 | uml_dir = NULL; |
| 67 | return err; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | static int actually_do_remove(char *dir) |
| 71 | { |
| 72 | DIR *directory; |
| 73 | struct dirent *ent; |
| 74 | int len; |
| 75 | char file[256]; |
| 76 | |
| 77 | directory = opendir(dir); |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 78 | if(directory == NULL) |
| 79 | return -errno; |
| 80 | |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 81 | while((ent = readdir(directory)) != NULL){ |
| 82 | if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) |
| 83 | continue; |
| 84 | len = strlen(dir) + sizeof("/") + strlen(ent->d_name) + 1; |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 85 | if(len > sizeof(file)) |
| 86 | return -E2BIG; |
| 87 | |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 88 | sprintf(file, "%s/%s", dir, ent->d_name); |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 89 | if(unlink(file) < 0) |
| 90 | return -errno; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 91 | } |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 92 | if(rmdir(dir) < 0) |
| 93 | return -errno; |
| 94 | |
| 95 | return 0; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 96 | } |
| 97 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 98 | /* This says that there isn't already a user of the specified directory even if |
| 99 | * there are errors during the checking. This is because if these errors |
| 100 | * happen, the directory is unusable by the pre-existing UML, so we might as |
| 101 | * well take it over. This could happen either by |
| 102 | * the existing UML somehow corrupting its umid directory |
| 103 | * something other than UML sticking stuff in the directory |
| 104 | * this boot racing with a shutdown of the other UML |
| 105 | * In any of these cases, the directory isn't useful for anything else. |
| 106 | */ |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 107 | |
| 108 | static int not_dead_yet(char *dir) |
| 109 | { |
| 110 | char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; |
| 111 | char pid[sizeof("nnnnn\0")], *end; |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 112 | int dead, fd, p, n, err; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 113 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 114 | n = snprintf(file, sizeof(file), "%s/pid", dir); |
| 115 | if(n >= sizeof(file)){ |
| 116 | printk("not_dead_yet - pid filename too long\n"); |
| 117 | err = -E2BIG; |
| 118 | goto out; |
| 119 | } |
| 120 | |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 121 | dead = 0; |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 122 | fd = open(file, O_RDONLY); |
Paolo 'Blaisorblade' Giarrusso | d84a19c | 2006-04-10 22:53:38 -0700 | [diff] [blame] | 123 | if(fd < 0) { |
| 124 | fd = -errno; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 125 | if(fd != -ENOENT){ |
| 126 | printk("not_dead_yet : couldn't open pid file '%s', " |
| 127 | "err = %d\n", file, -fd); |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 128 | } |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 129 | goto out; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 130 | } |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 131 | |
| 132 | err = 0; |
| 133 | n = read(fd, pid, sizeof(pid)); |
Paolo 'Blaisorblade' Giarrusso | d84a19c | 2006-04-10 22:53:38 -0700 | [diff] [blame] | 134 | if(n < 0){ |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 135 | printk("not_dead_yet : couldn't read pid file '%s', " |
Paolo 'Blaisorblade' Giarrusso | d84a19c | 2006-04-10 22:53:38 -0700 | [diff] [blame] | 136 | "err = %d\n", file, errno); |
| 137 | goto out_close; |
| 138 | } else if(n == 0){ |
| 139 | printk("not_dead_yet : couldn't read pid file '%s', " |
| 140 | "0-byte read\n", file); |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 141 | goto out_close; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 142 | } |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 143 | |
| 144 | p = strtoul(pid, &end, 0); |
| 145 | if(end == pid){ |
| 146 | printk("not_dead_yet : couldn't parse pid file '%s', " |
| 147 | "errno = %d\n", file, errno); |
| 148 | goto out_close; |
| 149 | } |
| 150 | |
Jeff Dike | 1fbbd684 | 2006-03-27 01:14:39 -0800 | [diff] [blame] | 151 | if((kill(p, 0) == 0) || (errno != ESRCH)){ |
| 152 | printk("umid \"%s\" is already in use by pid %d\n", umid, p); |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 153 | return 1; |
Jeff Dike | 1fbbd684 | 2006-03-27 01:14:39 -0800 | [diff] [blame] | 154 | } |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 155 | |
| 156 | err = actually_do_remove(dir); |
| 157 | if(err) |
| 158 | printk("not_dead_yet - actually_do_remove failed with " |
| 159 | "err = %d\n", err); |
| 160 | |
| 161 | return err; |
| 162 | |
Paolo 'Blaisorblade' Giarrusso | d84a19c | 2006-04-10 22:53:38 -0700 | [diff] [blame] | 163 | out_close: |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 164 | close(fd); |
Paolo 'Blaisorblade' Giarrusso | d84a19c | 2006-04-10 22:53:38 -0700 | [diff] [blame] | 165 | out: |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 166 | return 0; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | static void __init create_pid_file(void) |
| 170 | { |
| 171 | char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; |
| 172 | char pid[sizeof("nnnnn\0")]; |
| 173 | int fd, n; |
| 174 | |
| 175 | if(umid_file_name("pid", file, sizeof(file))) |
| 176 | return; |
| 177 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 178 | fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0644); |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 179 | if(fd < 0){ |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 180 | printk("Open of machine pid file \"%s\" failed: %s\n", |
Jeff Dike | 2ace87b | 2006-05-01 12:16:00 -0700 | [diff] [blame] | 181 | file, strerror(errno)); |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 182 | return; |
| 183 | } |
| 184 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 185 | snprintf(pid, sizeof(pid), "%d\n", getpid()); |
| 186 | n = write(fd, pid, strlen(pid)); |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 187 | if(n != strlen(pid)) |
Jeff Dike | 2ace87b | 2006-05-01 12:16:00 -0700 | [diff] [blame] | 188 | printk("Write of pid file failed - err = %d\n", errno); |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 189 | |
| 190 | close(fd); |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 191 | } |
| 192 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 193 | int __init set_umid(char *name) |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 194 | { |
| 195 | if(strlen(name) > UMID_LEN - 1) |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 196 | return -E2BIG; |
| 197 | |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 198 | strlcpy(umid, name, sizeof(umid)); |
| 199 | |
| 200 | return 0; |
| 201 | } |
| 202 | |
| 203 | static int umid_setup = 0; |
| 204 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 205 | int __init make_umid(void) |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 206 | { |
| 207 | int fd, err; |
| 208 | char tmp[256]; |
| 209 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 210 | if(umid_setup) |
| 211 | return 0; |
| 212 | |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 213 | make_uml_dir(); |
| 214 | |
| 215 | if(*umid == '\0'){ |
| 216 | strlcpy(tmp, uml_dir, sizeof(tmp)); |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 217 | strlcat(tmp, "XXXXXX", sizeof(tmp)); |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 218 | fd = mkstemp(tmp); |
| 219 | if(fd < 0){ |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 220 | printk("make_umid - mkstemp(%s) failed: %s\n", |
| 221 | tmp, strerror(errno)); |
| 222 | err = -errno; |
| 223 | goto err; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 224 | } |
| 225 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 226 | close(fd); |
| 227 | |
| 228 | set_umid(&tmp[strlen(uml_dir)]); |
| 229 | |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 230 | /* There's a nice tiny little race between this unlink and |
| 231 | * the mkdir below. It'd be nice if there were a mkstemp |
| 232 | * for directories. |
| 233 | */ |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 234 | if(unlink(tmp)){ |
| 235 | err = -errno; |
| 236 | goto err; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 237 | } |
| 238 | } |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 239 | |
| 240 | snprintf(tmp, sizeof(tmp), "%s%s", uml_dir, umid); |
| 241 | err = mkdir(tmp, 0777); |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 242 | if(err < 0){ |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 243 | err = -errno; |
Jeff Dike | 1fbbd684 | 2006-03-27 01:14:39 -0800 | [diff] [blame] | 244 | if(err != -EEXIST) |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 245 | goto err; |
| 246 | |
Jeff Dike | 1fbbd684 | 2006-03-27 01:14:39 -0800 | [diff] [blame] | 247 | /* 1 -> this umid is already in use |
| 248 | * < 0 -> we couldn't remove the umid directory |
| 249 | * In either case, we can't use this umid, so return -EEXIST. |
| 250 | */ |
| 251 | if(not_dead_yet(tmp) != 0) |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 252 | goto err; |
| 253 | |
| 254 | err = mkdir(tmp, 0777); |
| 255 | } |
Jeff Dike | 1fbbd684 | 2006-03-27 01:14:39 -0800 | [diff] [blame] | 256 | if(err){ |
| 257 | err = -errno; |
| 258 | printk("Failed to create '%s' - err = %d\n", umid, -errno); |
| 259 | goto err; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | umid_setup = 1; |
| 263 | |
| 264 | create_pid_file(); |
| 265 | |
Jeff Dike | 1fbbd684 | 2006-03-27 01:14:39 -0800 | [diff] [blame] | 266 | err = 0; |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 267 | err: |
| 268 | return err; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | static int __init make_umid_init(void) |
| 272 | { |
Jeff Dike | 1fbbd684 | 2006-03-27 01:14:39 -0800 | [diff] [blame] | 273 | if(!make_umid()) |
| 274 | return 0; |
| 275 | |
| 276 | /* If initializing with the given umid failed, then try again with |
| 277 | * a random one. |
| 278 | */ |
| 279 | printk("Failed to initialize umid \"%s\", trying with a random umid\n", |
| 280 | umid); |
| 281 | *umid = '\0'; |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 282 | make_umid(); |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 283 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 284 | return 0; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | __initcall(make_umid_init); |
| 288 | |
| 289 | int __init umid_file_name(char *name, char *buf, int len) |
| 290 | { |
| 291 | int n, err; |
| 292 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 293 | err = make_umid(); |
| 294 | if(err) |
| 295 | return err; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 296 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 297 | n = snprintf(buf, len, "%s%s/%s", uml_dir, umid, name); |
| 298 | if(n >= len){ |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 299 | printk("umid_file_name : buffer too short\n"); |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 300 | return -E2BIG; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 301 | } |
| 302 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 303 | return 0; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 304 | } |
| 305 | |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 306 | char *get_umid(void) |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 307 | { |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 308 | return umid; |
| 309 | } |
| 310 | |
| 311 | static int __init set_uml_dir(char *name, int *add) |
| 312 | { |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 313 | if(*name == '\0'){ |
| 314 | printf("uml_dir can't be an empty string\n"); |
| 315 | return 0; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 316 | } |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 317 | |
| 318 | if(name[strlen(name) - 1] == '/'){ |
| 319 | uml_dir = name; |
| 320 | return 0; |
| 321 | } |
| 322 | |
| 323 | uml_dir = malloc(strlen(name) + 2); |
| 324 | if(uml_dir == NULL){ |
| 325 | printf("Failed to malloc uml_dir - error = %d\n", errno); |
| 326 | |
| 327 | /* Return 0 here because do_initcalls doesn't look at |
| 328 | * the return value. |
| 329 | */ |
| 330 | return 0; |
| 331 | } |
| 332 | sprintf(uml_dir, "%s/", name); |
| 333 | |
| 334 | return 0; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | __uml_setup("uml_dir=", set_uml_dir, |
| 338 | "uml_dir=<directory>\n" |
| 339 | " The location to place the pid and umid files.\n\n" |
| 340 | ); |
| 341 | |
| 342 | static void remove_umid_dir(void) |
| 343 | { |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 344 | char dir[strlen(uml_dir) + UMID_LEN + 1], err; |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 345 | |
| 346 | sprintf(dir, "%s%s", uml_dir, umid); |
Jeff Dike | 7eebe8a | 2006-01-06 00:19:01 -0800 | [diff] [blame] | 347 | err = actually_do_remove(dir); |
| 348 | if(err) |
| 349 | printf("remove_umid_dir - actually_do_remove failed with " |
| 350 | "err = %d\n", err); |
Jeff Dike | 2264c475 | 2006-01-06 00:18:59 -0800 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | __uml_exitcall(remove_umid_dir); |