From owner-freebsd-questions@FreeBSD.ORG Sun Feb 7 11:27:46 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2072106566C for ; Sun, 7 Feb 2010 11:27:46 +0000 (UTC) (envelope-from nvass9573@gmx.com) Received: from mailout-eu.gmx.com (mailout-eu.gmx.com [213.165.64.42]) by mx1.freebsd.org (Postfix) with SMTP id 2CF0D8FC1D for ; Sun, 7 Feb 2010 11:27:46 +0000 (UTC) Received: (qmail invoked by alias); 07 Feb 2010 11:27:44 -0000 Received: from unknown (EHLO [192.168.73.193]) [91.140.119.91] by mail.gmx.com (mp-eu003) with SMTP; 07 Feb 2010 12:27:44 +0100 X-Authenticated: #46156728 X-Provags-ID: V01U2FsdGVkX19jVbBhTyNjKYrcy8gVa5U5G7csTfvGTQ+SE73xJV zc7GpDCdl83Fe2 Message-ID: <4B6EA394.5050604@gmx.com> Date: Sun, 07 Feb 2010 13:27:16 +0200 From: Nikos Vassiliadis User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20100111 Thunderbird/3.0.1 MIME-Version: 1.0 To: Mike Clarke References: <201002061511.11639.jmc-freebsd2@milibyte.co.uk> <20100206192540.bb4ce11b.freebsd@edvax.de> <201002062328.27744.jmc-freebsd2@milibyte.co.uk> In-Reply-To: <201002062328.27744.jmc-freebsd2@milibyte.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.5 Cc: Polytropon , freebsd-questions@freebsd.org Subject: Re: Detecting cards in USB card reader X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Feb 2010 11:27:46 -0000 On 2/7/2010 1:28 AM, Mike Clarke wrote: > curlew:/root# cat /dev/null> /dev/da0 > curlew:/root# ls -l /dev/da0* > crw-r----- 1 root operator 0, 176 6 Feb 23:15 /dev/da0 > crw-r----- 1 root operator 0, 129 6 Feb 23:18 /dev/da0s1 > > I can use this to initialise the card reader but I'd feel more > comfortable with something a bit less dangerous looking. While it may feel dangerous, is perfectly safe. There is no way doing an IO operation on a disk-like device using requests othen than multiplies of the physical block which currently is 512 bytes. Opening the disk for writing and trying to do a write request, will just force GEOM to re-examine the device. > lab# echo asd | cat > /dev/da0 > cat: stdout: Invalid argument failed > lab# echo > /dev/da0 > lab# echo $? > 1 failed > lab# /bin/echo asd > /dev/da0 > /bin/echo: write: Invalid argument failed Closer look: > lab# truss sh -c "echo > /dev/da0" snip > open("/dev/da0",O_WRONLY|O_CREAT|O_TRUNC,0666) = 2 (0x2) > dup2(0x2,0x1,0x1b6,0x1000008,0x2830d040,0x2830235c) = 1 (0x1) > close(2) = 0 (0x0) > write(1,"\n",1) ERR#22 'Invalid argument' failed FreeBSD lost the ability of doing such transparent transformations when the support for block devices went away. Yes, I know, it feels awkward. Apparently, you can easily drop the support for block devices but not the habitual feeling of danger of UNIX tradition. HTH, Nikos