From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1d7iCq-0000x7-CA for mharc-grub-devel@gnu.org; Mon, 08 May 2017 08:56:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7iCn-0000wq-6B for grub-devel@gnu.org; Mon, 08 May 2017 08:56:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7iCj-0003xd-TL for grub-devel@gnu.org; Mon, 08 May 2017 08:56:01 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:34920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d7iCj-0003x8-JB for grub-devel@gnu.org; Mon, 08 May 2017 08:55:57 -0400 Received: by mail-wr0-x243.google.com with SMTP id g12so8360969wrg.2 for ; Mon, 08 May 2017 05:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:reply-to:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=qM5SKdu+rNdsY9qtR/25+CUMYkQeIA+dLRi9y1E8Ra8=; b=FJvH8C/Ejs1MBFU2pEYLPlxG2hsqA2WiffA6qTz7xg6a5lspKT4ykN9+9dvglU8KTQ 9vOirFBw6pUpuZF8RLvSHxxN4s+Ib/8ku1weCKTXLkqTIQxcA0DSzbZ7wPp77uyYBsQb QYD8VlttK9zWb+0KD0Sha4nyc0YdsW67Oa2S4AX6ryaBqomVwX2BUEzh//zujEXun2LW YCKMjNf4B6Ro4dV39k5kel1M5to9ogHB5Ap3hFPKyOOd0N6iMmsSyvYAaXg0XXLBglu/ vebeiLj1U7lyjJRJAgGCgy8VUNIIHE0AjLQeG4O4uDfNVoL686A7L8xp5MrA/gMCkSG3 HSjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:reply-to :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=qM5SKdu+rNdsY9qtR/25+CUMYkQeIA+dLRi9y1E8Ra8=; b=HL6VOWtSUdNPpHV4xfatpt7aFBAkcCDGCHUicwSEL5lPQzdq2dvgR6SiwjuVMOo6fK LyILk5qkyY89ByW9PfEyQi5V027LLG4D35CJkkhSp0lbXF29ReUiW7i39NIr/dSQSoPc HycWwkWD+p72J4d/Ep2DpT9tHBSBChLboRna1fbKnDGhwCZECAXyy/yuA+JaDNr3TTgx QjErnRtWIp5MT2PY2SfxgBmtxph10GgB0d07ZVV7iEeJPNHlTNqWpwsrj1rHJSyeq0kN Ydk6hUhYbAuAbnT0ToKm4vxznIMJRrwJK/Vp06Ahc+ykvasNe0/zEFUpL4L7xt67goVN LVQA== X-Gm-Message-State: AN3rC/4ZUS4Pv8eijAqk39op62X4gpWMt909AC6R+u2Upl1gh9e/BXNL nkOl2pQD6MA7BJ+W X-Received: by 10.223.164.153 with SMTP id g25mr38985163wrb.103.1494248155773; Mon, 08 May 2017 05:55:55 -0700 (PDT) Received: from pali (atrey.karlin.mff.cuni.cz. [195.113.26.193]) by smtp.gmail.com with ESMTPSA id s110sm18492957wrc.5.2017.05.08.05.55.54 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 08 May 2017 05:55:54 -0700 (PDT) Date: Mon, 8 May 2017 14:55:49 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: grub-devel@gnu.org Subject: Re: [PATCH] * grub-core/fs/udf.c: Add support for UUID Message-ID: <20170508125549.GA6713@pali> Reply-To: Pali =?utf-8?B?Um9ow6Fy?= References: <1491849330-10140-1-git-send-email-pali.rohar@gmail.com> <20170419174839.GG18887@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170419174839.GG18887@pali> User-Agent: Mutt/1.5.23.1 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 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: Mon, 08 May 2017 12:56:02 -0000 Gentle PING for this patch! On Wednesday 19 April 2017 19:48:39 Pali Rohár wrote: > Hi! I would like to remind this patch. It allows to use UUID of UDF > partition in grub2. Linux tool blkid is already able to handle it, so it > is possible to specify UUID of UDF partition in /etc/fstab. > > UDF is filesystem used on optical disks (DVD), but also on hard disks as > it is natively supported by Windows, Linux and Mac OS X kernels. Which > is a good benefit for multi-boot environment. > > On Monday 10 April 2017 20:35:30 Pali Rohár wrote: > > Use same algorithm as in libblkid from util-linux. > > --- > > grub-core/fs/udf.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++-- > > 1 file changed, 131 insertions(+), 5 deletions(-) > > > > diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c > > index 839bff8..a4baa4c 100644 > > --- a/grub-core/fs/udf.c > > +++ b/grub-core/fs/udf.c > > @@ -321,6 +321,32 @@ struct grub_udf_partmap > > }; > > } GRUB_PACKED; > > > > +struct grub_udf_pvd > > +{ > > + struct grub_udf_tag tag; > > + grub_uint32_t seq_num; > > + grub_uint32_t pvd_num; > > + grub_uint8_t ident[32]; > > + grub_uint16_t vol_seq_num; > > + grub_uint16_t max_vol_seq_num; > > + grub_uint16_t interchange_level; > > + grub_uint16_t max_interchange_level; > > + grub_uint32_t charset_list; > > + grub_uint32_t max_charset_list; > > + grub_uint8_t volset_ident[128]; > > + struct grub_udf_charspec desc_charset; > > + struct grub_udf_charspec expl_charset; > > + struct grub_udf_extent_ad vol_abstract; > > + struct grub_udf_extent_ad vol_copyright; > > + struct grub_udf_regid app_ident; > > + struct grub_udf_timestamp recording_time; > > + struct grub_udf_regid imp_ident; > > + grub_uint8_t imp_use[64]; > > + grub_uint32_t pred_vds_loc; > > + grub_uint16_t flags; > > + grub_uint8_t reserved[22]; > > +} GRUB_PACKED; > > + > > struct grub_udf_lvd > > { > > struct grub_udf_tag tag; > > @@ -348,6 +374,7 @@ struct grub_udf_aed > > struct grub_udf_data > > { > > grub_disk_t disk; > > + struct grub_udf_pvd pvd; > > struct grub_udf_lvd lvd; > > struct grub_udf_pd pds[GRUB_UDF_MAX_PDS]; > > struct grub_udf_partmap *pms[GRUB_UDF_MAX_PMS]; > > @@ -692,7 +719,17 @@ grub_udf_mount (grub_disk_t disk) > > } > > > > tag.tag_ident = U16 (tag.tag_ident); > > - if (tag.tag_ident == GRUB_UDF_TAG_IDENT_PD) > > + if (tag.tag_ident == GRUB_UDF_TAG_IDENT_PVD) > > + { > > + if (grub_disk_read (disk, block << lbshift, 0, > > + sizeof (struct grub_udf_pvd), > > + &data->pvd)) > > + { > > + grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem"); > > + goto fail; > > + } > > + } > > + else if (tag.tag_ident == GRUB_UDF_TAG_IDENT_PD) > > { > > if (data->npd >= GRUB_UDF_MAX_PDS) > > { > > @@ -821,7 +858,7 @@ grub_udf_get_cluster_sector (grub_disk_t disk, grub_uint64_t *sec_per_lcn) > > #endif > > > > static char * > > -read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf) > > +read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf, int normalize_utf8) > > { > > grub_uint16_t *utf16 = NULL; > > grub_size_t utf16len = 0; > > @@ -832,6 +869,15 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf) > > if (raw[0] != 8 && raw[0] != 16) > > return NULL; > > > > + if (raw[0] == 8 && !normalize_utf8) > > + { > > + if (!outbuf) > > + outbuf = grub_strndup ((char *)raw + 1, sz - 1); > > + else > > + grub_memcpy (outbuf, raw + 1, sz - 1); > > + return outbuf; > > + } > > + > > if (raw[0] == 8) > > { > > unsigned i; > > @@ -923,7 +969,7 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir, > > != dirent.file_ident_length) > > return 0; > > > > - filename = read_string (raw, dirent.file_ident_length, 0); > > + filename = read_string (raw, dirent.file_ident_length, 0, 1); > > if (!filename) > > grub_print_error (); > > > > @@ -1009,7 +1055,7 @@ grub_udf_read_symlink (grub_fshelp_node_t node) > > /* in 4 + n bytes. out, at most: 1 + 2 * n bytes. */ > > if (optr != out) > > *optr++ = '/'; > > - if (!read_string (ptr + 4, s - 4, optr)) > > + if (!read_string (ptr + 4, s - 4, optr, 1)) > > goto fail; > > optr += grub_strlen (optr); > > break; > > @@ -1197,7 +1243,7 @@ grub_udf_label (grub_device_t device, char **label) > > > > if (data) > > { > > - *label = read_string (data->lvd.ident, sizeof (data->lvd.ident), 0); > > + *label = read_string (data->lvd.ident, sizeof (data->lvd.ident), 0, 1); > > grub_free (data); > > } > > else > > @@ -1206,6 +1252,85 @@ grub_udf_label (grub_device_t device, char **label) > > return grub_errno; > > } > > > > +static char * > > +gen_uuid_from_volset (char *volset_ident) > > +{ > > + grub_size_t i; > > + grub_size_t len; > > + grub_size_t binpos; > > + grub_uint8_t buf[17]; > > + char *uuid; > > + > > + len = grub_strlen (volset_ident); > > + if (len < 8) > > + return NULL; > > + > > + uuid = grub_malloc (17); > > + if (!uuid) > > + return NULL; > > + > > + if (len > 16) > > + len = 16; > > + > > + grub_memset (buf, 0, sizeof (buf)); > > + grub_memcpy (buf, volset_ident, len); > > + > > + binpos = 16; > > + for (i = 0; i < len; ++i) > > + { > > + if (!grub_isalnum (buf[i])) > > + { > > + binpos = i; > > + break; > > + } > > + } > > + > > + if (binpos < 8) > > + { > > + grub_snprintf (uuid, 17, "%02x%02x%02x%02x%02x%02x%02x%02x", > > + buf[0], buf[1], buf[2], buf[3], > > + buf[4], buf[5], buf[6], buf[7]); > > + } > > + else if (binpos < 16) > > + { > > + grub_memcpy (uuid, buf, 8); > > + grub_snprintf (uuid+8, 9, "%02x%02x%02x%02x", > > + buf[8], buf[9], buf[10], buf[11]); > > + } > > + else > > + { > > + grub_memcpy (uuid, buf, 16); > > + uuid[16] = 0; > > + } > > + > > + return uuid; > > +} > > + > > +static grub_err_t > > +grub_udf_uuid (grub_device_t device, char **uuid) > > +{ > > + char *volset_ident; > > + struct grub_udf_data *data; > > + data = grub_udf_mount (device->disk); > > + > > + if (data) > > + { > > + volset_ident = read_string (data->pvd.volset_ident, sizeof (data->pvd.volset_ident), 0, 0); > > + if (volset_ident) > > + { > > + *uuid = gen_uuid_from_volset (volset_ident); > > + grub_free (volset_ident); > > + } > > + else > > + *uuid = 0; > > + grub_free (data); > > + } > > + else > > + *uuid = 0; > > + > > + return grub_errno; > > +} > > + > > static struct grub_fs grub_udf_fs = { > > .name = "udf", > > .dir = grub_udf_dir, > > @@ -1213,6 +1338,7 @@ static struct grub_fs grub_udf_fs = { > > .read = grub_udf_read, > > .close = grub_udf_close, > > .label = grub_udf_label, > > + .uuid = grub_udf_uuid, > > #ifdef GRUB_UTIL > > .reserved_first_sector = 1, > > .blocklist_install = 1, > -- Pali Rohár pali.rohar@gmail.com