Date: Fri, 18 Jan 2002 21:41:29 +0600 (NOVT) From: Alexey Dokuchaev <danfe@inet.ssc.nsu.ru> To: arch@freebsd.org Subject: Re: request for review Message-ID: <Pine.LNX.4.10.10201182141050.13875-100000@inet.ssc.nsu.ru>
next in thread | raw e-mail | index | archive | help
Hello! The following program was compiled and run on different systems in order to examine their behaviour with respect to st_blksize returned for tty: #include <sys/types.h> #include <sys/stat.h> void f(int fd) { struct stat s; fstat(fd, &s); printf("fd %d: st_blksize: %d, st_mode: (0%08o)\n", fd, s.st_blksize, (unsigned) s.st_mode); } main() { f(0); f(1); return 0; } The results obtained are: OpenBSD 2.9 (i386): fd 0: st_blksize: 65536, st_mode: (000020620) fd 1: st_blksize: 65536, st_mode: (000020620) --- SunOS 5.6 (sun4u sparc SUNW,Ultra-Enterprise): fd 0: st_blksize: 8192, st_mode: (000020620) fd 1: st_blksize: 8192, st_mode: (000020620) --- Linux 2.2.19 and 2.4.16 (i686): fd 0: st_blksize: 1024, st_mode: (000020620) fd 1: st_blksize: 1024, st_mode: (000020620) --- FreeBSD 4.4-STABLE (December 6, 2001, August ?, 2001): fd 0: st_blksize: 0, st_mode: (000020620) fd 1: st_blksize: 0, st_mode: (000020620) Note that I stated the values for two -STABLE systems of mine, the reason for doing so arised from the same tests I conducted on both systems *after* I've applied the patch suggested by Max: FreeBSD 4.4-STABLE (December 6, 2001), with patched vfs_vnops.c: fd 0: st_blksize: 16384, st_mode: (000020620) fd 1: st_blksize: 16384, st_mode: (000020620) --- FreeBSD 4.4-STABLE (August ?, 2001), with patched vfs_vnops.c fd 0: st_blksize: 8192, st_mode: (000020620) fd 1: st_blksize: 8192, st_mode: (000020620) Note the different values returned for st_blksize in both cases. > Date: Tue, 15 Jan 2002 06:34:44 -0800 > From: Cy Schubert - ITSD Open Systems Group <Cy.Schubert@uumail.gov.bc.ca> > To: Poul-Henning Kamp <phk@critter.freebsd.dk> > Cc: Max Khon <fjoe@iclub.nsu.ru>, arch@freebsd.org > Subject: Re: request for review > > In addition to making FreeBSD consistent with OpenBSD and Linux, as > stated by the originator of this thread, the patch also makes FreeBSD > consistent with Solaris and Tru64-UNIX. I'm for it. That's exactly what bugs me! According to my tests, things are not quite consistent even within *BSD. Right now I do not have time to dig into the source code to get an explanation of why OpenBSD returned 64K, -CURRENT (according to Max) returned 512 bytes (!), and two of my -STABLE systems yielded different numbers as well. Maybe someone has the explanation off-hand, in this case, I'd appreciate the one sharing it with us :-) > > >? current-diffs > > >Index: vfs_vnops.c > > >=================================================================== > > >RCS file: /home/ncvs/src/sys/kern/vfs_vnops.c,v > > >retrieving revision 1.125 > > >diff -u -p -r1.125 vfs_vnops.c > > >--- vfs_vnops.c 18 Dec 2001 20:48:54 -0000 1.125 > > >+++ vfs_vnops.c 14 Jan 2002 18:04:45 -0000 > > >@@ -579,6 +579,8 @@ vn_stat(vp, sb, td) > > > sb->st_blksize = vp->v_rdev->si_bsize_phys; > > > if (sb->st_blksize < BLKDEV_IOSIZE) > > > sb->st_blksize = BLKDEV_IOSIZE; > > >+ } else if (vap->va_type == VCHR) { > > >+ sb->st_blksize = vap->va_blocksize; > > > } else { > > > sb->st_blksize = 0; > > > } And the last thing, I've been looking at the patch, and thought, maybe it would be more clear to patch vfs_vnops.c the following way instead: --- /sys/kern/vfs_vnops.c.orig Fri Jan 18 21:16:33 2002 +++ /sys/kern/vfs_vnops.c Thu Jan 17 20:26:11 2002 @@ -530,7 +530,7 @@ * Default to zero to catch bogus uses of this field. */ - if (vap->va_type == VREG) { + if (vap->va_type == VREG || vap->va_type == VCHR) { sb->st_blksize = vap->va_blocksize; } else if (vn_isdisk(vp, NULL)) { sb->st_blksize = vp->v_rdev->si_bsize_best; What do you think? Sincerely, DAN Fe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.10.10201182141050.13875-100000>