Importing usr.bin/mesg

Replaces commands/mesg. No Minix-specific changes needed.

Change-Id: Ief22ad7f050f8083d0b43a4ea90b348c504d99a2
This commit is contained in:
Thomas Cort
2013-10-25 12:14:32 -04:00
parent 93ce9b1174
commit b36343fc42
10 changed files with 207 additions and 93 deletions

View File

@@ -15,7 +15,7 @@ SUBDIR= add_route arp ash at backup btrace \
intr ipcrm ipcs irdpd isoread last \
less loadkeys loadramdisk logger look lp \
lpd lspci mail MAKEDEV \
mesg mined mkfifo \
mined mkfifo \
mount mt netconf \
nonamed od paste patch \
ping postinstall poweroff prep printroot \

View File

@@ -1,4 +0,0 @@
PROG= mesg
MAN=
.include <bsd.prog.mk>

View File

@@ -1,48 +0,0 @@
/* mesg - enable or disable communications. Author: John J. Ribera */
/*
* mesg - enable or disable communications.
*
* Usage: mesg [ y | n ]
*
* 'mesg n' will turn off group and world permissions of the
* user's terminal.
* 'mesg y' will enable group and world to write to the user's
* tty.
* mesg with no parameters will put the writeable status
* onto stdout.
*
* Author: John J. Ribera, Jr. 09/09/90
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv []);
int main(argc, argv)
int argc;
char *argv[];
{
struct stat statb;
char *tty_name;
if ((tty_name = ttyname(0)) == NULL) exit(2);
if (stat(tty_name, &statb) == -1) exit(2);
if (--argc) {
if (*argv[1] == 'n') statb.st_mode = 0600;
else if (*argv[1] == 'y') statb.st_mode = 0620;
else {
fprintf(stderr, "mesg: usage: mesg [n|y]\n");
exit(2);
}
if (chmod(tty_name, statb.st_mode) == -1) exit(2);
} else printf((statb.st_mode & 020) ? "is y\n" : "is n\n");
if (statb.st_mode & 020) exit(0);
exit(1);
}