Received: from list by lists.gnu.org with archive (Exim 4.71) id 1QrJhl-000745-Pz for mharc-grub-devel@gnu.org; Wed, 10 Aug 2011 21:05:01 -0400 Received: from eggs.gnu.org ([140.186.70.92]:59044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrJhj-00073u-Es for grub-devel@gnu.org; Wed, 10 Aug 2011 21:05:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrJhi-0001au-5J for grub-devel@gnu.org; Wed, 10 Aug 2011 21:04:59 -0400 Received: from mail-yx0-f169.google.com ([209.85.213.169]:48028) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrJhh-0001ao-VV for grub-devel@gnu.org; Wed, 10 Aug 2011 21:04:58 -0400 Received: by yxn22 with SMTP id 22so1164472yxn.0 for ; Wed, 10 Aug 2011 18:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; bh=nCS6WQXhgM+cSmEDiQqb/TwUIE9kN0a6YzT58n4A/1I=; b=rHAboqrzXcep3Q6tHBzv+PBuucTfkjrl4RPIXrQscEgf6Mhy+/i/CfeImBc/D7SUKD zWEZc3kiK4+j/x0xlusAz13Ayx3naNI+igBRKHMH7lpD14yyFpcpcYD67dD5XQLUTnev KSbLbUdL1xvHUIOmqH9uiGFhvRTM0m2v3qT4Y= Received: by 10.42.135.194 with SMTP id q2mr3737374ict.63.1313024696447; Wed, 10 Aug 2011 18:04:56 -0700 (PDT) Received: from fawn.thebedells.dyndns.org (cpe-74-76-197-33.nycap.res.rr.com [74.76.197.33]) by mx.google.com with ESMTPS id a9sm2252234icy.6.2011.08.10.18.04.53 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 10 Aug 2011 18:04:54 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Apple Message framework v1244.3) Subject: Re: getroot for ZFS without libzfs? From: Zachary Bedell In-Reply-To: Date: Wed, 10 Aug 2011 21:04:52 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <0C06B528-4EA9-48D4-820F-C6B408EC4CF0@gmail.com> References: <624ACA48-86E4-4ECB-A975-A47B1FB7F7E6@gmail.com> To: The development of GNU GRUB X-Mailer: Apple Mail (2.1244.3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.169 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2011 01:05:01 -0000 On Aug 10, 2011, at 8:22 AM, Robert Millan wrote: > 2011/8/9 Zachary Bedell : >> You'd need to look at all the raw devices to begin with and see which = if any has a ZFS label >=20 > Yes, but how do you know this is the label you wanted? Consider the > case where there's more than one pool with this name. The pool can be identified positively via the guid which is in the = labels and available via `zpool list -H -o guid `. It's not = possible to have two pools imported at once with the same name, so = getting the root dataset via parsing /proc/mounts, /etc/mtab, or = /etc/mnttab then going to `zpool list` will give you the guid of the = root pool definitively. Then just parse all the device labels until you = find a label with a matching guid. (And probably keep scanning for all = of the devices with that guid to install Grub to all of them similar to = the MD support, but I'm getting ahead of myself=85) It would also be possible to check the imported status of the pool since = a conflicted name couldn't be imported normally (though multiple pools = available via SAN fabric would probably invalidate that). It may also = be possible to compare the hostid of the host that has it imported, = though I'm not sure it's possible to get the hostid reliably without = going to libzfs. There's logic in the Linux ZFS driver that diverges = from both Solaris and FreeBSD a bit as far as how the hostid is = calculated from the live system, so that's probably a tough option. Is calling out to zpool as a helper kosher? The -H flag to zpool pool = is basically Sun's idea of a public API in that it's intended to output = only the requested fields with no header information for automated = parsing. >>> The other API that is available to us is /dev/zfs. But is that = device >>> meant to be used directly? How stable is this interface? >>=20 >> /dev/zfs is probably less stable than libzfs >=20 > Then I wouldn't use /dev/zfs. The less stable and standard is the ZFS > API GRUB uses, the more likely is that one can argue it doesn't fall > under the "system library" exception. Definitely agree. The fact that libzfs is specifically listed as = private API not intended for linking against also makes me wonder if the = syslib exception is a concern for that. > Directly accessing on-disk structures is entirely different, since a > data structure itself can't be copyrighted. Right. And a bonus that the on-disk is well documented by Sun with the = explicitly stated purpose of interoperability. Assuming calling out to zpool would be acceptable, I think I'm going to = dive in this week and see if I can get it running. The libzfs related = autoconf stuff is the biggest area that Linux is "special" in, and it = would be nice to yank that all out. -Zac