Annotation of /trunk/mkinitrd-magellan/busybox/miscutils/wall.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: 837 byte(s)
Sun May 30 11:32:42 2010 UTC (14 years ago) by niro
File MIME type: text/plain
File size: 837 byte(s)
-updated to busybox-1.16.1 and enabled blkid/uuid support in default config
1 | niro | 984 | /* vi: set sw=4 ts=4: */ |
2 | /* | ||
3 | * wall - write a message to all logged-in users | ||
4 | * Copyright (c) 2009 Bernhard Reutner-Fischer | ||
5 | * | ||
6 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | ||
7 | */ | ||
8 | |||
9 | #include "libbb.h" | ||
10 | #include <utmp.h> | ||
11 | |||
12 | int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
13 | int wall_main(int argc UNUSED_PARAM, char **argv) | ||
14 | { | ||
15 | struct utmp *ut; | ||
16 | char *msg; | ||
17 | int fd = argv[1] ? xopen(argv[1], O_RDONLY) : STDIN_FILENO; | ||
18 | |||
19 | msg = xmalloc_read(fd, NULL); | ||
20 | if (ENABLE_FEATURE_CLEAN_UP && argv[1]) | ||
21 | close(fd); | ||
22 | setutent(); | ||
23 | while ((ut = getutent()) != NULL) { | ||
24 | char *line; | ||
25 | if (ut->ut_type != USER_PROCESS) | ||
26 | continue; | ||
27 | line = concat_path_file("/dev", ut->ut_line); | ||
28 | xopen_xwrite_close(line, msg); | ||
29 | free(line); | ||
30 | } | ||
31 | if (ENABLE_FEATURE_CLEAN_UP) { | ||
32 | endutent(); | ||
33 | free(msg); | ||
34 | } | ||
35 | return EXIT_SUCCESS; | ||
36 | } |