+ return (int) (l / sizeof(uint16_t));
+}
+
+int efi_get_boot_options(uint16_t **options) {
+ _cleanup_closedir_ DIR *dir = NULL;
+ struct dirent *de;
+ uint16_t *list = NULL;
+ int count = 0;
+
+ assert(options);
+
+ dir = opendir("/sys/firmware/efi/efivars/");
+ if (!dir)
+ return -errno;
+
+ while ((de = readdir(dir))) {
+ size_t n;
+ int a, b, c, d;
+ uint16_t *t;
+
+ if (strncmp(de->d_name, "Boot", 4) != 0)
+ continue;
+
+ n = strlen(de->d_name);
+ if (n != 45)
+ continue;
+
+ if (strcmp(de->d_name + 8, "-8be4df61-93ca-11d2-aa0d-00e098032b8c") != 0)
+ continue;
+
+ a = de->d_name[4];
+ b = de->d_name[5];
+ c = de->d_name[6];
+ d = de->d_name[7];
+
+ if (!isdigit(a) || !isdigit(b) || !isdigit(c) || !isdigit(d))
+ continue;
+
+ t = realloc(list, (count + 1) * sizeof(uint16_t));
+ if (!t) {
+ free(list);
+ return -ENOMEM;
+ }
+
+ list = t;
+ list[count ++] = (a - '0') * 1000 + (b - '0') * 100 + (c - '0') * 10 + (d - '0');
+
+ }
+
+ *options = list;
+ return count;