Date: Sun, 20 Nov 2011 12:40:16 -0500 From: "Dieter BSD" <dieterbsd@engineer.com> To: freebsd-hackers@freebsd.org Subject: Re: easy way to determine if a stream or fd is seekable Message-ID: <20111120174025.233420@gmx.com>
next in thread | raw e-mail | index | archive | help
> something like the following inside lseek() would take care of tape drives: > > if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) { > if (ioctl(io->fd, FIODTYPE, &type) == -1) > err(1, "%s", io->name); > > if (type & D_TAPE) > return(EBADF) > } I'd suggest ENODEV ("Operation not supported by device") rather than EBADF ("Bad file descriptor"). To do this correctly, we'd need some standard way to ask the device driver if the device can perform the seek or not.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111120174025.233420>