]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - VtoyTool/vtoytool.h
Fix the order issue in TreeView mode. (#3218)
[Ventoy.git] / VtoyTool / vtoytool.h
1 /******************************************************************************
2 * vtoytool.h
3 *
4 * Copyright (c) 2022, 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 __VTOYTOOL_H__
22 #define __VTOYTOOL_H__
23
24 #define IS_DIGIT(x) ((x) >= '0' && (x) <= '9')
25
26 #ifndef USE_DIET_C
27 #ifndef __mips__
28 typedef unsigned long long uint64_t;
29 #endif
30 typedef unsigned int uint32_t;
31 typedef unsigned short uint16_t;
32 typedef unsigned char uint8_t;
33 #endif
34
35 #define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
36
37 typedef enum ventoy_fs_type
38 {
39 ventoy_fs_exfat = 0, /* 0: exfat */
40 ventoy_fs_ntfs, /* 1: NTFS */
41 ventoy_fs_ext, /* 2: ext2/ext3/ext4 */
42 ventoy_fs_xfs, /* 3: XFS */
43 ventoy_fs_udf, /* 4: UDF */
44 ventoy_fs_fat, /* 5: FAT */
45
46 ventoy_fs_max
47 }ventoy_fs_type;
48
49 #pragma pack(1)
50
51 typedef struct ventoy_guid
52 {
53 uint32_t data1;
54 uint16_t data2;
55 uint16_t data3;
56 uint8_t data4[8];
57 }ventoy_guid;
58
59
60 typedef struct ventoy_image_disk_region
61 {
62 uint32_t image_sector_count; /* image sectors contained in this region */
63 uint32_t image_start_sector; /* image sector start */
64 uint64_t disk_start_sector; /* disk sector start */
65 }ventoy_image_disk_region;
66
67 typedef struct ventoy_image_location
68 {
69 ventoy_guid guid;
70
71 /* image sector size, currently this value is always 2048 */
72 uint32_t image_sector_size;
73
74 /* disk sector size, normally the value is 512 */
75 uint32_t disk_sector_size;
76
77 uint32_t region_count;
78
79 /*
80 * disk region data
81 * If the image file has more than one fragments in disk,
82 * there will be more than one region data here.
83 * You can calculate the region count by
84 */
85 ventoy_image_disk_region regions[1];
86
87 /* ventoy_image_disk_region regions[2~region_count-1] */
88 }ventoy_image_location;
89
90 typedef struct ventoy_os_param
91 {
92 ventoy_guid guid; // VENTOY_GUID
93 uint8_t chksum; // checksum
94
95 uint8_t vtoy_disk_guid[16];
96 uint64_t vtoy_disk_size; // disk size in bytes
97 uint16_t vtoy_disk_part_id; // begin with 1
98 uint16_t vtoy_disk_part_type; // 0:exfat 1:ntfs other: reserved
99 char vtoy_img_path[384]; // It seems to be enough, utf-8 format
100 uint64_t vtoy_img_size; // image file size in bytes
101
102 /*
103 * Ventoy will write a copy of ventoy_image_location data into runtime memory
104 * this is the physically address and length of that memory.
105 * Address 0 means no such data exist.
106 * Address will be aligned by 4KB.
107 *
108 */
109 uint64_t vtoy_img_location_addr;
110 uint32_t vtoy_img_location_len;
111
112 uint8_t vtoy_reserved[32]; // Internal use by ventoy
113
114 uint8_t vtoy_disk_signature[4];
115
116 uint8_t reserved[27];
117 }ventoy_os_param;
118
119 #pragma pack()
120
121 int vtoy_find_disk_by_guid(ventoy_os_param *param, char *diskname);
122 #endif
123