5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/libext2fs_blockserver/docs/LICENCE.txt Tue May 04 00:19:19 2021 +0200
5.3 @@ -0,0 +1,481 @@
5.4 + GNU LIBRARY GENERAL PUBLIC LICENSE
5.5 + Version 2, June 1991
5.6 +
5.7 + Copyright (C) 1991 Free Software Foundation, Inc.
5.8 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
5.9 + Everyone is permitted to copy and distribute verbatim copies
5.10 + of this license document, but changing it is not allowed.
5.11 +
5.12 +[This is the first released version of the library GPL. It is
5.13 + numbered 2 because it goes with version 2 of the ordinary GPL.]
5.14 +
5.15 + Preamble
5.16 +
5.17 + The licenses for most software are designed to take away your
5.18 +freedom to share and change it. By contrast, the GNU General Public
5.19 +Licenses are intended to guarantee your freedom to share and change
5.20 +free software--to make sure the software is free for all its users.
5.21 +
5.22 + This license, the Library General Public License, applies to some
5.23 +specially designated Free Software Foundation software, and to any
5.24 +other libraries whose authors decide to use it. You can use it for
5.25 +your libraries, too.
5.26 +
5.27 + When we speak of free software, we are referring to freedom, not
5.28 +price. Our General Public Licenses are designed to make sure that you
5.29 +have the freedom to distribute copies of free software (and charge for
5.30 +this service if you wish), that you receive source code or can get it
5.31 +if you want it, that you can change the software or use pieces of it
5.32 +in new free programs; and that you know you can do these things.
5.33 +
5.34 + To protect your rights, we need to make restrictions that forbid
5.35 +anyone to deny you these rights or to ask you to surrender the rights.
5.36 +These restrictions translate to certain responsibilities for you if
5.37 +you distribute copies of the library, or if you modify it.
5.38 +
5.39 + For example, if you distribute copies of the library, whether gratis
5.40 +or for a fee, you must give the recipients all the rights that we gave
5.41 +you. You must make sure that they, too, receive or can get the source
5.42 +code. If you link a program with the library, you must provide
5.43 +complete object files to the recipients so that they can relink them
5.44 +with the library, after making changes to the library and recompiling
5.45 +it. And you must show them these terms so they know their rights.
5.46 +
5.47 + Our method of protecting your rights has two steps: (1) copyright
5.48 +the library, and (2) offer you this license which gives you legal
5.49 +permission to copy, distribute and/or modify the library.
5.50 +
5.51 + Also, for each distributor's protection, we want to make certain
5.52 +that everyone understands that there is no warranty for this free
5.53 +library. If the library is modified by someone else and passed on, we
5.54 +want its recipients to know that what they have is not the original
5.55 +version, so that any problems introduced by others will not reflect on
5.56 +the original authors' reputations.
5.57 +
5.58 + Finally, any free program is threatened constantly by software
5.59 +patents. We wish to avoid the danger that companies distributing free
5.60 +software will individually obtain patent licenses, thus in effect
5.61 +transforming the program into proprietary software. To prevent this,
5.62 +we have made it clear that any patent must be licensed for everyone's
5.63 +free use or not licensed at all.
5.64 +
5.65 + Most GNU software, including some libraries, is covered by the ordinary
5.66 +GNU General Public License, which was designed for utility programs. This
5.67 +license, the GNU Library General Public License, applies to certain
5.68 +designated libraries. This license is quite different from the ordinary
5.69 +one; be sure to read it in full, and don't assume that anything in it is
5.70 +the same as in the ordinary license.
5.71 +
5.72 + The reason we have a separate public license for some libraries is that
5.73 +they blur the distinction we usually make between modifying or adding to a
5.74 +program and simply using it. Linking a program with a library, without
5.75 +changing the library, is in some sense simply using the library, and is
5.76 +analogous to running a utility program or application program. However, in
5.77 +a textual and legal sense, the linked executable is a combined work, a
5.78 +derivative of the original library, and the ordinary General Public License
5.79 +treats it as such.
5.80 +
5.81 + Because of this blurred distinction, using the ordinary General
5.82 +Public License for libraries did not effectively promote software
5.83 +sharing, because most developers did not use the libraries. We
5.84 +concluded that weaker conditions might promote sharing better.
5.85 +
5.86 + However, unrestricted linking of non-free programs would deprive the
5.87 +users of those programs of all benefit from the free status of the
5.88 +libraries themselves. This Library General Public License is intended to
5.89 +permit developers of non-free programs to use free libraries, while
5.90 +preserving your freedom as a user of such programs to change the free
5.91 +libraries that are incorporated in them. (We have not seen how to achieve
5.92 +this as regards changes in header files, but we have achieved it as regards
5.93 +changes in the actual functions of the Library.) The hope is that this
5.94 +will lead to faster development of free libraries.
5.95 +
5.96 + The precise terms and conditions for copying, distribution and
5.97 +modification follow. Pay close attention to the difference between a
5.98 +"work based on the library" and a "work that uses the library". The
5.99 +former contains code derived from the library, while the latter only
5.100 +works together with the library.
5.101 +
5.102 + Note that it is possible for a library to be covered by the ordinary
5.103 +General Public License rather than by this special one.
5.104 +
5.105 + GNU LIBRARY GENERAL PUBLIC LICENSE
5.106 + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
5.107 +
5.108 + 0. This License Agreement applies to any software library which
5.109 +contains a notice placed by the copyright holder or other authorized
5.110 +party saying it may be distributed under the terms of this Library
5.111 +General Public License (also called "this License"). Each licensee is
5.112 +addressed as "you".
5.113 +
5.114 + A "library" means a collection of software functions and/or data
5.115 +prepared so as to be conveniently linked with application programs
5.116 +(which use some of those functions and data) to form executables.
5.117 +
5.118 + The "Library", below, refers to any such software library or work
5.119 +which has been distributed under these terms. A "work based on the
5.120 +Library" means either the Library or any derivative work under
5.121 +copyright law: that is to say, a work containing the Library or a
5.122 +portion of it, either verbatim or with modifications and/or translated
5.123 +straightforwardly into another language. (Hereinafter, translation is
5.124 +included without limitation in the term "modification".)
5.125 +
5.126 + "Source code" for a work means the preferred form of the work for
5.127 +making modifications to it. For a library, complete source code means
5.128 +all the source code for all modules it contains, plus any associated
5.129 +interface definition files, plus the scripts used to control compilation
5.130 +and installation of the library.
5.131 +
5.132 + Activities other than copying, distribution and modification are not
5.133 +covered by this License; they are outside its scope. The act of
5.134 +running a program using the Library is not restricted, and output from
5.135 +such a program is covered only if its contents constitute a work based
5.136 +on the Library (independent of the use of the Library in a tool for
5.137 +writing it). Whether that is true depends on what the Library does
5.138 +and what the program that uses the Library does.
5.139 +
5.140 + 1. You may copy and distribute verbatim copies of the Library's
5.141 +complete source code as you receive it, in any medium, provided that
5.142 +you conspicuously and appropriately publish on each copy an
5.143 +appropriate copyright notice and disclaimer of warranty; keep intact
5.144 +all the notices that refer to this License and to the absence of any
5.145 +warranty; and distribute a copy of this License along with the
5.146 +Library.
5.147 +
5.148 + You may charge a fee for the physical act of transferring a copy,
5.149 +and you may at your option offer warranty protection in exchange for a
5.150 +fee.
5.151 +
5.152 + 2. You may modify your copy or copies of the Library or any portion
5.153 +of it, thus forming a work based on the Library, and copy and
5.154 +distribute such modifications or work under the terms of Section 1
5.155 +above, provided that you also meet all of these conditions:
5.156 +
5.157 + a) The modified work must itself be a software library.
5.158 +
5.159 + b) You must cause the files modified to carry prominent notices
5.160 + stating that you changed the files and the date of any change.
5.161 +
5.162 + c) You must cause the whole of the work to be licensed at no
5.163 + charge to all third parties under the terms of this License.
5.164 +
5.165 + d) If a facility in the modified Library refers to a function or a
5.166 + table of data to be supplied by an application program that uses
5.167 + the facility, other than as an argument passed when the facility
5.168 + is invoked, then you must make a good faith effort to ensure that,
5.169 + in the event an application does not supply such function or
5.170 + table, the facility still operates, and performs whatever part of
5.171 + its purpose remains meaningful.
5.172 +
5.173 + (For example, a function in a library to compute square roots has
5.174 + a purpose that is entirely well-defined independent of the
5.175 + application. Therefore, Subsection 2d requires that any
5.176 + application-supplied function or table used by this function must
5.177 + be optional: if the application does not supply it, the square
5.178 + root function must still compute square roots.)
5.179 +
5.180 +These requirements apply to the modified work as a whole. If
5.181 +identifiable sections of that work are not derived from the Library,
5.182 +and can be reasonably considered independent and separate works in
5.183 +themselves, then this License, and its terms, do not apply to those
5.184 +sections when you distribute them as separate works. But when you
5.185 +distribute the same sections as part of a whole which is a work based
5.186 +on the Library, the distribution of the whole must be on the terms of
5.187 +this License, whose permissions for other licensees extend to the
5.188 +entire whole, and thus to each and every part regardless of who wrote
5.189 +it.
5.190 +
5.191 +Thus, it is not the intent of this section to claim rights or contest
5.192 +your rights to work written entirely by you; rather, the intent is to
5.193 +exercise the right to control the distribution of derivative or
5.194 +collective works based on the Library.
5.195 +
5.196 +In addition, mere aggregation of another work not based on the Library
5.197 +with the Library (or with a work based on the Library) on a volume of
5.198 +a storage or distribution medium does not bring the other work under
5.199 +the scope of this License.
5.200 +
5.201 + 3. You may opt to apply the terms of the ordinary GNU General Public
5.202 +License instead of this License to a given copy of the Library. To do
5.203 +this, you must alter all the notices that refer to this License, so
5.204 +that they refer to the ordinary GNU General Public License, version 2,
5.205 +instead of to this License. (If a newer version than version 2 of the
5.206 +ordinary GNU General Public License has appeared, then you can specify
5.207 +that version instead if you wish.) Do not make any other change in
5.208 +these notices.
5.209 +
5.210 + Once this change is made in a given copy, it is irreversible for
5.211 +that copy, so the ordinary GNU General Public License applies to all
5.212 +subsequent copies and derivative works made from that copy.
5.213 +
5.214 + This option is useful when you wish to copy part of the code of
5.215 +the Library into a program that is not a library.
5.216 +
5.217 + 4. You may copy and distribute the Library (or a portion or
5.218 +derivative of it, under Section 2) in object code or executable form
5.219 +under the terms of Sections 1 and 2 above provided that you accompany
5.220 +it with the complete corresponding machine-readable source code, which
5.221 +must be distributed under the terms of Sections 1 and 2 above on a
5.222 +medium customarily used for software interchange.
5.223 +
5.224 + If distribution of object code is made by offering access to copy
5.225 +from a designated place, then offering equivalent access to copy the
5.226 +source code from the same place satisfies the requirement to
5.227 +distribute the source code, even though third parties are not
5.228 +compelled to copy the source along with the object code.
5.229 +
5.230 + 5. A program that contains no derivative of any portion of the
5.231 +Library, but is designed to work with the Library by being compiled or
5.232 +linked with it, is called a "work that uses the Library". Such a
5.233 +work, in isolation, is not a derivative work of the Library, and
5.234 +therefore falls outside the scope of this License.
5.235 +
5.236 + However, linking a "work that uses the Library" with the Library
5.237 +creates an executable that is a derivative of the Library (because it
5.238 +contains portions of the Library), rather than a "work that uses the
5.239 +library". The executable is therefore covered by this License.
5.240 +Section 6 states terms for distribution of such executables.
5.241 +
5.242 + When a "work that uses the Library" uses material from a header file
5.243 +that is part of the Library, the object code for the work may be a
5.244 +derivative work of the Library even though the source code is not.
5.245 +Whether this is true is especially significant if the work can be
5.246 +linked without the Library, or if the work is itself a library. The
5.247 +threshold for this to be true is not precisely defined by law.
5.248 +
5.249 + If such an object file uses only numerical parameters, data
5.250 +structure layouts and accessors, and small macros and small inline
5.251 +functions (ten lines or less in length), then the use of the object
5.252 +file is unrestricted, regardless of whether it is legally a derivative
5.253 +work. (Executables containing this object code plus portions of the
5.254 +Library will still fall under Section 6.)
5.255 +
5.256 + Otherwise, if the work is a derivative of the Library, you may
5.257 +distribute the object code for the work under the terms of Section 6.
5.258 +Any executables containing that work also fall under Section 6,
5.259 +whether or not they are linked directly with the Library itself.
5.260 +
5.261 + 6. As an exception to the Sections above, you may also compile or
5.262 +link a "work that uses the Library" with the Library to produce a
5.263 +work containing portions of the Library, and distribute that work
5.264 +under terms of your choice, provided that the terms permit
5.265 +modification of the work for the customer's own use and reverse
5.266 +engineering for debugging such modifications.
5.267 +
5.268 + You must give prominent notice with each copy of the work that the
5.269 +Library is used in it and that the Library and its use are covered by
5.270 +this License. You must supply a copy of this License. If the work
5.271 +during execution displays copyright notices, you must include the
5.272 +copyright notice for the Library among them, as well as a reference
5.273 +directing the user to the copy of this License. Also, you must do one
5.274 +of these things:
5.275 +
5.276 + a) Accompany the work with the complete corresponding
5.277 + machine-readable source code for the Library including whatever
5.278 + changes were used in the work (which must be distributed under
5.279 + Sections 1 and 2 above); and, if the work is an executable linked
5.280 + with the Library, with the complete machine-readable "work that
5.281 + uses the Library", as object code and/or source code, so that the
5.282 + user can modify the Library and then relink to produce a modified
5.283 + executable containing the modified Library. (It is understood
5.284 + that the user who changes the contents of definitions files in the
5.285 + Library will not necessarily be able to recompile the application
5.286 + to use the modified definitions.)
5.287 +
5.288 + b) Accompany the work with a written offer, valid for at
5.289 + least three years, to give the same user the materials
5.290 + specified in Subsection 6a, above, for a charge no more
5.291 + than the cost of performing this distribution.
5.292 +
5.293 + c) If distribution of the work is made by offering access to copy
5.294 + from a designated place, offer equivalent access to copy the above
5.295 + specified materials from the same place.
5.296 +
5.297 + d) Verify that the user has already received a copy of these
5.298 + materials or that you have already sent this user a copy.
5.299 +
5.300 + For an executable, the required form of the "work that uses the
5.301 +Library" must include any data and utility programs needed for
5.302 +reproducing the executable from it. However, as a special exception,
5.303 +the source code distributed need not include anything that is normally
5.304 +distributed (in either source or binary form) with the major
5.305 +components (compiler, kernel, and so on) of the operating system on
5.306 +which the executable runs, unless that component itself accompanies
5.307 +the executable.
5.308 +
5.309 + It may happen that this requirement contradicts the license
5.310 +restrictions of other proprietary libraries that do not normally
5.311 +accompany the operating system. Such a contradiction means you cannot
5.312 +use both them and the Library together in an executable that you
5.313 +distribute.
5.314 +
5.315 + 7. You may place library facilities that are a work based on the
5.316 +Library side-by-side in a single library together with other library
5.317 +facilities not covered by this License, and distribute such a combined
5.318 +library, provided that the separate distribution of the work based on
5.319 +the Library and of the other library facilities is otherwise
5.320 +permitted, and provided that you do these two things:
5.321 +
5.322 + a) Accompany the combined library with a copy of the same work
5.323 + based on the Library, uncombined with any other library
5.324 + facilities. This must be distributed under the terms of the
5.325 + Sections above.
5.326 +
5.327 + b) Give prominent notice with the combined library of the fact
5.328 + that part of it is a work based on the Library, and explaining
5.329 + where to find the accompanying uncombined form of the same work.
5.330 +
5.331 + 8. You may not copy, modify, sublicense, link with, or distribute
5.332 +the Library except as expressly provided under this License. Any
5.333 +attempt otherwise to copy, modify, sublicense, link with, or
5.334 +distribute the Library is void, and will automatically terminate your
5.335 +rights under this License. However, parties who have received copies,
5.336 +or rights, from you under this License will not have their licenses
5.337 +terminated so long as such parties remain in full compliance.
5.338 +
5.339 + 9. You are not required to accept this License, since you have not
5.340 +signed it. However, nothing else grants you permission to modify or
5.341 +distribute the Library or its derivative works. These actions are
5.342 +prohibited by law if you do not accept this License. Therefore, by
5.343 +modifying or distributing the Library (or any work based on the
5.344 +Library), you indicate your acceptance of this License to do so, and
5.345 +all its terms and conditions for copying, distributing or modifying
5.346 +the Library or works based on it.
5.347 +
5.348 + 10. Each time you redistribute the Library (or any work based on the
5.349 +Library), the recipient automatically receives a license from the
5.350 +original licensor to copy, distribute, link with or modify the Library
5.351 +subject to these terms and conditions. You may not impose any further
5.352 +restrictions on the recipients' exercise of the rights granted herein.
5.353 +You are not responsible for enforcing compliance by third parties to
5.354 +this License.
5.355 +
5.356 + 11. If, as a consequence of a court judgment or allegation of patent
5.357 +infringement or for any other reason (not limited to patent issues),
5.358 +conditions are imposed on you (whether by court order, agreement or
5.359 +otherwise) that contradict the conditions of this License, they do not
5.360 +excuse you from the conditions of this License. If you cannot
5.361 +distribute so as to satisfy simultaneously your obligations under this
5.362 +License and any other pertinent obligations, then as a consequence you
5.363 +may not distribute the Library at all. For example, if a patent
5.364 +license would not permit royalty-free redistribution of the Library by
5.365 +all those who receive copies directly or indirectly through you, then
5.366 +the only way you could satisfy both it and this License would be to
5.367 +refrain entirely from distribution of the Library.
5.368 +
5.369 +If any portion of this section is held invalid or unenforceable under any
5.370 +particular circumstance, the balance of the section is intended to apply,
5.371 +and the section as a whole is intended to apply in other circumstances.
5.372 +
5.373 +It is not the purpose of this section to induce you to infringe any
5.374 +patents or other property right claims or to contest validity of any
5.375 +such claims; this section has the sole purpose of protecting the
5.376 +integrity of the free software distribution system which is
5.377 +implemented by public license practices. Many people have made
5.378 +generous contributions to the wide range of software distributed
5.379 +through that system in reliance on consistent application of that
5.380 +system; it is up to the author/donor to decide if he or she is willing
5.381 +to distribute software through any other system and a licensee cannot
5.382 +impose that choice.
5.383 +
5.384 +This section is intended to make thoroughly clear what is believed to
5.385 +be a consequence of the rest of this License.
5.386 +
5.387 + 12. If the distribution and/or use of the Library is restricted in
5.388 +certain countries either by patents or by copyrighted interfaces, the
5.389 +original copyright holder who places the Library under this License may add
5.390 +an explicit geographical distribution limitation excluding those countries,
5.391 +so that distribution is permitted only in or among countries not thus
5.392 +excluded. In such case, this License incorporates the limitation as if
5.393 +written in the body of this License.
5.394 +
5.395 + 13. The Free Software Foundation may publish revised and/or new
5.396 +versions of the Library General Public License from time to time.
5.397 +Such new versions will be similar in spirit to the present version,
5.398 +but may differ in detail to address new problems or concerns.
5.399 +
5.400 +Each version is given a distinguishing version number. If the Library
5.401 +specifies a version number of this License which applies to it and
5.402 +"any later version", you have the option of following the terms and
5.403 +conditions either of that version or of any later version published by
5.404 +the Free Software Foundation. If the Library does not specify a
5.405 +license version number, you may choose any version ever published by
5.406 +the Free Software Foundation.
5.407 +
5.408 + 14. If you wish to incorporate parts of the Library into other free
5.409 +programs whose distribution conditions are incompatible with these,
5.410 +write to the author to ask for permission. For software which is
5.411 +copyrighted by the Free Software Foundation, write to the Free
5.412 +Software Foundation; we sometimes make exceptions for this. Our
5.413 +decision will be guided by the two goals of preserving the free status
5.414 +of all derivatives of our free software and of promoting the sharing
5.415 +and reuse of software generally.
5.416 +
5.417 + NO WARRANTY
5.418 +
5.419 + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
5.420 +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
5.421 +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
5.422 +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
5.423 +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
5.424 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
5.425 +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
5.426 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
5.427 +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
5.428 +
5.429 + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
5.430 +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
5.431 +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
5.432 +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
5.433 +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
5.434 +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
5.435 +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
5.436 +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
5.437 +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
5.438 +DAMAGES.
5.439 +
5.440 + END OF TERMS AND CONDITIONS
5.441 +
5.442 + How to Apply These Terms to Your New Libraries
5.443 +
5.444 + If you develop a new library, and you want it to be of the greatest
5.445 +possible use to the public, we recommend making it free software that
5.446 +everyone can redistribute and change. You can do so by permitting
5.447 +redistribution under these terms (or, alternatively, under the terms of the
5.448 +ordinary General Public License).
5.449 +
5.450 + To apply these terms, attach the following notices to the library. It is
5.451 +safest to attach them to the start of each source file to most effectively
5.452 +convey the exclusion of warranty; and each file should have at least the
5.453 +"copyright" line and a pointer to where the full notice is found.
5.454 +
5.455 + <one line to give the library's name and a brief idea of what it does.>
5.456 + Copyright (C) <year> <name of author>
5.457 +
5.458 + This library is free software; you can redistribute it and/or
5.459 + modify it under the terms of the GNU Library General Public
5.460 + License as published by the Free Software Foundation; either
5.461 + version 2 of the License, or (at your option) any later version.
5.462 +
5.463 + This library is distributed in the hope that it will be useful,
5.464 + but WITHOUT ANY WARRANTY; without even the implied warranty of
5.465 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5.466 + Library General Public License for more details.
5.467 +
5.468 + You should have received a copy of the GNU Library General Public
5.469 + License along with this library; if not, write to the Free Software
5.470 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
5.471 +
5.472 +Also add information on how to contact you by electronic and paper mail.
5.473 +
5.474 +You should also get your employer (if you work as a programmer) or your
5.475 +school, if any, to sign a "copyright disclaimer" for the library, if
5.476 +necessary. Here is a sample; alter the names:
5.477 +
5.478 + Yoyodyne, Inc., hereby disclaims all copyright interest in the
5.479 + library `Frob' (a library for tweaking knobs) written by James Random Hacker.
5.480 +
5.481 + <signature of Ty Coon>, 1 April 1990
5.482 + Ty Coon, President of Vice
5.483 +
5.484 +That's all there is to it!
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/libext2fs_blockserver/lib/src/blockserver_io.c Tue May 04 00:19:19 2021 +0200
8.3 @@ -0,0 +1,284 @@
8.4 +/*
8.5 + * blockserver_io.c --- L4Re block server I/O manager.
8.6 + *
8.7 + * Copyright (C) 2019, 2020, 2021 Paul Boddie <paul@boddie.org.uk>
8.8 + *
8.9 + * This library is free software; you can redistribute it and/or
8.10 + * modify it under the terms of the GNU Library General Public
8.11 + * License as published by the Free Software Foundation; either
8.12 + * version 2 of the License, or (at your option) any later version.
8.13 + *
8.14 + * This library is distributed in the hope that it will be useful,
8.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8.17 + * Library General Public License for more details.
8.18 + *
8.19 + * You should have received a copy of the GNU Library General Public
8.20 + * License along with this library; if not, write to the Free Software
8.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
8.22 + * 02110-1301 USA
8.23 + */
8.24 +
8.25 +#include <stdio.h>
8.26 +#include <stdlib.h>
8.27 +
8.28 +#include <ext2fs/ext2fs.h>
8.29 +#include <fsclient/client.h>
8.30 +
8.31 +
8.32 +
8.33 +/* Specific data for interacting with block devices. */
8.34 +
8.35 +struct blockserver_private_data
8.36 +{
8.37 + int magic;
8.38 + int flags;
8.39 + file_t *file;
8.40 +};
8.41 +
8.42 +io_manager blockserver_io_manager; /* defined below */
8.43 +
8.44 +const char *blockserver_default_cap = "server";
8.45 +
8.46 +
8.47 +
8.48 +/* Allocate and initialise a channel for the indicated block device. */
8.49 +
8.50 +static errcode_t blockserver_open_channel(const char *name,
8.51 + file_t *file, int flags,
8.52 + io_channel *channel,
8.53 + io_manager io_mgr)
8.54 +{
8.55 + io_channel io = NULL;
8.56 + struct blockserver_private_data *data = NULL;
8.57 + errcode_t retval;
8.58 +
8.59 + /* Allocate memory for the channel. */
8.60 +
8.61 + retval = ext2fs_get_mem(sizeof(struct struct_io_channel), &io);
8.62 + if (retval)
8.63 + goto free_io;
8.64 +
8.65 + /* Initialise the channel. */
8.66 +
8.67 + memset(io, 0, sizeof(struct struct_io_channel));
8.68 +
8.69 + io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
8.70 + io->manager = io_mgr;
8.71 + io->block_size = 1024;
8.72 + io->read_error = 0;
8.73 + io->write_error = 0;
8.74 + io->refcount = 1;
8.75 +
8.76 + /* Allocate memory for the name and store it. */
8.77 +
8.78 + retval = ext2fs_get_mem(strlen(name)+1, &io->name);
8.79 + if (retval)
8.80 + goto free_io;
8.81 +
8.82 + strcpy(io->name, name);
8.83 +
8.84 + /* Allocate memory for the private data. */
8.85 +
8.86 + retval = ext2fs_get_mem(sizeof(struct blockserver_private_data), &data);
8.87 + if (retval)
8.88 + goto free_data;
8.89 +
8.90 + /* Initialise the private data. */
8.91 +
8.92 + io->private_data = data;
8.93 +
8.94 + memset(data, 0, sizeof(struct blockserver_private_data));
8.95 +
8.96 + data->magic = EXT2_ET_MAGIC_UNIX_IO_CHANNEL;
8.97 + data->flags = flags;
8.98 + data->file = file;
8.99 +
8.100 + /* Return the allocated channel. */
8.101 +
8.102 + *channel = io;
8.103 + return 0;
8.104 +
8.105 + /* Deallocation upon failure. */
8.106 +
8.107 +free_data:
8.108 + if (data)
8.109 + ext2fs_free_mem(&data);
8.110 +
8.111 +free_io:
8.112 + if (io)
8.113 + {
8.114 + if (io->name)
8.115 + ext2fs_free_mem(&io->name);
8.116 + ext2fs_free_mem(&io);
8.117 + }
8.118 +
8.119 + return retval;
8.120 +}
8.121 +
8.122 +
8.123 +
8.124 +/* Open a block device using the named capability. */
8.125 +
8.126 +static errcode_t blockserver_open(const char *name, int flags, io_channel *channel)
8.127 +{
8.128 + /* Open a device via the named capability. */
8.129 +
8.130 + file_t *file = client_open_device(blockserver_default_cap, name, flags);
8.131 +
8.132 + /* NOTE: May want a more appropriate error code. */
8.133 +
8.134 + if (file == NULL)
8.135 + return EXT2_ET_BAD_DEVICE_NAME;
8.136 +
8.137 + return blockserver_open_channel(name, file, flags, channel, blockserver_io_manager);
8.138 +}
8.139 +
8.140 +
8.141 +
8.142 +/* Close the block device associated with the given channel. */
8.143 +
8.144 +static errcode_t blockserver_close(io_channel channel)
8.145 +{
8.146 + struct blockserver_private_data *data;
8.147 +
8.148 + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
8.149 + data = (struct blockserver_private_data *) channel->private_data;
8.150 + EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
8.151 +
8.152 + client_close(data->file);
8.153 + return 0;
8.154 +}
8.155 +
8.156 +/* Update the block size in use. */
8.157 +
8.158 +static errcode_t blockserver_set_blksize(io_channel channel, int blksize)
8.159 +{
8.160 + struct blockserver_private_data *data;
8.161 +
8.162 + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
8.163 + data = (struct blockserver_private_data *) channel->private_data;
8.164 + EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
8.165 +
8.166 + if (channel->block_size != blksize)
8.167 + channel->block_size = blksize;
8.168 +
8.169 + return 0;
8.170 +}
8.171 +
8.172 +/* Flush unwritten data. Without a cache, this does nothing. */
8.173 +
8.174 +static errcode_t blockserver_flush(io_channel channel)
8.175 +{
8.176 + return 0;
8.177 +}
8.178 +
8.179 +static errcode_t blockserver_set_option(io_channel channel, const char *option, const char *arg)
8.180 +{
8.181 + return 0;
8.182 +}
8.183 +
8.184 +static errcode_t blockserver_get_stats(io_channel channel, io_stats *stats)
8.185 +{
8.186 + return 0;
8.187 +}
8.188 +
8.189 +static errcode_t blockserver_read_blk64(io_channel channel, unsigned long long block, int count, void *buf)
8.190 +{
8.191 + /* Negative count values indicate a precise amount to read. */
8.192 +
8.193 + unsigned long long to_read = count < 0 ? -count : count * channel->block_size;
8.194 + ssize_t read;
8.195 + struct blockserver_private_data *data;
8.196 + errcode_t retval = 0;
8.197 +
8.198 + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
8.199 + data = (struct blockserver_private_data *) channel->private_data;
8.200 + EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
8.201 +
8.202 + /* Perform the read at the given location. */
8.203 +
8.204 + client_seek(data->file, block * channel->block_size, SEEK_SET);
8.205 + read = client_read(data->file, buf, to_read);
8.206 +
8.207 + /* Check for a short read. */
8.208 +
8.209 + if ((read < 0) || ((size_t) read < to_read))
8.210 + retval = EXT2_ET_SHORT_READ;
8.211 +
8.212 + /* Handle read errors generally. */
8.213 +
8.214 + if (retval)
8.215 + if (channel->read_error)
8.216 + retval = (channel->read_error)(channel, block, count, buf,
8.217 + to_read, read, retval);
8.218 +
8.219 + return retval;
8.220 +}
8.221 +
8.222 +static errcode_t blockserver_write_blk64(io_channel channel, unsigned long long block, int count, const void *buf)
8.223 +{
8.224 + /* Negative count values indicate a precise amount to write. */
8.225 +
8.226 + unsigned long long to_write = count < 0 ? -count : count * channel->block_size;
8.227 + ssize_t written;
8.228 + struct blockserver_private_data *data;
8.229 + errcode_t retval = 0;
8.230 +
8.231 + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
8.232 + data = (struct blockserver_private_data *) channel->private_data;
8.233 + EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
8.234 +
8.235 + /* Perform the write at the given location. */
8.236 +
8.237 + client_seek(data->file, block * channel->block_size, SEEK_SET);
8.238 + written = client_write(data->file, buf, to_write);
8.239 +
8.240 + /* Check for a short write. */
8.241 +
8.242 + if ((written < 0) || ((size_t) written < to_write))
8.243 + retval = EXT2_ET_SHORT_WRITE;
8.244 +
8.245 + /* Handle write errors generally. */
8.246 +
8.247 + if (retval)
8.248 + if (channel->write_error)
8.249 + retval = (channel->write_error)(channel, block, count, buf,
8.250 + to_write, written, retval);
8.251 +
8.252 + return retval;
8.253 +}
8.254 +
8.255 +static errcode_t blockserver_read_blk(io_channel channel, unsigned long block, int count, void *buf)
8.256 +{
8.257 + return blockserver_read_blk64(channel, block, count, buf);
8.258 +}
8.259 +
8.260 +static errcode_t blockserver_write_blk(io_channel channel, unsigned long block, int count, const void *buf)
8.261 +{
8.262 + return blockserver_write_blk64(channel, block, count, buf);
8.263 +}
8.264 +
8.265 +/* Unsupported operations are omitted: see io_manager.c for optional operation
8.266 + details. */
8.267 +
8.268 +static struct struct_io_manager struct_blockserver_manager = {
8.269 + .magic = EXT2_ET_MAGIC_IO_MANAGER,
8.270 + .name = "L4Re blockserver I/O Manager",
8.271 + .open = blockserver_open,
8.272 + .close = blockserver_close,
8.273 + .set_blksize = blockserver_set_blksize,
8.274 + .read_blk = blockserver_read_blk,
8.275 + .write_blk = blockserver_write_blk,
8.276 + .flush = blockserver_flush,
8.277 + .write_byte = 0,
8.278 + .set_option = blockserver_set_option,
8.279 + .get_stats = blockserver_get_stats,
8.280 + .read_blk64 = blockserver_read_blk64,
8.281 + .write_blk64 = blockserver_write_blk64,
8.282 + .discard = 0,
8.283 + .cache_readahead = 0,
8.284 + .zeroout = 0,
8.285 +};
8.286 +
8.287 +io_manager blockserver_io_manager = &struct_blockserver_manager;