Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit b7d93c2

Browse files
committed
do unlink/symlink /dev/ptmx when hyperstart starts
Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
1 parent f6e080e commit b7d93c2

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/container.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,16 +313,12 @@ static int container_setup_mount(struct hyper_container *container)
313313
return -1;
314314
}
315315

316-
if (unlink("./dev/ptmx") < 0) {
317-
perror("remove /dev/ptmx failed");
318-
return -1;
319-
}
320-
if (symlink("/dev/pts/ptmx", "./dev/ptmx") < 0) {
316+
/* all containers share the same devtmpfs, so we need to ignore the errno EEXIST */
317+
if (symlink("/dev/pts/ptmx", "./dev/ptmx") < 0 && errno != EEXIST) {
321318
perror("link /dev/pts/ptmx to /dev/ptmx failed");
322319
return -1;
323320
}
324321

325-
/* all containers share the same devtmpfs, so we need to ignore the errno EEXIST */
326322
if ((symlink("/proc/self/fd", "./dev/fd") < 0 && errno != EEXIST) ||
327323
(symlink("/proc/self/fd/0", "./dev/stdin") < 0 && errno != EEXIST) ||
328324
(symlink("/proc/self/fd/1", "./dev/stdout") < 0 && errno != EEXIST) ||

src/init.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,15 @@ int main(int argc, char *argv[])
13801380
return -1;
13811381
}
13821382

1383+
if (unlink("/dev/ptmx") < 0) {
1384+
perror("remove /dev/ptmx failed");
1385+
return -1;
1386+
}
1387+
if (symlink("/dev/pts/ptmx", "/dev/ptmx") < 0) {
1388+
perror("link /dev/pts/ptmx to /dev/ptmx failed");
1389+
return -1;
1390+
}
1391+
13831392
cmdline = read_cmdline();
13841393

13851394
setsid();

0 commit comments

Comments
 (0)