From owner-freebsd-arch Fri Jan 18 7:42:17 2002 Delivered-To: freebsd-arch@freebsd.org Received: from aurora.nsu.ru (aurora.nsu.ru [193.124.215.195]) by hub.freebsd.org (Postfix) with ESMTP id 43A1A37B404 for ; Fri, 18 Jan 2002 07:42:11 -0800 (PST) Received: from inet.ssc.nsu.ru ([62.76.110.12]) by aurora.nsu.ru with esmtp (Exim 3.22 #1) id 16Rb9X-0004RW-00 for arch@freebsd.org; Fri, 18 Jan 2002 21:42:03 +0600 Received: from localhost (danfe@localhost) by inet.ssc.nsu.ru (8.9.3/8.9.3) with ESMTP id VAA13879 for ; Fri, 18 Jan 2002 21:41:29 +0600 Date: Fri, 18 Jan 2002 21:41:29 +0600 (NOVT) From: Alexey Dokuchaev To: arch@freebsd.org Subject: Re: request for review Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 #include 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 > To: Poul-Henning Kamp > Cc: Max Khon , 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