diff options
Diffstat (limited to 'recipes/ostree/ostree/0003-Allow-updating-files-in-root-of-boot.patch')
-rw-r--r-- | recipes/ostree/ostree/0003-Allow-updating-files-in-root-of-boot.patch | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/recipes/ostree/ostree/0003-Allow-updating-files-in-root-of-boot.patch b/recipes/ostree/ostree/0003-Allow-updating-files-in-root-of-boot.patch deleted file mode 100644 index d93da22..0000000 --- a/recipes/ostree/ostree/0003-Allow-updating-files-in-root-of-boot.patch +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | From f5a1391e64d4b17ed05fb47f23d5d35affb9f1fd Mon Sep 17 00:00:00 2001 | ||
2 | From: Gatis Paeglis <gatis.paeglis@theqtcompany.com> | ||
3 | Date: Thu, 5 Nov 2015 14:58:56 +0100 | ||
4 | Subject: [PATCH] Allow updating files in root of /boot | ||
5 | |||
6 | It is common for u-boot based systems to search | ||
7 | top level directory of the boot partiton for | ||
8 | additional files that are required for booting. | ||
9 | It can be difficult to change this search logic | ||
10 | if it is hardcoded somewhere low in the stack or | ||
11 | in u-boot env that is in read-only memory. To | ||
12 | allow updating these files you need to add a | ||
13 | symlink in your ostree sysroot: | ||
14 | |||
15 | cd sysroot/boot | ||
16 | ln -s loader/my-special-file my-special-file | ||
17 | |||
18 | The bellow code will make sure that loader/my-special-file | ||
19 | points to the correct target file version. | ||
20 | |||
21 | This does not break the atomic property of update. | ||
22 | --- | ||
23 | src/libostree/ostree-bootloader-uboot.c | 65 +++++++++++++++++++++++++++++++++ | ||
24 | 1 file changed, 65 insertions(+) | ||
25 | |||
26 | diff --git a/src/libostree/ostree-bootloader-uboot.c b/src/libostree/ostree-bootloader-uboot.c | ||
27 | index be1a40d..779c302 100644 | ||
28 | --- a/src/libostree/ostree-bootloader-uboot.c | ||
29 | +++ b/src/libostree/ostree-bootloader-uboot.c | ||
30 | @@ -131,6 +131,71 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, | ||
31 | } | ||
32 | } | ||
33 | |||
34 | + { | ||
35 | + /* It is common for u-boot based systems to search top level directory of the boot | ||
36 | + * partiton for additional files that are required for booting. It can be difficult | ||
37 | + * to change this search logic if it is hardcoded somewhere low in the stack or in | ||
38 | + * u-boot env that is in read-only memory. To allow updating these files you need to | ||
39 | + * add a symlink in your ostree sysroot: | ||
40 | + * | ||
41 | + * cd sysroot/boot | ||
42 | + * ln -s loader/my-special-file my-special-file | ||
43 | + * | ||
44 | + * The bellow code will make sure that loader/my-special-file points to the correct | ||
45 | + * target file version. | ||
46 | + * | ||
47 | + */ | ||
48 | + g_autoptr(GFile) child = NULL; | ||
49 | + int loader_fd; | ||
50 | + g_autoptr(GFileEnumerator) dir_enum = NULL; | ||
51 | + g_autoptr(GFile) real_boot = NULL; | ||
52 | + g_autofree char *loader_path = NULL; | ||
53 | + char buf[2048]; | ||
54 | + | ||
55 | + child = ot_gfile_resolve_path_printf (self->sysroot->path, "boot/loader.%d/", bootversion); | ||
56 | + loader_path = g_file_get_path(child); | ||
57 | + loader_fd = open (loader_path, O_RDONLY); | ||
58 | + if (loader_fd == -1) { | ||
59 | + perror("open"); | ||
60 | + goto out; | ||
61 | + } | ||
62 | + | ||
63 | + child = g_file_get_child (self->sysroot->path, "boot"); | ||
64 | + dir_enum = g_file_enumerate_children (child, OSTREE_GIO_FAST_QUERYINFO, | ||
65 | + G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, | ||
66 | + NULL, error); | ||
67 | + | ||
68 | + while (TRUE) { | ||
69 | + const char *symlink_target, *name; | ||
70 | + GFileInfo *file_info = NULL; | ||
71 | + | ||
72 | + if (!gs_file_enumerator_iterate (dir_enum, &file_info, NULL, cancellable, error)) { | ||
73 | + close(loader_fd); | ||
74 | + goto out; | ||
75 | + } | ||
76 | + | ||
77 | + if (file_info == NULL) | ||
78 | + break; | ||
79 | + | ||
80 | + if (g_file_info_get_is_symlink(file_info)) { | ||
81 | + symlink_target = g_file_info_get_symlink_target(file_info); | ||
82 | + if (g_str_has_prefix(symlink_target, "loader/")) { | ||
83 | + name = g_file_info_get_name(file_info); | ||
84 | + if (g_strcmp0 (name, "uEnv.txt") == 0) | ||
85 | + continue; | ||
86 | + | ||
87 | + snprintf(buf, sizeof(buf), "%s/%s", loader_path, name); | ||
88 | + remove(buf); | ||
89 | + snprintf(buf, sizeof(buf), "..%s/%s", boot_path, name); | ||
90 | + if (symlinkat(buf, loader_fd, name) == -1) | ||
91 | + perror("symlinkat"); | ||
92 | + } | ||
93 | + } | ||
94 | + } | ||
95 | + | ||
96 | + close(loader_fd); | ||
97 | + } | ||
98 | + | ||
99 | ret = TRUE; | ||
100 | out: | ||
101 | return ret; | ||
102 | -- | ||
103 | 2.1.4 | ||
104 | |||