diff -c -b /usr/src/sbin/dump/dump.8 ./jon/src/sbin/dump/dump.8 *** /usr/src/sbin/dump/dump.8 Sat Aug 18 22:33:40 2001 --- ./jon/src/sbin/dump/dump.8 Wed Nov 14 16:09:24 2001 *************** *** 42,48 **** .Nd filesystem backup .Sh SYNOPSIS .Nm ! .Op Fl 0123456789acknu .Op Fl B Ar records .Op Fl b Ar blocksize .Op Fl D Ar dumpdates --- 42,48 ---- .Nd filesystem backup .Sh SYNOPSIS .Nm ! .Op Fl 0123456789ackmnu .Op Fl B Ar records .Op Fl b Ar blocksize .Op Fl D Ar dumpdates *************** *** 178,190 **** available if this option was enabled when .Nm was compiled.) .It Fl n Whenever .Nm requires operator attention, notify all operators in the group .Dq operator ! by means similar to a .Xr wall 1 . .It Fl s Ar feet Attempt to calculate the amount of tape needed --- 178,198 ---- available if this option was enabled when .Nm was compiled.) + .It Fl m + Whenever + .Nm + requires operator attention, + notify the mail alias + .Dq operator + by use of + .Xr mail 1 . .It Fl n Whenever .Nm requires operator attention, notify all operators in the group .Dq operator ! by use of .Xr wall 1 . .It Fl s Ar feet Attempt to calculate the amount of tape needed diff -c -b /usr/src/sbin/dump/dump.h ./jon/src/sbin/dump/dump.h *** /usr/src/sbin/dump/dump.h Sat Oct 6 22:35:23 2001 --- ./jon/src/sbin/dump/dump.h Wed Nov 14 16:49:49 2001 *************** *** 79,84 **** --- 79,86 ---- int unlimited; /* if set, write to end of medium */ int notify; /* notify operator flag */ + int mail; /* mail ops flag */ + int wall; /* wall ops flag */ int blockswritten; /* number of blocks written on current tape */ int tapeno; /* current tape number */ time_t tstart_writing; /* when started writing the first tape block */ *************** *** 95,100 **** --- 97,104 ---- /* operator interface functions */ void broadcast __P((char *message)); + void mailcast __P((char *message)); + void wallcast __P((char *message)); void lastdump __P((int arg)); /* int should be char */ void msg __P((const char *fmt, ...)) __printflike(1, 2); void msgtail __P((const char *fmt, ...)) __printflike(1, 2); *************** *** 150,156 **** #define X_ABORT 3 /* abort dump; don't attempt checkpointing */ #define OPGRENT "operator" /* group entry to notify */ ! struct fstab *fstabsearch __P((char *key)); /* search fs_file and fs_spec */ #ifndef NAME_MAX --- 154,161 ---- #define X_ABORT 3 /* abort dump; don't attempt checkpointing */ #define OPGRENT "operator" /* group entry to notify */ ! #define OPMAIL "operator" /* mail alias to notify */ ! #define OPSUBJECT "dump requires attention" /* subject to use in mail */ struct fstab *fstabsearch __P((char *key)); /* search fs_file and fs_spec */ #ifndef NAME_MAX diff -c -b /usr/src/sbin/dump/main.c ./jon/src/sbin/dump/main.c *** /usr/src/sbin/dump/main.c Sat Oct 6 22:35:23 2001 --- ./jon/src/sbin/dump/main.c Wed Nov 14 16:18:43 2001 *************** *** 78,83 **** --- 78,85 ---- #endif int notify = 0; /* notify operator flag */ + int wall = 0; /* wall ops flag */ + int mail = 0; /* mail ops flag */ int blockswritten = 0; /* number of blocks written on current tape */ int tapeno = 0; /* current tape number */ int density = 0; /* density in bytes/0.1" " <- this is for hilit19 */ *************** *** 123,131 **** obsolete(&argc, &argv); #ifdef KERBEROS ! #define optstring "0123456789aB:b:cd:f:h:kns:T:uWwD:" #else ! #define optstring "0123456789aB:b:cd:f:h:ns:T:uWwD:" #endif while ((ch = getopt(argc, argv, optstring)) != -1) #undef optstring --- 125,133 ---- obsolete(&argc, &argv); #ifdef KERBEROS ! #define optstring "0123456789aB:b:cd:f:h:kmns:T:uWwD:" #else ! #define optstring "0123456789aB:b:cd:f:h:mns:T:uWwD:" #endif while ((ch = getopt(argc, argv, optstring)) != -1) #undef optstring *************** *** 178,185 **** break; #endif ! case 'n': /* notify operators */ ! notify = 1; break; case 's': /* tape size, feet */ --- 180,191 ---- break; #endif ! case 'm': /* notify ops by mail(1) */ ! mail = 1; ! break; ! ! case 'n': /* notify operators by wall(1) */ ! wall = 1; break; case 's': /* tape size, feet */ *************** *** 212,217 **** --- 218,226 ---- argc -= optind; argv += optind; + if (mail || wall) + notify = 1; + if (argc < 1) { (void)fprintf(stderr, "Must specify disk or filesystem\n"); exit(X_STARTUP); *************** *** 492,498 **** #ifdef KERBEROS "k" #endif ! "nu] [-B records] [-b blocksize] [-D dumpdates]\n" " [-d density] [-f file ] [-h level] [-s feet] " "[-T date] filesystem\n" " dump [-W | -w]\n"); --- 501,507 ---- #ifdef KERBEROS "k" #endif ! "mnu] [-B records] [-b blocksize] [-D dumpdates]\n" " [-d density] [-f file ] [-h level] [-s feet] " "[-T date] filesystem\n" " dump [-W | -w]\n"); diff -c -b /usr/src/sbin/dump/optr.c ./jon/src/sbin/dump/optr.c *** /usr/src/sbin/dump/optr.c Sat Nov 3 22:44:51 2001 --- ./jon/src/sbin/dump/optr.c Wed Nov 14 16:43:34 2001 *************** *** 125,141 **** void alarmcatch() { ! if (notify == 0) { ! if (timeout == 0) (void) fprintf(stderr, " DUMP: %s: (\"yes\" or \"no\") ", attnmessage); ! else msgtail("\a\a"); } else { if (timeout) { msgtail("\n"); ! broadcast(""); /* just print last msg */ } (void) fprintf(stderr," DUMP: %s: (\"yes\" or \"no\") ", attnmessage); --- 125,143 ---- void alarmcatch() { ! if (wall == 0) { ! if (timeout == 0) { ! if (mail) mailcast(""); /* mail warnings only get sent out once */ (void) fprintf(stderr, " DUMP: %s: (\"yes\" or \"no\") ", attnmessage); ! } else msgtail("\a\a"); + } else { if (timeout) { msgtail("\n"); ! wallcast(""); /* just print last msg */ } (void) fprintf(stderr," DUMP: %s: (\"yes\" or \"no\") ", attnmessage); *************** *** 158,173 **** } /* ! * We now use wall(1) to do the actual broadcasting. */ void broadcast(message) char *message; { FILE *fp; char buf[sizeof(_PATH_WALL) + sizeof(OPGRENT) + 3]; ! if (!notify) return; snprintf(buf, sizeof(buf), "%s -g %s", _PATH_WALL, OPGRENT); --- 160,197 ---- } /* ! * Generic function to warn operators in various ways ! * ! * Need to distiguish between wall(1) and mail(1) for ! * different usage when called from (e.g.) alarmcatch() */ void broadcast(message) char *message; { + if (!notify) + return; + + if (wall) + wallcast(message); + + if (mail) + mailcast(message); + } + + + /* + * Use wall(1) to do the broadcasting + */ + void + wallcast(message) + char *message; + { + FILE *fp; char buf[sizeof(_PATH_WALL) + sizeof(OPGRENT) + 3]; ! if (!wall) return; snprintf(buf, sizeof(buf), "%s -g %s", _PATH_WALL, OPGRENT); *************** *** 181,186 **** --- 205,240 ---- (void) fputs(message, fp); (void) pclose(fp); + + } + + /* + * Use mail(1) to do the "broadcasting" + */ + void + mailcast(message) + char *message; + { + + FILE *fp; + char buf[sizeof(_PATH_MAIL) + sizeof(OPSUBJECT) + sizeof(OPMAIL) + 5]; + + if (!mail) + return; + + snprintf(buf, sizeof(buf), "%s -s '%s' %s", + _PATH_MAIL, OPSUBJECT, OPMAIL); + if ((fp = popen(buf, "w")) == NULL) + return; + + (void) fputs("Message from the dump program to all operators\n\nDUMP: NEEDS ATTENTION: ", fp); + if (lastmsg[0]) + (void) fputs(lastmsg, fp); + if (message[0]) + (void) fputs(message, fp); + + (void) pclose(fp); + } /* diff -c -b /usr/src/sbin/dump/pathnames.h ./jon/src/sbin/dump/pathnames.h *** /usr/src/sbin/dump/pathnames.h Sat Oct 6 22:35:23 2001 --- ./jon/src/sbin/dump/pathnames.h Wed Nov 14 16:47:31 2001 *************** *** 42,44 **** --- 42,45 ---- #define _PATH_LOCK "/tmp/dumplockXXXXXX" #define _PATH_RMT "/etc/rmt" /* path on remote host */ #define _PATH_WALL "/usr/bin/wall" + #define _PATH_MAIL "/usr/bin/mail"