mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-16 17:11:13 +00:00
Compare commits
31 Commits
v1.0.08bet
...
v1.0.10
Author | SHA1 | Date | |
---|---|---|---|
|
84c500666a | ||
|
fe0dda6904 | ||
|
af1222be42 | ||
|
b3e796583c | ||
|
1d117b537d | ||
|
3c78caf1f5 | ||
|
7a65572096 | ||
|
6142cb0e32 | ||
|
a20ee56f83 | ||
|
d0edcc0ef0 | ||
|
c84c072209 | ||
|
8204c31df8 | ||
|
f028a6f89c | ||
|
263f5dd3a8 | ||
|
cf4b82e4db | ||
|
fdfa7e22c9 | ||
|
835cb958ed | ||
|
ce9c679ab3 | ||
|
967a259cee | ||
|
f25289e379 | ||
|
0490480467 | ||
|
0a1b6e221c | ||
|
3fc76d6b63 | ||
|
474b9a3fad | ||
|
3ca624f3ee | ||
|
d42bc35915 | ||
|
39b5edc345 | ||
|
9c183ed416 | ||
|
8e0c630fe5 | ||
|
9f57cb3929 | ||
|
525ef4f516 |
757
GPLv3
757
GPLv3
@@ -1,165 +1,674 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
0. Additional Definitions.
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
0. Definitions.
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
4. Combined Works.
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
1. Source Code.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
d) Do one of the following:
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
5. Combined Libraries.
|
||||
2. Basic Permissions.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
|
@@ -374,7 +374,7 @@ static int ventoy_is_mbr_match(ventoy_mbr_head *head)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (head->PartTbl[0].FsFlag != 0x07 || head->PartTbl[0].StartSectorId != 2048) {
|
||||
if (head->PartTbl[0].StartSectorId != 2048) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
1100
GRUB2/grub-2.04/grub-core/fs/ext2.c
Normal file
1100
GRUB2/grub-2.04/grub-core/fs/ext2.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -964,6 +964,10 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
|
||||
|
||||
info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY);
|
||||
info.case_insensitive = 1;
|
||||
|
||||
if (!info.dir)
|
||||
info.size = ctxt.dir.file_size;
|
||||
|
||||
#ifdef MODE_EXFAT
|
||||
if (!ctxt.dir.have_stream)
|
||||
continue;
|
||||
@@ -1270,54 +1274,6 @@ GRUB_MOD_FINI(fat)
|
||||
|
||||
#ifdef MODE_EXFAT
|
||||
|
||||
static int grub_fat_add_chunk(ventoy_img_chunk_list *chunk_list, grub_uint64_t sector, grub_uint64_t size, grub_uint32_t log_sector_size)
|
||||
{
|
||||
ventoy_img_chunk *last_chunk;
|
||||
ventoy_img_chunk *new_chunk;
|
||||
|
||||
if (chunk_list->cur_chunk == 0)
|
||||
{
|
||||
chunk_list->chunk[0].img_start_sector = 0;
|
||||
chunk_list->chunk[0].img_end_sector = (size >> 11) - 1;
|
||||
chunk_list->chunk[0].disk_start_sector = sector;
|
||||
chunk_list->chunk[0].disk_end_sector = sector + (size >> log_sector_size) - 1;
|
||||
chunk_list->cur_chunk = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
last_chunk = chunk_list->chunk + chunk_list->cur_chunk - 1;
|
||||
if (last_chunk->disk_end_sector + 1 == sector)
|
||||
{
|
||||
last_chunk->img_end_sector += (size >> 11);
|
||||
last_chunk->disk_end_sector += (size >> log_sector_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (chunk_list->cur_chunk == chunk_list->max_chunk)
|
||||
{
|
||||
new_chunk = grub_realloc(chunk_list->chunk, chunk_list->max_chunk * 2 * sizeof(ventoy_img_chunk));
|
||||
if (NULL == new_chunk)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
chunk_list->chunk = new_chunk;
|
||||
chunk_list->max_chunk *= 2;
|
||||
|
||||
/* issue: update last_chunk */
|
||||
last_chunk = chunk_list->chunk + chunk_list->cur_chunk - 1;
|
||||
}
|
||||
|
||||
new_chunk = chunk_list->chunk + chunk_list->cur_chunk;
|
||||
new_chunk->img_start_sector = last_chunk->img_end_sector + 1;
|
||||
new_chunk->img_end_sector = new_chunk->img_start_sector + (size >> 11) - 1;
|
||||
new_chunk->disk_start_sector = sector;
|
||||
new_chunk->disk_end_sector = sector + (size >> log_sector_size) - 1;
|
||||
|
||||
chunk_list->cur_chunk++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int grub_fat_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list)
|
||||
{
|
||||
grub_size_t size;
|
||||
@@ -1427,7 +1383,7 @@ int grub_fat_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_i
|
||||
if (size > len)
|
||||
size = len;
|
||||
|
||||
grub_fat_add_chunk(chunk_list, sector, size, disk->log_sector_size);
|
||||
grub_disk_blocklist_read(chunk_list, sector, size, disk->log_sector_size);
|
||||
|
||||
len -= size;
|
||||
logical_cluster++;
|
||||
@@ -1445,4 +1401,3 @@ END:
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
1239
GRUB2/grub-2.04/grub-core/fs/ntfs.c
Normal file
1239
GRUB2/grub-2.04/grub-core/fs/ntfs.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1152,6 +1152,8 @@ grub_udf_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
|
||||
|
||||
info.mtime -= 60 * tz;
|
||||
}
|
||||
if (!info.dir)
|
||||
info.size = U64 (node->block.fe.file_size);
|
||||
grub_free (node);
|
||||
return ctx->hook (filename, &info, ctx->hook_data);
|
||||
}
|
||||
|
1164
GRUB2/grub-2.04/grub-core/fs/xfs.c
Normal file
1164
GRUB2/grub-2.04/grub-core/fs/xfs.c
Normal file
File diff suppressed because it is too large
Load Diff
600
GRUB2/grub-2.04/grub-core/kern/disk.c
Normal file
600
GRUB2/grub-2.04/grub-core/kern/disk.c
Normal file
@@ -0,0 +1,600 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2004,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/disk.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/ventoy.h>
|
||||
|
||||
#define GRUB_CACHE_TIMEOUT 2
|
||||
|
||||
/* The last time the disk was used. */
|
||||
static grub_uint64_t grub_last_time = 0;
|
||||
|
||||
struct grub_disk_cache grub_disk_cache_table[GRUB_DISK_CACHE_NUM];
|
||||
|
||||
void (*grub_disk_firmware_fini) (void);
|
||||
int grub_disk_firmware_is_tainted;
|
||||
|
||||
#if DISK_CACHE_STATS
|
||||
static unsigned long grub_disk_cache_hits;
|
||||
static unsigned long grub_disk_cache_misses;
|
||||
|
||||
void
|
||||
grub_disk_cache_get_performance (unsigned long *hits, unsigned long *misses)
|
||||
{
|
||||
*hits = grub_disk_cache_hits;
|
||||
*misses = grub_disk_cache_misses;
|
||||
}
|
||||
#endif
|
||||
|
||||
grub_err_t (*grub_disk_write_weak) (grub_disk_t disk,
|
||||
grub_disk_addr_t sector,
|
||||
grub_off_t offset,
|
||||
grub_size_t size,
|
||||
const void *buf);
|
||||
#include "disk_common.c"
|
||||
|
||||
void
|
||||
grub_disk_cache_invalidate_all (void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < GRUB_DISK_CACHE_NUM; i++)
|
||||
{
|
||||
struct grub_disk_cache *cache = grub_disk_cache_table + i;
|
||||
|
||||
if (cache->data && ! cache->lock)
|
||||
{
|
||||
grub_free (cache->data);
|
||||
cache->data = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
grub_disk_cache_fetch (unsigned long dev_id, unsigned long disk_id,
|
||||
grub_disk_addr_t sector)
|
||||
{
|
||||
struct grub_disk_cache *cache;
|
||||
unsigned cache_index;
|
||||
|
||||
cache_index = grub_disk_cache_get_index (dev_id, disk_id, sector);
|
||||
cache = grub_disk_cache_table + cache_index;
|
||||
|
||||
if (cache->dev_id == dev_id && cache->disk_id == disk_id
|
||||
&& cache->sector == sector)
|
||||
{
|
||||
cache->lock = 1;
|
||||
#if DISK_CACHE_STATS
|
||||
grub_disk_cache_hits++;
|
||||
#endif
|
||||
return cache->data;
|
||||
}
|
||||
|
||||
#if DISK_CACHE_STATS
|
||||
grub_disk_cache_misses++;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_disk_cache_unlock (unsigned long dev_id, unsigned long disk_id,
|
||||
grub_disk_addr_t sector)
|
||||
{
|
||||
struct grub_disk_cache *cache;
|
||||
unsigned cache_index;
|
||||
|
||||
cache_index = grub_disk_cache_get_index (dev_id, disk_id, sector);
|
||||
cache = grub_disk_cache_table + cache_index;
|
||||
|
||||
if (cache->dev_id == dev_id && cache->disk_id == disk_id
|
||||
&& cache->sector == sector)
|
||||
cache->lock = 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_disk_cache_store (unsigned long dev_id, unsigned long disk_id,
|
||||
grub_disk_addr_t sector, const char *data)
|
||||
{
|
||||
unsigned cache_index;
|
||||
struct grub_disk_cache *cache;
|
||||
|
||||
cache_index = grub_disk_cache_get_index (dev_id, disk_id, sector);
|
||||
cache = grub_disk_cache_table + cache_index;
|
||||
|
||||
cache->lock = 1;
|
||||
grub_free (cache->data);
|
||||
cache->data = 0;
|
||||
cache->lock = 0;
|
||||
|
||||
cache->data = grub_malloc (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
|
||||
if (! cache->data)
|
||||
return grub_errno;
|
||||
|
||||
grub_memcpy (cache->data, data,
|
||||
GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
|
||||
cache->dev_id = dev_id;
|
||||
cache->disk_id = disk_id;
|
||||
cache->sector = sector;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
grub_disk_dev_t grub_disk_dev_list;
|
||||
|
||||
void
|
||||
grub_disk_dev_register (grub_disk_dev_t dev)
|
||||
{
|
||||
dev->next = grub_disk_dev_list;
|
||||
grub_disk_dev_list = dev;
|
||||
}
|
||||
|
||||
void
|
||||
grub_disk_dev_unregister (grub_disk_dev_t dev)
|
||||
{
|
||||
grub_disk_dev_t *p, q;
|
||||
|
||||
for (p = &grub_disk_dev_list, q = *p; q; p = &(q->next), q = q->next)
|
||||
if (q == dev)
|
||||
{
|
||||
*p = q->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the location of the first ',', if any, which is not
|
||||
escaped by a '\'. */
|
||||
static const char *
|
||||
find_part_sep (const char *name)
|
||||
{
|
||||
const char *p = name;
|
||||
char c;
|
||||
|
||||
while ((c = *p++) != '\0')
|
||||
{
|
||||
if (c == '\\' && *p == ',')
|
||||
p++;
|
||||
else if (c == ',')
|
||||
return p - 1;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
grub_disk_t
|
||||
grub_disk_open (const char *name)
|
||||
{
|
||||
const char *p;
|
||||
grub_disk_t disk;
|
||||
grub_disk_dev_t dev;
|
||||
char *raw = (char *) name;
|
||||
grub_uint64_t current_time;
|
||||
|
||||
grub_dprintf ("disk", "Opening `%s'...\n", name);
|
||||
|
||||
disk = (grub_disk_t) grub_zalloc (sizeof (*disk));
|
||||
if (! disk)
|
||||
return 0;
|
||||
disk->log_sector_size = GRUB_DISK_SECTOR_BITS;
|
||||
/* Default 1MiB of maximum agglomerate. */
|
||||
disk->max_agglomerate = 1048576 >> (GRUB_DISK_SECTOR_BITS
|
||||
+ GRUB_DISK_CACHE_BITS);
|
||||
|
||||
p = find_part_sep (name);
|
||||
if (p)
|
||||
{
|
||||
grub_size_t len = p - name;
|
||||
|
||||
raw = grub_malloc (len + 1);
|
||||
if (! raw)
|
||||
goto fail;
|
||||
|
||||
grub_memcpy (raw, name, len);
|
||||
raw[len] = '\0';
|
||||
disk->name = grub_strdup (raw);
|
||||
}
|
||||
else
|
||||
disk->name = grub_strdup (name);
|
||||
if (! disk->name)
|
||||
goto fail;
|
||||
|
||||
for (dev = grub_disk_dev_list; dev; dev = dev->next)
|
||||
{
|
||||
if ((dev->disk_open) (raw, disk) == GRUB_ERR_NONE)
|
||||
break;
|
||||
else if (grub_errno == GRUB_ERR_UNKNOWN_DEVICE)
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
else
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (! dev)
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"),
|
||||
name);
|
||||
goto fail;
|
||||
}
|
||||
if (disk->log_sector_size > GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS
|
||||
|| disk->log_sector_size < GRUB_DISK_SECTOR_BITS)
|
||||
{
|
||||
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"sector sizes of %d bytes aren't supported yet",
|
||||
(1 << disk->log_sector_size));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
disk->dev = dev;
|
||||
|
||||
if (p)
|
||||
{
|
||||
disk->partition = grub_partition_probe (disk, p + 1);
|
||||
if (! disk->partition)
|
||||
{
|
||||
/* TRANSLATORS: It means that the specified partition e.g.
|
||||
hd0,msdos1=/dev/sda1 doesn't exist. */
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("no such partition"));
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* The cache will be invalidated about 2 seconds after a device was
|
||||
closed. */
|
||||
current_time = grub_get_time_ms ();
|
||||
|
||||
if (current_time > (grub_last_time
|
||||
+ GRUB_CACHE_TIMEOUT * 1000))
|
||||
grub_disk_cache_invalidate_all ();
|
||||
|
||||
grub_last_time = current_time;
|
||||
|
||||
fail:
|
||||
|
||||
if (raw && raw != name)
|
||||
grub_free (raw);
|
||||
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_error_push ();
|
||||
grub_dprintf ("disk", "Opening `%s' failed.\n", name);
|
||||
grub_error_pop ();
|
||||
|
||||
grub_disk_close (disk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return disk;
|
||||
}
|
||||
|
||||
void
|
||||
grub_disk_close (grub_disk_t disk)
|
||||
{
|
||||
grub_partition_t part;
|
||||
grub_dprintf ("disk", "Closing `%s'.\n", disk->name);
|
||||
|
||||
if (disk->dev && disk->dev->disk_close)
|
||||
(disk->dev->disk_close) (disk);
|
||||
|
||||
/* Reset the timer. */
|
||||
grub_last_time = grub_get_time_ms ();
|
||||
|
||||
while (disk->partition)
|
||||
{
|
||||
part = disk->partition->parent;
|
||||
grub_free (disk->partition);
|
||||
disk->partition = part;
|
||||
}
|
||||
grub_free ((void *) disk->name);
|
||||
grub_free (disk);
|
||||
}
|
||||
|
||||
/* Small read (less than cache size and not pass across cache unit boundaries).
|
||||
sector is already adjusted and is divisible by cache unit size.
|
||||
*/
|
||||
static grub_err_t
|
||||
grub_disk_read_small_real (grub_disk_t disk, grub_disk_addr_t sector,
|
||||
grub_off_t offset, grub_size_t size, void *buf)
|
||||
{
|
||||
char *data;
|
||||
char *tmp_buf;
|
||||
|
||||
/* Fetch the cache. */
|
||||
data = grub_disk_cache_fetch (disk->dev->id, disk->id, sector);
|
||||
if (data)
|
||||
{
|
||||
/* Just copy it! */
|
||||
grub_memcpy (buf, data + offset, size);
|
||||
grub_disk_cache_unlock (disk->dev->id, disk->id, sector);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* Allocate a temporary buffer. */
|
||||
tmp_buf = grub_malloc (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
|
||||
if (! tmp_buf)
|
||||
return grub_errno;
|
||||
|
||||
/* Otherwise read data from the disk actually. */
|
||||
if (disk->total_sectors == GRUB_DISK_SIZE_UNKNOWN
|
||||
|| sector + GRUB_DISK_CACHE_SIZE
|
||||
< (disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)))
|
||||
{
|
||||
grub_err_t err;
|
||||
err = (disk->dev->disk_read) (disk, transform_sector (disk, sector),
|
||||
1U << (GRUB_DISK_CACHE_BITS
|
||||
+ GRUB_DISK_SECTOR_BITS
|
||||
- disk->log_sector_size), tmp_buf);
|
||||
if (!err)
|
||||
{
|
||||
/* Copy it and store it in the disk cache. */
|
||||
grub_memcpy (buf, tmp_buf + offset, size);
|
||||
grub_disk_cache_store (disk->dev->id, disk->id,
|
||||
sector, tmp_buf);
|
||||
grub_free (tmp_buf);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
grub_free (tmp_buf);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
{
|
||||
/* Uggh... Failed. Instead, just read necessary data. */
|
||||
unsigned num;
|
||||
grub_disk_addr_t aligned_sector;
|
||||
|
||||
sector += (offset >> GRUB_DISK_SECTOR_BITS);
|
||||
offset &= ((1 << GRUB_DISK_SECTOR_BITS) - 1);
|
||||
aligned_sector = (sector & ~((1ULL << (disk->log_sector_size
|
||||
- GRUB_DISK_SECTOR_BITS))
|
||||
- 1));
|
||||
offset += ((sector - aligned_sector) << GRUB_DISK_SECTOR_BITS);
|
||||
num = ((size + offset + (1ULL << (disk->log_sector_size))
|
||||
- 1) >> (disk->log_sector_size));
|
||||
|
||||
tmp_buf = grub_malloc (num << disk->log_sector_size);
|
||||
if (!tmp_buf)
|
||||
return grub_errno;
|
||||
|
||||
if ((disk->dev->disk_read) (disk, transform_sector (disk, aligned_sector),
|
||||
num, tmp_buf))
|
||||
{
|
||||
grub_error_push ();
|
||||
grub_dprintf ("disk", "%s read failed\n", disk->name);
|
||||
grub_error_pop ();
|
||||
grub_free (tmp_buf);
|
||||
return grub_errno;
|
||||
}
|
||||
grub_memcpy (buf, tmp_buf + offset, size);
|
||||
grub_free (tmp_buf);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_disk_read_small (grub_disk_t disk, grub_disk_addr_t sector,
|
||||
grub_off_t offset, grub_size_t size, void *buf)
|
||||
{
|
||||
grub_err_t err;
|
||||
|
||||
err = grub_disk_read_small_real (disk, sector, offset, size, buf);
|
||||
if (err)
|
||||
return err;
|
||||
if (disk->read_hook)
|
||||
(disk->read_hook) (sector + (offset >> GRUB_DISK_SECTOR_BITS),
|
||||
offset & (GRUB_DISK_SECTOR_SIZE - 1),
|
||||
size, disk->read_hook_data);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t grub_disk_blocklist_read(void *chunklist, grub_uint64_t sector,
|
||||
grub_uint64_t size, grub_uint32_t log_sector_size)
|
||||
{
|
||||
ventoy_img_chunk *last_chunk = NULL;
|
||||
ventoy_img_chunk *new_chunk = NULL;
|
||||
ventoy_img_chunk_list *chunk_list = (ventoy_img_chunk_list *)chunklist;
|
||||
|
||||
if (chunk_list->cur_chunk == 0)
|
||||
{
|
||||
chunk_list->chunk[0].img_start_sector = 0;
|
||||
chunk_list->chunk[0].img_end_sector = (size >> 11) - 1;
|
||||
chunk_list->chunk[0].disk_start_sector = sector;
|
||||
chunk_list->chunk[0].disk_end_sector = sector + (size >> log_sector_size) - 1;
|
||||
chunk_list->cur_chunk = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
last_chunk = chunk_list->chunk + chunk_list->cur_chunk - 1;
|
||||
if (last_chunk->disk_end_sector + 1 == sector)
|
||||
{
|
||||
last_chunk->img_end_sector += (size >> 11);
|
||||
last_chunk->disk_end_sector += (size >> log_sector_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (chunk_list->cur_chunk == chunk_list->max_chunk)
|
||||
{
|
||||
new_chunk = grub_realloc(chunk_list->chunk, chunk_list->max_chunk * 2 * sizeof(ventoy_img_chunk));
|
||||
if (NULL == new_chunk)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
chunk_list->chunk = new_chunk;
|
||||
chunk_list->max_chunk *= 2;
|
||||
|
||||
/* issue: update last_chunk */
|
||||
last_chunk = chunk_list->chunk + chunk_list->cur_chunk - 1;
|
||||
}
|
||||
|
||||
new_chunk = chunk_list->chunk + chunk_list->cur_chunk;
|
||||
new_chunk->img_start_sector = last_chunk->img_end_sector + 1;
|
||||
new_chunk->img_end_sector = new_chunk->img_start_sector + (size >> 11) - 1;
|
||||
new_chunk->disk_start_sector = sector;
|
||||
new_chunk->disk_end_sector = sector + (size >> log_sector_size) - 1;
|
||||
|
||||
chunk_list->cur_chunk++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read data from the disk. */
|
||||
grub_err_t
|
||||
grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||
grub_off_t offset, grub_size_t size, void *buf)
|
||||
{
|
||||
if (disk->read_hook == (grub_disk_read_hook_t)grub_disk_blocklist_read)
|
||||
{
|
||||
return grub_disk_blocklist_read((ventoy_img_chunk_list *)disk->read_hook_data, sector, size, disk->log_sector_size);
|
||||
}
|
||||
|
||||
/* First of all, check if the region is within the disk. */
|
||||
if (grub_disk_adjust_range (disk, §or, &offset, size) != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_error_push ();
|
||||
grub_dprintf ("disk", "Read out of range: sector 0x%llx (%s).\n",
|
||||
(unsigned long long) sector, grub_errmsg);
|
||||
grub_error_pop ();
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
/* First read until first cache boundary. */
|
||||
if (offset || (sector & (GRUB_DISK_CACHE_SIZE - 1)))
|
||||
{
|
||||
grub_disk_addr_t start_sector;
|
||||
grub_size_t pos;
|
||||
grub_err_t err;
|
||||
grub_size_t len;
|
||||
|
||||
start_sector = sector & ~((grub_disk_addr_t) GRUB_DISK_CACHE_SIZE - 1);
|
||||
pos = (sector - start_sector) << GRUB_DISK_SECTOR_BITS;
|
||||
len = ((GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS)
|
||||
- pos - offset);
|
||||
if (len > size)
|
||||
len = size;
|
||||
err = grub_disk_read_small (disk, start_sector,
|
||||
offset + pos, len, buf);
|
||||
if (err)
|
||||
return err;
|
||||
buf = (char *) buf + len;
|
||||
size -= len;
|
||||
offset += len;
|
||||
sector += (offset >> GRUB_DISK_SECTOR_BITS);
|
||||
offset &= ((1 << GRUB_DISK_SECTOR_BITS) - 1);
|
||||
}
|
||||
|
||||
/* Until SIZE is zero... */
|
||||
while (size >= (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS))
|
||||
{
|
||||
char *data = NULL;
|
||||
grub_disk_addr_t agglomerate;
|
||||
grub_err_t err;
|
||||
|
||||
/* agglomerate read until we find a first cached entry. */
|
||||
for (agglomerate = 0; agglomerate
|
||||
< (size >> (GRUB_DISK_SECTOR_BITS + GRUB_DISK_CACHE_BITS))
|
||||
&& agglomerate < disk->max_agglomerate;
|
||||
agglomerate++)
|
||||
{
|
||||
data = grub_disk_cache_fetch (disk->dev->id, disk->id,
|
||||
sector + (agglomerate
|
||||
<< GRUB_DISK_CACHE_BITS));
|
||||
if (data)
|
||||
break;
|
||||
}
|
||||
|
||||
if (data)
|
||||
{
|
||||
grub_memcpy ((char *) buf
|
||||
+ (agglomerate << (GRUB_DISK_CACHE_BITS
|
||||
+ GRUB_DISK_SECTOR_BITS)),
|
||||
data, GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS);
|
||||
grub_disk_cache_unlock (disk->dev->id, disk->id,
|
||||
sector + (agglomerate
|
||||
<< GRUB_DISK_CACHE_BITS));
|
||||
}
|
||||
|
||||
if (agglomerate)
|
||||
{
|
||||
grub_disk_addr_t i;
|
||||
|
||||
err = (disk->dev->disk_read) (disk, transform_sector (disk, sector),
|
||||
agglomerate << (GRUB_DISK_CACHE_BITS
|
||||
+ GRUB_DISK_SECTOR_BITS
|
||||
- disk->log_sector_size),
|
||||
buf);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
for (i = 0; i < agglomerate; i ++)
|
||||
grub_disk_cache_store (disk->dev->id, disk->id,
|
||||
sector + (i << GRUB_DISK_CACHE_BITS),
|
||||
(char *) buf
|
||||
+ (i << (GRUB_DISK_CACHE_BITS
|
||||
+ GRUB_DISK_SECTOR_BITS)));
|
||||
|
||||
|
||||
if (disk->read_hook)
|
||||
(disk->read_hook) (sector, 0, agglomerate << (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS),
|
||||
disk->read_hook_data);
|
||||
|
||||
sector += agglomerate << GRUB_DISK_CACHE_BITS;
|
||||
size -= agglomerate << (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS);
|
||||
buf = (char *) buf
|
||||
+ (agglomerate << (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS));
|
||||
}
|
||||
|
||||
if (data)
|
||||
{
|
||||
if (disk->read_hook)
|
||||
(disk->read_hook) (sector, 0, (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS),
|
||||
disk->read_hook_data);
|
||||
sector += GRUB_DISK_CACHE_SIZE;
|
||||
buf = (char *) buf + (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS);
|
||||
size -= (GRUB_DISK_CACHE_SIZE << GRUB_DISK_SECTOR_BITS);
|
||||
}
|
||||
}
|
||||
|
||||
/* And now read the last part. */
|
||||
if (size)
|
||||
{
|
||||
grub_err_t err;
|
||||
err = grub_disk_read_small (disk, sector, 0, size, buf);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
grub_uint64_t
|
||||
grub_disk_get_size (grub_disk_t disk)
|
||||
{
|
||||
if (disk->partition)
|
||||
return grub_partition_get_len (disk->partition);
|
||||
else if (disk->total_sectors != GRUB_DISK_SIZE_UNKNOWN)
|
||||
return disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
|
||||
else
|
||||
return GRUB_DISK_SIZE_UNKNOWN;
|
||||
}
|
@@ -34,6 +34,12 @@
|
||||
#include <grub/dl.h>
|
||||
#include <grub/env.h>
|
||||
|
||||
int g_ventoy_menu_refresh = 0;
|
||||
int g_ventoy_memdisk_mode = 0;
|
||||
int g_ventoy_iso_raw = 0;
|
||||
int g_ventoy_iso_uefi_drv = 0;
|
||||
int g_ventoy_last_entry = 0;
|
||||
|
||||
/* Time to delay after displaying an error message about a default/fallback
|
||||
entry failing to boot. */
|
||||
#define DEFAULT_ENTRY_ERROR_DELAY_MS 2500
|
||||
@@ -577,16 +583,20 @@ print_countdown (struct grub_term_coordinate *pos, int n)
|
||||
static int
|
||||
run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
{
|
||||
const char *cmdstr;
|
||||
grub_uint64_t saved_time;
|
||||
int default_entry, current_entry;
|
||||
int default_entry,current_entry;
|
||||
int timeout;
|
||||
enum timeout_style timeout_style;
|
||||
|
||||
default_entry = get_entry_number (menu, "default");
|
||||
|
||||
|
||||
if (g_ventoy_last_entry >= 0 && g_ventoy_last_entry < menu->size) {
|
||||
default_entry = g_ventoy_last_entry;
|
||||
}
|
||||
/* If DEFAULT_ENTRY is not within the menu entries, fall back to
|
||||
the first entry. */
|
||||
if (default_entry < 0 || default_entry >= menu->size)
|
||||
else if (default_entry < 0 || default_entry >= menu->size)
|
||||
default_entry = 0;
|
||||
|
||||
timeout = grub_menu_get_timeout ();
|
||||
@@ -787,34 +797,76 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
}
|
||||
goto refresh;
|
||||
|
||||
case GRUB_TERM_KEY_F2:
|
||||
cmdstr = grub_env_get("VTOY_F2_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
goto refresh;
|
||||
}
|
||||
break;
|
||||
case GRUB_TERM_KEY_F3:
|
||||
cmdstr = grub_env_get("VTOY_F3_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
goto refresh;
|
||||
}
|
||||
break;
|
||||
case GRUB_TERM_KEY_F4:
|
||||
cmdstr = grub_env_get("VTOY_F4_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
goto refresh;
|
||||
}
|
||||
break;
|
||||
case GRUB_TERM_KEY_F5:
|
||||
cmdstr = grub_env_get("VTOY_F5_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
goto refresh;
|
||||
}
|
||||
break;
|
||||
case GRUB_TERM_KEY_F6:
|
||||
cmdstr = grub_env_get("VTOY_F6_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
goto refresh;
|
||||
}
|
||||
break;
|
||||
case GRUB_TERM_KEY_F7:
|
||||
cmdstr = grub_env_get("VTOY_F7_CMD");
|
||||
if (cmdstr)
|
||||
{
|
||||
menu_fini ();
|
||||
grub_script_execute_sourcecode(cmdstr);
|
||||
goto refresh;
|
||||
}
|
||||
break;
|
||||
case GRUB_TERM_KEY_F1:
|
||||
menu_fini ();
|
||||
if (grub_env_get("VTOY_MEM_DISK")) {
|
||||
grub_env_unset("VTOY_MEM_DISK");
|
||||
}else {
|
||||
grub_env_set("VTOY_MEM_DISK", grub_env_get("VTOY_MEM_DISK_STR"));
|
||||
}
|
||||
grub_env_set("VTOY_MENU_REFRESH", "1");
|
||||
g_ventoy_memdisk_mode = 1 - g_ventoy_memdisk_mode;
|
||||
g_ventoy_menu_refresh = 1;
|
||||
goto refresh;
|
||||
|
||||
case GRUB_TERM_KEY_F3:
|
||||
case (GRUB_TERM_CTRL | 'i'):
|
||||
menu_fini ();
|
||||
if (grub_env_get("VTOY_ISO_RAW")) {
|
||||
grub_env_unset("VTOY_ISO_RAW");
|
||||
}else {
|
||||
grub_env_set("VTOY_ISO_RAW", grub_env_get("VTOY_ISO_RAW_STR"));
|
||||
}
|
||||
grub_env_set("VTOY_MENU_REFRESH", "1");
|
||||
g_ventoy_iso_raw = 1 - g_ventoy_iso_raw;
|
||||
g_ventoy_menu_refresh = 1;
|
||||
goto refresh;
|
||||
|
||||
case GRUB_TERM_KEY_F4:
|
||||
case (GRUB_TERM_CTRL | 'u'):
|
||||
menu_fini ();
|
||||
if (grub_env_get("VTOY_ISO_UEFI_DRV")) {
|
||||
grub_env_unset("VTOY_ISO_UEFI_DRV");
|
||||
}else {
|
||||
grub_env_set("VTOY_ISO_UEFI_DRV", grub_env_get("VTOY_ISO_UEFI_DRV_STR"));
|
||||
}
|
||||
grub_env_set("VTOY_MENU_REFRESH", "1");
|
||||
g_ventoy_iso_uefi_drv = 1 - g_ventoy_iso_uefi_drv;
|
||||
g_ventoy_menu_refresh = 1;
|
||||
goto refresh;
|
||||
|
||||
default:
|
||||
@@ -897,6 +949,8 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
|
||||
if (boot_entry < 0)
|
||||
break;
|
||||
|
||||
g_ventoy_last_entry = boot_entry;
|
||||
|
||||
e = grub_menu_get_entry (menu, boot_entry);
|
||||
if (! e)
|
||||
continue; /* Menu is empty. */
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include <grub/efi/efi.h>
|
||||
#endif
|
||||
#include <grub/time.h>
|
||||
#include <grub/relocator.h>
|
||||
#include <grub/ventoy.h>
|
||||
#include "ventoy_def.h"
|
||||
|
||||
@@ -52,11 +53,14 @@ int g_valid_initrd_count = 0;
|
||||
static grub_file_t g_old_file;
|
||||
|
||||
char g_img_swap_tmp_buf[1024];
|
||||
|
||||
img_info g_img_swap_tmp;
|
||||
img_info *g_ventoy_img_list = NULL;
|
||||
int g_ventoy_img_count = 0;
|
||||
|
||||
grub_device_t g_enum_dev = NULL;
|
||||
grub_fs_t g_enum_fs = NULL;
|
||||
img_iterator_node g_img_iterator_head;
|
||||
img_iterator_node *g_img_iterator_tail = NULL;
|
||||
|
||||
grub_uint8_t g_ventoy_break_level = 0;
|
||||
grub_uint8_t g_ventoy_debug_level = 0;
|
||||
@@ -71,6 +75,13 @@ ventoy_guid g_ventoy_guid = VENTOY_GUID;
|
||||
|
||||
ventoy_img_chunk_list g_img_chunk_list;
|
||||
|
||||
static char *g_tree_script_buf = NULL;
|
||||
static int g_tree_script_pos = 0;
|
||||
|
||||
static char *g_list_script_buf = NULL;
|
||||
static int g_list_script_pos = 0;
|
||||
|
||||
|
||||
void ventoy_debug(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
@@ -90,6 +101,36 @@ int ventoy_is_efi_os(void)
|
||||
return g_efi_os;
|
||||
}
|
||||
|
||||
static int ventoy_get_fs_type(const char *fs)
|
||||
{
|
||||
if (NULL == fs)
|
||||
{
|
||||
return ventoy_fs_max;
|
||||
}
|
||||
else if (grub_strncmp(fs, "exfat", 5) == 0)
|
||||
{
|
||||
return ventoy_fs_exfat;
|
||||
}
|
||||
else if (grub_strncmp(fs, "ntfs", 4) == 0)
|
||||
{
|
||||
return ventoy_fs_ntfs;
|
||||
}
|
||||
else if (grub_strncmp(fs, "ext", 3) == 0)
|
||||
{
|
||||
return ventoy_fs_ext;
|
||||
}
|
||||
else if (grub_strncmp(fs, "xfs", 3) == 0)
|
||||
{
|
||||
return ventoy_fs_xfs;
|
||||
}
|
||||
else if (grub_strncmp(fs, "udf", 3) == 0)
|
||||
{
|
||||
return ventoy_fs_udf;
|
||||
}
|
||||
|
||||
return ventoy_fs_max;
|
||||
}
|
||||
|
||||
static int ventoy_string_check(const char *str, grub_char_check_func check)
|
||||
{
|
||||
if (!str)
|
||||
@@ -530,7 +571,7 @@ static grub_err_t ventoy_cmd_check_compatible(grub_extcmd_context_t ctxt, int ar
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static int ventoy_cmp_img(img_info *img1, img_info *img2)
|
||||
int ventoy_cmp_img(img_info *img1, img_info *img2)
|
||||
{
|
||||
char *s1, *s2;
|
||||
int c1 = 0;
|
||||
@@ -560,15 +601,17 @@ static int ventoy_cmp_img(img_info *img1, img_info *img2)
|
||||
return (c1 - c2);
|
||||
}
|
||||
|
||||
static void ventoy_swap_img(img_info *img1, img_info *img2)
|
||||
void ventoy_swap_img(img_info *img1, img_info *img2)
|
||||
{
|
||||
grub_memcpy(g_img_swap_tmp_buf, img1->name, sizeof(img1->name));
|
||||
grub_memcpy(img1->name, img2->name, sizeof(img1->name));
|
||||
grub_memcpy(img2->name, g_img_swap_tmp_buf, sizeof(img1->name));
|
||||
grub_memcpy(&g_img_swap_tmp, img1, sizeof(img_info));
|
||||
|
||||
grub_memcpy(g_img_swap_tmp_buf, img1->path, sizeof(img1->path));
|
||||
grub_memcpy(img1->path, img2->path, sizeof(img1->path));
|
||||
grub_memcpy(img2->path, g_img_swap_tmp_buf, sizeof(img1->path));
|
||||
grub_memcpy(img1, img2, sizeof(img_info));
|
||||
img1->next = g_img_swap_tmp.next;
|
||||
img1->prev = g_img_swap_tmp.prev;
|
||||
|
||||
g_img_swap_tmp.next = img2->next;
|
||||
g_img_swap_tmp.prev = img2->prev;
|
||||
grub_memcpy(img2, &g_img_swap_tmp, sizeof(img_info));
|
||||
}
|
||||
|
||||
static int ventoy_img_name_valid(const char *filename, grub_size_t namelen)
|
||||
@@ -591,11 +634,27 @@ static int ventoy_img_name_valid(const char *filename, grub_size_t namelen)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ventoy_check_ignore_flag(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||
{
|
||||
if (0 == info->dir)
|
||||
{
|
||||
if (filename && filename[0] == '.' && 0 == grub_strncmp(filename, ".ventoyignore", 13))
|
||||
{
|
||||
*((int *)data) = 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_colect_img_files(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||
{
|
||||
int ignore = 0;
|
||||
grub_size_t len;
|
||||
img_info *img;
|
||||
img_info *tail;
|
||||
img_iterator_node *tmp;
|
||||
img_iterator_node *new_node;
|
||||
img_iterator_node *node = (img_iterator_node *)data;
|
||||
|
||||
@@ -609,14 +668,47 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_node = grub_malloc(sizeof(img_iterator_node));
|
||||
if (!ventoy_img_name_valid(filename, len))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (filename[0] == '$' && 0 == grub_strncmp(filename, "$RECYCLE.BIN", 12))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_node = grub_zalloc(sizeof(img_iterator_node));
|
||||
if (new_node)
|
||||
{
|
||||
new_node->tail = node->tail;
|
||||
grub_snprintf(new_node->dir, sizeof(new_node->dir), "%s%s/", node->dir, filename);
|
||||
new_node->dirlen = grub_snprintf(new_node->dir, sizeof(new_node->dir), "%s%s/", node->dir, filename);
|
||||
|
||||
new_node->next = g_img_iterator_head.next;
|
||||
g_img_iterator_head.next = new_node;
|
||||
g_enum_fs->fs_dir(g_enum_dev, new_node->dir, ventoy_check_ignore_flag, &ignore);
|
||||
if (ignore)
|
||||
{
|
||||
debug("Directory %s ignored...\n", new_node->dir);
|
||||
grub_free(new_node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_node->tail = node->tail;
|
||||
|
||||
new_node->parent = node;
|
||||
if (!node->firstchild)
|
||||
{
|
||||
node->firstchild = new_node;
|
||||
}
|
||||
|
||||
if (g_img_iterator_tail)
|
||||
{
|
||||
g_img_iterator_tail->next = new_node;
|
||||
g_img_iterator_tail = new_node;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_img_iterator_head.next = new_node;
|
||||
g_img_iterator_tail = new_node;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -646,6 +738,22 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
|
||||
{
|
||||
g_ventoy_img_list = img;
|
||||
}
|
||||
|
||||
img->size = info->size;
|
||||
img->id = g_ventoy_img_count;
|
||||
img->parent = node;
|
||||
if (node && NULL == node->firstiso)
|
||||
{
|
||||
node->firstiso = img;
|
||||
}
|
||||
|
||||
node->isocnt++;
|
||||
tmp = node->parent;
|
||||
while (tmp)
|
||||
{
|
||||
tmp->isocnt++;
|
||||
tmp = tmp->parent;
|
||||
}
|
||||
|
||||
*((img_info **)(node->tail)) = img;
|
||||
g_ventoy_img_count++;
|
||||
@@ -734,6 +842,96 @@ int ventoy_fill_data(grub_uint32_t buflen, char *buffer)
|
||||
return len;
|
||||
}
|
||||
|
||||
static img_info * ventoy_get_min_iso(img_iterator_node *node)
|
||||
{
|
||||
img_info *minimg = NULL;
|
||||
img_info *img = (img_info *)(node->firstiso);
|
||||
|
||||
while (img && (img_iterator_node *)(img->parent) == node)
|
||||
{
|
||||
if (img->select == 0 && (NULL == minimg || grub_strcmp(img->name, minimg->name) < 0))
|
||||
{
|
||||
minimg = img;
|
||||
}
|
||||
img = img->next;
|
||||
}
|
||||
|
||||
if (minimg)
|
||||
{
|
||||
minimg->select = 1;
|
||||
}
|
||||
|
||||
return minimg;
|
||||
}
|
||||
|
||||
static img_iterator_node * ventoy_get_min_child(img_iterator_node *node)
|
||||
{
|
||||
img_iterator_node *Minchild = NULL;
|
||||
img_iterator_node *child = node->firstchild;
|
||||
|
||||
while (child && child->parent == node)
|
||||
{
|
||||
if (child->select == 0 && (NULL == Minchild || grub_strcmp(child->dir, Minchild->dir) < 0))
|
||||
{
|
||||
Minchild = child;
|
||||
}
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
if (Minchild)
|
||||
{
|
||||
Minchild->select = 1;
|
||||
}
|
||||
|
||||
return Minchild;
|
||||
}
|
||||
|
||||
static int ventoy_dynamic_tree_menu(img_iterator_node *node)
|
||||
{
|
||||
int offset = 1;
|
||||
img_info *img;
|
||||
img_iterator_node *child = NULL;
|
||||
|
||||
if (node->isocnt == 0 || node->done == 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (node->parent && node->parent->dirlen < node->dirlen)
|
||||
{
|
||||
offset = node->parent->dirlen;
|
||||
}
|
||||
|
||||
if (node != &g_img_iterator_head)
|
||||
{
|
||||
node->dir[node->dirlen - 1] = 0;
|
||||
g_tree_script_pos += grub_snprintf(g_tree_script_buf + g_tree_script_pos, VTOY_MAX_SCRIPT_BUF - g_tree_script_pos,
|
||||
"submenu \"%-10s [%s]\" {\n", "DIR", node->dir + offset);
|
||||
}
|
||||
|
||||
while ((child = ventoy_get_min_child(node)) != NULL)
|
||||
{
|
||||
ventoy_dynamic_tree_menu(child);
|
||||
}
|
||||
|
||||
while ((img = ventoy_get_min_iso(node)) != NULL)
|
||||
{
|
||||
g_tree_script_pos += grub_snprintf(g_tree_script_buf + g_tree_script_pos, VTOY_MAX_SCRIPT_BUF - g_tree_script_pos,
|
||||
"menuentry \"%-10s %s\" --id=\"VID_%d\" {\n"
|
||||
" common_menuentry \n"
|
||||
"}\n",
|
||||
grub_get_human_size(img->size, GRUB_HUMAN_SIZE_SHORT), img->name, img->id);
|
||||
}
|
||||
|
||||
if (node != &g_img_iterator_head)
|
||||
{
|
||||
g_tree_script_pos += grub_snprintf(g_tree_script_buf + g_tree_script_pos, VTOY_MAX_SCRIPT_BUF - g_tree_script_pos, "}\n");
|
||||
}
|
||||
|
||||
node->done = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_fs_t fs;
|
||||
@@ -743,6 +941,7 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
|
||||
char *device_name = NULL;
|
||||
char buf[32];
|
||||
img_iterator_node *node = NULL;
|
||||
img_iterator_node *tmp = NULL;
|
||||
|
||||
(void)ctxt;
|
||||
|
||||
@@ -762,34 +961,49 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dev = grub_device_open(device_name);
|
||||
g_enum_dev = dev = grub_device_open(device_name);
|
||||
if (!dev)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fs = grub_fs_probe(dev);
|
||||
g_enum_fs = fs = grub_fs_probe(dev);
|
||||
if (!fs)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
grub_memset(&g_img_iterator_head, 0, sizeof(g_img_iterator_head));
|
||||
|
||||
g_img_iterator_head.tail = &tail;
|
||||
grub_strcpy(g_img_iterator_head.dir, "/");
|
||||
|
||||
fs->fs_dir(dev, "/", ventoy_colect_img_files, &g_img_iterator_head);
|
||||
|
||||
while (g_img_iterator_head.next)
|
||||
if (ventoy_get_fs_type(fs->name) >= ventoy_fs_max)
|
||||
{
|
||||
node = g_img_iterator_head.next;
|
||||
g_img_iterator_head.next = node->next;
|
||||
|
||||
fs->fs_dir(dev, node->dir, ventoy_colect_img_files, node);
|
||||
grub_free(node);
|
||||
debug("unsupported fs:<%s>\n", fs->name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
grub_memset(&g_img_iterator_head, 0, sizeof(g_img_iterator_head));
|
||||
|
||||
g_img_iterator_head.dirlen = 1;
|
||||
g_img_iterator_head.tail = &tail;
|
||||
grub_strcpy(g_img_iterator_head.dir, "/");
|
||||
|
||||
for (node = &g_img_iterator_head; node; node = node->next)
|
||||
{
|
||||
fs->fs_dir(dev, node->dir, ventoy_colect_img_files, node);
|
||||
}
|
||||
|
||||
for (node = &g_img_iterator_head; node; node = node->next)
|
||||
{
|
||||
ventoy_dynamic_tree_menu(node);
|
||||
}
|
||||
|
||||
/* free node */
|
||||
node = g_img_iterator_head.next;
|
||||
while (node)
|
||||
{
|
||||
tmp = node->next;
|
||||
grub_free(node);
|
||||
node = tmp;
|
||||
}
|
||||
|
||||
/* sort image list by image name */
|
||||
for (cur = g_ventoy_img_list; cur; cur = cur->next)
|
||||
{
|
||||
@@ -802,6 +1016,16 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
|
||||
}
|
||||
}
|
||||
|
||||
for (cur = g_ventoy_img_list; cur; cur = cur->next)
|
||||
{
|
||||
g_list_script_pos += grub_snprintf(g_list_script_buf + g_list_script_pos, VTOY_MAX_SCRIPT_BUF - g_list_script_pos,
|
||||
"menuentry \"%s\" --id=\"VID_%d\" {\n"
|
||||
" common_menuentry \n"
|
||||
"}\n",
|
||||
cur->name, cur->id);
|
||||
}
|
||||
g_list_script_buf[g_list_script_pos] = 0;
|
||||
|
||||
grub_snprintf(buf, sizeof(buf), "%d", g_ventoy_img_count);
|
||||
grub_env_set(args[1], buf);
|
||||
|
||||
@@ -876,7 +1100,9 @@ static grub_err_t ventoy_cmd_img_name(grub_extcmd_context_t ctxt, int argc, char
|
||||
|
||||
static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
const char *name = NULL;
|
||||
int img_id = 0;
|
||||
char *pos = NULL;
|
||||
const char *id = NULL;
|
||||
img_info *cur = g_ventoy_img_list;
|
||||
|
||||
(void)ctxt;
|
||||
@@ -886,13 +1112,22 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
|
||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {var}", cmd_raw_name);
|
||||
}
|
||||
|
||||
name = grub_env_get("chosen");
|
||||
id = grub_env_get("chosen");
|
||||
|
||||
pos = grub_strstr(id, "VID_");
|
||||
if (pos)
|
||||
{
|
||||
img_id = (int)grub_strtoul(pos + 4, NULL, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
img_id = (int)grub_strtoul(id, NULL, 10);
|
||||
}
|
||||
|
||||
while (cur)
|
||||
{
|
||||
if (0 == grub_strcmp(name, cur->name))
|
||||
if (img_id == cur->id)
|
||||
{
|
||||
grub_env_set(args[0], cur->path);
|
||||
break;
|
||||
}
|
||||
cur = cur->next;
|
||||
@@ -903,6 +1138,8 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
|
||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "No such image");
|
||||
}
|
||||
|
||||
grub_env_set(args[0], cur->path);
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
@@ -1012,19 +1249,7 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
|
||||
|
||||
param->vtoy_disk_size = disk->total_sectors * (1 << disk->log_sector_size);
|
||||
param->vtoy_disk_part_id = disk->partition->number + 1;
|
||||
|
||||
if (grub_strcmp(file->fs->name, "exfat") == 0)
|
||||
{
|
||||
param->vtoy_disk_part_type = 0;
|
||||
}
|
||||
else if (grub_strcmp(file->fs->name, "ntfs") == 0)
|
||||
{
|
||||
param->vtoy_disk_part_type = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
param->vtoy_disk_part_type = 0xFFFF;
|
||||
}
|
||||
param->vtoy_disk_part_type = ventoy_get_fs_type(file->fs->name);
|
||||
|
||||
pos = grub_strstr(file->name, "/");
|
||||
if (!pos)
|
||||
@@ -1051,6 +1276,52 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
|
||||
return;
|
||||
}
|
||||
|
||||
static int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start)
|
||||
{
|
||||
int fs_type;
|
||||
grub_uint32_t i = 0;
|
||||
grub_uint32_t sector = 0;
|
||||
grub_uint32_t count = 0;
|
||||
grub_off_t size = 0;
|
||||
grub_off_t read = 0;
|
||||
|
||||
fs_type = ventoy_get_fs_type(file->fs->name);
|
||||
if (fs_type == ventoy_fs_exfat)
|
||||
{
|
||||
grub_fat_get_file_chunk(start, file, chunklist);
|
||||
}
|
||||
else
|
||||
{
|
||||
file->read_hook = (grub_disk_read_hook_t)grub_disk_blocklist_read;
|
||||
file->read_hook_data = chunklist;
|
||||
|
||||
for (size = file->size; size > 0; size -= read)
|
||||
{
|
||||
read = (size > VTOY_SIZE_1GB) ? VTOY_SIZE_1GB : size;
|
||||
grub_file_read(file, NULL, read);
|
||||
}
|
||||
|
||||
for (i = 0; start > 0 && i < chunklist->cur_chunk; i++)
|
||||
{
|
||||
chunklist->chunk[i].disk_start_sector += start;
|
||||
chunklist->chunk[i].disk_end_sector += start;
|
||||
}
|
||||
|
||||
if (ventoy_fs_udf == fs_type)
|
||||
{
|
||||
for (i = 0; i < chunklist->cur_chunk; i++)
|
||||
{
|
||||
count = (chunklist->chunk[i].disk_end_sector + 1 - chunklist->chunk[i].disk_start_sector) >> 2;
|
||||
chunklist->chunk[i].img_start_sector = sector;
|
||||
chunklist->chunk[i].img_end_sector = sector + count - 1;
|
||||
sector += count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_file_t file;
|
||||
@@ -1080,8 +1351,7 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
|
||||
g_img_chunk_list.max_chunk = DEFAULT_CHUNK_NUM;
|
||||
g_img_chunk_list.cur_chunk = 0;
|
||||
|
||||
debug("get fat file chunk part start:%llu\n", (unsigned long long)file->device->disk->partition->start);
|
||||
grub_fat_get_file_chunk(file->device->disk->partition->start, file, &g_img_chunk_list);
|
||||
ventoy_get_block_list(file, &g_img_chunk_list, file->device->disk->partition->start);
|
||||
|
||||
grub_file_close(file);
|
||||
|
||||
@@ -1111,6 +1381,121 @@ static grub_err_t ventoy_cmd_dump_img_sector(grub_extcmd_context_t ctxt, int arg
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
static grub_err_t ventoy_cmd_relocator_chaindata(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static grub_err_t ventoy_cmd_relocator_chaindata(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int rc = 0;
|
||||
ulong chain_len = 0;
|
||||
char *chain_data = NULL;
|
||||
char *relocator_addr = NULL;
|
||||
grub_relocator_chunk_t ch;
|
||||
struct grub_relocator *relocator = NULL;
|
||||
char envbuf[64] = { 0 };
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
chain_data = (char *)grub_strtoul(args[0], NULL, 16);
|
||||
chain_len = grub_strtoul(args[1], NULL, 10);
|
||||
|
||||
relocator = grub_relocator_new ();
|
||||
if (!relocator)
|
||||
{
|
||||
debug("grub_relocator_new failed %p %lu\n", chain_data, chain_len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = grub_relocator_alloc_chunk_addr (relocator, &ch,
|
||||
0x100000, // GRUB_LINUX_BZIMAGE_ADDR,
|
||||
chain_len);
|
||||
if (rc)
|
||||
{
|
||||
debug("grub_relocator_alloc_chunk_addr failed %d %p %lu\n", rc, chain_data, chain_len);
|
||||
grub_relocator_unload (relocator);
|
||||
return 1;
|
||||
}
|
||||
|
||||
relocator_addr = get_virtual_current_address(ch);
|
||||
|
||||
grub_memcpy(relocator_addr, chain_data, chain_len);
|
||||
|
||||
grub_relocator_unload (relocator);
|
||||
|
||||
grub_snprintf(envbuf, sizeof(envbuf), "0x%lx", (unsigned long)relocator_addr);
|
||||
grub_env_set("vtoy_chain_relocator_addr", envbuf);
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
static grub_err_t ventoy_cmd_test_block_list(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_uint32_t i;
|
||||
grub_file_t file;
|
||||
ventoy_img_chunk_list chunklist;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
|
||||
if (!file)
|
||||
{
|
||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Can't open file %s\n", args[0]);
|
||||
}
|
||||
|
||||
/* get image chunk data */
|
||||
grub_memset(&chunklist, 0, sizeof(chunklist));
|
||||
chunklist.chunk = grub_malloc(sizeof(ventoy_img_chunk) * DEFAULT_CHUNK_NUM);
|
||||
if (NULL == chunklist.chunk)
|
||||
{
|
||||
return grub_error(GRUB_ERR_OUT_OF_MEMORY, "Can't allocate image chunk memoty\n");
|
||||
}
|
||||
|
||||
chunklist.max_chunk = DEFAULT_CHUNK_NUM;
|
||||
chunklist.cur_chunk = 0;
|
||||
|
||||
ventoy_get_block_list(file, &chunklist, 0);
|
||||
|
||||
grub_file_close(file);
|
||||
|
||||
grub_printf("filesystem: <%s> entry number:<%u>\n", file->fs->name, chunklist.cur_chunk);
|
||||
|
||||
for (i = 0; i < chunklist.cur_chunk; i++)
|
||||
{
|
||||
grub_printf("%llu+%llu,", (ulonglong)chunklist.chunk[i].disk_start_sector,
|
||||
(ulonglong)(chunklist.chunk[i].disk_end_sector + 1 - chunklist.chunk[i].disk_start_sector));
|
||||
}
|
||||
|
||||
grub_printf("\n==================================\n");
|
||||
for (i = 0; i < chunklist.cur_chunk; i++)
|
||||
{
|
||||
grub_printf("%2u: [%llu %llu] - [%llu %llu]\n", i,
|
||||
(ulonglong)chunklist.chunk[i].img_start_sector,
|
||||
(ulonglong)chunklist.chunk[i].img_end_sector,
|
||||
(ulonglong)chunklist.chunk[i].disk_start_sector,
|
||||
(ulonglong)chunklist.chunk[i].disk_end_sector
|
||||
);
|
||||
}
|
||||
|
||||
grub_free(chunklist.chunk);
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_add_replace_file(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i;
|
||||
@@ -1138,6 +1523,193 @@ static grub_err_t ventoy_cmd_add_replace_file(grub_extcmd_context_t ctxt, int ar
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_dump_menu(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
grub_printf("List Mode: CurLen:%d MaxLen:%u\n", g_list_script_pos, VTOY_MAX_SCRIPT_BUF);
|
||||
grub_printf("%s", g_list_script_buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("Tree Mode: CurLen:%d MaxLen:%u\n", g_tree_script_pos, VTOY_MAX_SCRIPT_BUF);
|
||||
grub_printf("%s", g_tree_script_buf);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_dump_auto_install(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
ventoy_plugin_dump_auto_install();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_check_mode(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
if (argc != 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (args[0][0] == '0')
|
||||
{
|
||||
return g_ventoy_memdisk_mode ? 0 : 1;
|
||||
}
|
||||
else if (args[0][0] == '1')
|
||||
{
|
||||
return g_ventoy_iso_raw ? 0 : 1;
|
||||
}
|
||||
else if (args[0][0] == '2')
|
||||
{
|
||||
return g_ventoy_iso_uefi_drv ? 0 : 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_dynamic_menu(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
static int configfile_mode = 0;
|
||||
char memfile[128] = {0};
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
/*
|
||||
* args[0]: 0:normal 1:configfile
|
||||
* args[1]: 0:list_buf 1:tree_buf
|
||||
*/
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
debug("Invalid argc %d\n", argc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (args[0][0] == '0')
|
||||
{
|
||||
if (args[1][0] == '0')
|
||||
{
|
||||
grub_script_execute_sourcecode(g_list_script_buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_script_execute_sourcecode(g_tree_script_buf);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (configfile_mode)
|
||||
{
|
||||
debug("Now already in F3 mode %d\n", configfile_mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (args[1][0] == '0')
|
||||
{
|
||||
grub_snprintf(memfile, sizeof(memfile), "configfile mem:0x%llx:size:%d",
|
||||
(ulonglong)(ulong)g_list_script_buf, g_list_script_pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_ventoy_last_entry = -1;
|
||||
grub_snprintf(memfile, sizeof(memfile), "configfile mem:0x%llx:size:%d",
|
||||
(ulonglong)(ulong)g_tree_script_buf, g_tree_script_pos);
|
||||
}
|
||||
|
||||
configfile_mode = 1;
|
||||
grub_script_execute_sourcecode(memfile);
|
||||
configfile_mode = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_find_bootable_hdd(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int id = 0;
|
||||
int find = 0;
|
||||
grub_disk_t disk;
|
||||
const char *isopath = NULL;
|
||||
char hdname[32];
|
||||
ventoy_mbr_head mbr;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
|
||||
if (argc != 1)
|
||||
{
|
||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s variable\n", cmd_raw_name);
|
||||
}
|
||||
|
||||
isopath = grub_env_get("iso_path");
|
||||
if (!isopath)
|
||||
{
|
||||
debug("isopath is null %p\n", isopath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
debug("isopath is %s\n", isopath);
|
||||
|
||||
for (id = 0; id < 30 && (find == 0); id++)
|
||||
{
|
||||
grub_snprintf(hdname, sizeof(hdname), "hd%d,", id);
|
||||
if (grub_strstr(isopath, hdname))
|
||||
{
|
||||
debug("skip %s ...\n", hdname);
|
||||
continue;
|
||||
}
|
||||
|
||||
grub_snprintf(hdname, sizeof(hdname), "hd%d", id);
|
||||
|
||||
disk = grub_disk_open(hdname);
|
||||
if (!disk)
|
||||
{
|
||||
debug("%s not exist\n", hdname);
|
||||
break;
|
||||
}
|
||||
|
||||
grub_memset(&mbr, 0, sizeof(mbr));
|
||||
if (0 == grub_disk_read(disk, 0, 0, 512, &mbr))
|
||||
{
|
||||
if (mbr.Byte55 == 0x55 && mbr.ByteAA == 0xAA)
|
||||
{
|
||||
if (mbr.PartTbl[0].Active == 0x80 || mbr.PartTbl[1].Active == 0x80 ||
|
||||
mbr.PartTbl[2].Active == 0x80 || mbr.PartTbl[3].Active == 0x80)
|
||||
{
|
||||
|
||||
grub_env_set(args[0], hdname);
|
||||
find = 1;
|
||||
}
|
||||
}
|
||||
debug("%s is %s\n", hdname, find ? "bootable" : "NOT bootable");
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("read %s failed\n", hdname);
|
||||
}
|
||||
|
||||
grub_disk_close(disk);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@@ -1189,6 +1761,10 @@ static int ventoy_env_init(void)
|
||||
char buf[64];
|
||||
|
||||
grub_env_set("vtdebug_flag", "");
|
||||
grub_env_export("vtdebug_flag");
|
||||
|
||||
g_tree_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
||||
g_list_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
||||
|
||||
ventoy_filt_register(0, ventoy_wrapper_open);
|
||||
|
||||
@@ -1219,6 +1795,11 @@ static cmd_para ventoy_cmds[] =
|
||||
{ "vt_img_sector", ventoy_cmd_img_sector, 0, NULL, "{imageName}", "", NULL },
|
||||
{ "vt_dump_img_sector", ventoy_cmd_dump_img_sector, 0, NULL, "", "", NULL },
|
||||
{ "vt_load_cpio", ventoy_cmd_load_cpio, 0, NULL, "", "", NULL },
|
||||
{ "vt_find_first_bootable_hd", ventoy_cmd_find_bootable_hdd, 0, NULL, "", "", NULL },
|
||||
{ "vt_dump_menu", ventoy_cmd_dump_menu, 0, NULL, "", "", NULL },
|
||||
{ "vt_dynamic_menu", ventoy_cmd_dynamic_menu, 0, NULL, "", "", NULL },
|
||||
{ "vt_check_mode", ventoy_cmd_check_mode, 0, NULL, "", "", NULL },
|
||||
{ "vt_dump_auto_install", ventoy_cmd_dump_auto_install, 0, NULL, "", "", NULL },
|
||||
|
||||
{ "vt_is_udf", ventoy_cmd_is_udf, 0, NULL, "", "", NULL },
|
||||
{ "vt_file_size", ventoy_cmd_file_size, 0, NULL, "", "", NULL },
|
||||
@@ -1239,6 +1820,8 @@ static cmd_para ventoy_cmds[] =
|
||||
{ "vt_windows_chain_data", ventoy_cmd_windows_chain_data, 0, NULL, "", "", NULL },
|
||||
|
||||
{ "vt_add_replace_file", ventoy_cmd_add_replace_file, 0, NULL, "", "", NULL },
|
||||
{ "vt_relocator_chaindata", ventoy_cmd_relocator_chaindata, 0, NULL, "", "", NULL },
|
||||
{ "vt_test_block_list", ventoy_cmd_test_block_list, 0, NULL, "", "", NULL },
|
||||
|
||||
|
||||
{ "vt_load_plugin", ventoy_cmd_load_plugin, 0, NULL, "", "", NULL },
|
||||
|
@@ -21,10 +21,15 @@
|
||||
#ifndef __VENTOY_DEF_H__
|
||||
#define __VENTOY_DEF_H__
|
||||
|
||||
#define VTOY_MAX_SCRIPT_BUF (4 * 1024 * 1024)
|
||||
|
||||
#define VTOY_SIZE_1GB 1073741824
|
||||
|
||||
#define JSON_SUCCESS 0
|
||||
#define JSON_FAILED 1
|
||||
#define JSON_NOT_FOUND 2
|
||||
|
||||
#define ulong unsigned long
|
||||
#define ulonglong unsigned long long
|
||||
|
||||
#define vtoy_to_upper(c) (((char)(c) >= 'a' && (char)(c) <= 'z') ? ((char)(c) - 'a' + 'A') : (char)(c))
|
||||
@@ -115,11 +120,15 @@ typedef struct ventoy_udf_override
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
typedef struct img_info
|
||||
{
|
||||
char path[512];
|
||||
char name[256];
|
||||
int id;
|
||||
grub_uint64_t size;
|
||||
int select;
|
||||
|
||||
void *parent;
|
||||
|
||||
struct img_info *next;
|
||||
struct img_info *prev;
|
||||
@@ -130,8 +139,19 @@ typedef struct img_iterator_node
|
||||
struct img_iterator_node *next;
|
||||
img_info **tail;
|
||||
char dir[400];
|
||||
int dirlen;
|
||||
int isocnt;
|
||||
int done;
|
||||
int select;
|
||||
|
||||
struct img_iterator_node *parent;
|
||||
struct img_iterator_node *firstchild;
|
||||
|
||||
void *firstiso;
|
||||
}img_iterator_node;
|
||||
|
||||
|
||||
|
||||
typedef struct initrd_info
|
||||
{
|
||||
char name[256];
|
||||
@@ -400,7 +420,7 @@ grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc,
|
||||
grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
int ventoy_cpio_newc_fill_head(void *buf, int filesize, void *filedata, const char *name);
|
||||
int ventoy_cpio_newc_fill_head(void *buf, int filesize, const void *filedata, const char *name);
|
||||
grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...);
|
||||
int ventoy_is_file_exist(const char *fmt, ...);
|
||||
int ventoy_fill_data(grub_uint32_t buflen, char *buffer);
|
||||
@@ -504,5 +524,54 @@ static inline int ventoy_is_word_end(int c)
|
||||
return (c == 0 || c == ',' || ventoy_isspace(c));
|
||||
}
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct ventoy_part_table
|
||||
{
|
||||
grub_uint8_t Active; // 0x00 0x80
|
||||
|
||||
grub_uint8_t StartHead;
|
||||
grub_uint16_t StartSector : 6;
|
||||
grub_uint16_t StartCylinder : 10;
|
||||
|
||||
grub_uint8_t FsFlag;
|
||||
|
||||
grub_uint8_t EndHead;
|
||||
grub_uint16_t EndSector : 6;
|
||||
grub_uint16_t EndCylinder : 10;
|
||||
|
||||
grub_uint32_t StartSectorId;
|
||||
grub_uint32_t SectorCount;
|
||||
}ventoy_part_table;
|
||||
|
||||
typedef struct ventoy_mbr_head
|
||||
{
|
||||
grub_uint8_t BootCode[446];
|
||||
ventoy_part_table PartTbl[4];
|
||||
grub_uint8_t Byte55;
|
||||
grub_uint8_t ByteAA;
|
||||
}ventoy_mbr_head;
|
||||
#pragma pack()
|
||||
|
||||
|
||||
typedef struct install_template
|
||||
{
|
||||
char isopath[256];
|
||||
char templatepath[256];
|
||||
|
||||
struct install_template *next;
|
||||
}install_template;
|
||||
|
||||
extern int g_ventoy_last_entry;
|
||||
extern int g_ventoy_memdisk_mode;
|
||||
extern int g_ventoy_iso_raw;
|
||||
extern int g_ventoy_iso_uefi_drv;
|
||||
|
||||
int ventoy_cmp_img(img_info *img1, img_info *img2);
|
||||
void ventoy_swap_img(img_info *img1, img_info *img2);
|
||||
char * ventoy_plugin_get_install_template(const char *isopath);
|
||||
void ventoy_plugin_dump_auto_install(void);
|
||||
int ventoy_fill_windows_rtdata(void *buf, char *isopath);
|
||||
|
||||
|
||||
#endif /* __VENTOY_DEF_H__ */
|
||||
|
||||
|
@@ -588,7 +588,7 @@ static void ventoy_cpio_newc_fill_int(grub_uint32_t value, char *buf, int buflen
|
||||
}
|
||||
}
|
||||
|
||||
int ventoy_cpio_newc_fill_head(void *buf, int filesize, void *filedata, const char *name)
|
||||
int ventoy_cpio_newc_fill_head(void *buf, int filesize, const void *filedata, const char *name)
|
||||
{
|
||||
int namelen = 0;
|
||||
int headlen = 0;
|
||||
@@ -852,18 +852,22 @@ grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc,
|
||||
|
||||
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_uint8_t *buf;
|
||||
char *template_file = NULL;
|
||||
char *template_buf = NULL;
|
||||
grub_uint8_t *buf = NULL;
|
||||
grub_uint32_t mod;
|
||||
grub_uint32_t headlen;
|
||||
grub_uint32_t initrd_head_len;
|
||||
grub_uint32_t padlen;
|
||||
grub_uint32_t img_chunk_size;
|
||||
grub_uint32_t template_size = 0;
|
||||
grub_file_t file;
|
||||
grub_file_t scriptfile;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
|
||||
if (argc != 1)
|
||||
if (argc != 3)
|
||||
{
|
||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s cpiofile\n", cmd_raw_name);
|
||||
}
|
||||
@@ -888,7 +892,30 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
|
||||
g_ventoy_cpio_size = 0;
|
||||
}
|
||||
|
||||
g_ventoy_cpio_buf = grub_malloc(file->size + 4096 + img_chunk_size);
|
||||
template_file = ventoy_plugin_get_install_template(args[1]);
|
||||
if (template_file)
|
||||
{
|
||||
debug("auto install template: <%s>\n", template_file);
|
||||
scriptfile = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", args[2], template_file);
|
||||
if (scriptfile)
|
||||
{
|
||||
debug("auto install script size %d\n", (int)scriptfile->size);
|
||||
template_size = scriptfile->size;
|
||||
template_buf = grub_malloc(template_size);
|
||||
if (template_buf)
|
||||
{
|
||||
grub_file_read(scriptfile, template_buf, template_size);
|
||||
}
|
||||
|
||||
grub_file_close(scriptfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("Failed to open install script %s%s\n", args[2], template_file);
|
||||
}
|
||||
}
|
||||
|
||||
g_ventoy_cpio_buf = grub_malloc(file->size + 4096 + template_size + img_chunk_size);
|
||||
if (NULL == g_ventoy_cpio_buf)
|
||||
{
|
||||
grub_file_close(file);
|
||||
@@ -910,6 +937,12 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
|
||||
headlen = ventoy_cpio_newc_fill_head(buf, img_chunk_size, g_img_chunk_list.chunk, "ventoy/ventoy_image_map");
|
||||
buf += headlen + ventoy_align(img_chunk_size, 4);
|
||||
|
||||
if (template_buf)
|
||||
{
|
||||
headlen = ventoy_cpio_newc_fill_head(buf, template_size, template_buf, "ventoy/autoinstall");
|
||||
buf += headlen + ventoy_align(template_size, 4);
|
||||
}
|
||||
|
||||
/* step2: insert os param to cpio */
|
||||
headlen = ventoy_cpio_newc_fill_head(buf, 0, NULL, "ventoy/ventoy_os_param");
|
||||
padlen = sizeof(ventoy_os_param);
|
||||
|
@@ -38,6 +38,8 @@
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static install_template *g_install_template_head = NULL;
|
||||
|
||||
static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
const char *value;
|
||||
@@ -46,7 +48,15 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "file");
|
||||
if (value)
|
||||
{
|
||||
grub_snprintf(filepath, sizeof(filepath), "%s/ventoy/%s", isodisk, value);
|
||||
if (value[0] == '/')
|
||||
{
|
||||
grub_snprintf(filepath, sizeof(filepath), "%s%s", isodisk, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_snprintf(filepath, sizeof(filepath), "%s/ventoy/%s", isodisk, value);
|
||||
}
|
||||
|
||||
if (ventoy_is_file_exist(filepath) == 0)
|
||||
{
|
||||
debug("Theme file %s does not exist\n", filepath);
|
||||
@@ -67,9 +77,67 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
const char *iso = NULL;
|
||||
const char *script = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
install_template *node = NULL;
|
||||
install_template *next = NULL;
|
||||
|
||||
(void)isodisk;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_ARRAY)
|
||||
{
|
||||
debug("Not array %d\n", json->enDataType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_install_template_head)
|
||||
{
|
||||
for (node = g_install_template_head; node; node = next)
|
||||
{
|
||||
next = node->next;
|
||||
grub_free(node);
|
||||
}
|
||||
|
||||
g_install_template_head = NULL;
|
||||
}
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (iso && iso[0] == '/')
|
||||
{
|
||||
script = vtoy_json_get_string_ex(pNode->pstChild, "template");
|
||||
if (script && script[0] == '/')
|
||||
{
|
||||
node = grub_zalloc(sizeof(install_template));
|
||||
if (node)
|
||||
{
|
||||
grub_snprintf(node->isopath, sizeof(node->isopath), "%s", iso);
|
||||
grub_snprintf(node->templatepath, sizeof(node->templatepath), "%s", script);
|
||||
|
||||
if (g_install_template_head)
|
||||
{
|
||||
node->next = g_install_template_head;
|
||||
}
|
||||
|
||||
g_install_template_head = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static plugin_entry g_plugin_entries[] =
|
||||
{
|
||||
{ "theme", ventoy_plugin_theme_entry },
|
||||
{ "auto_install", ventoy_plugin_auto_install_entry },
|
||||
};
|
||||
|
||||
static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
|
||||
@@ -149,3 +217,33 @@ grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **a
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
|
||||
void ventoy_plugin_dump_auto_install(void)
|
||||
{
|
||||
install_template *node = NULL;
|
||||
|
||||
for (node = g_install_template_head; node; node = node->next)
|
||||
{
|
||||
grub_printf("IMAGE:<%s>\n", node->isopath);
|
||||
grub_printf("SCRIPT:<%s>\n\n", node->templatepath);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
char * ventoy_plugin_get_install_template(const char *isopath)
|
||||
{
|
||||
install_template *node = NULL;
|
||||
|
||||
for (node = g_install_template_head; node; node = node->next)
|
||||
{
|
||||
if (grub_strcmp(node->isopath, isopath) == 0)
|
||||
{
|
||||
return node->templatepath;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -401,7 +401,7 @@ static int ventoy_update_all_hash(void *meta_data, wim_directory_entry *dir)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dir->len == 0)
|
||||
if (dir->len < sizeof(wim_directory_entry))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -420,7 +420,7 @@ static int ventoy_update_all_hash(void *meta_data, wim_directory_entry *dir)
|
||||
}
|
||||
|
||||
dir = (wim_directory_entry *)((char *)dir + dir->len);
|
||||
} while (dir->len);
|
||||
} while (dir->len >= sizeof(wim_directory_entry));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -440,14 +440,14 @@ static int ventoy_cat_exe_file_data(grub_uint32_t exe_len, grub_uint8_t *exe_dat
|
||||
jump_align = ventoy_align(jump_len, 16);
|
||||
|
||||
g_wim_data.jump_exe_len = jump_len;
|
||||
g_wim_data.bin_raw_len = jump_align + sizeof(ventoy_os_param) + exe_len;
|
||||
g_wim_data.bin_raw_len = jump_align + sizeof(ventoy_os_param) + sizeof(ventoy_windows_data) + exe_len;
|
||||
g_wim_data.bin_align_len = ventoy_align(g_wim_data.bin_raw_len, 2048);
|
||||
|
||||
g_wim_data.jump_bin_data = grub_malloc(g_wim_data.bin_align_len);
|
||||
if (g_wim_data.jump_bin_data)
|
||||
{
|
||||
grub_memcpy(g_wim_data.jump_bin_data, jump_data, jump_len);
|
||||
grub_memcpy(g_wim_data.jump_bin_data + jump_align + sizeof(ventoy_os_param), exe_data, exe_len);
|
||||
grub_memcpy(g_wim_data.jump_bin_data + jump_align + sizeof(ventoy_os_param) + sizeof(ventoy_windows_data), exe_data, exe_len);
|
||||
}
|
||||
|
||||
debug("jump_exe_len:%u bin_raw_len:%u bin_align_len:%u\n",
|
||||
@@ -456,7 +456,35 @@ static int ventoy_cat_exe_file_data(grub_uint32_t exe_len, grub_uint8_t *exe_dat
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_update_before_chain(ventoy_os_param *param)
|
||||
int ventoy_fill_windows_rtdata(void *buf, char *isopath)
|
||||
{
|
||||
char *pos = NULL;
|
||||
char *script = NULL;
|
||||
ventoy_windows_data *data = (ventoy_windows_data *)buf;
|
||||
|
||||
grub_memset(data, 0, sizeof(ventoy_windows_data));
|
||||
|
||||
pos = grub_strstr(isopath, "/");
|
||||
if (!pos)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
script = ventoy_plugin_get_install_template(pos);
|
||||
if (script)
|
||||
{
|
||||
debug("auto install script <%s>\n", script);
|
||||
grub_snprintf(data->auto_install_script, sizeof(data->auto_install_script) - 1, "%s", script);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("auto install script not found %p\n", pos);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_update_before_chain(ventoy_os_param *param, char *isopath)
|
||||
{
|
||||
grub_uint32_t jump_align = 0;
|
||||
wim_lookup_entry *meta_look = NULL;
|
||||
@@ -469,6 +497,7 @@ static int ventoy_update_before_chain(ventoy_os_param *param)
|
||||
if (g_wim_data.jump_bin_data)
|
||||
{
|
||||
grub_memcpy(g_wim_data.jump_bin_data + jump_align, param, sizeof(ventoy_os_param));
|
||||
ventoy_fill_windows_rtdata(g_wim_data.jump_bin_data + jump_align + sizeof(ventoy_os_param), isopath);
|
||||
}
|
||||
|
||||
grub_crypto_hash(GRUB_MD_SHA1, g_wim_data.bin_hash.sha1, g_wim_data.jump_bin_data, g_wim_data.bin_raw_len);
|
||||
@@ -878,7 +907,7 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c
|
||||
|
||||
if (g_wim_data.jump_bin_data && g_wim_data.new_meta_data)
|
||||
{
|
||||
ventoy_update_before_chain(&(chain->os_param));
|
||||
ventoy_update_before_chain(&(chain->os_param), args[0]);
|
||||
}
|
||||
|
||||
/* part 2: chain head */
|
||||
@@ -928,4 +957,3 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
|
||||
|
265
GRUB2/grub-2.04/include/grub/disk.h
Normal file
265
GRUB2/grub-2.04/include/grub/disk.h
Normal file
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_DISK_HEADER
|
||||
#define GRUB_DISK_HEADER 1
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/device.h>
|
||||
/* For NULL. */
|
||||
#include <grub/mm.h>
|
||||
|
||||
/* These are used to set a device id. When you add a new disk device,
|
||||
you must define a new id for it here. */
|
||||
enum grub_disk_dev_id
|
||||
{
|
||||
GRUB_DISK_DEVICE_BIOSDISK_ID,
|
||||
GRUB_DISK_DEVICE_OFDISK_ID,
|
||||
GRUB_DISK_DEVICE_LOOPBACK_ID,
|
||||
GRUB_DISK_DEVICE_EFIDISK_ID,
|
||||
GRUB_DISK_DEVICE_DISKFILTER_ID,
|
||||
GRUB_DISK_DEVICE_HOST_ID,
|
||||
GRUB_DISK_DEVICE_ATA_ID,
|
||||
GRUB_DISK_DEVICE_MEMDISK_ID,
|
||||
GRUB_DISK_DEVICE_NAND_ID,
|
||||
GRUB_DISK_DEVICE_SCSI_ID,
|
||||
GRUB_DISK_DEVICE_CRYPTODISK_ID,
|
||||
GRUB_DISK_DEVICE_ARCDISK_ID,
|
||||
GRUB_DISK_DEVICE_HOSTDISK_ID,
|
||||
GRUB_DISK_DEVICE_PROCFS_ID,
|
||||
GRUB_DISK_DEVICE_CBFSDISK_ID,
|
||||
GRUB_DISK_DEVICE_UBOOTDISK_ID,
|
||||
GRUB_DISK_DEVICE_XEN,
|
||||
GRUB_DISK_DEVICE_OBDISK_ID,
|
||||
};
|
||||
|
||||
struct grub_disk;
|
||||
#ifdef GRUB_UTIL
|
||||
struct grub_disk_memberlist;
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GRUB_DISK_PULL_NONE,
|
||||
GRUB_DISK_PULL_REMOVABLE,
|
||||
GRUB_DISK_PULL_RESCAN,
|
||||
GRUB_DISK_PULL_MAX
|
||||
} grub_disk_pull_t;
|
||||
|
||||
typedef int (*grub_disk_dev_iterate_hook_t) (const char *name, void *data);
|
||||
|
||||
/* Disk device. */
|
||||
struct grub_disk_dev
|
||||
{
|
||||
/* The device name. */
|
||||
const char *name;
|
||||
|
||||
/* The device id used by the cache manager. */
|
||||
enum grub_disk_dev_id id;
|
||||
|
||||
/* Call HOOK with each device name, until HOOK returns non-zero. */
|
||||
int (*disk_iterate) (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
||||
grub_disk_pull_t pull);
|
||||
|
||||
/* Open the device named NAME, and set up DISK. */
|
||||
grub_err_t (*disk_open) (const char *name, struct grub_disk *disk);
|
||||
|
||||
/* Close the disk DISK. */
|
||||
void (*disk_close) (struct grub_disk *disk);
|
||||
|
||||
/* Read SIZE sectors from the sector SECTOR of the disk DISK into BUF. */
|
||||
grub_err_t (*disk_read) (struct grub_disk *disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, char *buf);
|
||||
|
||||
/* Write SIZE sectors from BUF into the sector SECTOR of the disk DISK. */
|
||||
grub_err_t (*disk_write) (struct grub_disk *disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, const char *buf);
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
struct grub_disk_memberlist *(*disk_memberlist) (struct grub_disk *disk);
|
||||
const char * (*disk_raidname) (struct grub_disk *disk);
|
||||
#endif
|
||||
|
||||
/* The next disk device. */
|
||||
struct grub_disk_dev *next;
|
||||
};
|
||||
typedef struct grub_disk_dev *grub_disk_dev_t;
|
||||
|
||||
extern grub_disk_dev_t EXPORT_VAR (grub_disk_dev_list);
|
||||
|
||||
struct grub_partition;
|
||||
|
||||
typedef void (*grub_disk_read_hook_t) (grub_disk_addr_t sector,
|
||||
unsigned offset, unsigned length,
|
||||
void *data);
|
||||
|
||||
/* Disk. */
|
||||
struct grub_disk
|
||||
{
|
||||
/* The disk name. */
|
||||
const char *name;
|
||||
|
||||
/* The underlying disk device. */
|
||||
grub_disk_dev_t dev;
|
||||
|
||||
/* The total number of sectors. */
|
||||
grub_uint64_t total_sectors;
|
||||
|
||||
/* Logarithm of sector size. */
|
||||
unsigned int log_sector_size;
|
||||
|
||||
/* Maximum number of sectors read divided by GRUB_DISK_CACHE_SIZE. */
|
||||
unsigned int max_agglomerate;
|
||||
|
||||
/* The id used by the disk cache manager. */
|
||||
unsigned long id;
|
||||
|
||||
/* The partition information. This is machine-specific. */
|
||||
struct grub_partition *partition;
|
||||
|
||||
/* Called when a sector was read. OFFSET is between 0 and
|
||||
the sector size minus 1, and LENGTH is between 0 and the sector size. */
|
||||
grub_disk_read_hook_t read_hook;
|
||||
|
||||
/* Caller-specific data passed to the read hook. */
|
||||
void *read_hook_data;
|
||||
|
||||
/* Device-specific data. */
|
||||
void *data;
|
||||
};
|
||||
typedef struct grub_disk *grub_disk_t;
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
struct grub_disk_memberlist
|
||||
{
|
||||
grub_disk_t disk;
|
||||
struct grub_disk_memberlist *next;
|
||||
};
|
||||
typedef struct grub_disk_memberlist *grub_disk_memberlist_t;
|
||||
#endif
|
||||
|
||||
/* The sector size. */
|
||||
#define GRUB_DISK_SECTOR_SIZE 0x200
|
||||
#define GRUB_DISK_SECTOR_BITS 9
|
||||
|
||||
/* The maximum number of disk caches. */
|
||||
#define GRUB_DISK_CACHE_NUM 1021
|
||||
|
||||
/* The size of a disk cache in 512B units. Must be at least as big as the
|
||||
largest supported sector size, currently 16K. */
|
||||
#define GRUB_DISK_CACHE_BITS 6
|
||||
#define GRUB_DISK_CACHE_SIZE (1 << GRUB_DISK_CACHE_BITS)
|
||||
|
||||
#define GRUB_DISK_MAX_MAX_AGGLOMERATE ((1 << (30 - GRUB_DISK_CACHE_BITS - GRUB_DISK_SECTOR_BITS)) - 1)
|
||||
|
||||
/* Return value of grub_disk_get_size() in case disk size is unknown. */
|
||||
#define GRUB_DISK_SIZE_UNKNOWN 0xffffffffffffffffULL
|
||||
|
||||
/* This is called from the memory manager. */
|
||||
void grub_disk_cache_invalidate_all (void);
|
||||
|
||||
void EXPORT_FUNC(grub_disk_dev_register) (grub_disk_dev_t dev);
|
||||
void EXPORT_FUNC(grub_disk_dev_unregister) (grub_disk_dev_t dev);
|
||||
static inline int
|
||||
grub_disk_dev_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data)
|
||||
{
|
||||
grub_disk_dev_t p;
|
||||
grub_disk_pull_t pull;
|
||||
|
||||
for (pull = 0; pull < GRUB_DISK_PULL_MAX; pull++)
|
||||
for (p = grub_disk_dev_list; p; p = p->next)
|
||||
if (p->disk_iterate && (p->disk_iterate) (hook, hook_data, pull))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_disk_t EXPORT_FUNC(grub_disk_open) (const char *name);
|
||||
void EXPORT_FUNC(grub_disk_close) (grub_disk_t disk);
|
||||
grub_err_t EXPORT_FUNC(grub_disk_blocklist_read)(void *chunklist, grub_uint64_t sector,
|
||||
grub_uint64_t size, grub_uint32_t log_sector_size);
|
||||
|
||||
grub_err_t EXPORT_FUNC(grub_disk_read) (grub_disk_t disk,
|
||||
grub_disk_addr_t sector,
|
||||
grub_off_t offset,
|
||||
grub_size_t size,
|
||||
void *buf);
|
||||
grub_err_t grub_disk_write (grub_disk_t disk,
|
||||
grub_disk_addr_t sector,
|
||||
grub_off_t offset,
|
||||
grub_size_t size,
|
||||
const void *buf);
|
||||
extern grub_err_t (*EXPORT_VAR(grub_disk_write_weak)) (grub_disk_t disk,
|
||||
grub_disk_addr_t sector,
|
||||
grub_off_t offset,
|
||||
grub_size_t size,
|
||||
const void *buf);
|
||||
|
||||
|
||||
grub_uint64_t EXPORT_FUNC(grub_disk_get_size) (grub_disk_t disk);
|
||||
|
||||
#if DISK_CACHE_STATS
|
||||
void
|
||||
EXPORT_FUNC(grub_disk_cache_get_performance) (unsigned long *hits, unsigned long *misses);
|
||||
#endif
|
||||
|
||||
extern void (* EXPORT_VAR(grub_disk_firmware_fini)) (void);
|
||||
extern int EXPORT_VAR(grub_disk_firmware_is_tainted);
|
||||
|
||||
static inline void
|
||||
grub_stop_disk_firmware (void)
|
||||
{
|
||||
/* To prevent two drivers operating on the same disks. */
|
||||
grub_disk_firmware_is_tainted = 1;
|
||||
if (grub_disk_firmware_fini)
|
||||
{
|
||||
grub_disk_firmware_fini ();
|
||||
grub_disk_firmware_fini = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Disk cache. */
|
||||
struct grub_disk_cache
|
||||
{
|
||||
enum grub_disk_dev_id dev_id;
|
||||
unsigned long disk_id;
|
||||
grub_disk_addr_t sector;
|
||||
char *data;
|
||||
int lock;
|
||||
};
|
||||
|
||||
extern struct grub_disk_cache EXPORT_VAR(grub_disk_cache_table)[GRUB_DISK_CACHE_NUM];
|
||||
|
||||
#if defined (GRUB_UTIL)
|
||||
void grub_lvm_init (void);
|
||||
void grub_ldm_init (void);
|
||||
void grub_mdraid09_init (void);
|
||||
void grub_mdraid1x_init (void);
|
||||
void grub_diskfilter_init (void);
|
||||
void grub_lvm_fini (void);
|
||||
void grub_ldm_fini (void);
|
||||
void grub_mdraid09_fini (void);
|
||||
void grub_mdraid1x_fini (void);
|
||||
void grub_diskfilter_fini (void);
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_DISK_HEADER */
|
132
GRUB2/grub-2.04/include/grub/fs.h
Normal file
132
GRUB2/grub-2.04/include/grub/fs.h
Normal file
@@ -0,0 +1,132 @@
|
||||
/* fs.h - filesystem manager */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2004,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_FS_HEADER
|
||||
#define GRUB_FS_HEADER 1
|
||||
|
||||
#include <grub/device.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
#include <grub/list.h>
|
||||
/* For embedding types. */
|
||||
#ifdef GRUB_UTIL
|
||||
#include <grub/partition.h>
|
||||
#endif
|
||||
|
||||
/* Forward declaration is required, because of mutual reference. */
|
||||
struct grub_file;
|
||||
|
||||
struct grub_dirhook_info
|
||||
{
|
||||
unsigned dir:1;
|
||||
unsigned mtimeset:1;
|
||||
unsigned case_insensitive:1;
|
||||
unsigned inodeset:1;
|
||||
grub_int32_t mtime;
|
||||
grub_uint64_t inode;
|
||||
grub_uint64_t size;
|
||||
};
|
||||
|
||||
typedef int (*grub_fs_dir_hook_t) (const char *filename,
|
||||
const struct grub_dirhook_info *info,
|
||||
void *data);
|
||||
|
||||
/* Filesystem descriptor. */
|
||||
struct grub_fs
|
||||
{
|
||||
/* The next filesystem. */
|
||||
struct grub_fs *next;
|
||||
struct grub_fs **prev;
|
||||
|
||||
/* My name. */
|
||||
const char *name;
|
||||
|
||||
/* Call HOOK with each file under DIR. */
|
||||
grub_err_t (*fs_dir) (grub_device_t device, const char *path,
|
||||
grub_fs_dir_hook_t hook, void *hook_data);
|
||||
|
||||
/* Open a file named NAME and initialize FILE. */
|
||||
grub_err_t (*fs_open) (struct grub_file *file, const char *name);
|
||||
|
||||
/* Read LEN bytes data from FILE into BUF. */
|
||||
grub_ssize_t (*fs_read) (struct grub_file *file, char *buf, grub_size_t len);
|
||||
|
||||
/* Close the file FILE. */
|
||||
grub_err_t (*fs_close) (struct grub_file *file);
|
||||
|
||||
/* Return the label of the device DEVICE in LABEL. The label is
|
||||
returned in a grub_malloc'ed buffer and should be freed by the
|
||||
caller. */
|
||||
grub_err_t (*fs_label) (grub_device_t device, char **label);
|
||||
|
||||
/* Return the uuid of the device DEVICE in UUID. The uuid is
|
||||
returned in a grub_malloc'ed buffer and should be freed by the
|
||||
caller. */
|
||||
grub_err_t (*fs_uuid) (grub_device_t device, char **uuid);
|
||||
|
||||
/* Get writing time of filesystem. */
|
||||
grub_err_t (*fs_mtime) (grub_device_t device, grub_int32_t *timebuf);
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
/* Determine sectors available for embedding. */
|
||||
grub_err_t (*fs_embed) (grub_device_t device, unsigned int *nsectors,
|
||||
unsigned int max_nsectors,
|
||||
grub_embed_type_t embed_type,
|
||||
grub_disk_addr_t **sectors);
|
||||
|
||||
/* Whether this filesystem reserves first sector for DOS-style boot. */
|
||||
int reserved_first_sector;
|
||||
|
||||
/* Whether blocklist installs have a chance to work. */
|
||||
int blocklist_install;
|
||||
#endif
|
||||
};
|
||||
typedef struct grub_fs *grub_fs_t;
|
||||
|
||||
/* This is special, because block lists are not files in usual sense. */
|
||||
extern struct grub_fs grub_fs_blocklist;
|
||||
|
||||
/* This hook is used to automatically load filesystem modules.
|
||||
If this hook loads a module, return non-zero. Otherwise return zero.
|
||||
The newly loaded filesystem is assumed to be inserted into the head of
|
||||
the linked list GRUB_FS_LIST through the function grub_fs_register. */
|
||||
typedef int (*grub_fs_autoload_hook_t) (void);
|
||||
extern grub_fs_autoload_hook_t EXPORT_VAR(grub_fs_autoload_hook);
|
||||
extern grub_fs_t EXPORT_VAR (grub_fs_list);
|
||||
|
||||
#ifndef GRUB_LST_GENERATOR
|
||||
static inline void
|
||||
grub_fs_register (grub_fs_t fs)
|
||||
{
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_fs_list), GRUB_AS_LIST (fs));
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
grub_fs_unregister (grub_fs_t fs)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST (fs));
|
||||
}
|
||||
|
||||
#define FOR_FILESYSTEMS(var) FOR_LIST_ELEMENTS((var), (grub_fs_list))
|
||||
|
||||
grub_fs_t EXPORT_FUNC(grub_fs_probe) (grub_device_t device);
|
||||
|
||||
#endif /* ! GRUB_FS_HEADER */
|
@@ -28,6 +28,17 @@
|
||||
|
||||
#define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
|
||||
|
||||
typedef enum ventoy_fs_type
|
||||
{
|
||||
ventoy_fs_exfat = 0, /* 0: exfat */
|
||||
ventoy_fs_ntfs, /* 1: NTFS */
|
||||
ventoy_fs_ext, /* 2: ext2/ext3/ext4 */
|
||||
ventoy_fs_xfs, /* 3: XFS */
|
||||
ventoy_fs_udf, /* 4: UDF */
|
||||
|
||||
ventoy_fs_max
|
||||
}ventoy_fs_type;
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct ventoy_guid
|
||||
@@ -104,6 +115,15 @@ typedef struct ventoy_os_param
|
||||
grub_uint8_t reserved[31];
|
||||
}ventoy_os_param;
|
||||
|
||||
|
||||
typedef struct ventoy_windows_data
|
||||
{
|
||||
char auto_install_script[384];
|
||||
grub_uint8_t reserved[128];
|
||||
}ventoy_windows_data;
|
||||
|
||||
|
||||
|
||||
#pragma pack()
|
||||
|
||||
// compile assert check : sizeof(ventoy_os_param) must be 512
|
||||
|
48
IMG/cpio/ventoy/hook/arch/ventoy-disk.sh
Normal file
48
IMG/cpio/ventoy/hook/arch/ventoy-disk.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtlog "######### $0 $* ############"
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
|
||||
vtlog "ln -s /dev/$vtDM $1"
|
||||
ln -s /dev/$vtDM "$1"
|
||||
fi
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
||||
|
@@ -19,16 +19,21 @@
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
# some archlinux initramfs doesn't contain device-mapper udev rules file
|
||||
ARCH_UDEV_DIR=$(ventoy_get_udev_conf_dir)
|
||||
if [ -s "$ARCH_UDEV_DIR/13-dm-disk.rules" ]; then
|
||||
echo 'dm-disk rule exist' >> $VTLOG
|
||||
if $GREP -q '^"$mount_handler"' /init; then
|
||||
echo 'use mount_handler ...' >> $VTLOG
|
||||
$SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ventoy-disk.sh \"\$archisodevice\"" -i /init
|
||||
else
|
||||
echo 'Copy dm-disk rule file' >> $VTLOG
|
||||
$CAT $VTOY_PATH/hook/default/13-dm-disk.rules > "$ARCH_UDEV_DIR/13-dm-disk.rules"
|
||||
# some archlinux initramfs doesn't contain device-mapper udev rules file
|
||||
ARCH_UDEV_DIR=$(ventoy_get_udev_conf_dir)
|
||||
if [ -s "$ARCH_UDEV_DIR/13-dm-disk.rules" ]; then
|
||||
echo 'dm-disk rule exist' >> $VTLOG
|
||||
else
|
||||
echo 'Copy dm-disk rule file' >> $VTLOG
|
||||
$CAT $VTOY_PATH/hook/default/13-dm-disk.rules > "$ARCH_UDEV_DIR/13-dm-disk.rules"
|
||||
fi
|
||||
|
||||
# use default proc
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
|
||||
fi
|
||||
|
||||
# use default proc
|
||||
ventoy_systemd_udevd_work_around
|
||||
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
|
||||
|
38
IMG/cpio/ventoy/hook/berry/ventoy-disk.sh
Normal file
38
IMG/cpio/ventoy/hook/berry/ventoy-disk.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
20
IMG/cpio/ventoy/hook/berry/ventoy-hook.sh
Normal file
20
IMG/cpio/ventoy/hook/berry/ventoy-hook.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
$SED "/for .*\$DEVICES/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/berry/ventoy-disk.sh" -i /init
|
@@ -23,6 +23,12 @@ if [ -e /init ] && $GREP -q '^mountroot$' /init; then
|
||||
$SED "/^mountroot$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/disk_mount_hook.sh" -i /init
|
||||
$SED "/^mountroot$/i\\export LIVEMEDIA=/dev/mapper/ventoy" -i /init
|
||||
$SED "/^mountroot$/i\\export LIVE_MEDIA=/dev/mapper/ventoy" -i /init
|
||||
|
||||
if $GREP -q 'live-media=' /proc/cmdline; then
|
||||
if [ -f /scripts/casper ] && $GREP -q '^ *LIVEMEDIA=' /scripts/casper; then
|
||||
$SED "s#^ *LIVEMEDIA=.*#LIVEMEDIA=/dev/mapper/ventoy#" -i /scripts/casper
|
||||
fi
|
||||
fi
|
||||
|
||||
elif [ -e /init ] && $GREP -q '/start-udev$' /init; then
|
||||
echo "Here use notify ..." >> $VTLOG
|
||||
@@ -35,3 +41,15 @@ else
|
||||
ventoy_systemd_udevd_work_around
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/debian/udev_disk_hook.sh %k"
|
||||
fi
|
||||
|
||||
if [ -f $VTOY_PATH/autoinstall ]; then
|
||||
echo "Do auto install ..." >> $VTLOG
|
||||
|
||||
if $GREP -q "^mount /proc$" /init; then
|
||||
$SED "/^mount \/proc/a export file=$VTOY_PATH/autoinstall; export auto='true'; export priority='critical'" -i /init
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
26
IMG/cpio/ventoy/hook/gobo/ventoy-hook.sh
Normal file
26
IMG/cpio/ventoy/hook/gobo/ventoy-hook.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/mapper/ventoy#" -i /lib/dracut-lib.sh
|
||||
|
||||
ventoy_set_inotify_script gobo/ventoy-inotifyd-hook.sh
|
||||
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/gobo/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/01-ventoy-inotifyd-start.sh
|
47
IMG/cpio/ventoy/hook/gobo/ventoy-inotifyd-hook.sh
Normal file
47
IMG/cpio/ventoy/hook/gobo/ventoy-inotifyd-hook.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vtlog "##### INOTIFYD: $2/$3 is created ..."
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
if is_inotify_ventoy_part $3; then
|
||||
vtlog "find ventoy partition $3 ..."
|
||||
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 noreplace
|
||||
|
||||
# blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
# vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
#
|
||||
# if [ "$vtDM" = "dm-0" ]; then
|
||||
# vtlog "This is dm-0, OK ..."
|
||||
# else
|
||||
# vtlog "####### This is $vtDM ####### this is abnormal ..."
|
||||
# ventoy_swap_device /dev/dm-0 /dev/$vtDM
|
||||
# fi
|
||||
|
||||
set_ventoy_hook_finish
|
||||
fi
|
||||
|
||||
PATH=$VTPATH_OLD
|
31
IMG/cpio/ventoy/hook/gobo/ventoy-inotifyd-start.sh
Normal file
31
IMG/cpio/ventoy/hook/gobo/ventoy-inotifyd-start.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtHook=$($CAT $VTOY_PATH/inotifyd-hook-script.txt)
|
||||
|
||||
vtdisk=$(get_ventoy_disk_name)
|
||||
if [ "$vtdisk" = "unknown" ]; then
|
||||
vtlog "... start inotifyd listen $vtHook ..."
|
||||
$BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $vtHook /dev:n 2>&- &
|
||||
else
|
||||
vtlog "... $vtdisk already exist ..."
|
||||
$BUSYBOX_PATH/sh $vtHook n /dev "${vtdisk#/dev/}2"
|
||||
fi
|
42
IMG/cpio/ventoy/hook/guix/ventoy-disk.sh
Normal file
42
IMG/cpio/ventoy/hook/guix/ventoy-disk.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vtlog "##### INOTIFYD: $2/$3 is created ..."
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
if is_inotify_ventoy_part $3; then
|
||||
vtlog "find ventoy partition ..."
|
||||
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3
|
||||
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
|
||||
vtlog "This is $vtDM ..."
|
||||
|
||||
set_ventoy_hook_finish
|
||||
fi
|
||||
|
||||
PATH=$VTPATH_OLD
|
25
IMG/cpio/ventoy/hook/guix/ventoy-hook.sh
Normal file
25
IMG/cpio/ventoy/hook/guix/ventoy-hook.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$BUSYBOX_PATH/mkdir /dev
|
||||
$BUSYBOX_PATH/mknode -m 0666 /dev/null c 1 3
|
||||
|
||||
$BUSYBOX_PATH/nohup $VTOY_PATH/hook/guix/ventoy-waitdev.sh &
|
37
IMG/cpio/ventoy/hook/guix/ventoy-waitdev.sh
Normal file
37
IMG/cpio/ventoy/hook/guix/ventoy-waitdev.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
while ! [ -e /dev/null ]; do
|
||||
echo 'xxxxxxxxxx'
|
||||
echo 'xxxxxxxxxx' > /dev/console
|
||||
sleep 1
|
||||
done
|
||||
|
||||
vtlog "... start inotifyd listen $vtHook ..."
|
||||
$BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $VTOY_PATH/hook/guix/ventoy-disk.sh /dev:n 2>&- &
|
||||
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
50
IMG/cpio/ventoy/hook/nutyx/ventoy-disk.sh
Normal file
50
IMG/cpio/ventoy/hook/nutyx/ventoy-disk.sh
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||
|
||||
blkdev_num=$(dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
|
||||
vtlog "link /dev/$vtDM $VTOY_DM_PATH"
|
||||
ln -s /dev/$vtDM $VTOY_DM_PATH
|
||||
|
||||
set_ventoy_hook_finish
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
22
IMG/cpio/ventoy/hook/nutyx/ventoy-hook.sh
Normal file
22
IMG/cpio/ventoy/hook/nutyx/ventoy-hook.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
$SED "/find_media$/i $BUSYBOX_PATH/sh $VTOY_PATH/hook/nutyx/ventoy-disk.sh" -i /init
|
@@ -22,10 +22,30 @@
|
||||
#ventoy_systemd_udevd_work_around
|
||||
#ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
|
||||
|
||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0#" -i /lib/dracut-lib.sh
|
||||
if [ -f $VTOY_PATH/autoinstall ]; then
|
||||
VTKS="inst.ks=file:$VTOY_PATH/autoinstall"
|
||||
else
|
||||
for vtParam in $($CAT /proc/cmdline); do
|
||||
if echo $vtParam | $GREP -q 'inst.ks=hd:LABEL='; then
|
||||
vtRawKs=$(echo $vtParam | $AWK -F: '{print $NF}')
|
||||
VTKS="inst.ks=hd:/dev/dm-0:$vtRawKs"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "VTKS=$VTKS" >> $VTLOG
|
||||
|
||||
if $GREP -q 'root=live' /proc/cmdline; then
|
||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/dm-0 $VTKS#" -i /lib/dracut-lib.sh
|
||||
else
|
||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0 $VTKS#" -i /lib/dracut-lib.sh
|
||||
fi
|
||||
|
||||
ventoy_set_inotify_script rhel7/ventoy-inotifyd-hook.sh
|
||||
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/default/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/01-ventoy-inotifyd-start.sh
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/01-ventoy-inotifyd-start.sh
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-timeout.sh /lib/dracut/hooks/initqueue/timeout/01-ventoy-timeout.sh
|
||||
|
||||
# suppress write protected mount warning
|
||||
if [ -e /usr/sbin/anaconda-diskroot ]; then
|
||||
|
@@ -41,6 +41,9 @@ if is_inotify_ventoy_part $3; then
|
||||
ventoy_swap_device /dev/dm-0 /dev/$vtDM
|
||||
fi
|
||||
|
||||
vtlog "set anaconda-diskroot ..."
|
||||
/sbin/initqueue --settled --onetime --name anaconda-diskroot anaconda-diskroot /dev/dm-0
|
||||
|
||||
set_ventoy_hook_finish
|
||||
fi
|
||||
|
||||
|
31
IMG/cpio/ventoy/hook/rhel7/ventoy-inotifyd-start.sh
Normal file
31
IMG/cpio/ventoy/hook/rhel7/ventoy-inotifyd-start.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtHook=$($CAT $VTOY_PATH/inotifyd-hook-script.txt)
|
||||
|
||||
vtdisk=$(get_ventoy_disk_name)
|
||||
if [ "$vtdisk" = "unknown" ]; then
|
||||
vtlog "... start inotifyd listen $vtHook ..."
|
||||
$BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $vtHook /dev:n 2>&- &
|
||||
else
|
||||
vtlog "... $vtdisk already exist ..."
|
||||
$BUSYBOX_PATH/sh $vtHook n /dev "${vtdisk#/dev/}2"
|
||||
fi
|
32
IMG/cpio/ventoy/hook/rhel7/ventoy-timeout.sh
Normal file
32
IMG/cpio/ventoy/hook/rhel7/ventoy-timeout.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtlog "##### $0 $* ..."
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
blkdev_num=$(dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
|
||||
vtlog "diskroot $vtDM ..."
|
||||
/sbin/initqueue --settled --onetime --name anaconda-diskroot anaconda-diskroot /dev/$vtDM
|
||||
|
||||
PATH=$VTPATH_OLD
|
@@ -19,6 +19,17 @@
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
if [ -f $VTOY_PATH/autoinstall ]; then
|
||||
if [ -f /linuxrc.config ]; then
|
||||
echo "AutoYaST: file:///ventoy/autoinstall" >> /info-ventoy
|
||||
$SED "1 iinfo: file:/info-ventoy" -i /linuxrc.config
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#echo "Exec: /bin/sh $VTOY_PATH/hook/suse/cdrom-hook.sh" >> /info-ventoy
|
||||
#echo "install: hd:/?device=/dev/mapper/ventoy" >> /info-ventoy
|
||||
#$SED "1 iinfo: file:/info-ventoy" -i /linuxrc.config
|
||||
|
||||
ventoy_systemd_udevd_work_around
|
||||
ventoy_add_udev_rule "$VTOY_PATH/hook/suse/udev_disk_hook.sh %k"
|
||||
|
@@ -165,6 +165,25 @@ ventoy_get_os_type() {
|
||||
echo 'arch'; return
|
||||
fi
|
||||
|
||||
if $GREP -q 'berry ' /proc/version; then
|
||||
echo 'berry'; return
|
||||
fi
|
||||
|
||||
if $GREP -q 'Gobo ' /proc/version; then
|
||||
echo 'gobo'; return
|
||||
fi
|
||||
|
||||
if $GREP -q 'NuTyX' /proc/version; then
|
||||
echo 'nutyx'; return
|
||||
fi
|
||||
|
||||
if [ -d /gnu ]; then
|
||||
vtLineNum=$($FIND /gnu/ -name guix | $BUSYBOX_PATH/wc -l)
|
||||
if [ $vtLineNum -gt 0 ]; then
|
||||
echo 'guix'; return
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "default"
|
||||
}
|
||||
|
||||
|
5
INSTALL/DO_NOT_RUN_Ventoy2Disk_HERE.txt
Normal file
5
INSTALL/DO_NOT_RUN_Ventoy2Disk_HERE.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
For Ventoy2Disk.exe (Windows) or Ventoy2Disk.sh (Linux).
|
||||
|
||||
You should download the install package, decompress it, and run the exe/sh there.
|
||||
They should NOT be run in the source tree(INSTALL directory).
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -9,12 +9,16 @@ fi
|
||||
. ./tool/ventoy_lib.sh
|
||||
|
||||
print_usage() {
|
||||
echo 'Usage: VentoyInstaller.sh OPTION /dev/sdX'
|
||||
echo ' OPTION:'
|
||||
echo 'Usage: Ventoy2Disk.sh CMD [ OPTION ] /dev/sdX'
|
||||
echo ' CMD:'
|
||||
echo ' -i install ventoy to sdX (fail if disk already installed with ventoy)'
|
||||
echo ' -u update ventoy in sdX'
|
||||
echo ' -I force install ventoy to sdX (no matter installed or not)'
|
||||
echo ''
|
||||
echo ' OPTION: (optional)'
|
||||
echo ' -s enable secure boot support (default is disabled)'
|
||||
echo ''
|
||||
|
||||
}
|
||||
|
||||
echo ''
|
||||
@@ -26,36 +30,67 @@ echo ''
|
||||
|
||||
vtdebug "############# Ventoy2Disk $0 ################"
|
||||
|
||||
if [ "$1" = "-i" ]; then
|
||||
MODE="install"
|
||||
elif [ "$1" = "-I" ]; then
|
||||
MODE="install"
|
||||
FORCE="Y"
|
||||
elif [ "$1" = "-u" ]; then
|
||||
MODE="update"
|
||||
else
|
||||
print_usage
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [ -b "$2" ]; then
|
||||
print_usage
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$SUDO_USER" ]; then
|
||||
if [ "$USER" != "root" ]; then
|
||||
vterr "EUID is $EUID root permission is required."
|
||||
echo ''
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
while [ -n "$1" ]; do
|
||||
if [ "$1" = "-i" ]; then
|
||||
MODE="install"
|
||||
elif [ "$1" = "-I" ]; then
|
||||
MODE="install"
|
||||
FORCE="Y"
|
||||
elif [ "$1" = "-u" ]; then
|
||||
MODE="update"
|
||||
elif [ "$1" = "-s" ]; then
|
||||
SECUREBOOT="YES"
|
||||
else
|
||||
if ! [ -b "$1" ]; then
|
||||
vterr "$1 is NOT a valid device"
|
||||
print_usage
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
fi
|
||||
DISK=$1
|
||||
fi
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$MODE" ]; then
|
||||
print_usage
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [ -b "$DISK" ]; then
|
||||
vterr "Disk $DISK does not exist"
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e /sys/class/block/${DISK#/dev/}/start ]; then
|
||||
vterr "$DISK is a partition, please use the whole disk"
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if dd if="$DISK" of=/dev/null bs=1 count=1 >/dev/null 2>&1; then
|
||||
vtdebug "root permission check ok ..."
|
||||
else
|
||||
vterr "Failed to access $DISK, maybe root privilege is needed!"
|
||||
echo ''
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
fi
|
||||
|
||||
vtdebug "MODE=$MODE FORCE=$FORCE"
|
||||
|
||||
if ! [ -f ./boot/boot.img ]; then
|
||||
if [ -d ./grub ]; then
|
||||
vterr "Don't run me here, please download the released install package, and run there."
|
||||
else
|
||||
vterr "Please run under the right directory!"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#decompress tool
|
||||
cd tool
|
||||
chmod +x ./xzcat
|
||||
@@ -75,24 +110,8 @@ if ! check_tool_work_ok; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
DISK=$2
|
||||
|
||||
if ! [ -b "$DISK" ]; then
|
||||
vterr "Disk $DISK does not exist"
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ -e /sys/class/block/${DISK#/dev/}/start ]; then
|
||||
vterr "$DISK is a partition, please use the whole disk"
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
fi
|
||||
|
||||
grep "^$DISK" /proc/mounts | while read mtline; do
|
||||
mtpnt=$(echo $mtline | awk '{print $2}')
|
||||
mtpnt=$(echo $mtline | awk '{print $DISK}')
|
||||
vtdebug "Trying to umount $mtpnt ..."
|
||||
umount $mtpnt >/dev/null 2>&1
|
||||
done
|
||||
@@ -195,6 +214,7 @@ if [ "$MODE" = "install" ]; then
|
||||
|
||||
chmod +x ./tool/vtoy_gen_uuid
|
||||
|
||||
vtinfo "writing data to disk ..."
|
||||
dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=446
|
||||
./tool/xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1
|
||||
./tool/xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector
|
||||
@@ -205,7 +225,32 @@ if [ "$MODE" = "install" ]; then
|
||||
#disk signature
|
||||
./tool/vtoy_gen_uuid | dd status=none conv=fsync of=${DISK} skip=12 seek=440 bs=1 count=4
|
||||
|
||||
vtinfo "sync data ..."
|
||||
sync
|
||||
|
||||
vtinfo "esp partition processing ..."
|
||||
|
||||
if [ "$SECUREBOOT" != "YES" ]; then
|
||||
mkdir ./tmp_mnt
|
||||
|
||||
vtdebug "mounting part2 ...."
|
||||
for tt in 1 2 3; do
|
||||
if mount ${DISK}2 ./tmp_mnt; then
|
||||
vtdebug "mounting part2 success"
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
rm -f ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
|
||||
rm -f ./tmp_mnt/EFI/BOOT/grubx64.efi
|
||||
rm -f ./tmp_mnt/EFI/BOOT/MokManager.efi
|
||||
rm -f ./tmp_mnt/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
|
||||
mv ./tmp_mnt/EFI/BOOT/grubx64_real.efi ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
|
||||
|
||||
umount ./tmp_mnt
|
||||
rm -rf ./tmp_mnt
|
||||
fi
|
||||
|
||||
echo ""
|
||||
vtinfo "Install Ventoy to $DISK successfully finished."
|
||||
@@ -248,6 +293,28 @@ else
|
||||
./tool/xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start
|
||||
|
||||
sync
|
||||
|
||||
if [ "$SECUREBOOT" != "YES" ]; then
|
||||
mkdir ./tmp_mnt
|
||||
|
||||
vtdebug "mounting part2 ...."
|
||||
for tt in 1 2 3; do
|
||||
if mount ${DISK}2 ./tmp_mnt; then
|
||||
vtdebug "mounting part2 success"
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
rm -f ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
|
||||
rm -f ./tmp_mnt/EFI/BOOT/grubx64.efi
|
||||
rm -f ./tmp_mnt/EFI/BOOT/MokManager.efi
|
||||
rm -f ./tmp_mnt/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
|
||||
mv ./tmp_mnt/EFI/BOOT/grubx64_real.efi ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
|
||||
|
||||
umount ./tmp_mnt
|
||||
rm -rf ./tmp_mnt
|
||||
fi
|
||||
|
||||
echo ""
|
||||
vtinfo "Update Ventoy to $DISK successfully finished."
|
||||
|
@@ -16,33 +16,26 @@
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
function ventoy_boot_from_hdd {
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
if [ "$iso_path" = "(hd0,1)" ]; then
|
||||
if [ -b (hd1) ]; then
|
||||
set root=(hd1)
|
||||
drivemap -s hd0 hd1
|
||||
chainloader +1
|
||||
boot
|
||||
else
|
||||
echo "No local hdd found ..."
|
||||
sleep 3
|
||||
fi
|
||||
else
|
||||
set root=(hd0)
|
||||
chainloader +1
|
||||
boot
|
||||
fi
|
||||
else
|
||||
exit
|
||||
function ventoy_power {
|
||||
echo '<1> Reboot'
|
||||
echo '<2> Halt'
|
||||
echo '<0> Return to menu'
|
||||
echo -e '\nPlease enter your choice:'
|
||||
|
||||
unset vtOpt
|
||||
read vtOpt
|
||||
|
||||
if [ "$vtOpt" = "1" ]; then
|
||||
echo -e '\n\nSystem is rebooting ... \n'
|
||||
sleep 1
|
||||
reboot
|
||||
elif [ "$vtOpt" = "2" ]; then
|
||||
echo -e '\n\nSystem is halting ... \n'
|
||||
sleep 1
|
||||
halt
|
||||
fi
|
||||
}
|
||||
|
||||
function ventoy_reboot {
|
||||
reboot
|
||||
}
|
||||
|
||||
|
||||
function get_os_type {
|
||||
set vtoy_os=Linux
|
||||
for file in "efi/microsoft" "sources/boot.wim" "boot/bcd" "bootmgr.efi" "boot/etfsboot.com"; do
|
||||
@@ -57,6 +50,21 @@ function get_os_type {
|
||||
fi
|
||||
}
|
||||
|
||||
function vt_check_pe {
|
||||
unset VT_PE_SUPPORT
|
||||
|
||||
if [ -f $1/HBCD_PE.ini ]; then
|
||||
set ventoy_compatible=YES
|
||||
set VT_PE_SUPPORT=YES
|
||||
elif [ -f $1/easyu.flg ]; then
|
||||
set VT_PE_SUPPORT=YES
|
||||
elif [ -f $1/USM.ICO ]; then
|
||||
set VT_PE_SUPPORT=YES
|
||||
elif [ -d $1/USM_TOOL ]; then
|
||||
set VT_PE_SUPPORT=YES
|
||||
fi
|
||||
}
|
||||
|
||||
function locate_initrd {
|
||||
vt_linux_locate_initrd
|
||||
|
||||
@@ -69,7 +77,8 @@ function locate_initrd {
|
||||
function find_wim_file {
|
||||
unset ventoy_wim_file
|
||||
|
||||
for file in "sources/boot.wim" "sources/BOOT.WIM" "Sources/Win10PEx64.WIM" "boot/BOOT.WIM" "winpe_x64.wim"; do
|
||||
for file in "sources/boot.wim" "sources/BOOT.WIM" "Sources/Win10PEx64.WIM" "boot/BOOT.WIM" \
|
||||
"winpe_x64.wim" "boot/10pex64.wim" "BOOT/USM1PE6L.WIM" "BOOT/USM1PE6F.WIM"; do
|
||||
if [ -e $1/$file ]; then
|
||||
set ventoy_wim_file=$1/$file
|
||||
break
|
||||
@@ -115,6 +124,15 @@ function distro_specify_initrd_file {
|
||||
function distro_specify_initrd_file_phase2 {
|
||||
if [ -f (loop)/boot/initrd.img ]; then
|
||||
vt_linux_specify_initrd_file /boot/initrd.img
|
||||
elif [ -f (loop)/Setup/initrd.gz ]; then
|
||||
vt_linux_specify_initrd_file /Setup/initrd.gz
|
||||
elif [ -f (loop)/isolinux/initramfs ]; then
|
||||
vt_linux_specify_initrd_file /isolinux/initramfs
|
||||
elif [ -f (loop)/boot/iniramfs.igz ]; then
|
||||
vt_linux_specify_initrd_file /boot/iniramfs.igz
|
||||
elif [ -f (loop)/initrd-x86_64 ]; then
|
||||
vt_linux_specify_initrd_file /initrd-x86_64
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -146,15 +164,15 @@ function uefi_windows_menu_func {
|
||||
|
||||
function uefi_linux_menu_func {
|
||||
if [ "$ventoy_compatible" = "NO" ]; then
|
||||
vt_load_cpio ${vtoy_path}/ventoy.cpio
|
||||
vt_load_cpio ${vtoy_path}/ventoy.cpio $2 $1
|
||||
|
||||
vt_linux_clear_initrd
|
||||
|
||||
if [ -d (loop)/pmagic ]; then
|
||||
vt_linux_specify_initrd_file /pmagic/initrd.img
|
||||
else
|
||||
for file in "boot/grub/grub.cfg" "EFI/BOOT/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "EFI/BOOT/BOOTX64.conf"; do
|
||||
if [ -e (loop)/$file ]; then
|
||||
for file in "boot/grub/grub.cfg" "EFI/BOOT/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "EFI/BOOT/BOOTX64.conf" "/grub/grub.cfg"; do
|
||||
if [ -e (loop)/$file ]; then
|
||||
vt_linux_parse_initrd_grub file (loop)/$file
|
||||
fi
|
||||
done
|
||||
@@ -211,7 +229,7 @@ function uefi_iso_menu_func {
|
||||
if [ -n "$vtisouefi" ]; then
|
||||
set LoadIsoEfiDriver=on
|
||||
unset vtisouefi
|
||||
elif [ -n "$VTOY_ISO_UEFI_DRV" ]; then
|
||||
elif vt_check_mode 2; then
|
||||
set LoadIsoEfiDriver=on
|
||||
else
|
||||
unset LoadIsoEfiDriver
|
||||
@@ -239,7 +257,7 @@ function uefi_iso_menu_func {
|
||||
if [ -n "$vtcompat" ]; then
|
||||
set ventoy_compatible=YES
|
||||
unset vtcompat
|
||||
elif [ -n "$VTOY_ISO_RAW" ]; then
|
||||
elif vt_check_mode 1; then
|
||||
set ventoy_compatible=YES
|
||||
else
|
||||
vt_check_compatible (loop)
|
||||
@@ -248,15 +266,16 @@ function uefi_iso_menu_func {
|
||||
vt_img_sector ${1}${chosen_path}
|
||||
|
||||
if [ "$vtoy_os" = "Windows" ]; then
|
||||
if [ "$ventoy_fs_probe" = "iso9660" ]; then
|
||||
set ventoy_compatible=YES
|
||||
elif [ -f (loop)/HBCD_PE.ini ]; then
|
||||
set ventoy_compatible=YES
|
||||
vt_check_pe (loop)
|
||||
if [ "$VT_PE_SUPPORT" != "YES" ]; then
|
||||
if [ "$ventoy_fs_probe" = "iso9660" ]; then
|
||||
set ventoy_compatible=YES
|
||||
fi
|
||||
fi
|
||||
|
||||
uefi_windows_menu_func $1
|
||||
uefi_windows_menu_func $1 ${chosen_path}
|
||||
else
|
||||
uefi_linux_menu_func $1
|
||||
uefi_linux_menu_func $1 ${chosen_path}
|
||||
fi
|
||||
|
||||
terminal_output gfxterm
|
||||
@@ -274,8 +293,6 @@ function uefi_iso_memdisk {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function legacy_windows_menu_func {
|
||||
vt_windows_reset
|
||||
|
||||
@@ -295,8 +312,7 @@ function legacy_windows_menu_func {
|
||||
fi
|
||||
|
||||
if [ -n "$vtoy_chain_mem_addr" ]; then
|
||||
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft
|
||||
initrd16 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
|
||||
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
|
||||
boot
|
||||
else
|
||||
echo "chain empty failed"
|
||||
@@ -306,8 +322,7 @@ function legacy_windows_menu_func {
|
||||
|
||||
function legacy_linux_menu_func {
|
||||
if [ "$ventoy_compatible" = "NO" ]; then
|
||||
|
||||
vt_load_cpio $vtoy_path/ventoy.cpio
|
||||
vt_load_cpio $vtoy_path/ventoy.cpio $2 $1
|
||||
|
||||
vt_linux_clear_initrd
|
||||
|
||||
@@ -352,9 +367,8 @@ function legacy_linux_menu_func {
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
if [ -n "$vtoy_chain_mem_addr" ]; then
|
||||
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag}
|
||||
initrd16 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
|
||||
if [ -n "$vtoy_chain_mem_addr" ]; then
|
||||
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
|
||||
boot
|
||||
else
|
||||
echo "chain empty failed"
|
||||
@@ -383,7 +397,7 @@ function legacy_iso_menu_func {
|
||||
if [ -n "$vtcompat" ]; then
|
||||
set ventoy_compatible=YES
|
||||
unset vtcompat
|
||||
elif [ -n "$VTOY_ISO_RAW" ]; then
|
||||
elif vt_check_mode 1; then
|
||||
set ventoy_compatible=YES
|
||||
else
|
||||
vt_check_compatible (loop)
|
||||
@@ -392,15 +406,16 @@ function legacy_iso_menu_func {
|
||||
vt_img_sector ${1}${chosen_path}
|
||||
|
||||
if [ "$vtoy_os" = "Windows" ]; then
|
||||
if [ "$ventoy_fs_probe" = "iso9660" ]; then
|
||||
set ventoy_compatible=YES
|
||||
elif [ -f (loop)/HBCD_PE.ini ]; then
|
||||
set ventoy_compatible=YES
|
||||
vt_check_pe (loop)
|
||||
if [ "$VT_PE_SUPPORT" != "YES" ]; then
|
||||
if [ "$ventoy_fs_probe" = "iso9660" ]; then
|
||||
set ventoy_compatible=YES
|
||||
fi
|
||||
fi
|
||||
|
||||
legacy_windows_menu_func $1
|
||||
legacy_windows_menu_func $1 ${chosen_path}
|
||||
else
|
||||
legacy_linux_menu_func $1
|
||||
legacy_linux_menu_func $1 ${chosen_path}
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -413,6 +428,22 @@ function legacy_iso_memdisk {
|
||||
boot
|
||||
}
|
||||
|
||||
function common_menuentry {
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
if vt_check_mode 0; then
|
||||
legacy_iso_memdisk $iso_path
|
||||
else
|
||||
legacy_iso_menu_func $iso_path
|
||||
fi
|
||||
else
|
||||
if vt_check_mode 0; then
|
||||
uefi_iso_memdisk $iso_path
|
||||
else
|
||||
uefi_iso_menu_func $iso_path
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
@@ -422,7 +453,13 @@ function legacy_iso_memdisk {
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
set VENTOY_VERSION="1.0.08b2"
|
||||
set VENTOY_VERSION="1.0.9Y"
|
||||
|
||||
|
||||
# Default menu display mode, you can change it as you want.
|
||||
# 0: List mode
|
||||
# 1: TreeView mode
|
||||
set VTOY_DEFAULT_MENU_MODE=0
|
||||
|
||||
#disable timeout
|
||||
unset timeout
|
||||
@@ -431,8 +468,21 @@ set VTOY_MEM_DISK_STR="MEMDISK"
|
||||
set VTOY_ISO_RAW_STR="ISO RAW"
|
||||
set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
|
||||
|
||||
set VTOY_F2_CMD="ventoy_boot_from_hdd"
|
||||
set VTOY_F3_CMD="ventoy_reboot"
|
||||
set VTOY_F2_CMD="ventoy_power"
|
||||
|
||||
if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
|
||||
set VTOY_F3_CMD="vt_dynamic_menu 1 1"
|
||||
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:TreeView"
|
||||
else
|
||||
set VTOY_F3_CMD="vt_dynamic_menu 1 0"
|
||||
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:ListView"
|
||||
fi
|
||||
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
|
||||
else
|
||||
set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION UEFI www.ventoy.net"
|
||||
fi
|
||||
|
||||
vt_device $root vtoy_dev
|
||||
|
||||
@@ -473,33 +523,16 @@ terminal_output gfxterm
|
||||
set ventoy_img_count=0
|
||||
vt_list_img $iso_path ventoy_img_count
|
||||
|
||||
#Dynamic menu for every iso file
|
||||
if vt_cmp $ventoy_img_count ne 0; then
|
||||
set imgid=0
|
||||
while vt_cmp $imgid lt $ventoy_img_count; do
|
||||
vt_img_name $imgid img_name
|
||||
menuentry "$img_name" {
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
if [ -n "$VTOY_MEM_DISK" ]; then
|
||||
legacy_iso_memdisk $iso_path
|
||||
else
|
||||
legacy_iso_menu_func $iso_path
|
||||
fi
|
||||
else
|
||||
if [ -n "$VTOY_MEM_DISK" ]; then
|
||||
uefi_iso_memdisk $iso_path
|
||||
else
|
||||
uefi_iso_menu_func $iso_path
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
vt_incr imgid 1
|
||||
done
|
||||
#Main menu
|
||||
if [ $ventoy_img_count -gt 0 ]; then
|
||||
if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
|
||||
vt_dynamic_menu 0 0
|
||||
else
|
||||
vt_dynamic_menu 0 1
|
||||
fi
|
||||
else
|
||||
menuentry "No ISO files found (Press enter to reboot ...)" {
|
||||
echo -e "\n Rebooting ... "
|
||||
reboot
|
||||
}
|
||||
fi
|
||||
|
||||
|
Binary file not shown.
@@ -19,7 +19,7 @@ terminal-box: "terminal_box_*.png"
|
||||
item_font = "ascii"
|
||||
item_color = "#ffffff"
|
||||
item_height = 30
|
||||
item_icon_space = 1
|
||||
|
||||
item_spacing = 1
|
||||
item_padding = 1
|
||||
|
||||
@@ -27,8 +27,7 @@ terminal-box: "terminal_box_*.png"
|
||||
selected_item_color= "#f2f2f2"
|
||||
selected_item_pixmap_style = "select_*.png"
|
||||
|
||||
#icon_height = 30
|
||||
#icon_width = 30
|
||||
item_icon_space = 0
|
||||
|
||||
scrollbar = true
|
||||
scrollbar_width = 10
|
||||
@@ -50,11 +49,11 @@ terminal-box: "terminal_box_*.png"
|
||||
}
|
||||
|
||||
+ hbox{
|
||||
left = 40%
|
||||
left = 30%
|
||||
top = 95%
|
||||
width = 10%
|
||||
height = 25
|
||||
+ label {text = "F1:Memdisk" color = "blue" align = "left"}
|
||||
+ label {text = "@VTOY_HOTKEY_TIP@" color = "blue" align = "left"}
|
||||
}
|
||||
|
||||
|
||||
|
Binary file not shown.
@@ -14,16 +14,6 @@ ventoy_true() {
|
||||
}
|
||||
|
||||
ventoy_is_linux64() {
|
||||
if [ -e /lib64 ]; then
|
||||
ventoy_true
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -e /usr/lib64 ]; then
|
||||
ventoy_true
|
||||
return
|
||||
fi
|
||||
|
||||
if uname -a | egrep -q 'x86_64|amd64'; then
|
||||
ventoy_true
|
||||
return
|
||||
@@ -165,12 +155,12 @@ is_disk_contains_ventoy() {
|
||||
return
|
||||
fi
|
||||
|
||||
PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | ./tool/hexdump -n1 -e '1/1 "%02X"')
|
||||
if [ "$PART1_TYPE" != "07" ]; then
|
||||
vtdebug "part1 type is $PART2_TYPE not 07"
|
||||
ventoy_false
|
||||
return
|
||||
fi
|
||||
# PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | ./tool/hexdump -n1 -e '1/1 "%02X"')
|
||||
# if [ "$PART1_TYPE" != "07" ]; then
|
||||
# vtdebug "part1 type is $PART2_TYPE not 07"
|
||||
# ventoy_false
|
||||
# return
|
||||
# fi
|
||||
|
||||
if [ -e /sys/class/block/${PART1#/dev/}/start ]; then
|
||||
PART1_START=$(cat /sys/class/block/${PART1#/dev/}/start)
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -117,6 +117,10 @@ static void cmdline_strip ( char *cmdline, const char *cruft ) {
|
||||
*/
|
||||
static int cmdline_init ( void ) {
|
||||
userptr_t cmdline_user;
|
||||
userptr_t chainaddr;
|
||||
char *pos1;
|
||||
char *pos2;
|
||||
int chainlen;
|
||||
char *cmdline;
|
||||
size_t len;
|
||||
int rc;
|
||||
@@ -129,6 +133,23 @@ static int cmdline_init ( void ) {
|
||||
cmdline_user = phys_to_user ( cmdline_phys );
|
||||
len = ( strlen_user ( cmdline_user, 0 ) + 1 /* NUL */ );
|
||||
|
||||
pos1 = strstr((char *)cmdline_user, "mem:");
|
||||
if (pos1)
|
||||
{
|
||||
pos2 = strstr(pos1, ":size:");
|
||||
if (pos2)
|
||||
{
|
||||
*pos2 = 0;
|
||||
chainaddr = phys_to_user(strtoul(pos1 + 4 + 2, NULL, 16)); // skip 0x prefix in hex number
|
||||
chainlen = (int)strtoul(pos2 + 6, NULL, 10);
|
||||
*pos2 = ':';
|
||||
|
||||
g_initrd_addr = (void *)umalloc(chainlen);
|
||||
g_initrd_len = chainlen;
|
||||
memcpy_user((userptr_t)g_initrd_addr, 0, chainaddr, 0, chainlen);
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate and copy command line */
|
||||
cmdline_copy = malloc ( len );
|
||||
if ( ! cmdline_copy ) {
|
||||
@@ -137,6 +158,9 @@ static int cmdline_init ( void ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_cmdline_copy;
|
||||
}
|
||||
|
||||
g_cmdline_copy = cmdline_copy;
|
||||
|
||||
cmdline = cmdline_copy;
|
||||
copy_from_user ( cmdline, cmdline_user, 0, len );
|
||||
DBGC ( colour, "RUNTIME found command line \"%s\" at %08x\n",
|
||||
@@ -221,11 +245,6 @@ static int initrd_init ( void ) {
|
||||
memcpy_user ( image->data, 0, phys_to_user ( initrd_phys ), 0,
|
||||
initrd_len );
|
||||
|
||||
g_initrd_addr = (void *)image->data;
|
||||
g_initrd_len = image->len;
|
||||
g_cmdline_copy = cmdline_copy;
|
||||
|
||||
|
||||
/* Mark initrd as consumed */
|
||||
initrd_phys = 0;
|
||||
|
||||
|
@@ -126,11 +126,8 @@ void hide_umalloc ( physaddr_t start, physaddr_t end ) {
|
||||
*
|
||||
*/
|
||||
void hide_textdata ( void ) {
|
||||
/* Deleted by longpanda */
|
||||
#if 0
|
||||
hide_region ( &hidemem_textdata, virt_to_phys ( _textdata ),
|
||||
virt_to_phys ( _etextdata ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
BIN
LANGUAGES/languages.ini
Normal file
BIN
LANGUAGES/languages.ini
Normal file
Binary file not shown.
@@ -1,11 +1,11 @@
|
||||
# Ventoy
|
||||
Ventoy is an open source tool to create bootable USB drive for ISO files.
|
||||
With ventoy, you don't need to format the disk again and again, you just need to copy the iso file to the USB drive and boot it.
|
||||
With ventoy, you don't need to format the disk over and over, you just need to copy the iso file to the USB drive and boot it.
|
||||
You can copy many iso files at a time and ventoy will give you a boot menu to select them.
|
||||
Both Legacy BIOS and UEFI are supported in the same way. 200+ ISO files are tested.
|
||||
A "Ventoy Compatible" concept is introduced by ventoy, which can help to support any ISO file.
|
||||
|
||||
See http://www.ventoy.net for detail.
|
||||
See https://www.ventoy.net for detail.
|
||||
|
||||
# Features
|
||||
* 100% open source
|
||||
@@ -13,16 +13,17 @@ See http://www.ventoy.net for detail.
|
||||
* Fast (limited only by the speed of copying iso file)
|
||||
* Directly boot from iso file, no extraction needed
|
||||
* Legacy + UEFI supported in the same way
|
||||
* UEFI Secure Boot supported (since 1.0.07+) Notes
|
||||
* UEFI Secure Boot supported (since 1.0.07+)
|
||||
* ISO files larger than 4GB supported
|
||||
* Native boot menu style for Legacy & UEFI
|
||||
* Most type of OS supported, 200+ iso files tested
|
||||
* Not only boot but also complete installation process
|
||||
* "Ventoy Compatible" concept
|
||||
* Plugin Framework
|
||||
* Auto installation supported (1.0.09+)
|
||||
* Readonly to USB drive during boot
|
||||
* USB normal use unafftected
|
||||
* Data nondestructive during version upgrade
|
||||
* No need to update Ventoy when a new distro is released
|
||||
|
||||

|
||||

|
||||
|
@@ -22,53 +22,7 @@
|
||||
#include "Ventoy2Disk.h"
|
||||
#include "Language.h"
|
||||
|
||||
const TCHAR * g_Str_English[STR_ID_MAX] =
|
||||
{
|
||||
TEXT("Error"),
|
||||
TEXT("Warning"),
|
||||
TEXT("Info"),
|
||||
TEXT("Please run under the correct directory!"),
|
||||
TEXT("Device"),
|
||||
TEXT("Ventoy At Local"),
|
||||
TEXT("Ventoy In Device"),
|
||||
TEXT("Status - READY"),
|
||||
TEXT("Install"),
|
||||
TEXT("Update"),
|
||||
TEXT("Upgrade operation is safe, ISO files will be unchanged.\r\nContinue?"),
|
||||
TEXT("The disk will be formatted and all the data will be lost.\r\nContinue?"),
|
||||
TEXT("The disk will be formatted and all the data will be lost.\r\nContinue? (Double Check)"),
|
||||
TEXT("Congratulations!\r\nVentoy has been successfully installed to the device."),
|
||||
TEXT("An error occurred during the installation. You can replug the USB and try again. Check log.txt for detail."),
|
||||
TEXT("Congratulations!\r\nVentoy has been successfully updated to the device."),
|
||||
TEXT("An error occurred during the update. You can replug the USB and try again. Check log.txt for detail."),
|
||||
|
||||
TEXT("A thread is running, please wait..."),
|
||||
};
|
||||
|
||||
const TCHAR * g_Str_ChineseSimple[STR_ID_MAX] =
|
||||
{
|
||||
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!"),
|
||||
TEXT("<EFBFBD>豸"),
|
||||
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ventoy"),
|
||||
TEXT("<EFBFBD>豸<EFBFBD><EFBFBD> Ventoy"),
|
||||
TEXT("״̬ - <><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||
TEXT("<EFBFBD><EFBFBD>װ"),
|
||||
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ȫ<EFBFBD><EFBFBD>, ISO<53>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ᶪʧ\r\n<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||
TEXT("<EFBFBD><EFBFBD><EFBFBD>̻ᱻ<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6>ᶪʧ!\r\n<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||
TEXT("<EFBFBD><EFBFBD><EFBFBD>̻ᱻ<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6>ᶪʧ!\r\n<EFBFBD>ٴ<EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||
TEXT("<EFBFBD><EFBFBD>ϲ<EFBFBD><EFBFBD>! Ventoy <20>Ѿ<EFBFBD><D1BE>ɹ<EFBFBD><C9B9><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>."),
|
||||
TEXT("<EFBFBD><EFBFBD>װ Ventoy <20><><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>°β<C2B0>һ<EFBFBD><D2BB>U<EFBFBD><55>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>, <20><>ϸ<EFBFBD><CFB8>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> log.txt <20>ļ<EFBFBD>."),
|
||||
TEXT("<EFBFBD><EFBFBD>ϲ<EFBFBD><EFBFBD>! <20>°汾<C2B0><E6B1BE> Ventoy <20>Ѿ<EFBFBD><D1BE>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>."),
|
||||
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ventoy <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>°β<C2B0>һ<EFBFBD><D2BB>U<EFBFBD><55>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>, <20><>ϸ<EFBFBD><CFB8>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> log.txt <20>ļ<EFBFBD>."),
|
||||
|
||||
TEXT("<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD>ȴ<EFBFBD>..."),
|
||||
};
|
||||
|
||||
const TCHAR * GetString(enum STR_ID ID)
|
||||
{
|
||||
return g_Str_English[ID];
|
||||
return g_cur_lang_data->MsgString[ID];
|
||||
};
|
||||
|
@@ -21,35 +21,65 @@
|
||||
#ifndef __LANGUAGE_H__
|
||||
#define __LANGUAGE_H__
|
||||
|
||||
|
||||
typedef enum STR_ID
|
||||
{
|
||||
STR_ERROR = 0,
|
||||
STR_WARNING,
|
||||
STR_INFO,
|
||||
STR_INCORRECT_DIR,
|
||||
STR_ERROR = 0,
|
||||
STR_WARNING, // 1
|
||||
STR_INFO, // 2
|
||||
STR_INCORRECT_DIR, //3
|
||||
STR_INCORRECT_TREE_DIR, //4
|
||||
|
||||
STR_DEVICE,
|
||||
STR_LOCAL_VER,
|
||||
STR_DISK_VER,
|
||||
STR_STATUS,
|
||||
STR_INSTALL,
|
||||
STR_UPDATE,
|
||||
STR_DEVICE, //5
|
||||
STR_LOCAL_VER, //6
|
||||
STR_DISK_VER, //7
|
||||
STR_STATUS, //8
|
||||
STR_INSTALL, //9
|
||||
STR_UPDATE, //10
|
||||
|
||||
STR_UPDATE_TIP,
|
||||
STR_INSTALL_TIP,
|
||||
STR_INSTALL_TIP2,
|
||||
STR_UPDATE_TIP, //11
|
||||
STR_INSTALL_TIP, //12
|
||||
STR_INSTALL_TIP2,//13
|
||||
|
||||
STR_INSTALL_SUCCESS,
|
||||
STR_INSTALL_FAILED,
|
||||
STR_UPDATE_SUCCESS,
|
||||
STR_UPDATE_FAILED,
|
||||
STR_INSTALL_SUCCESS,//14
|
||||
STR_INSTALL_FAILED,//15
|
||||
STR_UPDATE_SUCCESS,//16
|
||||
STR_UPDATE_FAILED,//17
|
||||
|
||||
STR_WAIT_PROCESS,
|
||||
STR_WAIT_PROCESS,//18
|
||||
|
||||
STR_MENU_OPTION,//19
|
||||
STR_MENU_SECURE_BOOT,//20
|
||||
|
||||
STR_ID_MAX
|
||||
STR_ID_MAX
|
||||
}STR_ID;
|
||||
|
||||
extern BOOL g_SecureBoot;
|
||||
|
||||
#define VTOY_MENU_SECURE_BOOT 0xA000
|
||||
#define VTOY_MENU_LANGUAGE_BEGIN 0xB000
|
||||
|
||||
|
||||
#define VENTOY_LANGUAGE_INI TEXT(".\\ventoy\\languages.ini")
|
||||
#define VENTOY_CFG_INI TEXT(".\\Ventoy2Disk.ini")
|
||||
#define VENTOY_CFG_INI_A ".\\Ventoy2Disk.ini"
|
||||
#define VENTOY_MAX_LANGUAGE 200
|
||||
|
||||
#define GET_INI_STRING(Section, Key, Buf) GetPrivateProfileString(Section, Key, TEXT("#"), Buf, sizeof(Buf), VENTOY_LANGUAGE_INI)
|
||||
|
||||
typedef struct VENTOY_LANGUAGE
|
||||
{
|
||||
WCHAR Name[128];
|
||||
WCHAR FontFamily[64];
|
||||
int FontSize;
|
||||
|
||||
WCHAR StrId[STR_ID_MAX][64];
|
||||
WCHAR MsgString[STR_ID_MAX][1024];
|
||||
|
||||
}VENTOY_LANGUAGE;
|
||||
|
||||
extern VENTOY_LANGUAGE *g_cur_lang_data;
|
||||
|
||||
const TCHAR * GetString(enum STR_ID ID);
|
||||
|
||||
#define _G(a) GetString(a)
|
||||
|
@@ -824,10 +824,137 @@ int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, CHAR *VerBuf, size_
|
||||
|
||||
|
||||
|
||||
|
||||
static unsigned int g_disk_unxz_len = 0;
|
||||
static BYTE *g_part_img_pos = NULL;
|
||||
static BYTE *g_part_img_buf[VENTOY_EFI_PART_SIZE / SIZE_1MB];
|
||||
|
||||
|
||||
static int VentoyFatMemRead(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
|
||||
{
|
||||
uint32 i;
|
||||
uint32 offset;
|
||||
BYTE *MbBuf = NULL;
|
||||
|
||||
for (i = 0; i < SectorCount; i++)
|
||||
{
|
||||
offset = (Sector + i) * 512;
|
||||
|
||||
if (g_part_img_buf[1] == NULL)
|
||||
{
|
||||
MbBuf = g_part_img_buf[0] + offset;
|
||||
memcpy(Buffer + i * 512, MbBuf, 512);
|
||||
}
|
||||
else
|
||||
{
|
||||
MbBuf = g_part_img_buf[offset / SIZE_1MB];
|
||||
memcpy(Buffer + i * 512, MbBuf + (offset % SIZE_1MB), 512);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int VentoyFatMemWrite(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
|
||||
{
|
||||
uint32 i;
|
||||
uint32 offset;
|
||||
BYTE *MbBuf = NULL;
|
||||
|
||||
for (i = 0; i < SectorCount; i++)
|
||||
{
|
||||
offset = (Sector + i) * 512;
|
||||
|
||||
if (g_part_img_buf[1] == NULL)
|
||||
{
|
||||
MbBuf = g_part_img_buf[0] + offset;
|
||||
memcpy(MbBuf, Buffer + i * 512, 512);
|
||||
}
|
||||
else
|
||||
{
|
||||
MbBuf = g_part_img_buf[offset / SIZE_1MB];
|
||||
memcpy(MbBuf + (offset % SIZE_1MB), Buffer + i * 512, 512);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int VentoyProcSecureBoot(BOOL SecureBoot)
|
||||
{
|
||||
int rc = 0;
|
||||
int size;
|
||||
char *filebuf = NULL;
|
||||
void *file = NULL;
|
||||
|
||||
Log("VentoyProcSecureBoot %d ...", SecureBoot);
|
||||
|
||||
if (SecureBoot)
|
||||
{
|
||||
Log("Secure boot is enabled ...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
fl_init();
|
||||
|
||||
if (0 == fl_attach_media(VentoyFatMemRead, VentoyFatMemWrite))
|
||||
{
|
||||
file = fl_fopen("/EFI/BOOT/grubx64_real.efi", "rb");
|
||||
Log("Open ventoy efi file %p ", file);
|
||||
if (file)
|
||||
{
|
||||
fl_fseek(file, 0, SEEK_END);
|
||||
size = (int)fl_ftell(file);
|
||||
fl_fseek(file, 0, SEEK_SET);
|
||||
|
||||
Log("ventoy efi file size %d ...", size);
|
||||
|
||||
filebuf = (char *)malloc(size);
|
||||
if (filebuf)
|
||||
{
|
||||
fl_fread(filebuf, 1, size, file);
|
||||
}
|
||||
|
||||
fl_fclose(file);
|
||||
|
||||
Log("Now delete all efi files ...");
|
||||
fl_remove("/EFI/BOOT/BOOTX64.EFI");
|
||||
fl_remove("/EFI/BOOT/grubx64.efi");
|
||||
fl_remove("/EFI/BOOT/grubx64_real.efi");
|
||||
fl_remove("/EFI/BOOT/MokManager.efi");
|
||||
|
||||
file = fl_fopen("/EFI/BOOT/BOOTX64.EFI", "wb");
|
||||
Log("Open bootx64 efi file %p ", file);
|
||||
if (file)
|
||||
{
|
||||
if (filebuf)
|
||||
{
|
||||
fl_fwrite(filebuf, 1, size, file);
|
||||
}
|
||||
|
||||
fl_fflush(file);
|
||||
fl_fclose(file);
|
||||
}
|
||||
|
||||
if (filebuf)
|
||||
{
|
||||
free(filebuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
fl_shutdown();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int disk_xz_flush(void *src, unsigned int size)
|
||||
{
|
||||
unsigned int i;
|
||||
@@ -919,6 +1046,9 @@ static int FormatPart2Fat(HANDLE hDrive, UINT64 StartSectorId)
|
||||
if (len == writelen)
|
||||
{
|
||||
Log("decompress finished success");
|
||||
|
||||
VentoyProcSecureBoot(g_SecureBoot);
|
||||
|
||||
for (i = 0; i < VENTOY_EFI_PART_SIZE / SIZE_1MB; i++)
|
||||
{
|
||||
dwSize = 0;
|
||||
@@ -965,6 +1095,9 @@ static int FormatPart2Fat(HANDLE hDrive, UINT64 StartSectorId)
|
||||
if (g_disk_unxz_len == VENTOY_EFI_PART_SIZE)
|
||||
{
|
||||
Log("decompress finished success");
|
||||
|
||||
VentoyProcSecureBoot(g_SecureBoot);
|
||||
|
||||
for (int i = 0; i < VENTOY_EFI_PART_SIZE / SIZE_1MB; i++)
|
||||
{
|
||||
dwSize = 0;
|
||||
|
@@ -130,8 +130,7 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes)
|
||||
PartStartSector = 2048;
|
||||
PartSectorCount = (UINT32)((SizeBytes - VENTOY_EFI_PART_SIZE - SIZE_1MB) / 512);
|
||||
|
||||
if (MBR.PartTbl[0].FsFlag != 0x07 ||
|
||||
MBR.PartTbl[0].StartSectorId != PartStartSector ||
|
||||
if (MBR.PartTbl[0].StartSectorId != PartStartSector ||
|
||||
MBR.PartTbl[0].SectorCount != PartSectorCount)
|
||||
{
|
||||
Log("Part1 not match %u %u", PartStartSector, PartSectorCount);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -43,6 +43,17 @@ typedef unsigned char uint8_t;
|
||||
|
||||
#define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
|
||||
|
||||
typedef enum ventoy_fs_type
|
||||
{
|
||||
ventoy_fs_exfat = 0, /* 0: exfat */
|
||||
ventoy_fs_ntfs, /* 1: NTFS */
|
||||
ventoy_fs_ext, /* 2: ext2/ext3/ext4 */
|
||||
ventoy_fs_xfs, /* 3: XFS */
|
||||
ventoy_fs_udf, /* 4: UDF */
|
||||
|
||||
ventoy_fs_max
|
||||
}ventoy_fs_type;
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct ventoy_guid
|
||||
@@ -130,6 +141,11 @@ static int verbose = 0;
|
||||
|
||||
static ventoy_guid vtoy_guid = VENTOY_GUID;
|
||||
|
||||
static const char *g_ventoy_fs[ventoy_fs_max] =
|
||||
{
|
||||
"exfat", "ntfs", "ext*", "xfs", "udf"
|
||||
};
|
||||
|
||||
static int vtoy_check_os_param(ventoy_os_param *param)
|
||||
{
|
||||
uint32_t i;
|
||||
@@ -410,14 +426,10 @@ static int vtoy_print_os_param(ventoy_os_param *param, char *diskname)
|
||||
cnt = vtoy_find_disk_by_guid(param->vtoy_disk_guid, diskname);
|
||||
debug("find 0 disk by size, try with guid cnt=%d...\n", cnt);
|
||||
}
|
||||
|
||||
if (param->vtoy_disk_part_type == 0)
|
||||
|
||||
if (param->vtoy_disk_part_type < ventoy_fs_max)
|
||||
{
|
||||
fs = "exfat";
|
||||
}
|
||||
else if (param->vtoy_disk_part_type == 0)
|
||||
{
|
||||
fs = "ntfs";
|
||||
fs = g_ventoy_fs[param->vtoy_disk_part_type];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -29,6 +29,7 @@
|
||||
#include "fat_filelib.h"
|
||||
|
||||
static ventoy_os_param g_os_param;
|
||||
static ventoy_windows_data g_windows_data;
|
||||
static UINT8 g_os_param_reserved[32];
|
||||
static BOOL g_64bit_system = FALSE;
|
||||
static ventoy_guid g_ventoy_guid = VENTOY_GUID;
|
||||
@@ -703,6 +704,40 @@ static int DeleteVentoyPart2MountPoint(DWORD PhyDrive)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ProcessUnattendedInstallation(const char *script)
|
||||
{
|
||||
DWORD dw;
|
||||
HKEY hKey;
|
||||
LSTATUS Ret;
|
||||
CHAR Letter;
|
||||
CHAR CurDir[MAX_PATH];
|
||||
|
||||
Log("Copy unattended XML ...");
|
||||
|
||||
GetCurrentDirectory(sizeof(CurDir), CurDir);
|
||||
Letter = CurDir[0];
|
||||
if ((Letter >= 'A' && Letter <= 'Z') || (Letter >= 'a' && Letter <= 'z'))
|
||||
{
|
||||
Log("Current Drive Letter: %C", Letter);
|
||||
}
|
||||
else
|
||||
{
|
||||
Letter = 'X';
|
||||
}
|
||||
|
||||
sprintf_s(CurDir, sizeof(CurDir), "%C:\\Autounattend.xml", Letter);
|
||||
Log("Copy file <%s> --> <%s>", script, CurDir);
|
||||
CopyFile(script, CurDir, FALSE);
|
||||
|
||||
Ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "System\\Setup", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dw);
|
||||
if (ERROR_SUCCESS == Ret)
|
||||
{
|
||||
Ret = RegSetValueEx(hKey, "UnattendFile", 0, REG_SZ, CurDir, (DWORD)(strlen(CurDir) + 1));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int VentoyHook(ventoy_os_param *param)
|
||||
{
|
||||
int rc;
|
||||
@@ -755,6 +790,24 @@ static int VentoyHook(ventoy_os_param *param)
|
||||
// for protect
|
||||
rc = DeleteVentoyPart2MountPoint(DiskExtent.DiskNumber);
|
||||
Log("Delete ventoy mountpoint: %s", rc == 0 ? "SUCCESS" : "NO NEED");
|
||||
|
||||
if (g_windows_data.auto_install_script[0])
|
||||
{
|
||||
sprintf_s(IsoPath, sizeof(IsoPath), "%C:%s", Letter, g_windows_data.auto_install_script);
|
||||
if (IsPathExist(FALSE, "%s", IsoPath))
|
||||
{
|
||||
Log("use auto install script %s...", IsoPath);
|
||||
ProcessUnattendedInstallation(IsoPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("auto install script %s not exist", IsoPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("auto install no need");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -815,11 +868,12 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile)
|
||||
for (PeStart = 0; PeStart < FileSize; PeStart += 16)
|
||||
{
|
||||
if (CheckOsParam((ventoy_os_param *)(Buffer + PeStart)) &&
|
||||
CheckPeHead(Buffer + PeStart + sizeof(ventoy_os_param)))
|
||||
CheckPeHead(Buffer + PeStart + sizeof(ventoy_os_param) + sizeof(ventoy_windows_data)))
|
||||
{
|
||||
Log("Find os pararm at %u", PeStart);
|
||||
|
||||
memcpy(&g_os_param, Buffer + PeStart, sizeof(ventoy_os_param));
|
||||
memcpy(&g_windows_data, Buffer + PeStart + sizeof(ventoy_os_param), sizeof(ventoy_windows_data));
|
||||
memcpy(g_os_param_reserved, g_os_param.vtoy_reserved, sizeof(g_os_param_reserved));
|
||||
|
||||
if (g_os_param_reserved[0] == 1)
|
||||
@@ -837,7 +891,7 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile)
|
||||
}
|
||||
}
|
||||
|
||||
PeStart += sizeof(ventoy_os_param);
|
||||
PeStart += sizeof(ventoy_os_param) + sizeof(ventoy_windows_data);
|
||||
sprintf_s(LunchFile, MAX_PATH, "ventoy\\%s", GetFileNameInPath(ExeFileName));
|
||||
SaveBuffer2File(LunchFile, Buffer + PeStart, FileSize - PeStart);
|
||||
break;
|
||||
|
@@ -65,6 +65,12 @@ typedef struct ventoy_os_param
|
||||
UINT8 reserved[31];
|
||||
}ventoy_os_param;
|
||||
|
||||
typedef struct ventoy_windows_data
|
||||
{
|
||||
char auto_install_script[384];
|
||||
UINT8 reserved[128];
|
||||
}ventoy_windows_data;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user