Detecting cards in USB card reader
nvass9573 at gmx.com
Sun Feb 7 11:27:46 UTC 2010
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
> lab# echo > /dev/da0
> lab# echo $?
> lab# /bin/echo asd > /dev/da0
> /bin/echo: write: Invalid argument
> lab# truss sh -c "echo > /dev/da0"
> 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'
FreeBSD lost the ability of doing such transparent
transformations when the support for block devices
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
More information about the freebsd-questions