Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
6a506ee7
Commit
6a506ee7
authored
Nov 24, 2021
by
longpanda
Browse files
Optimization for FreeBSD fragments process.
parent
32643ecd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
140 additions
and
55 deletions
+140
-55
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
+4
-32
Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/12.x/32/geom_ventoy.ko.xz
...toy_unix/FreeBSD/geom_ventoy_ko/12.x/32/geom_ventoy.ko.xz
+0
-0
Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/12.x/64/geom_ventoy.ko.xz
...toy_unix/FreeBSD/geom_ventoy_ko/12.x/64/geom_ventoy.ko.xz
+0
-0
Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/13.x/32/geom_ventoy.ko.xz
...toy_unix/FreeBSD/geom_ventoy_ko/13.x/32/geom_ventoy.ko.xz
+0
-0
Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/13.x/64/geom_ventoy.ko.xz
...toy_unix/FreeBSD/geom_ventoy_ko/13.x/64/geom_ventoy.ko.xz
+0
-0
Unix/ventoy_unix_src/FreeBSD/geom_ventoy_src/12.x/sys/geom/ventoy/g_ventoy.c
...c/FreeBSD/geom_ventoy_src/12.x/sys/geom/ventoy/g_ventoy.c
+87
-19
Unix/ventoy_unix_src/FreeBSD/geom_ventoy_src/12.x/sys/geom/ventoy/g_ventoy.h
...c/FreeBSD/geom_ventoy_src/12.x/sys/geom/ventoy/g_ventoy.h
+27
-0
Unix/ventoy_unix_src/FreeBSD/geom_ventoy_src/13.x/sys/geom/ventoy/g_ventoy.c
...c/FreeBSD/geom_ventoy_src/13.x/sys/geom/ventoy/g_ventoy.c
+22
-4
No files found.
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
View file @
6a506ee7
...
@@ -51,35 +51,11 @@
...
@@ -51,35 +51,11 @@
GRUB_MOD_LICENSE
(
"GPLv3+"
);
GRUB_MOD_LICENSE
(
"GPLv3+"
);
static
grub_uint8_t
g_check_mbr_data
[
440
]
=
{
static
grub_uint8_t
g_check_mbr_data
[]
=
{
0xEB
,
0x63
,
0x90
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0xEB
,
0x63
,
0x90
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x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x56
,
0x54
,
0x00
,
0x47
,
0x65
,
0x00
,
0x48
,
0x44
,
0x00
,
0x52
,
0x64
,
0x00
,
0x20
,
0x45
,
0x72
,
0x0D
,
0x56
,
0x54
,
0x00
,
0x47
,
0x65
,
0x00
,
0x48
,
0x44
,
0x00
,
0x52
,
0x64
,
0x00
,
0x20
,
0x45
,
0x72
,
0x0D
,
0x0A
,
0x00
,
0xBB
,
0x01
,
0x00
,
0xB4
,
0x0E
,
0xCD
,
0x10
,
0xAC
,
0x3C
,
0x00
,
0x75
,
0xF4
,
0xC3
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
};
initrd_info
*
g_initrd_img_list
=
NULL
;
initrd_info
*
g_initrd_img_list
=
NULL
;
...
@@ -655,12 +631,8 @@ static int ventoy_check_official_device(grub_device_t dev)
...
@@ -655,12 +631,8 @@ static int ventoy_check_official_device(grub_device_t dev)
grub_memset
(
mbr
,
0
,
512
);
grub_memset
(
mbr
,
0
,
512
);
grub_disk_read
(
disk
,
0
,
0
,
512
,
mbr
);
grub_disk_read
(
disk
,
0
,
0
,
512
,
mbr
);
grub_disk_close
(
disk
);
grub_disk_close
(
disk
);
g_check_mbr_data
[
92
]
=
mbr
[
92
];
if
(
grub_memcmp
(
g_check_mbr_data
,
mbr
,
0x30
)
||
grub_memcmp
(
g_check_mbr_data
+
0x30
,
mbr
+
0x190
,
16
))
g_check_mbr_data
[
102
]
=
mbr
[
102
];
g_check_mbr_data
[
103
]
=
mbr
[
103
];
grub_memcpy
(
g_check_mbr_data
+
0x180
,
mbr
+
0x180
,
16
);
if
(
grub_memcmp
(
g_check_mbr_data
,
mbr
,
440
))
{
{
return
ventoy_set_check_result
(
12
);
return
ventoy_set_check_result
(
12
);
}
}
...
...
Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/12.x/32/geom_ventoy.ko.xz
View file @
6a506ee7
No preview for this file type
Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/12.x/64/geom_ventoy.ko.xz
View file @
6a506ee7
No preview for this file type
Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/13.x/32/geom_ventoy.ko.xz
View file @
6a506ee7
No preview for this file type
Unix/ventoy_unix/FreeBSD/geom_ventoy_ko/13.x/64/geom_ventoy.ko.xz
View file @
6a506ee7
No preview for this file type
Unix/ventoy_unix_src/FreeBSD/geom_ventoy_src/12.x/sys/geom/ventoy/g_ventoy.c
View file @
6a506ee7
...
@@ -65,12 +65,22 @@ static g_taste_t g_ventoy_taste;
...
@@ -65,12 +65,22 @@ static g_taste_t g_ventoy_taste;
static
g_ctl_req_t
g_ventoy_config
;
static
g_ctl_req_t
g_ventoy_config
;
static
g_dumpconf_t
g_ventoy_dumpconf
;
static
g_dumpconf_t
g_ventoy_dumpconf
;
static
const
char
*
g_ventoy_disk_uuid
=
NULL
;
static
char
g_ventoy_disk_uuid
[
64
]
;
static
bool
g_ventoy_tasted
=
false
;
static
bool
g_ventoy_tasted
=
false
;
static
off_t
g_ventoy_disk_size
=
0
;
static
off_t
g_ventoy_disk_size
=
0
;
static
off_t
g_disk_map_start
=
0
;
static
off_t
g_disk_map_start
=
0
;
static
off_t
g_disk_map_end
=
0
;
static
off_t
g_disk_map_end
=
0
;
struct
g_ventoy_map
g_ventoy_map_data
__attribute__
((
aligned
(
65536
)))
=
{
{
VENTOY_UNIX_SEG_MAGIC0
,
VENTOY_UNIX_SEG_MAGIC1
,
VENTOY_UNIX_SEG_MAGIC2
,
VENTOY_UNIX_SEG_MAGIC3
},
{
0
,
0
,
0
,
0
},
0
,
0
,
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
},
{
{
0
,
0
}
},
{
VENTOY_UNIX_SEG_MAGIC0
,
VENTOY_UNIX_SEG_MAGIC1
,
VENTOY_UNIX_SEG_MAGIC2
,
VENTOY_UNIX_SEG_MAGIC3
}
};
struct
g_class
g_ventoy_class
=
{
struct
g_class
g_ventoy_class
=
{
.
name
=
G_VENTOY_CLASS_NAME
,
.
name
=
G_VENTOY_CLASS_NAME
,
.
version
=
G_VERSION
,
.
version
=
G_VERSION
,
...
@@ -677,23 +687,50 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
...
@@ -677,23 +687,50 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
static
bool
g_vtoy_check_disk
(
struct
g_class
*
mp
,
struct
g_provider
*
pp
)
static
bool
g_vtoy_check_disk
(
struct
g_class
*
mp
,
struct
g_provider
*
pp
)
{
{
int
i
;
int
i
;
bool
ret
=
true
;
uint8_t
*
buf
;
uint8_t
*
buf
;
char
uuid
[
64
];
char
uuid
[
64
];
const
char
*
value
;
const
char
*
value
;
struct
g_consumer
*
cp
;
struct
g_consumer
*
cp
;
struct
g_geom
*
gp
;
struct
g_geom
*
gp
;
uint8_t
mbrdata
[]
=
{
0xEB
,
0x63
,
0x90
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x56
,
0x54
,
0x00
,
0x47
,
0x65
,
0x00
,
0x48
,
0x44
,
0x00
,
0x52
,
0x64
,
0x00
,
0x20
,
0x45
,
0x72
,
0x0D
,
};
if
(
g_ventoy_disk_size
==
0
)
if
(
g_ventoy_disk_size
==
0
)
{
{
if
(
resource_string_value
(
"ventoy"
,
0
,
"disksize"
,
&
value
)
==
0
)
if
(
VENTOY_MAP_VALID
(
g_ventoy_map_data
.
magic2
)
)
{
{
G_DEBUG
(
"ventoy.disksize: %s
\n
"
,
value
);
G_DEBUG
(
"ventoy map data is valid. [OK]
\n
"
);
g_ventoy_disk_size
=
strtouq
(
value
,
NULL
,
0
);
for
(
i
=
0
;
i
<
16
;
i
++
)
{
sprintf
(
uuid
+
i
*
2
,
"%02x"
,
g_ventoy_map_data
.
diskuuid
[
i
]);
}
snprintf
(
g_ventoy_disk_uuid
,
sizeof
(
g_ventoy_disk_uuid
),
"%s"
,
uuid
);
g_ventoy_disk_size
=
g_ventoy_map_data
.
disksize
;
G_DEBUG
(
"ventoy.disksize: %llu
\n
"
,
(
unsigned
long
long
)
g_ventoy_disk_size
);
G_DEBUG
(
"ventoy.diskuuid: <%s>
\n
"
,
g_ventoy_disk_uuid
);
}
}
else
if
(
resource_string_value
(
"ventoy"
,
0
,
"diskuuid"
,
&
g_ventoy_disk_uuid
)
==
0
)
{
{
G_DEBUG
(
"ventoy.diskuuid: <%s>
\n
"
,
g_ventoy_disk_uuid
);
G_DEBUG
(
"ventoy map data is invalid, get from resource
\n
"
);
if
(
resource_string_value
(
"ventoy"
,
0
,
"disksize"
,
&
value
)
==
0
)
{
G_DEBUG
(
"ventoy.disksize: %s
\n
"
,
value
);
g_ventoy_disk_size
=
strtouq
(
value
,
NULL
,
0
);
}
if
(
resource_string_value
(
"ventoy"
,
0
,
"diskuuid"
,
&
value
)
==
0
)
{
snprintf
(
g_ventoy_disk_uuid
,
sizeof
(
g_ventoy_disk_uuid
),
"%s"
,
value
);
G_DEBUG
(
"ventoy.diskuuid: <%s>
\n
"
,
value
);
}
}
}
}
}
...
@@ -735,14 +772,25 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
...
@@ -735,14 +772,25 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{
{
sprintf
(
uuid
+
i
*
2
,
"%02x"
,
buf
[
0x180
+
i
]);
sprintf
(
uuid
+
i
*
2
,
"%02x"
,
buf
[
0x180
+
i
]);
}
}
if
(
strncmp
(
g_ventoy_disk_uuid
,
uuid
,
32
))
{
ret
=
false
;
}
if
(
memcmp
(
mbrdata
,
buf
,
0x30
)
||
memcmp
(
mbrdata
+
0x30
,
buf
+
0x190
,
16
))
{
ret
=
false
;
}
g_free
(
buf
);
g_free
(
buf
);
if
(
strncmp
(
g_ventoy_disk_uuid
,
uuid
,
32
)
==
0
)
if
(
ret
)
{
{
return
true
;
G_DEBUG
(
"ventoy disk check OK
\n
"
)
;
}
}
return
false
;
return
ret
;
}
}
static
struct
g_geom
*
static
struct
g_geom
*
...
@@ -778,7 +826,16 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
...
@@ -778,7 +826,16 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
G_DEBUG
(
"######### ventoy disk <%s> #############
\n
"
,
pp
->
name
);
G_DEBUG
(
"######### ventoy disk <%s> #############
\n
"
,
pp
->
name
);
resource_int_value
(
"ventoy"
,
0
,
"segnum"
,
&
disknum
);
if
(
VENTOY_MAP_VALID
(
g_ventoy_map_data
.
magic2
))
{
disknum
=
(
int
)
g_ventoy_map_data
.
segnum
;
G_DEBUG
(
"segnum from map data is:<%d>
\n
"
,
disknum
);
}
else
{
resource_int_value
(
"ventoy"
,
0
,
"segnum"
,
&
disknum
);
G_DEBUG
(
"segnum from resource is:<%d>
\n
"
,
disknum
);
}
strlcpy
(
md
.
md_magic
,
G_VENTOY_MAGIC
,
sizeof
(
md
.
md_magic
));
strlcpy
(
md
.
md_magic
,
G_VENTOY_MAGIC
,
sizeof
(
md
.
md_magic
));
md
.
md_version
=
G_VENTOY_VERSION
;
md
.
md_version
=
G_VENTOY_VERSION
;
...
@@ -800,18 +857,29 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
...
@@ -800,18 +857,29 @@ g_ventoy_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
for
(
i
=
0
;
i
<
disknum
;
i
++
)
for
(
i
=
0
;
i
<
disknum
;
i
++
)
{
{
if
(
resource_string_value
(
"ventoy"
,
i
,
"seg"
,
&
value
)
==
0
)
if
(
VENTOY_MAP_VALID
(
g_ventoy_map_data
.
magic2
)
)
{
{
g_disk_map_start
=
strtouq
(
value
,
&
endpos
,
0
);
G_DEBUG
(
"[map] ventoy segment%d: 0x%llx@0x%llx
\n
"
,
i
,
g_disk_map_end
=
strtouq
(
endpos
+
1
,
NULL
,
0
);
(
long
long
)
g_ventoy_map_data
.
seglist
[
i
].
seg_start_bytes
,
(
long
long
)
g_ventoy_map_data
.
seglist
[
i
].
seg_end_bytes
);
g_disk_map_start
=
(
off_t
)
g_ventoy_map_data
.
seglist
[
i
].
seg_start_bytes
;
g_disk_map_end
=
(
off_t
)
g_ventoy_map_data
.
seglist
[
i
].
seg_end_bytes
;
}
}
else
else
{
{
printf
(
"Failed to parse ventoy seg %d
\n
"
,
i
);
if
(
resource_string_value
(
"ventoy"
,
i
,
"seg"
,
&
value
)
==
0
)
continue
;
{
g_disk_map_start
=
strtouq
(
value
,
&
endpos
,
0
);
g_disk_map_end
=
strtouq
(
endpos
+
1
,
NULL
,
0
);
}
else
{
printf
(
"Failed to parse ventoy seg %d
\n
"
,
i
);
continue
;
}
G_DEBUG
(
"[resource] ventoy segment%d: %s
\n
"
,
i
,
value
);
}
}
G_DEBUG
(
"ventoy segment%d: %s
\n
"
,
i
,
value
);
G_VENTOY_DEBUG
(
1
,
"Adding disk %s to %s."
,
pp
->
name
,
gp
->
name
);
G_VENTOY_DEBUG
(
1
,
"Adding disk %s to %s."
,
pp
->
name
,
gp
->
name
);
error
=
g_ventoy_add_disk
(
sc
,
pp
,
i
);
error
=
g_ventoy_add_disk
(
sc
,
pp
,
i
);
...
...
Unix/ventoy_unix_src/FreeBSD/geom_ventoy_src/12.x/sys/geom/ventoy/g_ventoy.h
View file @
6a506ee7
...
@@ -76,6 +76,33 @@ struct g_ventoy_softc {
...
@@ -76,6 +76,33 @@ struct g_ventoy_softc {
struct
mtx
sc_lock
;
struct
mtx
sc_lock
;
};
};
#define sc_name sc_geom->name
#define sc_name sc_geom->name
#pragma pack(1)
#define VENTOY_UNIX_SEG_MAGIC0 0x11223344
#define VENTOY_UNIX_SEG_MAGIC1 0x55667788
#define VENTOY_UNIX_SEG_MAGIC2 0x99aabbcc
#define VENTOY_UNIX_SEG_MAGIC3 0xddeeff00
#define VENTOY_UNIX_MAX_SEGNUM 40960
struct
g_ventoy_seg
{
uint64_t
seg_start_bytes
;
uint64_t
seg_end_bytes
;
};
struct
g_ventoy_map
{
uint32_t
magic1
[
4
];
uint32_t
magic2
[
4
];
uint64_t
segnum
;
uint64_t
disksize
;
uint8_t
diskuuid
[
16
];
struct
g_ventoy_seg
seglist
[
VENTOY_UNIX_MAX_SEGNUM
];
uint32_t
magic3
[
4
];
};
#pragma pack()
#define VENTOY_MAP_VALID(magic2) \
(magic2[0] == VENTOY_UNIX_SEG_MAGIC0 && magic2[1] == VENTOY_UNIX_SEG_MAGIC1 && magic2[2] == VENTOY_UNIX_SEG_MAGIC2 && magic2[3] == VENTOY_UNIX_SEG_MAGIC3)
#endif
/* _KERNEL */
#endif
/* _KERNEL */
struct
g_ventoy_metadata
{
struct
g_ventoy_metadata
{
...
...
Unix/ventoy_unix_src/FreeBSD/geom_ventoy_src/13.x/sys/geom/ventoy/g_ventoy.c
View file @
6a506ee7
...
@@ -721,11 +721,18 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
...
@@ -721,11 +721,18 @@ g_ventoy_destroy_geom(struct gctl_req *req __unused,
static
bool
g_vtoy_check_disk
(
struct
g_class
*
mp
,
struct
g_provider
*
pp
)
static
bool
g_vtoy_check_disk
(
struct
g_class
*
mp
,
struct
g_provider
*
pp
)
{
{
int
i
;
int
i
;
bool
ret
=
true
;
uint8_t
*
buf
;
uint8_t
*
buf
;
char
uuid
[
64
];
char
uuid
[
64
];
const
char
*
value
;
const
char
*
value
;
struct
g_consumer
*
cp
;
struct
g_consumer
*
cp
;
struct
g_geom
*
gp
;
struct
g_geom
*
gp
;
uint8_t
mbrdata
[]
=
{
0xEB
,
0x63
,
0x90
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x56
,
0x54
,
0x00
,
0x47
,
0x65
,
0x00
,
0x48
,
0x44
,
0x00
,
0x52
,
0x64
,
0x00
,
0x20
,
0x45
,
0x72
,
0x0D
,
};
if
(
g_ventoy_disk_size
==
0
)
if
(
g_ventoy_disk_size
==
0
)
{
{
...
@@ -799,14 +806,25 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
...
@@ -799,14 +806,25 @@ static bool g_vtoy_check_disk(struct g_class *mp, struct g_provider *pp)
{
{
sprintf
(
uuid
+
i
*
2
,
"%02x"
,
buf
[
0x180
+
i
]);
sprintf
(
uuid
+
i
*
2
,
"%02x"
,
buf
[
0x180
+
i
]);
}
}
if
(
strncmp
(
g_ventoy_disk_uuid
,
uuid
,
32
))
{
ret
=
false
;
}
if
(
memcmp
(
mbrdata
,
buf
,
0x30
)
||
memcmp
(
mbrdata
+
0x30
,
buf
+
0x190
,
16
))
{
ret
=
false
;
}
g_free
(
buf
);
g_free
(
buf
);
if
(
strncmp
(
g_ventoy_disk_uuid
,
uuid
,
32
)
==
0
)
if
(
ret
)
{
{
return
true
;
G_DEBUG
(
"ventoy disk check OK
\n
"
)
;
}
}
return
false
;
return
ret
;
}
}
static
struct
g_geom
*
static
struct
g_geom
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment