xfs behaviour on OpenBSD

Kristaps Johnson kristaps at gradient-enterprises.com
Thu Jun 15 13:29:53 CEST 2006


Hello everybody.  I wonder if somebody can shed some light on strange 
behahiour (or sloppy thinking on my part).

If I mount_xfs on OpenBSD (3.9), and run two versions of a programme, one 
that read(2)s and one that fread(3)s, the read returns end-of-file while 
the fread returns correct values.

Sample code (minimal for brevity):

-------
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int
main(int argc, char *argv[])
{
         char c = 0;
#if READ
         int fd = open("/dev/xfs0", O_RDWR);
         read(fd, &c, 1);
#else /* FREAD */
         FILE *f = fopen("/dev/xfs0", "r+");
         fread(&c, 1, 1, f);
#endif
         printf("read character %d\n", c);
         return(0);
}
--------

...just to demonstrate.  When I raise an oper (e.g., "ls /mnt/xfs0") the 
read returns end-of-file while the fread returns a proper value.

Any suggestions?

Thanks,
Kristaps


More information about the Arla-drinkers mailing list