* Remove trailing space from FAT label
@ 2009-02-04 12:01 phcoder
2009-02-04 16:32 ` Pavel Roskin
2009-02-07 22:36 ` Robert Millan
0 siblings, 2 replies; 4+ messages in thread
From: phcoder @ 2009-02-04 12:01 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 167 bytes --]
Hello. Here is the patch to remove trailing spaces from FAT label. These
spaces generally aren't considiered to be part of label
Thanks
Vladimir 'phcoder' Serbinenko
[-- Attachment #2: fatlabel.diff --]
[-- Type: text/x-diff, Size: 915 bytes --]
Index: fs/fat.c
===================================================================
--- fs/fat.c (revision 1973)
+++ fs/fat.c (working copy)
@@ -809,7 +809,13 @@
if (dir.attr == GRUB_FAT_ATTR_VOLUME_ID)
{
- *label = grub_strndup ((char *) dir.name, 11);
+ int labellen = 0, i;
+ for (i = 0; i < 11; i++)
+ if (dir.name[i] != ' ')
+ labellen = i + 1;
+
+ *label = grub_strndup ((char *) dir.name, labellen);
+
return GRUB_ERR_NONE;
}
}
Index: ChangeLog
===================================================================
--- ChangeLog (revision 1973)
+++ ChangeLog (working copy)
@@ -1,3 +1,9 @@
+2009-02-04 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Remove trailing spaces from FAT label
+
+ * fs/fat.c (grub_fat_label): Remove trailing spaces
+
2009-02-04 Felix Zielcke <fzielcke@z-51.de>
util/getroot.c (grub_util_get_grub_dev): Add support for /dev/mdNpN and
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Remove trailing space from FAT label
2009-02-04 12:01 Remove trailing space from FAT label phcoder
@ 2009-02-04 16:32 ` Pavel Roskin
2009-02-04 18:15 ` phcoder
2009-02-07 22:36 ` Robert Millan
1 sibling, 1 reply; 4+ messages in thread
From: Pavel Roskin @ 2009-02-04 16:32 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, 2009-02-04 at 13:01 +0100, phcoder wrote:
> Hello. Here is the patch to remove trailing spaces from FAT label. These
> spaces generally aren't considiered to be part of label
Suppose the label is "DOS \0DDDDDDDD", then your algorithm will fail to
strip the final space, as it would iterate past the binary null. I
don't know if it can happen, but I guess it's better to be prepared.
Also, please see how ordinary 8.3 filenames are handled. Look for "8.3"
in fs/fat.c. grub_isspace() is used to check for spaces. Binary nulls
and spaces terminate the name. There may be no spaces anywhere in the
name.
Perhaps we could use the same mechanism for the label except that no "."
is added.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Remove trailing space from FAT label
2009-02-04 16:32 ` Pavel Roskin
@ 2009-02-04 18:15 ` phcoder
0 siblings, 0 replies; 4+ messages in thread
From: phcoder @ 2009-02-04 18:15 UTC (permalink / raw)
To: The development of GRUB 2
Hello
> Suppose the label is "DOS \0DDDDDDDD",
Such a label is incorrect. But I agree with you that we should reuse the
code and be fault-tolerant (I regularly see FAT volumes breaking the
specifications). Additionally there is a mechanism of nice fat label
which works the same way as long names (supported only by some OS).
Unifying the code would make these labels accessible. So I'll write a
new proposition soon.
Thanks
Vladimir 'phcoder' Serbinenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Remove trailing space from FAT label
2009-02-04 12:01 Remove trailing space from FAT label phcoder
2009-02-04 16:32 ` Pavel Roskin
@ 2009-02-07 22:36 ` Robert Millan
1 sibling, 0 replies; 4+ messages in thread
From: Robert Millan @ 2009-02-07 22:36 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Feb 04, 2009 at 01:01:55PM +0100, phcoder wrote:
> Hello. Here is the patch to remove trailing spaces from FAT label. These
> spaces generally aren't considiered to be part of label
> Thanks
> Vladimir 'phcoder' Serbinenko
> Index: fs/fat.c
> ===================================================================
> --- fs/fat.c (revision 1973)
> +++ fs/fat.c (working copy)
> @@ -809,7 +809,13 @@
>
> if (dir.attr == GRUB_FAT_ATTR_VOLUME_ID)
> {
> - *label = grub_strndup ((char *) dir.name, 11);
> + int labellen = 0, i;
> + for (i = 0; i < 11; i++)
Please use a descriptive macro instead of hardcoding 11.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-02-07 22:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-04 12:01 Remove trailing space from FAT label phcoder
2009-02-04 16:32 ` Pavel Roskin
2009-02-04 18:15 ` phcoder
2009-02-07 22:36 ` Robert Millan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.