On Fri, Apr 25, 2014 at 09:07:25PM +0200, Kay Sievers wrote: > On Fri, Apr 25, 2014 at 8:25 PM, Julian Andres Klode <[email protected]> wrote: > > > The Debian kernels are configured > > CONFIG_FAT_DEFAULT_IOCHARSET="utf8" > > which causes iocharset=utf8 to be the default here, rather than > > iocharset=ascii. I can now > > either work around that in the gummiboot package by one of > > > > (1) unlink() and then rename() > > (2) do a stupid glob() [Bb][Oo][Tt][Xx]64.[Ee][Ff][Ii] (and the same for > > the rest of the path) > > > > I don't think you'd like either of those upstream, so you might want to > > change > > the generator to pass iocharset=ascii. We do not (apart from me) use that > > generator, though, so it won't help Debian -- we generate a fstab entry > > during > > system installation instead. > > Are we sure that this is the expected kernel behaviour? Seems pretty > odd to be caused by the charset option: > > With ascii all is fine: > # mount /dev/sda1 /boot -o iocharset=ascii > # touch /boot/EFI/A > # rm /boot/EFI/a > rm: remove regular empty file ‘/boot/EFI/a’? y > > With UTF8 it breaks: > # mount /dev/sda1 /boot -o iocharset=utf8 > # touch /boot/EFI/A > # rm /boot/EFI/a > rm: cannot remove ‘/boot/EFI/a’: No such file or directory > > And it gets even more weird here: > > All is fine: > [root@lon /]# touch /boot/EFI/a > [root@lon /]# touch /boot/EFI/A > > This fails: > [root@lon /]# touch /boot/EFI/A > [root@lon /]# touch /boot/EFI/a > touch: cannot touch ‘/boot/EFI/a’: File exists
So I attached a -patch- workaround for this problem, or well, most instances of it. It simply opens the directory EFI/Boot and checks for an existing bootx64.efi in whatever case. If it finds one, it uses that case, otherwise it uses lower-case (previous code used uppercase, I can change that back, but this is a bit shorter). I also have a version that globs() the entire path and uses the first match if it exists, but it's slightly longer. And most systems should have EFI/Boot in that case anyway. -- Julian Andres Klode - Debian Developer, Ubuntu Member See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/. Please do not top-post if possible.
>From 676b1f04015af0cf88327f8326b20d21f3445786 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode <[email protected]> Date: Tue, 3 Jun 2014 17:41:51 +0200 Subject: [PATCH] setup: Normalize the boot*.efi to the case used by the file system Ensure that bootx64.efi and friends use the same case as the already existing file to ensure that we correctly replace it on systems where the ESP is mounted using utf8 (such as Debian). This also changes the default case of these files to lower case as it completely replaces the strupper function. Bug-Debian: http://bugs.debian.org/745280 --- src/setup/setup.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/setup/setup.c b/src/setup/setup.c index 0cfaccf..cb96a85 100644 --- a/src/setup/setup.c +++ b/src/setup/setup.c @@ -682,13 +682,33 @@ finish: return r; } -static char* strupper(char *s) { - char *p; +static int normalize_filename_case(char *name) { + char *base_start; + char *base; + DIR *d; + struct dirent *de; + + base_start = strrchr(name, '/'); + base = base_start + 1; + + *base_start = 0; + d = opendir(name); + *base_start = '/'; + + if (d == NULL) + return -errno; - for (p = s; *p; p++) - *p = toupper(*p); + while ((de = readdir(d))) { + /* Normalize (only) the base name of the given path */ + if (strcasecmp(de->d_name, base) == 0) { + strcpy(base, de->d_name); + break; + } + } - return s; + closedir(d); + + return 0; } static int mkdir_one(const char *prefix, const char *suffix) { @@ -765,7 +785,7 @@ static int copy_one_file(const char *esp_path, const char *name, bool force) { r = -ENOMEM; goto finish; } - strupper(strrchr(v, '/') + 1); + normalize_filename_case(v); k = copy_file(p, v, force); if (k < 0 && r == 0) { -- 2.0.0.rc4

