From owner-freebsd-questions@FreeBSD.ORG Wed Jul 20 05:50:34 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7E2C216A41F for ; Wed, 20 Jul 2005 05:50:34 +0000 (GMT) (envelope-from shmach@osprey.net) Received: from mx1.osprey.net (mx1.osprey.net [12.105.144.92]) by mx1.FreeBSD.org (Postfix) with ESMTP id F1B3B43D48 for ; Wed, 20 Jul 2005 05:50:33 +0000 (GMT) (envelope-from shmach@osprey.net) Received: from localhost (tyr.osprey.net [12.105.144.92]) by mx1.osprey.net (Postfix) with ESMTP id ACFE06A3AB for ; Wed, 20 Jul 2005 00:55:01 -0500 (CDT) Received: from mx1.osprey.net ([12.105.144.92]) by localhost (tyr [12.105.144.92]) (amavisd-new, port 10024) with ESMTP id 01839-01 for ; Wed, 20 Jul 2005 00:55:01 -0500 (CDT) Received: from localhost (55-pool1.ras10.kstop.alerondial.net [206.149.64.55]) by mx1.osprey.net (Postfix) with ESMTP id AFE97320DF for ; Wed, 20 Jul 2005 00:54:59 -0500 (CDT) Message-ID: X-Mailer: XFMail 1.5.5 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Date: Wed, 20 Jul 2005 00:58:13 -0500 (CDT) Sender: spectre@localhost.osprey.net From: shmach@osprey.net To: freebsd-questions@freebsd.org X-Virus-Scanned: amavisd-new at osprey.net Subject: problem with devfs X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: shmach@osprey.net List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2005 05:50:34 -0000 Hello everyone, I'm a CS student, and this previous semester I took a unix class where our teacher gave us some code for an assignment, with the goal being to compile and install it. The jist of it was the program created a device in /dev called voice, which would "speak" whatever was written to it using festival. I thought this was kinda spiffy, and tried to install it on my system at home, freebsd 5.3. The program tries to write to /dev, and because 5.3 uses devfs, /dev is read only, so it obviously fails. I thought that maybe using mknod would allow me to create a device, but the man page for mknod states that it can "be used to recreate deleted device nodes under a devfs(5) mount point by invoking it using dummy arguments", but that doesn't really help me here as the device node never existed in the first place. So, I guess I want to know if there's a way to override devfs, or would I have to write a kernel module in order to get thing to install in /dev. I don't know how to write device drivers, but I'm willing to give anything a try. :) what follows is the code. if anyone's interested, the code is also available for download from my teacher's site: http://www.emporia.edu/math-cs/simpson/bsimpson.htm The version I'm using is 1.0. #define FIFO_BUFFER_SIZE 4096 #define FIFO_NAME "/dev/voice" #define FESTIVAL "/usr/local/bin/festival" #define LOCAL "localhost" #define FESTIVAL_PORT 1314 #define PHRASE_HEAD "(SayText \"" #define PHRASE_TAIL "\")" #define INSTALL_PHRASE "(SayText \"/dev/voice installed\")" #define PAUSE_INTERVAL 5 #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include void signal_handler(int the_sig); void signal_handler(int the_sig) { if(the_sig==SIGTERM) { kill(getppid(),SIGTERM); unlink(FIFO_NAME); exit(0); }; }; int main() { static char buffer[FIFO_BUFFER_SIZE]; int buffer_count,public_fifo; int sock,phrase_len; struct sockaddr_in client,server; struct hostent *host; char *phrase; signal(SIGTERM,&signal_handler); daemon(0,0); if(fork()==0) { printf("in the child now\n"); sleep(PAUSE_INTERVAL); host=gethostbyname(LOCAL); server.sin_family=AF_INET; server.sin_port=htons(FESTIVAL_PORT); memcpy(&server.sin_addr.s_addr,host->h_addr,host->h_length); sock=socket(AF_INET,SOCK_STREAM,0); client.sin_family=AF_INET; client.sin_port=htons(0); client.sin_addr.s_addr=htonl(INADDR_ANY); if(bind(sock,(struct sockaddr *) &client,sizeof(client)) == -1){ printf("couldn't bind to port\n"); exit(2); } connect(sock,(struct sockaddr *)&server,sizeof(server)); if(mkfifo(FIFO_NAME, 06660)<0) { printf("bad things\n"); if(errno==17) { unlink(FIFO_NAME); mknod(FIFO_NAME, S_IFIFO | 0666, 0); }; printf("there's been a fucking error...\n"); }; public_fifo=open(FIFO_NAME,O_RDWR); if(public_fifo<0) { printf("couldn't open fifo\n"); exit(1); } sleep(PAUSE_INTERVAL); sendto(sock,INSTALL_PHRASE,strlen(INSTALL_PHRASE),0,(struct sockaddr *)&server,sizeof(server)); kill(getppid(),SIGTERM); while(1) { memset(buffer,0x0,FIFO_BUFFER_SIZE); buffer_count = read(public_fifo,buffer,FIFO_BUFFER_SIZE); if(buffer_count > 0) { phrase=new char[12+strlen(buffer)]; phrase_len=12+strlen(buffer); memset(phrase,0x0,phrase_len); strcat(phrase,PHRASE_HEAD); strcat(phrase,buffer); strcat(phrase,PHRASE_TAIL); sendto(sock,phrase,phrase_len,0,(struct sockaddr *)&server,sizeof(server)); delete phrase; kill(getppid(),SIGTERM); }; }; } else execl(FESTIVAL,"festival","--server",(char *)NULL); return 0; } ---------------------------------- E-Mail: shmach@osprey.net Date: 20-Jul-2005 Time: 00:25:52 This message was sent by XFMail ----------------------------------