Annotation of /trunk/mkinitrd-magellan/busybox/init/mesg.c
Parent Directory | Revision Log
Revision 984 -
(hide annotations)
(download)
Sun May 30 11:32:42 2010 UTC (14 years ago) by niro
File MIME type: text/plain
File size: 1064 byte(s)
Sun May 30 11:32:42 2010 UTC (14 years ago) by niro
File MIME type: text/plain
File size: 1064 byte(s)
-updated to busybox-1.16.1 and enabled blkid/uuid support in default config
1 | niro | 532 | /* vi: set sw=4 ts=4: */ |
2 | /* | ||
3 | * mesg implementation for busybox | ||
4 | * | ||
5 | * Copyright (c) 2002 Manuel Novoa III <mjn3@codepoet.org> | ||
6 | * | ||
7 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. | ||
8 | */ | ||
9 | |||
10 | niro | 816 | #include "libbb.h" |
11 | niro | 532 | |
12 | #ifdef USE_TTY_GROUP | ||
13 | #define S_IWGRP_OR_S_IWOTH S_IWGRP | ||
14 | #else | ||
15 | #define S_IWGRP_OR_S_IWOTH (S_IWGRP | S_IWOTH) | ||
16 | #endif | ||
17 | |||
18 | niro | 816 | int mesg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
19 | niro | 984 | int mesg_main(int argc UNUSED_PARAM, char **argv) |
20 | niro | 532 | { |
21 | struct stat sb; | ||
22 | niro | 816 | const char *tty; |
23 | niro | 532 | char c = 0; |
24 | |||
25 | niro | 984 | argv++; |
26 | |||
27 | if (!argv[0] | ||
28 | || (!argv[1] && ((c = argv[0][0]) == 'y' || c == 'n')) | ||
29 | niro | 816 | ) { |
30 | niro | 984 | tty = xmalloc_ttyname(STDERR_FILENO); |
31 | niro | 816 | if (tty == NULL) { |
32 | niro | 532 | tty = "ttyname"; |
33 | } else if (stat(tty, &sb) == 0) { | ||
34 | niro | 816 | mode_t m; |
35 | niro | 984 | if (c == 0) { |
36 | niro | 816 | puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n"); |
37 | niro | 532 | return EXIT_SUCCESS; |
38 | } | ||
39 | niro | 816 | m = (c == 'y') ? sb.st_mode | S_IWGRP_OR_S_IWOTH |
40 | : sb.st_mode & ~(S_IWGRP|S_IWOTH); | ||
41 | if (chmod(tty, m) == 0) { | ||
42 | niro | 532 | return EXIT_SUCCESS; |
43 | } | ||
44 | } | ||
45 | niro | 816 | bb_simple_perror_msg_and_die(tty); |
46 | niro | 532 | } |
47 | bb_show_usage(); | ||
48 | } |