Re: geom_label problems when MS-DOS FS label is blank (all spaces)

From: Yuriy Tsibizov <Yuriy.Tsibizov_at_gfk.ru>
Date: Sat, 12 May 2007 20:43:16 +0400 (MSD)
On Sat, 12 May 2007, Stefan Farfeleder wrote:
> On Sat, May 12, 2007 at 10:51:25AM +0400, Yuriy Tsibizov wrote:
>>> In this situation libdisk can't parse kern.geom.conftxt and sysinstall
>>> exits with BARF 171 message.
>>
>>  It can be fixed with following patch. "all spaces" volume will be treated
>>  like a volume without label.
>>
>>  Index: g_label_msdosfs.c
>>  ===================================================================
>>  RCS file: /home/ncvs/src/sys/geom/label/g_label_msdosfs.c,v
>>  retrieving revision 1.6
>>  diff -u -r1.6 g_label_msdosfs.c
>>  --- g_label_msdosfs.c	30 Sep 2006 08:16:49 -0000	1.6
>>  +++ g_label_msdosfs.c	12 May 2007 06:39:23 -0000
>>  _at__at_ -200,7 +200,7 _at__at_
>>   	}
>>
>>   endofchecks:
>>  -	for (i = size - 1; i > 0; i--) {
>>  +	for (i = size - 1; i >= 0; i--) {
>>   		if (label[i] == '\0')
>>   			continue;
>>   		else if (label[i] == ' ')
>
> This won't work because i is unsigned.

Ok, I see that this patch is not correct.

Do you like this one?

Index: g_label_msdosfs.c
===================================================================
RCS file: /home/ncvs/src/sys/geom/label/g_label_msdosfs.c,v
retrieving revision 1.6
diff -u -r1.6 g_label_msdosfs.c
--- g_label_msdosfs.c	30 Sep 2006 08:16:49 -0000	1.6
+++ g_label_msdosfs.c	12 May 2007 13:37:06 -0000
_at__at_ -208,6 +208,8 _at__at_
  		else
  			break;
  	}
+	if (label[i] == ' ')
+		label[i] = '\0';

  error:
  	if (sector0 != NULL)

(there is no need to check for i == 0, because label[i] is not equal
to ' ' if i > 0 after for() loop)

Yuriy.
Received on Sat May 12 2007 - 14:43:30 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:10 UTC