From owner-freebsd-usb@freebsd.org Tue Mar 20 10:25:00 2018 Return-Path: Delivered-To: freebsd-usb@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 28E1AF65955 for ; Tue, 20 Mar 2018 10:25:00 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AF9A06B93D for ; Tue, 20 Mar 2018 10:24:59 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.128.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 22F292602E8; Tue, 20 Mar 2018 11:24:58 +0100 (CET) Subject: Re: R: R: usb's quirks ... how to sniff bios'es messages addressed to usb rom chip To: Vincenzo Di Salvo Cc: freebsd-usb@freebsd.org References: <77f62042-bb44-7b36-0845-b88d233bfed0@selasky.org> <000401d3bfbe$c7f99370$57ecba50$@it> <49bf1a27-e01b-d0fd-91c4-47c18c688290@selasky.org> From: Hans Petter Selasky Message-ID: <8c59ec50-c36d-2bc3-6490-3f12c9a4c92c@selasky.org> Date: Tue, 20 Mar 2018 11:24:53 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Mar 2018 10:25:00 -0000 On 03/20/18 10:07, Vincenzo Di Salvo wrote: > Hi, > probably what you are saying is so important that solves my doubt about a my misunderstanding about USB protocol and my idea to use the usbdump is totally wrong and no more usefull. > > Foundamentally my goal is only understand if, pluging a usb device, a direct writing operation can or not occur from the processor into the usb device. > Hi, You need to distinguish between daemons and the operating system, OS. When you plug a USB disk device, typically what happens is that the OS will read from the disk to figure out partition tables and disk slices. This part is read-only. Later on the OS will tell this information to user-space, for example hald, and then depending on what software you have installed, the disk will be automatically mounted, which might involve a few write requests. mount(8) has a -r option to avoid any writes to the disk. Usually this is not set for desktop environments. > So, please, let me ask another question to exclude all my misunderstanding. > > You wrote: > “A processor runs on the USB device replying to this protocol. There is no direct hardware access. You need to ask the manufacturer which USB request returns the counter you are asking for”. > > 1- If "there is no direct hardware access", this means that the processor can only do read-only accesses to the USB device. Is it correct ? yes/no: The USB storage protocol has separate read and write commands. The PC sends either a read command or a write command to the USB device and a small CPU interprets this command and replies back the the PC. This small CPU then makes a new request for the actual disk drive. > > 2- Speaking of “which USB request returns the counter” do you mean that the counter increment occurs "internally" following a request of the processor, excluding a direct writing operation of the processor into the usb device ?. Is it correct ? yes/no: USB itself doesn't have any counters for disk access. There is only one running counter, but it doesn't distinguish between read and write requests. Any request increments the counter by one. The OS might however keep statistics on how many read/write requests have been performed. In FreeBSD these statistics is usually available through the "sysctl -a" tree. > > If so, your reply solves my limited knowledges of the usb protocol. > Further, it is common that when you read files, the access time is updated in the file tables. This cause write requests. Look for the description of the "noatime" option in the mount manual page. --HPS