Changeset 132

Show
Ignore:
Timestamp:
03/05/06 01:11:46 (3 years ago)
Author:
bonbons
Message:

vmount:

Fixed incorrect construction of linked list of fstab entries
(was causing only first and last etry to get mounted)

vexec:

Improved code on using /dev/console

  • using STD*_FILENO constants
  • using ioctl to get rid of incorrect controlling tty info
    Swapped order of chroot and context migration

vlogin:

Swapped order of chroot and context migration

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0.4/src/tools/vexec.c

    r130 r132  
    3333#include <vserver.h> 
    3434#include <errno.h> 
     35#include <sys/ioctl.h> 
    3536 
    3637#include "printf.h" 
     
    169170                                        PEXIT("Failed to set context flags", EXIT_COMMAND); 
    170171                        } 
    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); 
    174172                         
    175173                        /* chroot to cwd */ 
     
    181179                                        PEXIT("Failed to chroot to cwd", EXIT_COMMAND); 
    182180                        } 
     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); 
    183185                         
    184186                        // TODO: change TTY and stdin/out to something sensible for the guest! 
     
    191193                                } else if (S_ISCHR(st.st_mode)) { 
    192194                                        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                                        } 
    198205                                } else 
    199206                                        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  
    311311                        PEXIT("Failed to restore cwd", EXIT_COMMAND); 
    312312        } 
     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); 
    313320         
    314321        /* enter context */ 
     
    329336        if (openpty(&t.fd, &slave, NULL, NULL, NULL) == -1) 
    330337                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); 
    338338         
    339339        pid_t pid = fork(); 
  • branches/1.0.4/src/tools/vmount.c

    r130 r132  
    210210                        if (first && last) 
    211211                                last->next = tmp; 
    212                         else { 
    213                                 last = tmp; 
     212                        else 
    214213                                first = tmp; 
    215                         } 
     214                        last = tmp; 
    216215                        n++; 
    217216                } 
     
    293292         
    294293error: 
    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)); 
    296295        return -1; 
    297296