Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: block device file detection.



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@xxxxxxxxxxxxxxxxx:/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



Messages sorted by: Reverse Date, Date, Thread, Author