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 majord...@freebsd.org with "unsubscribe freebsd-hackers" in the body of the message