Date: Tue, 29 Jan 2008 11:22:10 +0300 From: "Peter Trifonov" <petert@dcn.nord.nw.ru> To: "'Henrik Gulbrandsen'" <henrik@gulbra.net> Cc: freebsd-usb@freebsd.org Subject: RE: Mounting USB flash drive Message-ID: <001001c86250$0b12db30$21389190$@nord.nw.ru> In-Reply-To: <1201541812.2277.418.camel@Particle> References: <000901c861bc$cb8b9e90$62a2dbb0$@nord.nw.ru> <1201541812.2277.418.camel@Particle>
next in thread | previous in thread | raw e-mail | index | archive | help
Dear Henrik, > Peter, I think you may be overly optimistic here. The patches that you > Just so you know what you're into, the partial fix may seem to work, Thank you very much for your warning. > but > can give you a system panic after up to a few hundred detach attempts. > Or after less than ten attempts. It's really a random timing issue. In my case system stability is not the key issue, since I am just setting up a terminal to be used by students. But I will print warnings everywhere... Just a small suggestion for your patch set. The /etc/devd/umass script contains the following: # Verify that there is a slice to mount if [ ! -e /dev/${drv}s1 ]; then exit 1; fi I have seen some flash drives which do not contain any partitions, i.e. they look like a big floppy. In this case one should not look for /dev/daXsY, but mount /dev/daX. I am using the following devd script, which manages mount points in /mnt directory: -------------------------------------- #!/usr/bin/perl #This script should be invoked every time USB device is attached or detached #Copyright (c) 2008 Peter Trifonov petert@dcn.nord.nw.ru # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. #wait for devices to settle sleep (2); #get a list of devices $DevNodes=`ls /dev/`; @DevNodes=($DevNodes=~m/(da\d+(?:s\d+)?)/g); #get a list of mount points $DirNodes=`ls /mnt/`; @DirNodes=($DirNodes=~m/(da\d+(?:s\d+)?)/g); foreach $Dev(@DevNodes) { $DevNodes{$Dev}+=1; #if there is a device called daNsMM, daN should be excluded if ($Dev=~m/(da\d+)s\d+/) { print "Skipping $1\n"; $DevNodes{$1}-=1; }; }; foreach $Dir(@DirNodes) { $DirNodes{$Dir}=1; }; #look for new devices foreach $Dev(@DevNodes) { if (!$DirNodes{$Dev}&&($DevNodes{$Dev}>0)) { print "Mounting $Dev...\n"; mkdir "/mnt/$Dev"; system("/sbin/mount_msdosfs -m 777 -L ru_RU.KOI8-R /dev/$Dev /mnt/$Dev"); }; }; #look for mountpoints to be eliminated foreach $Dir(@DirNodes) { if (!$DevNodes{$Dir}) { print "Unmounting $Dir...\n"; system("umount -f /mnt/$Dir"); rmdir "/mnt/$Dir"; }; }; --------------------- With best regards, P. Trifonov
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001001c86250$0b12db30$21389190$>