zsh-workers
 help / color / mirror / code / Atom feed
From: Tanaka Akira <akr@m17n.org>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: block device file detection.
Date: 04 May 2000 15:32:53 +0900	[thread overview]
Message-ID: <hvobt2mrfje.fsf@serein.m17n.org> (raw)

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


                 reply	other threads:[~2000-05-04  6:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=hvobt2mrfje.fsf@serein.m17n.org \
    --to=akr@m17n.org \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).