All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: keyboard layout patches
Date: Mon, 18 Jan 2010 14:20:10 +0100	[thread overview]
Message-ID: <4B54600A.4050904@gmail.com> (raw)
In-Reply-To: <20100118001016.GA12122@pina.cat>

[-- Attachment #1: Type: text/plain, Size: 2596 bytes --]

Carles Pina i Estany wrote:
> Hello,
>
> I've done a first version of keyboard_layout. Find a patch attached, or
> check the branch:
> bzr.savannah.gnu.org/srv/bzr/grub/people/cpina/keyboard_layouts
>
> I've tested only in at_keyboard. Using something like:
>
> insmod at_keyboard
> terminal_input at_keyboard
> insmod keyboard_layouts
> set keymaps_dir=/boot/grub/layouts
> load_keyboard es
>
> and before I generate the file called "es" and copied into
> /boot/grub/layouts using grub-mklayout es
>
> How could grub-mkinstall (00_header.in) know the current keyboard in the
> system? 
setxkbmap -print will give you the x layout but it won't work outside of X.
> I wold tweak 00_header.in to generate the keymap file and setup
> it.
>   
It may be executed by a daemon with no X available.
> Comments about the current patch are welcomed, I would change it on next
> days.
>
> Some days ago I read:
> "There are 2 hard problems in computer science: cache invalidation,
> naming things, and off-by-1 errors."
>
> Don't hesitate to tell me how would you rename some things, I'll do.
> I'm not happy with the name of some variables/functions but I cannot
> think about it today :-)
>
>   

+/* Layout file format constants.  */
+static const char file_magic[7] = { 'G', 'R', 'U', 'B', 'L', 'A', 'Y' };

Don't use misaligned magics.

+  prefix = grub_env_get ("keymaps_dir");
+  if (!prefix)
+    return grub_error (GRUB_ERR_READ_ERROR,
+		       "`keymaps_dir' variable not set up");
+
+  filename =
+    grub_malloc (grub_strlen (prefix) + grub_strlen ("/") +
+		 grub_strlen (args[0]) + 1);
Can you add support for complete filenames?
+  grub_sprintf (filename, "%s/%s", prefix, args[0]);

+  sprintf (command, CKBCOMP " %s", keymap);
+
+  fp = popen (command, "r");
+
Opens the possibility to execute any code by specifying layouts like |rm -rf /
+  for (i= 0; i < 128; i++)
+    {
+      keyboard_map_normal[i] = '\0';
+      keyboard_map_shift[i] = '\0';
+    }
use memset
+  grub_util_write_image ("GRUBLAY", 7, fp);
+  grub_util_write_image ((char *) &version, 4, fp);

should be macroified and put somewhere in a header instead of duplicating

Can you think of a way to restoring keyboard map to English?
> Cheers,
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]

  parent reply	other threads:[~2010-01-18 13:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-18  0:10 keyboard layout patches Carles Pina i Estany
2010-01-18  8:15 ` Felix Zielcke
2010-01-18 13:20 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2010-01-18 13:53   ` Carles Pina i Estany
2010-01-18 15:00     ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-01-18 19:25       ` Carles Pina i Estany
2010-01-18 19:31         ` Colin Watson
2010-01-18 22:17           ` Carles Pina i Estany
2010-01-19 23:21         ` Robert Millan
2010-01-20  0:03           ` Carles Pina i Estany
2010-01-19 23:19     ` Robert Millan
2010-01-18 20:04   ` Carles Pina i Estany
2010-01-19 23:22     ` Robert Millan
2010-01-18 23:27 ` Carles Pina i Estany

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B54600A.4050904@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.