Project

General

Profile

Bug #629 ยป vinum.patch

pavalos, 05/06/2007 06:42 PM

View differences:

Makefile 29 Apr 2007 16:05:21 -0000
MAN= vinum.8
WARNS?= 2
CFLAGS+= -I${.CURDIR}/../../sys
DPADD= ${LIBUTIL} ${LIBREADLINE} ${LIBTERMCAP}
LDADD= -lreadline -ltermcap -ldevstat
CFLAGS+= -I${.CURDIR}/../../lib/libedit -I${.CURDIR}/../../sys
DPADD= ${LIBEDIT} ${LIBTERMCAP} ${LIBDEVSTAT}
LDADD= -ledit -ltermcap -ldevstat
.include <bsd.prog.mk>
commands.c 6 May 2007 18:31:39 -0000
#include <sys/linker.h>
#include <sys/module.h>
#include <sys/wait.h>
#include <readline/history.h>
#include <readline/readline.h>
#include <devstat.h>
v.c 6 May 2007 18:31:31 -0000
#include "vext.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <readline/history.h>
#include <readline/readline.h>
#include <sys/linker.h>
#include <sys/module.h>
#include <sys/resource.h>
FILE *cf; /* config file handle */
FILE *history; /* history file */
FILE *hist; /* history file */
char *historyfile; /* and its name */
char *dateformat; /* format in which to store date */
......
errno);
exit(1);
}
history = fopen(historyfile, "a+");
if (history != NULL) {
hist = fopen(historyfile, "a+");
if (hist != NULL) {
timestamp();
fprintf(history, "*** " VINUMMOD " started ***\n");
fflush(history); /* before we start the daemon */
fprintf(hist, "*** " VINUMMOD " started ***\n");
fflush(hist); /* before we start the daemon */
}
superdev = open(VINUM_SUPERDEV_NAME, O_RDWR); /* open vinum superdevice */
if (superdev < 0) { /* no go */
......
if (tokens)
parseline(tokens, token); /* and do what he says */
}
if (history)
fflush(history);
if (hist)
fflush(hist);
}
}
return 0; /* normal completion */
......
int j;
enum keyword command; /* command to execute */
if (history != NULL) { /* save the command to history file */
if (hist != NULL) { /* save the command to history file */
timestamp();
for (i = 0; i < args; i++) /* all args */
fprintf(history, "%s ", argv[i]);
fputs("\n", history);
fprintf(hist, "%s ", argv[i]);
fputs("\n", hist);
}
if ((args == 0) /* empty line */
||(*argv[0] == '#')) /* or a comment, */
......
perror(VINUMMOD ": Can't write to /dev");
return;
}
if (history) {
if (hist) {
timestamp();
fprintf(history, "*** Created devices ***\n");
fprintf(hist, "*** Created devices ***\n");
}
if (superdev >= 0) /* super device open */
close(superdev);
......
char datetext[MAXDATETEXT];
time_t sec;
if (history != NULL) {
if (hist != NULL) {
if (gettimeofday(&now, NULL) != 0) {
fprintf(stderr, "Can't get time: %s\n", strerror(errno));
return;
......
sec = now.tv_sec;
date = localtime(&sec);
strftime(datetext, MAXDATETEXT, dateformat, date),
fprintf(history,
fprintf(hist,
"%s.%06ld ",
datetext,
now.tv_usec);
    (1-1/1)