]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
79706e22fd4d7547839f125d2ecbc7dbe98766fd
[Ventoy.git] / GRUB2 / MOD_SRC / grub-2.04 / grub-core / ventoy / ventoy_def.h
1 /******************************************************************************
2 * ventoy_def.h
3 *
4 * Copyright (c) 2020, longpanda <admin@ventoy.net>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #ifndef __VENTOY_DEF_H__
22 #define __VENTOY_DEF_H__
23
24 #define VTOY_MAX_SCRIPT_BUF (4 * 1024 * 1024)
25
26 #define VTOY_PART_BUF_LEN (128 * 1024)
27
28 #define VTOY_FILT_MIN_FILE_SIZE 32768
29
30 #define VTOY_SIZE_1GB 1073741824
31 #define VTOY_SIZE_512KB (512 * 1024)
32
33 #define JSON_SUCCESS 0
34 #define JSON_FAILED 1
35 #define JSON_NOT_FOUND 2
36
37 #define ulong unsigned long
38 #define ulonglong unsigned long long
39
40 #define vtoy_to_upper(c) (((char)(c) >= 'a' && (char)(c) <= 'z') ? ((char)(c) - 'a' + 'A') : (char)(c))
41
42 #define VENTOY_CMD_RETURN(err) grub_errno = (err); return (err)
43 #define VENTOY_FILE_TYPE (GRUB_FILE_TYPE_NO_DECOMPRESS | GRUB_FILE_TYPE_LINUX_INITRD)
44
45 #define ventoy_env_op1(op, a) grub_env_##op(a)
46 #define ventoy_env_op2(op, a, b) grub_env_##op((a), (b))
47
48 #define ventoy_get_env(key) ventoy_env_op1(get, key)
49 #define ventoy_set_env(key, val) ventoy_env_op2(set, key, val)
50
51 typedef struct ventoy_initrd_ctx
52 {
53 const char *path_prefix;
54 const char *dir_prefix;
55 }ventoy_initrd_ctx;
56
57 typedef struct cmd_para
58 {
59 const char *name;
60 grub_extcmd_func_t func;
61 grub_command_flags_t flags;
62 const struct grub_arg_option *parser;
63
64 const char *summary;
65 const char *description;
66
67 grub_extcmd_t cmd;
68 }cmd_para;
69
70 #define ventoy_align_2k(value) ((value + 2047) / 2048 * 2048)
71 #define ventoy_align(value, align) (((value) + ((align) - 1)) & (~((align) - 1)))
72
73 #pragma pack(1)
74 typedef struct cpio_newc_header
75 {
76 char c_magic[6];
77 char c_ino[8];
78 char c_mode[8];
79 char c_uid[8];
80 char c_gid[8];
81 char c_nlink[8];
82 char c_mtime[8];
83 char c_filesize[8];
84 char c_devmajor[8];
85 char c_devminor[8];
86 char c_rdevmajor[8];
87 char c_rdevminor[8];
88 char c_namesize[8];
89 char c_check[8];
90 }cpio_newc_header;
91 #pragma pack()
92
93
94 #define cmd_raw_name ctxt->extcmd->cmd->name
95 #define check_free(p, func) if (p) { func(p); p = NULL; }
96 #define grub_check_free(p) if (p) { grub_free(p); p = NULL; }
97
98 typedef int (*grub_char_check_func)(int c);
99 #define ventoy_is_decimal(str) ventoy_string_check(str, grub_isdigit)
100
101
102 // El Torito Boot Record Volume Descriptor
103 #pragma pack(1)
104 typedef struct eltorito_descriptor
105 {
106 grub_uint8_t type;
107 grub_uint8_t id[5];
108 grub_uint8_t version;
109 grub_uint8_t system_id[32];
110 grub_uint8_t reserved[32];
111 grub_uint32_t sector;
112 }eltorito_descriptor;
113
114 typedef struct ventoy_iso9660_override
115 {
116 grub_uint32_t first_sector;
117 grub_uint32_t first_sector_be;
118 grub_uint32_t size;
119 grub_uint32_t size_be;
120 }ventoy_iso9660_override;
121
122 typedef struct ventoy_udf_override
123 {
124 grub_uint32_t length;
125 grub_uint32_t position;
126 }ventoy_udf_override;
127
128 typedef struct ventoy_iso9660_vd
129 {
130 grub_uint8_t type;
131 grub_uint8_t id[5];
132 grub_uint8_t ver;
133 grub_uint8_t res;
134 char sys[32];
135 char vol[32];
136 }ventoy_iso9660_vd;
137
138 #pragma pack()
139
140 #define img_type_iso 0
141 #define img_type_wim 1
142 #define img_type_efi 2
143 #define img_type_img 3
144
145 typedef struct img_info
146 {
147 int pathlen;
148 char path[512];
149 char name[256];
150
151 const char *alias;
152 const char *class;
153 const char *menu_prefix;
154
155 int id;
156 int type;
157 grub_uint64_t size;
158 int select;
159 int unsupport;
160
161 void *parent;
162
163 struct img_info *next;
164 struct img_info *prev;
165 }img_info;
166
167 typedef struct img_iterator_node
168 {
169 struct img_iterator_node *next;
170 img_info **tail;
171 char dir[400];
172 int dirlen;
173 int isocnt;
174 int done;
175 int select;
176
177 struct img_iterator_node *parent;
178 struct img_iterator_node *firstchild;
179
180 void *firstiso;
181 }img_iterator_node;
182
183
184
185 typedef struct initrd_info
186 {
187 char name[256];
188
189 grub_uint64_t offset;
190 grub_uint64_t size;
191
192 grub_uint8_t iso_type; // 0: iso9660 1:udf
193 grub_uint32_t udf_start_block;
194
195 grub_uint64_t override_offset;
196 grub_uint32_t override_length;
197 char override_data[32];
198
199 struct initrd_info *next;
200 struct initrd_info *prev;
201 }initrd_info;
202
203 extern initrd_info *g_initrd_img_list;
204 extern initrd_info *g_initrd_img_tail;
205 extern int g_initrd_img_count;
206 extern int g_valid_initrd_count;
207
208 extern img_info *g_ventoy_img_list;
209 extern int g_ventoy_img_count;
210
211 extern grub_uint8_t *g_ventoy_cpio_buf;
212 extern grub_uint32_t g_ventoy_cpio_size;
213 extern cpio_newc_header *g_ventoy_initrd_head;
214 extern grub_uint8_t *g_ventoy_runtime_buf;
215
216 extern ventoy_guid g_ventoy_guid;
217
218 extern ventoy_img_chunk_list g_img_chunk_list;
219 extern ventoy_img_chunk_list g_wimiso_chunk_list;
220 extern char *g_wimiso_path;
221
222 extern int g_ventoy_debug;
223 void ventoy_debug(const char *fmt, ...);
224 #define debug(fmt, ...) if (g_ventoy_debug) ventoy_debug("[VTOY]: "fmt, __VA_ARGS__)
225
226 #define vtoy_ssprintf(buf, pos, fmt, ...) \
227 pos += grub_snprintf(buf + pos, VTOY_MAX_SCRIPT_BUF - pos, fmt, __VA_ARGS__)
228
229 #define FLAG_HEADER_RESERVED 0x00000001
230 #define FLAG_HEADER_COMPRESSION 0x00000002
231 #define FLAG_HEADER_READONLY 0x00000004
232 #define FLAG_HEADER_SPANNED 0x00000008
233 #define FLAG_HEADER_RESOURCE_ONLY 0x00000010
234 #define FLAG_HEADER_METADATA_ONLY 0x00000020
235 #define FLAG_HEADER_WRITE_IN_PROGRESS 0x00000040
236 #define FLAG_HEADER_RP_FIX 0x00000080 // reparse point fixup
237 #define FLAG_HEADER_COMPRESS_RESERVED 0x00010000
238 #define FLAG_HEADER_COMPRESS_XPRESS 0x00020000
239 #define FLAG_HEADER_COMPRESS_LZX 0x00040000
240 #define FLAG_HEADER_COMPRESS_LZMS 0x00080000
241
242 #define RESHDR_FLAG_FREE 0x01
243 #define RESHDR_FLAG_METADATA 0x02
244 #define RESHDR_FLAG_COMPRESSED 0x04
245 #define RESHDR_FLAG_SPANNED 0x08
246
247 #pragma pack(1)
248
249 /* A WIM resource header */
250 typedef struct wim_resource_header
251 {
252 grub_uint64_t size_in_wim:56; /* Compressed length */
253 grub_uint64_t flags:8; /* flags */
254 grub_uint64_t offset; /* Offset */
255 grub_uint64_t raw_size; /* Uncompressed length */
256 }wim_resource_header;
257
258 /* WIM resource header length mask */
259 #define WIM_RESHDR_ZLEN_MASK 0x00ffffffffffffffULL
260
261 /* WIM resource header flags */
262 typedef enum wim_resource_header_flags
263 {
264 WIM_RESHDR_METADATA = ( 0x02ULL << 56 ), /* Resource contains metadata */
265 WIM_RESHDR_COMPRESSED = ( 0x04ULL << 56 ), /* Resource is compressed */
266 WIM_RESHDR_PACKED_STREAMS = ( 0x10ULL << 56 ), /* Resource is compressed using packed streams */
267 }wim_resource_header_flags;
268
269 #define WIM_HEAD_SIGNATURE "MSWIM\0\0"
270
271 /* WIM header */
272 typedef struct wim_header
273 {
274 grub_uint8_t signature[8]; /* Signature */
275 grub_uint32_t header_len; /* Header length */
276 grub_uint32_t version; /* Verson */
277 grub_uint32_t flags; /* Flags */
278 grub_uint32_t chunk_len; /* Chunk length */
279 grub_uint8_t guid[16]; /* GUID */
280 grub_uint16_t part; /* Part number */
281 grub_uint16_t parts; /* Total number of parts */
282 grub_uint32_t images; /* number of images */
283 wim_resource_header lookup; /* Lookup table */
284 wim_resource_header xml; /* XML data */
285 wim_resource_header metadata; /* Boot metadata */
286 grub_uint32_t boot_index; /* Boot index */
287 wim_resource_header integrity; /* Integrity table */
288 grub_uint8_t reserved[60]; /* Reserved */
289 } wim_header;
290
291 /* WIM header flags */
292 typedef enum wim_header_flags
293 {
294 WIM_HDR_XPRESS = 0x00020000, /* WIM uses Xpress compresson */
295 WIM_HDR_LZX = 0x00040000, /* WIM uses LZX compression */
296 }wim_header_flags;
297
298 /* A WIM file hash */
299 typedef struct wim_hash
300 {
301 /* SHA-1 hash */
302 grub_uint8_t sha1[20];
303 }wim_hash;
304
305 /* A WIM lookup table entry */
306 typedef struct wim_lookup_entry
307 {
308 wim_resource_header resource; /* Resource header */
309 grub_uint16_t part; /* Part number */
310 grub_uint32_t refcnt; /* Reference count */
311 wim_hash hash; /* Hash */
312 }wim_lookup_entry;
313
314 /* WIM chunk length */
315 #define WIM_CHUNK_LEN 32768
316
317 /* A WIM chunk buffer */
318 typedef struct wim_chunk_buffer
319 {
320 grub_uint8_t data[WIM_CHUNK_LEN]; /*Data */
321 }wim_chunk_buffer;
322
323 /* Security data */
324 typedef struct wim_security_header
325 {
326 grub_uint32_t len; /* Length */
327 grub_uint32_t count; /* Number of entries */
328 }wim_security_header;
329
330 /* Directory entry */
331 typedef struct wim_directory_entry
332 {
333 grub_uint64_t len; /* Length */
334 grub_uint32_t attributes; /* Attributes */
335 grub_uint32_t security; /* Security ID */
336 grub_uint64_t subdir; /* Subdirectory offset */
337 grub_uint8_t reserved1[16]; /* Reserved */
338 grub_uint64_t created; /* Creation time */
339 grub_uint64_t accessed; /* Last access time */
340 grub_uint64_t written; /* Last written time */
341 wim_hash hash; /* Hash */
342 grub_uint8_t reserved2[12]; /* Reserved */
343 grub_uint16_t streams; /* Streams */
344 grub_uint16_t short_name_len; /* Short name length */
345 grub_uint16_t name_len; /* Name length */
346 }wim_directory_entry;
347
348 /** Normal file */
349 #define WIM_ATTR_NORMAL 0x00000080UL
350
351 /** No security information exists for this file */
352 #define WIM_NO_SECURITY 0xffffffffUL
353
354 #pragma pack()
355
356
357 typedef struct wim_tail
358 {
359 grub_uint32_t wim_raw_size;
360 grub_uint32_t wim_align_size;
361
362 grub_uint8_t iso_type;
363 grub_uint64_t file_offset;
364 grub_uint32_t udf_start_block;
365 grub_uint64_t fe_entry_size_offset;
366 grub_uint64_t override_offset;
367 grub_uint32_t override_len;
368 grub_uint8_t override_data[32];
369
370 wim_header wim_header;
371
372 wim_hash bin_hash;
373 grub_uint32_t jump_exe_len;
374 grub_uint8_t *jump_bin_data;
375 grub_uint32_t bin_raw_len;
376 grub_uint32_t bin_align_len;
377
378 grub_uint8_t *new_meta_data;
379 grub_uint32_t new_meta_len;
380 grub_uint32_t new_meta_align_len;
381
382 grub_uint8_t *new_lookup_data;
383 grub_uint32_t new_lookup_len;
384 grub_uint32_t new_lookup_align_len;
385 }wim_tail;
386
387 typedef struct wim_patch
388 {
389 int pathlen;
390 char path[256];
391
392 wim_hash old_hash;
393 wim_tail wim_data;
394 wim_lookup_entry *replace_look;
395
396 int valid;
397
398 struct wim_patch *next;
399 }wim_patch;
400
401
402 typedef enum _JSON_TYPE
403 {
404 JSON_TYPE_NUMBER = 0,
405 JSON_TYPE_STRING,
406 JSON_TYPE_BOOL,
407 JSON_TYPE_ARRAY,
408 JSON_TYPE_OBJECT,
409 JSON_TYPE_NULL,
410 JSON_TYPE_BUTT
411 }JSON_TYPE;
412
413
414 typedef struct _VTOY_JSON
415 {
416 struct _VTOY_JSON *pstPrev;
417 struct _VTOY_JSON *pstNext;
418 struct _VTOY_JSON *pstChild;
419
420 JSON_TYPE enDataType;
421 union
422 {
423 char *pcStrVal;
424 int iNumVal;
425 grub_uint64_t lValue;
426 }unData;
427
428 char *pcName;
429 }VTOY_JSON;
430
431 typedef struct _JSON_PARSE
432 {
433 char *pcKey;
434 void *pDataBuf;
435 grub_uint32_t uiBufSize;
436 }JSON_PARSE;
437
438 #define JSON_NEW_ITEM(pstJson, ret) \
439 { \
440 (pstJson) = (VTOY_JSON *)grub_zalloc(sizeof(VTOY_JSON)); \
441 if (NULL == (pstJson)) \
442 { \
443 json_debug("Failed to alloc memory for json.\n"); \
444 return (ret); \
445 } \
446 }
447
448 typedef int (*ventoy_plugin_entry_pf)(VTOY_JSON *json, const char *isodisk);
449 typedef int (*ventoy_plugin_check_pf)(VTOY_JSON *json, const char *isodisk);
450
451 typedef struct plugin_entry
452 {
453 const char *key;
454 ventoy_plugin_entry_pf entryfunc;
455 ventoy_plugin_check_pf checkfunc;
456 }plugin_entry;
457
458
459 void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param);
460 grub_err_t ventoy_cmd_isolinux_initrd_collect(grub_extcmd_context_t ctxt, int argc, char **args);
461 grub_err_t ventoy_cmd_grub_initrd_collect(grub_extcmd_context_t ctxt, int argc, char **args);
462 grub_err_t ventoy_cmd_specify_initrd_file(grub_extcmd_context_t ctxt, int argc, char **args);
463 grub_err_t ventoy_cmd_dump_initrd_list(grub_extcmd_context_t ctxt, int argc, char **args);
464 grub_err_t ventoy_cmd_clear_initrd_list(grub_extcmd_context_t ctxt, int argc, char **args);
465 grub_uint32_t ventoy_get_iso_boot_catlog(grub_file_t file);
466 int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector);
467 grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
468 grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args);
469 grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
470 grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
471 grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args);
472 grub_err_t ventoy_cmd_trailer_cpio(grub_extcmd_context_t ctxt, int argc, char **args);
473 int ventoy_cpio_newc_fill_head(void *buf, int filesize, const void *filedata, const char *name);
474 grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...);
475 grub_uint64_t ventoy_grub_get_file_size(const char *fmt, ...);
476 int ventoy_is_file_exist(const char *fmt, ...);
477 int ventoy_is_dir_exist(const char *fmt, ...);
478 int ventoy_fill_data(grub_uint32_t buflen, char *buffer);
479 grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **args);
480 grub_err_t ventoy_cmd_wimdows_reset(grub_extcmd_context_t ctxt, int argc, char **args);
481 grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
482 grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
483 grub_err_t ventoy_cmd_dump_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
484
485 VTOY_JSON *vtoy_json_find_item
486 (
487 VTOY_JSON *pstJson,
488 JSON_TYPE enDataType,
489 const char *szKey
490 );
491 int vtoy_json_parse_value
492 (
493 char *pcNewStart,
494 char *pcRawStart,
495 VTOY_JSON *pstJson,
496 const char *pcData,
497 const char **ppcEnd
498 );
499 VTOY_JSON * vtoy_json_create(void);
500 int vtoy_json_parse(VTOY_JSON *pstJson, const char *szJsonData);
501
502 int vtoy_json_scan_parse
503 (
504 const VTOY_JSON *pstJson,
505 grub_uint32_t uiParseNum,
506 JSON_PARSE *pstJsonParse
507 );
508
509 int vtoy_json_scan_array
510 (
511 VTOY_JSON *pstJson,
512 const char *szKey,
513 VTOY_JSON **ppstArrayItem
514 );
515
516 int vtoy_json_scan_array_ex
517 (
518 VTOY_JSON *pstJson,
519 const char *szKey,
520 VTOY_JSON **ppstArrayItem
521 );
522 int vtoy_json_scan_object
523 (
524 VTOY_JSON *pstJson,
525 const char *szKey,
526 VTOY_JSON **ppstObjectItem
527 );
528 int vtoy_json_get_int
529 (
530 VTOY_JSON *pstJson,
531 const char *szKey,
532 int *piValue
533 );
534 int vtoy_json_get_uint
535 (
536 VTOY_JSON *pstJson,
537 const char *szKey,
538 grub_uint32_t *puiValue
539 );
540 int vtoy_json_get_uint64
541 (
542 VTOY_JSON *pstJson,
543 const char *szKey,
544 grub_uint64_t *pui64Value
545 );
546 int vtoy_json_get_bool
547 (
548 VTOY_JSON *pstJson,
549 const char *szKey,
550 grub_uint8_t *pbValue
551 );
552 int vtoy_json_get_string
553 (
554 VTOY_JSON *pstJson,
555 const char *szKey,
556 grub_uint32_t uiBufLen,
557 char *pcBuf
558 );
559 const char * vtoy_json_get_string_ex(VTOY_JSON *pstJson, const char *szKey);
560 int vtoy_json_destroy(VTOY_JSON *pstJson);
561
562
563 grub_uint32_t CalculateCrc32
564 (
565 const void *Buffer,
566 grub_uint32_t Length,
567 grub_uint32_t InitValue
568 );
569
570 static inline int ventoy_isspace (int c)
571 {
572 return (c == '\n' || c == '\r' || c == ' ' || c == '\t');
573 }
574
575 static inline int ventoy_is_word_end(int c)
576 {
577 return (c == 0 || c == ',' || ventoy_isspace(c));
578 }
579
580 #pragma pack(1)
581 typedef struct ventoy_part_table
582 {
583 grub_uint8_t Active; // 0x00 0x80
584
585 grub_uint8_t StartHead;
586 grub_uint16_t StartSector : 6;
587 grub_uint16_t StartCylinder : 10;
588
589 grub_uint8_t FsFlag;
590
591 grub_uint8_t EndHead;
592 grub_uint16_t EndSector : 6;
593 grub_uint16_t EndCylinder : 10;
594
595 grub_uint32_t StartSectorId;
596 grub_uint32_t SectorCount;
597 }ventoy_part_table;
598
599 typedef struct ventoy_mbr_head
600 {
601 grub_uint8_t BootCode[446];
602 ventoy_part_table PartTbl[4];
603 grub_uint8_t Byte55;
604 grub_uint8_t ByteAA;
605 }ventoy_mbr_head;
606 #pragma pack()
607
608 typedef struct file_fullpath
609 {
610 char path[256];
611 }file_fullpath;
612
613 typedef struct install_template
614 {
615 int pathlen;
616 char isopath[256];
617
618 int autosel;
619 int cursel;
620 int templatenum;
621 file_fullpath *templatepath;
622
623 struct install_template *next;
624 }install_template;
625
626 typedef struct persistence_config
627 {
628 int pathlen;
629 char isopath[256];
630
631 int autosel;
632 int cursel;
633 int backendnum;
634 file_fullpath *backendpath;
635
636 struct persistence_config *next;
637 }persistence_config;
638
639 #define vtoy_alias_image_file 0
640 #define vtoy_alias_directory 1
641
642 typedef struct menu_alias
643 {
644 int type;
645 int pathlen;
646 char isopath[256];
647 char alias[256];
648
649 struct menu_alias *next;
650 }menu_alias;
651
652 #define vtoy_class_image_file 0
653 #define vtoy_class_directory 1
654
655 typedef struct menu_class
656 {
657 int type;
658 int patlen;
659 char pattern[256];
660 char class[64];
661
662 struct menu_class *next;
663 }menu_class;
664
665 typedef struct injection_config
666 {
667 int pathlen;
668 char isopath[256];
669 char archive[256];
670
671 struct injection_config *next;
672 }injection_config;
673
674 extern int g_ventoy_menu_esc;
675 extern int g_ventoy_suppress_esc;
676 extern int g_ventoy_last_entry;
677 extern int g_ventoy_memdisk_mode;
678 extern int g_ventoy_iso_raw;
679 extern int g_ventoy_iso_uefi_drv;
680 extern int g_ventoy_case_insensitive;
681 extern grub_uint8_t g_ventoy_chain_type;
682
683
684 #define ventoy_unix_fill_virt(new_data, new_len) \
685 { \
686 data_secs = (new_len + 2047) / 2048; \
687 cur->mem_sector_start = sector; \
688 cur->mem_sector_end = cur->mem_sector_start + data_secs; \
689 cur->mem_sector_offset = offset; \
690 cur->remap_sector_start = 0; \
691 cur->remap_sector_end = 0; \
692 cur->org_sector_start = 0; \
693 grub_memcpy(override + offset, new_data, new_len); \
694 cur++; \
695 sector += data_secs; \
696 offset += new_len; \
697 chain->virt_img_size_in_bytes += data_secs * 2048; \
698 }
699
700 char * ventoy_get_line(char *start);
701 int ventoy_cmp_img(img_info *img1, img_info *img2);
702 void ventoy_swap_img(img_info *img1, img_info *img2);
703 char * ventoy_plugin_get_cur_install_template(const char *isopath);
704 install_template * ventoy_plugin_find_install_template(const char *isopath);
705 persistence_config * ventoy_plugin_find_persistent(const char *isopath);
706 void ventoy_plugin_dump_injection(void);
707 void ventoy_plugin_dump_auto_install(void);
708 int ventoy_fill_windows_rtdata(void *buf, char *isopath);
709 int ventoy_plugin_get_persistent_chunklist(const char *isopath, int index, ventoy_img_chunk_list *chunk_list);
710 const char * ventoy_plugin_get_injection(const char *isopath);
711 const char * ventoy_plugin_get_menu_alias(int type, const char *isopath);
712 const char * ventoy_plugin_get_menu_class(int type, const char *name);
713 int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
714 int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
715 void ventoy_plugin_dump_persistence(void);
716 grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, char **args);
717 grub_err_t ventoy_cmd_linux_get_main_initrd_index(grub_extcmd_context_t ctxt, int argc, char **args);
718 grub_err_t ventoy_cmd_collect_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
719 grub_err_t ventoy_cmd_wim_patch_count(grub_extcmd_context_t ctxt, int argc, char **args);
720 grub_err_t ventoy_cmd_locate_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
721 grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
722 int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid);
723 grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args);
724 grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args);
725 grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char **args);
726 grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, char **args);
727 grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, char **args);
728
729 #endif /* __VENTOY_DEF_H__ */
730