Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/loginutils/getty.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 22  Line 22 
22  #include <utmp.h> /* updwtmp() */  #include <utmp.h> /* updwtmp() */
23  #endif  #endif
24    
25    #ifndef IUCLC
26    # define IUCLC 0
27    #endif
28    
29  /*  /*
30   * Some heuristics to find out what environment we are in: if it is not   * Some heuristics to find out what environment we are in: if it is not
31   * System V, assume it is SunOS 4.   * System V, assume it is SunOS 4.
32   */   */
33  #ifdef LOGIN_PROCESS                    /* defined in System V utmp.h */  #ifdef LOGIN_PROCESS                    /* defined in System V utmp.h */
34  #include <sys/utsname.h>  #include <sys/utsname.h>
 #include <time.h>  
35  #else /* if !sysV style, wtmp/utmp code is off */  #else /* if !sysV style, wtmp/utmp code is off */
36  #undef ENABLE_FEATURE_UTMP  #undef ENABLE_FEATURE_UTMP
37  #undef ENABLE_FEATURE_WTMP  #undef ENABLE_FEATURE_WTMP
# Line 164  static void parse_speeds(struct options Line 167  static void parse_speeds(struct options
167   debug("entered parse_speeds\n");   debug("entered parse_speeds\n");
168   while ((cp = strsep(&arg, ",")) != NULL) {   while ((cp = strsep(&arg, ",")) != NULL) {
169   op->speeds[op->numspeed] = bcode(cp);   op->speeds[op->numspeed] = bcode(cp);
170   if (op->speeds[op->numspeed] <= 0)   if (op->speeds[op->numspeed] < 0)
171   bb_error_msg_and_die("bad speed: %s", cp);   bb_error_msg_and_die("bad speed: %s", cp);
172     /* note: arg "0" turns into speed B0 */
173   op->numspeed++;   op->numspeed++;
174   if (op->numspeed > MAX_SPEED)   if (op->numspeed > MAX_SPEED)
175   bb_error_msg_and_die("too many alternate speeds");   bb_error_msg_and_die("too many alternate speeds");
# Line 235  static void open_tty(const char *tty) Line 239  static void open_tty(const char *tty)
239  // cur_dir_fd = xopen(".", O_DIRECTORY | O_NONBLOCK);  // cur_dir_fd = xopen(".", O_DIRECTORY | O_NONBLOCK);
240  // xchdir("/dev");  // xchdir("/dev");
241  // xstat(tty, &st);  // xstat(tty, &st);
242  // if ((st.st_mode & S_IFMT) != S_IFCHR)  // if (!S_ISCHR(st.st_mode))
243  // bb_error_msg_and_die("%s: not a character device", tty);  // bb_error_msg_and_die("%s: not a character device", tty);
244    
245   if (tty[0] != '/')   if (tty[0] != '/')
# Line 271  static void open_tty(const char *tty) Line 275  static void open_tty(const char *tty)
275  /* termios_init - initialize termios settings */  /* termios_init - initialize termios settings */
276  static void termios_init(struct termios *tp, int speed, struct options *op)  static void termios_init(struct termios *tp, int speed, struct options *op)
277  {  {
278     speed_t ispeed, ospeed;
279   /*   /*
280   * Initial termios settings: 8-bit characters, raw-mode, blocking i/o.   * Initial termios settings: 8-bit characters, raw-mode, blocking i/o.
281   * Special characters are set after we have read the login name; all   * Special characters are set after we have read the login name; all
# Line 281  static void termios_init(struct termios Line 286  static void termios_init(struct termios
286   /* flush input and output queues, important for modems! */   /* flush input and output queues, important for modems! */
287   ioctl(0, TCFLSH, TCIOFLUSH); /* tcflush(0, TCIOFLUSH)? - same */   ioctl(0, TCFLSH, TCIOFLUSH); /* tcflush(0, TCIOFLUSH)? - same */
288  #endif  #endif
289     ispeed = ospeed = speed;
290   tp->c_cflag = CS8 | HUPCL | CREAD | speed;   if (speed == B0) {
291     /* Speed was specified as "0" on command line.
292     * Just leave it unchanged */
293     ispeed = cfgetispeed(tp);
294     ospeed = cfgetospeed(tp);
295     }
296     tp->c_cflag = CS8 | HUPCL | CREAD;
297   if (op->flags & F_LOCAL)   if (op->flags & F_LOCAL)
298   tp->c_cflag |= CLOCAL;   tp->c_cflag |= CLOCAL;
299     cfsetispeed(tp, ispeed);
300     cfsetospeed(tp, ospeed);
301    
302   tp->c_iflag = tp->c_lflag = tp->c_line = 0;   tp->c_iflag = tp->c_lflag = tp->c_line = 0;
303   tp->c_oflag = OPOST | ONLCR;   tp->c_oflag = OPOST | ONLCR;
# Line 474  static char *get_logname(char *logname, Line 487  static char *get_logname(char *logname,
487   case CTL('D'):   case CTL('D'):
488   exit(EXIT_SUCCESS);   exit(EXIT_SUCCESS);
489   default:   default:
490   if (!isascii(ascval) || !isprint(ascval)) {   if (ascval < ' ') {
491   /* ignore garbage characters */   /* ignore garbage characters */
492   } else if ((int)(bp - logname) >= size_logname - 1) {   } else if ((int)(bp - logname) >= size_logname - 1) {
493   bb_error_msg_and_die("%s: input overrun", op->tty);   bb_error_msg_and_die("%s: input overrun", op->tty);
# Line 570  static void touch(const char *filename) Line 583  static void touch(const char *filename)
583  }  }
584    
585  /* update_utmp - update our utmp entry */  /* update_utmp - update our utmp entry */
586  static void update_utmp(const char *line, char *fakehost)  static NOINLINE void update_utmp(const char *line, char *fakehost)
587  {  {
588   struct utmp ut;   struct utmp ut;
589   struct utmp *utp;   struct utmp *utp;
# Line 714  int getty_main(int argc UNUSED_PARAM, ch Line 727  int getty_main(int argc UNUSED_PARAM, ch
727   /* Write the modem init string and DON'T flush the buffers */   /* Write the modem init string and DON'T flush the buffers */
728   if (options.flags & F_INITSTRING) {   if (options.flags & F_INITSTRING) {
729   debug("writing init string\n");   debug("writing init string\n");
730     /* todo: use xwrite_str? */
731   full_write(STDOUT_FILENO, options.initstring, strlen(options.initstring));   full_write(STDOUT_FILENO, options.initstring, strlen(options.initstring));
732   }   }
733    
# Line 753  int getty_main(int argc UNUSED_PARAM, ch Line 767  int getty_main(int argc UNUSED_PARAM, ch
767   break;   break;
768   /* we are here only if options.numspeed > 1 */   /* we are here only if options.numspeed > 1 */
769   baud_index = (baud_index + 1) % options.numspeed;   baud_index = (baud_index + 1) % options.numspeed;
770   termios.c_cflag &= ~CBAUD;   cfsetispeed(&termios, options.speeds[baud_index]);
771   termios.c_cflag |= options.speeds[baud_index];   cfsetospeed(&termios, options.speeds[baud_index]);
772   tcsetattr_stdin_TCSANOW(&termios);   tcsetattr_stdin_TCSANOW(&termios);
773   }   }
774   }   }

Legend:
Removed from v.983  
changed lines
  Added in v.984