Changeset 132
- Timestamp:
- 03/05/06 01:11:46 (3 years ago)
- Files:
-
- branches/1.0.4/src/tools/vexec.c (modified) (4 diffs)
- branches/1.0.4/src/tools/vlogin.c (modified) (2 diffs)
- branches/1.0.4/src/tools/vmount.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0.4/src/tools/vexec.c
r130 r132 33 33 #include <vserver.h> 34 34 #include <errno.h> 35 #include <sys/ioctl.h> 35 36 36 37 #include "printf.h" … … 169 170 PEXIT("Failed to set context flags", EXIT_COMMAND); 170 171 } 171 DEBUGF("Migrating with mflags=%lx\n", mflags.flags);172 if (vx_migrate(opts.xid, &mflags) == -1)173 PEXIT("Failed to migrate to context", EXIT_COMMAND);174 172 175 173 /* chroot to cwd */ … … 181 179 PEXIT("Failed to chroot to cwd", EXIT_COMMAND); 182 180 } 181 182 DEBUGF("Migrating with mflags=%lx\n", mflags.flags); 183 if (vx_migrate(opts.xid, &mflags) == -1) 184 PEXIT("Failed to migrate to context", EXIT_COMMAND); 183 185 184 186 // TODO: change TTY and stdin/out to something sensible for the guest! … … 191 193 } else if (S_ISCHR(st.st_mode)) { 192 194 int fd = open("/dev/console", O_RDWR); // O_NOCTTY); 193 if (fd < 0) vu_printf("Failed to open /dev/console: %s\n", strerror(errno)); 194 if (fd > 0) dup2(fd, 0); 195 if (fd >= 0 && fd != 1) dup2(fd, 1); 196 if (fd >= 0 && fd != 2) dup2(fd, 2); 197 if (fd > 2) close(fd); 195 if (fd < 0) { 196 vu_dprintf(STDERR_FILENO, "Failed to open /dev/console: %s\n", strerror(errno)); 197 } else { 198 ioctl(0, TIOCNOTTY, 0); 199 if (fd != STDIN_FILENO) dup2(fd, STDIN_FILENO); 200 if (fd != STDOUT_FILENO) dup2(fd, STDOUT_FILENO); 201 if (fd != STDERR_FILENO) dup2(fd, STDERR_FILENO); 202 if (fd != STDIN_FILENO && fd != STDERR_FILENO && fd != STDOUT_FILENO) 203 close(fd); 204 } 198 205 } else 199 206 vu_dprintf(STDERR_FILENO, "Cannot use /dev/console as it's not a character device.\n"); branches/1.0.4/src/tools/vlogin.c
r130 r132 311 311 PEXIT("Failed to restore cwd", EXIT_COMMAND); 312 312 } 313 314 /* chroot to cwd */ 315 if (chdir(".") == -1) 316 PEXIT("Failed to chdir to cwd", EXIT_COMMAND); 317 318 if (chroot(".") == -1) 319 PEXIT("Failed to chroot to cwd", EXIT_COMMAND); 313 320 314 321 /* enter context */ … … 329 336 if (openpty(&t.fd, &slave, NULL, NULL, NULL) == -1) 330 337 PEXIT("Failed to open new pseudo terminal", EXIT_COMMAND); 331 332 /* chroot to cwd */333 if (chdir(".") == -1)334 PEXIT("Failed to chdir to cwd", EXIT_COMMAND);335 336 if (chroot(".") == -1)337 PEXIT("Failed to chroot to cwd", EXIT_COMMAND);338 338 339 339 pid_t pid = fork(); branches/1.0.4/src/tools/vmount.c
r130 r132 210 210 if (first && last) 211 211 last->next = tmp; 212 else { 213 last = tmp; 212 else 214 213 first = tmp; 215 }214 last = tmp; 216 215 n++; 217 216 } … … 293 292 294 293 error: 295 vu_printf("Mount failed for '%s' type '%s' ", fsent->target, fsent->vfstype);294 vu_printf("Mount failed for '%s' type '%s': %s\n", fsent->target, fsent->vfstype, strerror(errno)); 296 295 return -1; 297 296
