Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!etnibsd!vsh From: vsh@etnibsd.UUCP (Steve Harris) Newsgroups: comp.lang.perl Subject: perl will not open block-special files Message-ID: <1108@etnibsd.UUCP> Date: 8 Feb 90 19:35:57 GMT Organization: Eaton Corp, Semiconductor Equipment Div., Beverly, MA Lines: 53 I wrote a little script to read disk blocks. It starts with the following two lines: $DEV = "<" . $ARGV[0]; # make sure DEV is opened for reading open DEV || die "cannot open $DEV"; The open works fine when I open a character device, but fails when I try to open a block device: perl test.pl /dev/xy0c # fails; xy0c is block-special perl test.pl /dev/rxy0c # okay; rxy0c is character-special If I open stdin and use shell redirection to associate stdin with the file, the open succeeds: perl test.pl - < /dev/rxy0c # okay; open stdin So I dug into the source, and found, in "doio.c", the following code: /**********************************************************/ if (stio->type && stio->type != '|' && stio->type != '-') { if (fstat(fileno(fp),&statbuf) < 0) { (void)fclose(fp); return FALSE; } if ((statbuf.st_mode & S_IFMT) != S_IFREG && #ifdef S_IFSOCK (statbuf.st_mode & S_IFMT) != S_IFSOCK && #endif #ifdef S_IFFIFO (statbuf.st_mode & S_IFMT) != S_IFFIFO && #endif (statbuf.st_mode & S_IFMT) != S_IFCHR) { (void)fclose(fp); return FALSE; } } /**********************************************************/ I'm not sure what's going on here, but it sure looks like perl wants the device to be either regular, character-special, socket, or fifo. Why is this? Is it necessary? Is this "fixed" with a patch I haven't had time to obtain and install? (I'm running 3.0, patch level 1; I know I should get up to date but it works well enough that I have not done so, yet.) Also, in the scripts in the perl library, every comment line begins with ";#", not just "#". Why is this? (Inquiring minds, etc.) -- Steve Harris - Eaton Corp. - Beverly, MA - uunet!etnibsd!vsh