From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1avq9o-0005xA-UN for mharc-grub-devel@gnu.org; Thu, 28 Apr 2016 13:55:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avq9m-0005u7-Ny for grub-devel@gnu.org; Thu, 28 Apr 2016 13:55:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avq9j-0005bx-J8 for grub-devel@gnu.org; Thu, 28 Apr 2016 13:55:18 -0400 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]:35156) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avq9j-0005bk-C4 for grub-devel@gnu.org; Thu, 28 Apr 2016 13:55:15 -0400 Received: by mail-lf0-x229.google.com with SMTP id c126so105020704lfb.2 for ; Thu, 28 Apr 2016 10:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=qsUMpV2eMpZb/dT8T8K5+ngUJ8wkBhRA+58DMRQQ8Io=; b=aaZTJlMRZIiict/5hOZf4bIT1BThj9RgMsOr1Oem1mF/Ad27YZVyIOQ3CyVK4moOen EUCWyii+uH5TJ2EJdr9JWl6+Z0yDRGBwKXzAdByZYn7oZpWIh2aI1JG4e7giaDwOBR8U QfAaL2Ouo+ruBtnIujKqTjxs1ZeEAiIHeVaT3PwA5EsX10QMmiSdVj2gY2lkkS0Ay+fY xm9I2gYZLTZTNWQipOqnrFi5quU8aiF4gkkqJPLU/yWcwoYGnq5drJFY8ahPPytDpEN2 GkQ+1DNRCIZeL/41cS9nTcMTsM0ar6yhokdGpkynQHhdgXTka07chN563qEvAIfKn7SQ MGHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=qsUMpV2eMpZb/dT8T8K5+ngUJ8wkBhRA+58DMRQQ8Io=; b=iPBs+yLz02OmHQY0mhmS5xAIqt5htOUuP5HDDWWGiBIKNtskFaXEQ/MXzTW5iWYAWh 0Mz7dEZq/Sna2Y1tcU9V+zM+5V8ai6rIJxk+IkfdhAzrY3LuxZAYkgXvpViWtnvKefXn FRq9QhFauWkXmuP64wUl1T3RVKNfKZAGF67VNciOwwpHgyk3bbv6I6IjpWD1793Vvp4U CZ3GQG6g8H7f2C9D27XHTz37ah7oI+XovLMwFwaHR82YDcQwiZtYnGB6sBdJ18IjFkep EzoXZmpuhWduq5QdxCTirCMxMTAPxv8E7LpxTB0kd+QyPqu+U5K00IxL1KnE6FSdWJGq 9S9A== X-Gm-Message-State: AOPr4FXRj5mLIcSGrinQBFQpfb5wkr7+L2lDzzCeChPPt3nc8ChMo/yp0SINcdoAZITNRg== X-Received: by 10.25.26.75 with SMTP id a72mr6589354lfa.17.1461866114399; Thu, 28 Apr 2016 10:55:14 -0700 (PDT) Received: from [192.168.1.42] (ppp109-252-90-74.pppoe.spdop.ru. [109.252.90.74]) by smtp.gmail.com with ESMTPSA id wt10sm1817397lbb.25.2016.04.28.10.55.13 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Apr 2016 10:55:13 -0700 (PDT) Subject: Re: How to receive notification of a new (disk) device being connected? To: The development of GNU GRUB References: <3df1c98b8135d4f64b0f9c3a8fa02df6@iam.tj> From: Andrei Borzenkov Message-ID: <57224E80.6060307@gmail.com> Date: Thu, 28 Apr 2016 20:55:12 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <3df1c98b8135d4f64b0f9c3a8fa02df6@iam.tj> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::229 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Apr 2016 17:55:19 -0000 28.04.2016 16:03, TJ пишет: > I'm currently finalising a patch that adds key-file support to > cryptodisk::cryptomount and luks. > > As well as being able to grub_device_iterate(hook,...) to search the > existing devices for the key-file the code needs to wait for TIMEOUT > seconds for additional (usually USB Mass Storage) devices to be > connected and when they are search them for the key-file. > > Is there an existing mechanism to receive such notifications, or a > blocking call that returns if a device is connected or a timeout is hit? > No. GRUB depends on firmware for disk access and not every firmware supports hotplugging in the first place. > Otherwise it looks like I'll have to track which devices are connected > when the TIMEOUT loop is first entered, grub_sleep(), then > grub_device_iterate() and see if the device list has any new entries. > > Secondly: am I correct to think using grub_search_fs_file(keyfile_name, > variable_name, ...) is the correct way to search for the key-file across > all devices, or do I need to use a specific hint type to indicate all > devices should be searched? > Hints are used to optimize search - if you can guess firmware device name, you avoid need to search across all devices. But it is in no way mandatory, and search should work without it.