From owner-freebsd-usb@FreeBSD.ORG Tue Jan 29 08:22:16 2008 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A8FC16A417 for ; Tue, 29 Jan 2008 08:22:16 +0000 (UTC) (envelope-from petert@dcn.nord.nw.ru) Received: from dcn.infos.ru (gw-9cor.infos.ru [195.209.229.106]) by mx1.freebsd.org (Postfix) with ESMTP id CCF3C13C442 for ; Tue, 29 Jan 2008 08:22:15 +0000 (UTC) (envelope-from petert@dcn.nord.nw.ru) Received: from dcn.research.dcn (localhost.research.dcn [127.0.0.1]) by dcn.research.dcn (Postfix) with SMTP id BE5A74ACC1; Tue, 29 Jan 2008 11:22:13 +0300 (MSK) Received: by dcn.infos.ru (Postfix, from userid 65534) id 48FB64ACC0; Tue, 29 Jan 2008 11:22:13 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on dcn.research.dcn X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_50 autolearn=no version=3.2.3 Received: from kas30pipe.localhost (localhost.research.dcn [127.0.0.1]) by dcn.infos.ru (Postfix) with ESMTP id 7AE524ACB3; Tue, 29 Jan 2008 11:22:10 +0300 (MSK) Received: from bullet (bullet.research.dcn [10.0.103.26]) by dcn.infos.ru (Postfix) with ESMTP id 74F2C4ACA7; Tue, 29 Jan 2008 11:22:10 +0300 (MSK) From: "Peter Trifonov" To: "'Henrik Gulbrandsen'" References: <000901c861bc$cb8b9e90$62a2dbb0$@nord.nw.ru> <1201541812.2277.418.camel@Particle> In-Reply-To: <1201541812.2277.418.camel@Particle> Date: Tue, 29 Jan 2008 11:22:10 +0300 Message-ID: <001001c86250$0b12db30$21389190$@nord.nw.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Achh2QFwivKlq8GRRuK3JiwzTiD7eAAdIXig Content-Language: ru x-cr-hashedpuzzle: BY8+ FHLR F44S GWxr GpYT JL+R MEQA NxUf PlPZ PmxO QNFm Qh9o RFVt RPBu R+TF TqVD; 2; ZgByAGUAZQBiAHMAZAAtAHUAcwBiAEAAZgByAGUAZQBiAHMAZAAuAG8AcgBnADsAaABlAG4AcgBpAGsAQABnAHUAbABiAHIAYQAuAG4AZQB0AA==; Sosha1_v1; 7; {6E159FC6-B052-4433-AB15-9B1912A5CED6}; cABlAHQAZQByAHQAQABkAGMAbgAuAG4AbwByAGQALgBuAHcALgByAHUA; Tue, 29 Jan 2008 08:22:06 GMT; UgBFADoAIABNAG8AdQBuAHQAaQBuAGcAIABVAFMAQgAgAGYAbABhAHMAaAAgAGQAcgBpAHYAZQA= x-cr-puzzleid: {6E159FC6-B052-4433-AB15-9B1912A5CED6} X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release X-SpamTest-Info: Not protected Cc: freebsd-usb@freebsd.org Subject: RE: Mounting USB flash drive X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jan 2008 08:22:16 -0000 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