Changeset 1765 in MondoRescue for branches/2.2.5/mindi-busybox/init/mesg.c


Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (17 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/init/mesg.c

    r821 r1765  
    88 */
    99
    10 #include "busybox.h"
    11 #include <unistd.h>
    12 #include <stdlib.h>
     10#include "libbb.h"
    1311
    1412#ifdef USE_TTY_GROUP
     
    1816#endif
    1917
    20 int mesg_main(int argc, char *argv[])
     18int mesg_main(int argc, char **argv);
     19int mesg_main(int argc, char **argv)
    2120{
    2221    struct stat sb;
    23     char *tty;
     22    const char *tty;
    2423    char c = 0;
    2524
    26     if ((--argc == 0)
    27         || ((argc == 1) && (((c = **++argv) == 'y') || (c == 'n')))) {
    28         if ((tty = ttyname(STDERR_FILENO)) == NULL) {
     25    if (--argc == 0
     26     || (argc == 1 && ((c = **++argv) == 'y' || c == 'n'))
     27    ) {
     28        tty = ttyname(STDERR_FILENO);
     29        if (tty == NULL) {
    2930            tty = "ttyname";
    3031        } else if (stat(tty, &sb) == 0) {
     32            mode_t m;
    3133            if (argc == 0) {
    32                 puts(((sb.st_mode & (S_IWGRP | S_IWOTH)) ==
    33                       0) ? "is n" : "is y");
     34                puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n");
    3435                return EXIT_SUCCESS;
    3536            }
    36             if (chmod
    37                 (tty,
    38                  (c ==
    39                   'y') ? sb.st_mode | (S_IWGRP_OR_S_IWOTH) : sb.
    40                  st_mode & ~(S_IWGRP | S_IWOTH)) == 0) {
     37            m = (c == 'y') ? sb.st_mode | S_IWGRP_OR_S_IWOTH
     38                           : sb.st_mode & ~(S_IWGRP|S_IWOTH);
     39            if (chmod(tty, m) == 0) {
    4140                return EXIT_SUCCESS;
    4241            }
Note: See TracChangeset for help on using the changeset viewer.