Date: Mon, 31 May 1999 13:18:25 -0400 (EDT) From: Zhihui Zhang <zzhang@cs.binghamton.edu> To: freebsd-hackers@freebsd.org Subject: Accessing special device files Message-ID: <Pine.GSO.3.96.990531123322.17589A-100000@sol.cs.binghamton.edu>
next in thread | raw e-mail | index | archive | help
I write a small program to read/write each FreeBSD partition via special device file names, e.g. /dev/wd0s2e, /dev/rwd0s2e, etc. I have two questions about doing this: (1) If I try to read() on these files, the buffer size must be given in multiples of 512 (sector size). Otherwise, I will get an EINVAL error. Why is this the case? Does the same thing happen to the write() system call? (2) I use lseek() on these device files, it returns the correct offset for me. But actually it does not work. I read in a recent posting saying that you can't expect lseek(fd, 0, SEEK_END) to work unless the file descriptor is associated with a regular file because file size information is not available at that level. Does this apply to all kinds of lseek(), include SEEK_SET and SEEK_CUR? Or maybe the offset must also given in a multiple of 512 for some reason. If I give lseek(fd, 8193, SEEK_SET), it will actually do lseek(fd, 8192, SEEK_SET)? Thanks for any help. -------------------------------------------------- Zhihui Zhang. Please visit http://www.freebsd.org -------------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.3.96.990531123322.17589A-100000>