代码拉取完成,页面将自动刷新
同步操作将从 src-anolis-os/grub2 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <[email protected]>
Date: Tue, 26 Jun 2018 14:01:26 +0200
Subject: [PATCH] Use BLS fragment filename as menu entry id and for criteria
to sort
The BLS config filenames are guaranteed to be unique, so they can be
used as GRUB2 entry id and can also be used to sort the menu entries.
Signed-off-by: Javier Martinez Canillas <[email protected]>
---
grub-core/commands/blscfg.c | 62 +++++++++------------------------------------
1 file changed, 12 insertions(+), 50 deletions(-)
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
index 70939a818..cd8659384 100644
--- a/grub-core/commands/blscfg.c
+++ b/grub-core/commands/blscfg.c
@@ -70,6 +70,7 @@ struct bls_entry
{
struct keyval **keyvals;
int nkeyvals;
+ char *filename;
};
static struct bls_entry **entries;
@@ -166,6 +167,7 @@ static void bls_free_entry(struct bls_entry *entry)
grub_free (entry->keyvals);
grub_memset (entry, 0, sizeof (*entry));
+ grub_free (entry->filename);
grub_free (entry);
}
@@ -327,58 +329,12 @@ finish:
typedef int (*void_cmp_t)(void *, void *);
-static int nulcmp(char *s0, char *s1, void_cmp_t cmp)
-{
- grub_dprintf("blscfg", "%s got here\n", __func__);
- if (s1 && !s0)
- return 1;
- if (s0 && !s1)
- return -1;
- if (!s0 && !s1)
- return 0;
- if (cmp)
- return cmp(s0, s1);
- return grub_strcmp(s0, s1);
-}
-
-static int
-bls_keyval_cmp(struct bls_entry *e0, struct bls_entry *e1, const char *keyname)
-{
- char *val0, *val1;
-
- val0 = bls_get_val (e0, keyname, NULL);
- val1 = bls_get_val (e1, keyname, NULL);
-
- if (val1 && !val0)
- return 1;
-
- if (val0 && !val1)
- return -1;
-
- if (!val0 && !val1)
- return 0;
-
- return nulcmp(val0, val1, (void_cmp_t)vercmp);
-}
-
static int bls_cmp(const void *p0, const void *p1, void *state UNUSED)
{
struct bls_entry * e0 = *(struct bls_entry **)p0;
struct bls_entry * e1 = *(struct bls_entry **)p1;
- int rc = 0;
- rc = bls_keyval_cmp (e0, e1, "id");
-
- if (rc == 0)
- rc = bls_keyval_cmp (e0, e1, "version");
-
- if (rc == 0)
- rc = bls_keyval_cmp (e0, e1, "title");
-
- if (rc == 0)
- rc = bls_keyval_cmp (e0, e1, "linux");
-
- return rc;
+ return vercmp(e0->filename, e1->filename);
}
struct read_entry_info {
@@ -424,6 +380,12 @@ static int read_entry (
if (!entry)
goto finish;
+ entry->filename = grub_strndup(filename, n - 5);
+ if (!entry->filename)
+ goto finish;
+
+ entry->filename[n - 5] = '\0';
+
for (;;)
{
char *buf;
@@ -548,7 +510,7 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile)
char *options = NULL;
char **initrds = NULL;
char *initrd = NULL;
- char *id = NULL;
+ char *id = entry->filename;
char *hotkey = NULL;
char *users = NULL;
@@ -570,7 +532,6 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile)
title = bls_get_val (entry, "title", NULL);
options = bls_get_val (entry, "options", NULL);
initrds = bls_make_list (entry, "initrd", NULL);
- id = bls_get_val (entry, "id", NULL);
hotkey = bls_get_val (entry, "grub_hotkey", NULL);
users = bls_get_val (entry, "grub_users", NULL);
@@ -584,7 +545,8 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile)
argv[i] = args[i-1];
argv[argc] = NULL;
- grub_dprintf ("blscfg", "adding menu entry for \"%s\"\n", title);
+ grub_dprintf ("blscfg", "adding menu entry for \"%s\" with id \"%s\"\n",
+ title, id);
if (initrds)
{
int initrd_size = sizeof (GRUB_INITRD_CMD);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。