Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!hplabs!hpcc01!hpwrce!ted From: ted@hpwrce.HP.COM ( Ted Johnson) Newsgroups: comp.sys.hp Subject: Re: cartridge tape status Message-ID: <7870018@hpwrce.HP.COM> Date: 9 Aug 90 19:51:33 GMT References: <1990Aug8.185132.13130@cs.uoregon.edu> Organization: Response Center Lab Lines: 38 >Is their some kind sole who has figured a way to tell if a tape has been loaded >in a hp 9145 ct drive without unloading the tape, and would be willing to >share? One ugly way that works (on a s300 & hp-ux 7.0) is to do something like the following (warning! This code is from memory, and is untested, unsupported, etc., etc.) #include #include #include #include #include #define SIZE 8192 /*you have to read 8k bytes via the cs80 raw device driver, else it'll fail.*/ main() { int fd, nbytes; char buf[SIZE]; fd = open("/dev/update.src",O_RDWR | O_NONBLOCK); nybtes = read(fd, buf, SIZE); if (nbytes == -1) { printf("read failed, so no tape in drive\n"); else { printf("tape is in drive and loaded\n"); } close(fd); /*the following open() *rewinds* the tape */ fd = open("/dev/update.src",O_RDWR | O_NONBLOCK); } -Ted Johnson #include ;-)