From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3235 invoked from network); 4 May 2000 06:31:56 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 4 May 2000 06:31:56 -0000 Received: (qmail 5442 invoked by alias); 4 May 2000 06:31:50 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11137 Received: (qmail 5403 invoked from network); 4 May 2000 06:31:47 -0000 To: zsh-workers@sunsite.auc.dk Subject: PATCH: block device file detection. MIME-Version: 1.0 (generated by SEMI 1.13.7 - "Awazu") Content-Type: text/plain; charset=US-ASCII From: Tanaka Akira Date: 04 May 2000 15:32:53 +0900 Message-ID: User-Agent: T-gnus/6.14.1 (based on Gnus v5.8.3) (revision 16) SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/20.6 (i686-pc-linux-gnu) MULE/4.0 (HANANOEN) I found that FreeBSD 4.0 mount a disk with a character special file. % df / Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s2a 49583 24954 20663 55% / % ls -l /dev/ad0s2a crw-r----- 1 root operator 116, 0x00030000 May 1 04:40 /dev/ad0s2a % uname -a FreeBSD dhcp21.m17n.org 4.0-RELEASE FreeBSD 4.0-RELEASE #0: Mon Mar 20 22:50:22 GMT 2000 root@monster.cdrom.com:/usr/src/sys/compile/GENERIC i386 So, `make check' is failed as: | Test ./07cond.ztst failed: bad status 1, expected 0 from: | # Find a block special file system. This is a little tricky. | block=$(df / | awk ' | $NF == "/" {print $1} | $1 == "/" && substr($2,0,1) == "(" { | if((l = index($2,")") - 2) < 0) l = length($2) - 1; | print substr($2,2,l)}') && | [[ -b $block && ! -b zerolength ]] | Was testing: -b cond | ./07cond.ztst: test failed. I modified the block special file detection code to use find -type b. I tested this code on FreeBSD 4.0/3.2/2.2.6, NetBSD 1.4.2, Solaris 7, SunOS 4.1.4 and Linux. Index: Test/07cond.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/07cond.ztst,v retrieving revision 1.2 diff -u -r1.2 07cond.ztst --- Test/07cond.ztst 2000/04/01 20:49:48 1.2 +++ Test/07cond.ztst 2000/05/04 06:15:53 @@ -27,11 +27,7 @@ 0:-a cond # Find a block special file system. This is a little tricky. - block=$(df / | awk ' - $NF == "/" {print $1} - $1 == "/" && substr($2,0,1) == "(" { - if((l = index($2,")") - 2) < 0) l = length($2) - 1; - print substr($2,2,l)}') && + block=$(find /dev /devices -type b -print 2>/dev/null|head -1) && [[ -b $block && ! -b zerolength ]] 0:-b cond -- Tanaka Akira