commit 1f7c90208107d8a697ad61b93ca50c3d39ea0dcd Author: Ben Goldsworthy Date: Tue Jun 23 23:18:47 2020 +0100 Initial commit diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..78df873 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + 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. + + 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. + + 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. + + 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. + + 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. + + 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. + + 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. + + 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. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "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. + + 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 "covered work" means either the unmodified Program or a work based +on the Program. + + 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. + + 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. + + 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. + + 1. Source Code. + + 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. + + 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. + + 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. + + 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. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + 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. + + 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. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + 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. + + 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. + + 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. + + + Copyright (C) + + 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 . + +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: + + Copyright (C) + 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 +. + + 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 +. diff --git a/doc/Benix.html b/doc/Benix.html new file mode 100755 index 0000000..87ec070 --- /dev/null +++ b/doc/Benix.html @@ -0,0 +1,273 @@ + + + + + +Benix + + + + + + + + + + + + +
+

Class Benix

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • Benix
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class Benix
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      Benix() 
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + +
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static voidmain(java.lang.String[] args) +
      Interacts with the Benix API
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Benix

        +
        public Benix()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        main

        +
        public static void main(java.lang.String[] args)
        +
        Interacts with the Benix API
        +
        +
        Parameters:
        +
        args - arguments passed in from the command line.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/doc/Block.html b/doc/Block.html new file mode 100755 index 0000000..68ba2e3 --- /dev/null +++ b/doc/Block.html @@ -0,0 +1,409 @@ + + + + + +Block + + + + + + + + + + + + +
+

Class Block

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • Block
    • +
    +
  • +
+
+
    +
  • +
    +
    Direct Known Subclasses:
    +
    GroupDesc, SuperBlock
    +
    +
    +
    +
    public class Block
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      intBLOCK_SIZE 
      +
    • +
    + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      Block(java.nio.ByteBuffer block, + boolean debug) +
      Constructor method.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      byteget() +
      Gets one byte, increments the pointer.
      +
      byteget(int index) +
      Gets one byte from a given index.
      +
      intgetInt(int index) +
      Gets four bytes from a given index.
      +
      shortgetShort(int index) +
      Gets two bytes from a given index.
      +
      voidhexDump() +
      Prints a formatted hex dump of the block's contents.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Block

        +
        public Block(java.nio.ByteBuffer block,
        +             boolean debug)
        +
        Constructor method.
        +
        +
        Parameters:
        +
        block - The block byte dump.
        +
        debug - Whether debug mode is active or not.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        get

        +
        public byte get()
        +
        Gets one byte, increments the pointer.
        +
        +
        Returns:
        +
        A byte.
        +
        +
      • +
      + + + +
        +
      • +

        get

        +
        public byte get(int index)
        +
        Gets one byte from a given index.
        +
        +
        Parameters:
        +
        index - The index.
        +
        Returns:
        +
        A byte.
        +
        +
      • +
      + + + +
        +
      • +

        getShort

        +
        public short getShort(int index)
        +
        Gets two bytes from a given index.
        +
        +
        Parameters:
        +
        index - The index.
        +
        Returns:
        +
        A short.
        +
        +
      • +
      + + + +
        +
      • +

        getInt

        +
        public int getInt(int index)
        +
        Gets four bytes from a given index.
        +
        +
        Parameters:
        +
        index - The index.
        +
        Returns:
        +
        An int.
        +
        +
      • +
      + + + +
        +
      • +

        hexDump

        +
        public void hexDump()
        +
        Prints a formatted hex dump of the block's contents.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/doc/BlockGroup.html b/doc/BlockGroup.html new file mode 100755 index 0000000..61f7758 --- /dev/null +++ b/doc/BlockGroup.html @@ -0,0 +1,427 @@ + + + + + +BlockGroup + + + + + + + + + + + + +
+

Class BlockGroup

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • BlockGroup
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class BlockGroup
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      intBLOCK_SIZE 
      intINODE_SIZE 
      +
    • +
    + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      BlockGroup(java.nio.ByteBuffer block, + boolean debug) +
      Constructor method.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      java.nio.ByteBuffergetBlock(int id) +
      Accessor function.
      +
      intgetFileInodePointer(java.lang.String fileName) +
      Accessor function.
      +
      intgetFileLength(java.lang.String fileName) +
      Accessor function.
      +
      InodegetInode(int id, + boolean debug) +
      Accessor function.
      +
      voidlistDir() +
      Prints the directory listing.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        BlockGroup

        +
        public BlockGroup(java.nio.ByteBuffer block,
        +                  boolean debug)
        +
        Constructor method.
        +
        +
        Parameters:
        +
        block - The blockgroup byte dump.
        +
        debug - Whether debug mode is active or not.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getBlock

        +
        public java.nio.ByteBuffer getBlock(int id)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        id - The index of the block.
        +
        Returns:
        +
        A Block.
        +
        +
      • +
      + + + +
        +
      • +

        getInode

        +
        public Inode getInode(int id,
        +                      boolean debug)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        id - The index of the inode.
        +
        debug - Whether debug mode is active or not.
        +
        Returns:
        +
        An Inode.
        +
        +
      • +
      + + + +
        +
      • +

        listDir

        +
        public void listDir()
        +
        Prints the directory listing.
        +
      • +
      + + + +
        +
      • +

        getFileInodePointer

        +
        public int getFileInodePointer(java.lang.String fileName)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        fileName - The filename.
        +
        Returns:
        +
        The file's inode pointer.
        +
        +
      • +
      + + + +
        +
      • +

        getFileLength

        +
        public int getFileLength(java.lang.String fileName)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        fileName - The filename.
        +
        Returns:
        +
        The file's length.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/doc/Directory.html b/doc/Directory.html new file mode 100755 index 0000000..f0181a4 --- /dev/null +++ b/doc/Directory.html @@ -0,0 +1,631 @@ + + + + + +Directory + + + + + + + + + + + + +
+

Class Directory

+
+
+
    +
  • java.lang.Object
  • +
  • + +
  • +
+
+
    +
  • +
    +
    +
    public class Directory
    +extends Ext2File
    +
  • +
+
+
+ +
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Directory

        +
        public Directory(Block[] content,
        +                 boolean debug)
        +
        Constructor method.
        +
        +
        Parameters:
        +
        content - The array of Blocks containing the file.
        +
        debug - Whether debug mode is active or not.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getFileNum

        +
        public int getFileNum(java.lang.String fileName)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        fileName - The name of the file.
        +
        Returns:
        +
        The index of the file.
        +
        +
      • +
      + + + +
        +
      • +

        getNumofFiles

        +
        public int getNumofFiles()
        +
        Accessor function.
        +
        +
        Returns:
        +
        The number of files in the directory.
        +
        +
      • +
      + + + +
        +
      • +

        getInodePointer

        +
        public int getInodePointer(int fileNum)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        fileNum - The index of the file.
        +
        Returns:
        +
        The inode pointer of the file.
        +
        +
      • +
      + + + +
        +
      • +

        getLength

        +
        public short getLength(int fileNum)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        fileNum - The index of the file.
        +
        Returns:
        +
        The length of the file.
        +
        +
      • +
      + + + +
        +
      • +

        getNameLength

        +
        public byte getNameLength(int fileNum)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        fileNum - The index of the file.
        +
        Returns:
        +
        The length of the name of the file.
        +
        +
      • +
      + + + +
        +
      • +

        getType

        +
        public char getType(int fileNum)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        fileNum - The index of the file.
        +
        Returns:
        +
        The type character of the file.
        +
        +
      • +
      + + + +
        +
      • +

        getTypeIndicator

        +
        public byte getTypeIndicator(int fileNum)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        fileNum - The index of the file.
        +
        Returns:
        +
        The type indicator of the file.
        +
        +
      • +
      + + + +
        +
      • +

        getName

        +
        public java.lang.String getName(int fileNum)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        fileNum - The index of the file.
        +
        Returns:
        +
        The name of the file.
        +
        +
      • +
      + + + +
        +
      • +

        listDir

        +
        public void listDir()
        +
        Prints the directory listing.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/doc/Ext2File.html b/doc/Ext2File.html new file mode 100755 index 0000000..014aac6 --- /dev/null +++ b/doc/Ext2File.html @@ -0,0 +1,345 @@ + + + + + +Ext2File + + + + + + + + + + + + +
+

Class Ext2File

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • Ext2File
    • +
    +
  • +
+
+
    +
  • +
    +
    Direct Known Subclasses:
    +
    Directory
    +
    +
    +
    +
    public class Ext2File
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      intBLOCK_SIZE 
      +
    • +
    + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      Ext2File(Block[] blocks, + boolean debug) +
      Constructor method.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      BlockgetBlock(int num) +
      Accessor function.
      +
      voidhexDump() +
      Prints a formatted hex dump of the block's contents.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Ext2File

        +
        public Ext2File(Block[] blocks,
        +                boolean debug)
        +
        Constructor method.
        +
        +
        Parameters:
        +
        blocks - The array of Blocks containing the file.
        +
        debug - Whether debug mode is active or not.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getBlock

        +
        public Block getBlock(int num)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        num - The Index of the block.
        +
        Returns:
        +
        The Block.
        +
        +
      • +
      + + + +
        +
      • +

        hexDump

        +
        public void hexDump()
        +
        Prints a formatted hex dump of the block's contents.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/doc/GroupDesc.html b/doc/GroupDesc.html new file mode 100755 index 0000000..de63429 --- /dev/null +++ b/doc/GroupDesc.html @@ -0,0 +1,310 @@ + + + + + +GroupDesc + + + + + + + + + + + + +
+

Class GroupDesc

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • Block
    • +
    • +
        +
      • GroupDesc
      • +
      +
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public final class GroupDesc
    +extends Block
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      GroupDesc(java.nio.ByteBuffer groupDesc, + boolean debug) +
      Constructor method.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        GroupDesc

        +
        public GroupDesc(java.nio.ByteBuffer groupDesc,
        +                 boolean debug)
        +
        Constructor method.
        +
        +
        Parameters:
        +
        groupDesc - The block byte dump.
        +
        debug - Whether debug mode is active or not.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getInodeTablePointer

        +
        public int getInodeTablePointer()
        +
        Accessor function.
        +
        +
        Returns:
        +
        The inode table pointer of the block group.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/doc/Inode.html b/doc/Inode.html new file mode 100755 index 0000000..4e86939 --- /dev/null +++ b/doc/Inode.html @@ -0,0 +1,344 @@ + + + + + +Inode + + + + + + + + + + + + +
+

Class Inode

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • Inode
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class Inode
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      Inode(short fileMode, + short uID, + int fileSizeLower, + int lastAccessed, + int creationTime, + int lastModified, + int deletionTime, + short gID, + short hardLinks, + int[] blockPointers, + int indirectPointer, + int dIndirectPointer, + int tIndirectPointer, + int fileSizeUpper, + boolean debug) +
      Constructor method.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      intgetBlockPointer(int blockID) +
      Accessor function.
      +
      intgetFileSizeLower() +
      Accessor function.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Inode

        +
        public Inode(short fileMode,
        +             short uID,
        +             int fileSizeLower,
        +             int lastAccessed,
        +             int creationTime,
        +             int lastModified,
        +             int deletionTime,
        +             short gID,
        +             short hardLinks,
        +             int[] blockPointers,
        +             int indirectPointer,
        +             int dIndirectPointer,
        +             int tIndirectPointer,
        +             int fileSizeUpper,
        +             boolean debug)
        +
        Constructor method.
        +
        +
        Parameters:
        +
        fileMode - The file mode.
        +
        uID - The owner user ID.
        +
        fileSizeLower - The lower 32 bits of the file size.
        +
        lastAccessed - The time of last access.
        +
        creationTime - The time of creation.
        +
        lastModified - The time of last modification.
        +
        deletionTime - The time of deletion.
        +
        gID - The owner group ID.
        +
        hardLinks - The number of hard links to the file.
        +
        blockPointers - The twelve block pointers.
        +
        indirectPointer - The indirect block pointer.
        +
        dIndirectPointer - The double indirect block pointer.
        +
        tIndirectPointer - The triple indirect block pointer.
        +
        fileSizeUpper - The upper 32 bits of the file size.
        +
        debug - Whether debug mode is active or not.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getBlockPointer

        +
        public int getBlockPointer(int blockID)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        blockID - The index of the block.
        +
        Returns:
        +
        The block pointer.
        +
        +
      • +
      + + + +
        +
      • +

        getFileSizeLower

        +
        public int getFileSizeLower()
        +
        Accessor function.
        +
        +
        Returns:
        +
        The lower 32 bits of the filesize.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/doc/SuperBlock.html b/doc/SuperBlock.html new file mode 100755 index 0000000..cfaa9bd --- /dev/null +++ b/doc/SuperBlock.html @@ -0,0 +1,430 @@ + + + + + +SuperBlock + + + + + + + + + + + + +
+

Class SuperBlock

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • Block
    • +
    • +
        +
      • SuperBlock
      • +
      +
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public final class SuperBlock
    +extends Block
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        SuperBlock

        +
        public SuperBlock(java.nio.ByteBuffer superBlock,
        +                  boolean debug)
        +
        Constructor method.
        +
        +
        Parameters:
        +
        superBlock - The block byte dump.
        +
        debug - Whether debug mode is active or not.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getNumofInodes

        +
        public int getNumofInodes()
        +
        Accessor function.
        +
        +
        Returns:
        +
        The number of inodes.
        +
        +
      • +
      + + + +
        +
      • +

        getNumofBlocks

        +
        public int getNumofBlocks()
        +
        Accessor function.
        +
        +
        Returns:
        +
        The number of blocks.
        +
        +
      • +
      + + + +
        +
      • +

        getBlocksPerGroup

        +
        public int getBlocksPerGroup()
        +
        Accessor function.
        +
        +
        Returns:
        +
        The number of blocks per block group.
        +
        +
      • +
      + + + +
        +
      • +

        getInodesPerGroup

        +
        public int getInodesPerGroup()
        +
        Accessor function.
        +
        +
        Returns:
        +
        The number of inodes per block group.
        +
        +
      • +
      + + + +
        +
      • +

        getInodeSize

        +
        public int getInodeSize()
        +
        Accessor function.
        +
        +
        Returns:
        +
        The size of inodes in bytes.
        +
        +
      • +
      + + + +
        +
      • +

        getVolumeLabel

        +
        public java.lang.String getVolumeLabel()
        +
        Accessor function.
        +
        +
        Returns:
        +
        The label of the volume.
        +
        +
      • +
      + + + +
        +
      • +

        getNumofBlockGroups

        +
        public int getNumofBlockGroups()
        +
        Accessor function.
        +
        +
        Returns:
        +
        The number of of block groups.
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/doc/Volume.html b/doc/Volume.html new file mode 100755 index 0000000..d22d8eb --- /dev/null +++ b/doc/Volume.html @@ -0,0 +1,375 @@ + + + + + +Volume + + + + + + + + + + + + +
+

Class Volume

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • Volume
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public class Volume
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      intBLOCK_SIZE 
      intINODE_SIZE 
      +
    • +
    + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      Volume(java.lang.String fileName) +
      Constructor method.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      Block[]getFile(java.lang.String fileName) +
      Accessor function.
      +
      voidlistDir(java.lang.String dirName) +
      Prints the directory listing.
      +
      voidlistRoot() +
      Prints the directory listing.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Volume

        +
        public Volume(java.lang.String fileName)
        +
        Constructor method.
        +
        +
        Parameters:
        +
        fileName - The name of the ext2 dump.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getFile

        +
        public Block[] getFile(java.lang.String fileName)
        +
        Accessor function.
        +
        +
        Parameters:
        +
        fileName - The name of the file.
        +
        Returns:
        +
        The array of Blocks the file covers.
        +
        +
      • +
      + + + +
        +
      • +

        listDir

        +
        public void listDir(java.lang.String dirName)
        +
        Prints the directory listing.
        +
        +
        Parameters:
        +
        dirName - The directory name.
        +
        +
      • +
      + + + +
        +
      • +

        listRoot

        +
        public void listRoot()
        +
        Prints the directory listing.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/doc/allclasses-frame.html b/doc/allclasses-frame.html new file mode 100755 index 0000000..26f7045 --- /dev/null +++ b/doc/allclasses-frame.html @@ -0,0 +1,27 @@ + + + + + +All Classes + + + + + +

All Classes

+ + + diff --git a/doc/allclasses-noframe.html b/doc/allclasses-noframe.html new file mode 100755 index 0000000..aee0ba0 --- /dev/null +++ b/doc/allclasses-noframe.html @@ -0,0 +1,27 @@ + + + + + +All Classes + + + + + +

All Classes

+ + + diff --git a/doc/constant-values.html b/doc/constant-values.html new file mode 100755 index 0000000..15b1352 --- /dev/null +++ b/doc/constant-values.html @@ -0,0 +1,288 @@ + + + + + +Constant Field Values + + + + + + + + + + + +
+

Constant Field Values

+

Contents

+ +
+
+ + +

<Unnamed>.*

+ +
+ + + + + + diff --git a/doc/deprecated-list.html b/doc/deprecated-list.html new file mode 100755 index 0000000..51ee807 --- /dev/null +++ b/doc/deprecated-list.html @@ -0,0 +1,120 @@ + + + + + +Deprecated List + + + + + + + + +
+ + + + + + + +
+ + +
+

Deprecated API

+

Contents

+
+ +
+ + + + + + + +
+ + + + diff --git a/doc/help-doc.html b/doc/help-doc.html new file mode 100755 index 0000000..5d7545c --- /dev/null +++ b/doc/help-doc.html @@ -0,0 +1,217 @@ + + + + + +API Help + + + + + + + + + + + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+
    +
  • +

    Package

    +

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    +
      +
    • Interfaces (italic)
    • +
    • Classes
    • +
    • Enums
    • +
    • Exceptions
    • +
    • Errors
    • +
    • Annotation Types
    • +
    +
  • +
  • +

    Class/Interface

    +

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
      +
    • Class inheritance diagram
    • +
    • Direct Subclasses
    • +
    • All Known Subinterfaces
    • +
    • All Known Implementing Classes
    • +
    • Class/interface declaration
    • +
    • Class/interface description
    • +
    +
      +
    • Nested Class Summary
    • +
    • Field Summary
    • +
    • Constructor Summary
    • +
    • Method Summary
    • +
    +
      +
    • Field Detail
    • +
    • Constructor Detail
    • +
    • Method Detail
    • +
    +

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    +
  • +
  • +

    Annotation Type

    +

    Each annotation type has its own separate page with the following sections:

    +
      +
    • Annotation Type declaration
    • +
    • Annotation Type description
    • +
    • Required Element Summary
    • +
    • Optional Element Summary
    • +
    • Element Detail
    • +
    +
  • +
  • +

    Enum

    +

    Each enum has its own separate page with the following sections:

    +
      +
    • Enum declaration
    • +
    • Enum description
    • +
    • Enum Constant Summary
    • +
    • Enum Constant Detail
    • +
    +
  • +
  • +

    Tree (Class Hierarchy)

    +

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    +
      +
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • +
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    • +
    +
  • +
  • +

    Deprecated API

    +

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    +
  • +
  • +

    Index

    +

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

    +
  • +
  • +

    Prev/Next

    +

    These links take you to the next or previous class, interface, package, or related page.

    +
  • +
  • +

    Frames/No Frames

    +

    These links show and hide the HTML frames. All pages are available with or without frames.

    +
  • +
  • +

    All Classes

    +

    The All Classes link shows all classes and interfaces except non-static nested types.

    +
  • +
  • +

    Serialized Form

    +

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    +
  • +
  • +

    Constant Field Values

    +

    The Constant Field Values page lists the static final fields and their values.

    +
  • +
+This help file applies to API documentation generated using the standard doclet.
+ + + + + + diff --git a/doc/index-all.html b/doc/index-all.html new file mode 100755 index 0000000..07469d1 --- /dev/null +++ b/doc/index-all.html @@ -0,0 +1,409 @@ + + + + + +Index + + + + + + + + + + + +
B D E G H I L M N S T V  + + +

B

+
+
Benix - Class in <Unnamed>
+
 
+
Benix() - Constructor for class Benix
+
 
+
Block - Class in <Unnamed>
+
 
+
Block(ByteBuffer, boolean) - Constructor for class Block
+
+
Constructor method.
+
+
BLOCK_SIZE - Variable in class Block
+
 
+
BLOCK_SIZE - Variable in class BlockGroup
+
 
+
BLOCK_SIZE - Variable in class Ext2File
+
 
+
BLOCK_SIZE - Variable in class Volume
+
 
+
BlockGroup - Class in <Unnamed>
+
 
+
BlockGroup(ByteBuffer, boolean) - Constructor for class BlockGroup
+
+
Constructor method.
+
+
+ + + +

D

+
+
Directory - Class in <Unnamed>
+
 
+
Directory(Block[], boolean) - Constructor for class Directory
+
+
Constructor method.
+
+
+ + + +

E

+
+
Ext2File - Class in <Unnamed>
+
 
+
Ext2File(Block[], boolean) - Constructor for class Ext2File
+
+
Constructor method.
+
+
+ + + +

G

+
+
get() - Method in class Block
+
+
Gets one byte, increments the pointer.
+
+
get(int) - Method in class Block
+
+
Gets one byte from a given index.
+
+
getBlock(int) - Method in class BlockGroup
+
+
Accessor function.
+
+
getBlock(int) - Method in class Ext2File
+
+
Accessor function.
+
+
getBlockPointer(int) - Method in class Inode
+
+
Accessor function.
+
+
getBlocksPerGroup() - Method in class SuperBlock
+
+
Accessor function.
+
+
getFile(String) - Method in class Volume
+
+
Accessor function.
+
+
getFileInodePointer(String) - Method in class BlockGroup
+
+
Accessor function.
+
+
getFileLength(String) - Method in class BlockGroup
+
+
Accessor function.
+
+
getFileNum(String) - Method in class Directory
+
+
Accessor function.
+
+
getFileSizeLower() - Method in class Inode
+
+
Accessor function.
+
+
getInode(int, boolean) - Method in class BlockGroup
+
+
Accessor function.
+
+
getInodePointer(int) - Method in class Directory
+
+
Accessor function.
+
+
getInodeSize() - Method in class SuperBlock
+
+
Accessor function.
+
+
getInodesPerGroup() - Method in class SuperBlock
+
+
Accessor function.
+
+
getInodeTablePointer() - Method in class GroupDesc
+
+
Accessor function.
+
+
getInt(int) - Method in class Block
+
+
Gets four bytes from a given index.
+
+
getLength(int) - Method in class Directory
+
+
Accessor function.
+
+
getName(int) - Method in class Directory
+
+
Accessor function.
+
+
getNameLength(int) - Method in class Directory
+
+
Accessor function.
+
+
getNumofBlockGroups() - Method in class SuperBlock
+
+
Accessor function.
+
+
getNumofBlocks() - Method in class SuperBlock
+
+
Accessor function.
+
+
getNumofFiles() - Method in class Directory
+
+
Accessor function.
+
+
getNumofInodes() - Method in class SuperBlock
+
+
Accessor function.
+
+
getShort(int) - Method in class Block
+
+
Gets two bytes from a given index.
+
+
getType(int) - Method in class Directory
+
+
Accessor function.
+
+
getTypeIndicator(int) - Method in class Directory
+
+
Accessor function.
+
+
getVolumeLabel() - Method in class SuperBlock
+
+
Accessor function.
+
+
GroupDesc - Class in <Unnamed>
+
 
+
GroupDesc(ByteBuffer, boolean) - Constructor for class GroupDesc
+
+
Constructor method.
+
+
+ + + +

H

+
+
hexDump() - Method in class Block
+
+
Prints a formatted hex dump of the block's contents.
+
+
hexDump() - Method in class Ext2File
+
+
Prints a formatted hex dump of the block's contents.
+
+
+ + + +

I

+
+
Inode - Class in <Unnamed>
+
 
+
Inode(short, short, int, int, int, int, int, short, short, int[], int, int, int, int, boolean) - Constructor for class Inode
+
+
Constructor method.
+
+
INODE_FIELD_SIZE - Variable in class Directory
+
 
+
INODE_SIZE - Variable in class BlockGroup
+
 
+
INODE_SIZE - Variable in class Volume
+
 
+
+ + + +

L

+
+
LENGTH_FIELD_OFFSET - Variable in class Directory
+
 
+
LENGTH_FIELD_SIZE - Variable in class Directory
+
 
+
listDir() - Method in class BlockGroup
+
+
Prints the directory listing.
+
+
listDir() - Method in class Directory
+
+
Prints the directory listing.
+
+
listDir(String) - Method in class Volume
+
+
Prints the directory listing.
+
+
listRoot() - Method in class Volume
+
+
Prints the directory listing.
+
+
+ + + +

M

+
+
main(String[]) - Static method in class Benix
+
+
Interacts with the Benix API
+
+
+ + + +

N

+
+
NAME_FIELD_OFFSET - Variable in class Directory
+
 
+
NAME_LENGTH_FIELD_OFFSET - Variable in class Directory
+
 
+
NAME_LENGTH_FIELD_SIZE - Variable in class Directory
+
 
+
+ + + +

S

+
+
SuperBlock - Class in <Unnamed>
+
 
+
SuperBlock(ByteBuffer, boolean) - Constructor for class SuperBlock
+
+
Constructor method.
+
+
+ + + +

T

+
+
TYPE_INDICATOR_FIELD_OFFSET - Variable in class Directory
+
 
+
TYPE_INDICATOR_FIELD_SIZE - Variable in class Directory
+
 
+
+ + + +

V

+
+
Volume - Class in <Unnamed>
+
 
+
Volume(String) - Constructor for class Volume
+
+
Constructor method.
+
+
+B D E G H I L M N S T V 
+ + + + + + diff --git a/doc/index.html b/doc/index.html new file mode 100755 index 0000000..0422a30 --- /dev/null +++ b/doc/index.html @@ -0,0 +1,71 @@ + + + + + +Generated Documentation (Untitled) + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="Benix.html">Non-frame version</a>.</p> + + + diff --git a/doc/overview-tree.html b/doc/overview-tree.html new file mode 100755 index 0000000..a2e1247 --- /dev/null +++ b/doc/overview-tree.html @@ -0,0 +1,143 @@ + + + + + +Class Hierarchy + + + + + + + + + + + +
+

Hierarchy For All Packages

+
+
+

Class Hierarchy

+ +
+ + + + + + diff --git a/doc/package-frame.html b/doc/package-frame.html new file mode 100755 index 0000000..58deefe --- /dev/null +++ b/doc/package-frame.html @@ -0,0 +1,28 @@ + + + + + +<Unnamed> + + + + + +

<Unnamed>

+ + + diff --git a/doc/package-list b/doc/package-list new file mode 100755 index 0000000..d3f5a12 --- /dev/null +++ b/doc/package-list @@ -0,0 +1 @@ + diff --git a/doc/package-summary.html b/doc/package-summary.html new file mode 100755 index 0000000..dd08e1b --- /dev/null +++ b/doc/package-summary.html @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + +
+

Package <Unnamed>

+
+
+ +
+ + + + + + diff --git a/doc/package-tree.html b/doc/package-tree.html new file mode 100755 index 0000000..b19537e --- /dev/null +++ b/doc/package-tree.html @@ -0,0 +1,143 @@ + + + + + + Class Hierarchy + + + + + + + + + + + +
+

Hierarchy For Package <Unnamed>

+
+
+

Class Hierarchy

+ +
+ + + + + + diff --git a/doc/script.js b/doc/script.js new file mode 100755 index 0000000..c3a1cae --- /dev/null +++ b/doc/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/doc/stylesheet.css b/doc/stylesheet.css new file mode 100755 index 0000000..b8dad08 --- /dev/null +++ b/doc/stylesheet.css @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff --git a/src/Benix.java b/src/Benix.java new file mode 100755 index 0000000..fe96df0 --- /dev/null +++ b/src/Benix.java @@ -0,0 +1,47 @@ +/****************************************************************************** + * Benix 0.8 * + * Copyright © 2015 Ben Goldsworthy (rumps) * + * * + * A program to simulate an OS and read a file store. * + * * + * This file is part of Benix. * + * * + * Benix 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. * + * * + * Benix 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 Benix. If not, see . * + ******************************************************************************/ + +/** + ** This class runs the OS. + **/ + +/** + ** @author Ben Goldsworthy (rumps) + ** @version 0.8 + **/ +public class Benix { + /** + ** Interacts with the Benix API + ** + ** @param args arguments passed in from the command line. + **/ + public static void main(String[] args) { + // mounts the volume + Volume vol = new Volume("../ext2fs"); + vol.listRoot(); + + Ext2File file = new Ext2File(vol.getFile("two-cities"), false); + + Directory dir = new Directory(vol.getFile("lost+found"), false); + dir.listDir(); + } +} diff --git a/src/Block.java b/src/Block.java new file mode 100755 index 0000000..d877d27 --- /dev/null +++ b/src/Block.java @@ -0,0 +1,112 @@ +/****************************************************************************** + * Benix 0.8 * + * Copyright © 2015 Ben Goldsworthy (rumps) * + * * + * A program to simulate an OS and read a file store. * + * * + * This file is part of Benix. * + * * + * Benix 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. * + * * + * Benix 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 Benix. If not, see . * + ******************************************************************************/ + +/** + ** This class represents a block. + **/ + +import java.nio.ByteBuffer; +import java.lang.StringBuffer; + +/** + ** @author Ben Goldsworthy (rumps) + ** @version 0.8 + **/ +public class Block { + public final int BLOCK_SIZE = 1024; + + ByteBuffer block; + + /** + ** Constructor method. + ** + ** @param block The block byte dump. + ** @param debug Whether debug mode is active or not. + **/ + public Block(ByteBuffer block, boolean debug) { + this.block = block; + } + + /** + ** Gets one byte, increments the pointer. + ** + ** @return A byte. + **/ + public byte get() { + return block.get(); + } + /** + ** Gets one byte from a given index. + ** + ** @param index The index. + ** @return A byte. + **/ + public byte get(int index) { + return block.get(index); + } + + /** + ** Gets two bytes from a given index. + ** + ** @param index The index. + ** @return A short. + **/ + public short getShort(int index) { + return block.getShort(index); + } + + /** + ** Gets four bytes from a given index. + ** + ** @param index The index. + ** @return An int. + **/ + public int getInt(int index) { + return block.getInt(index); + } + + /** + ** Prints a formatted hex dump of the block's contents. + **/ + public void hexDump() { + StringBuffer hexDump; + StringBuffer ASCIIVals; + byte val; + while (block.hasRemaining()) { + hexDump = new StringBuffer(); + ASCIIVals = new StringBuffer(); + for (int i = 0; i < 8; i++) { + val = block.get(); + hexDump.append(String.format("%02X ", val)); + ASCIIVals.append(((val > 31 && val < 126) ? (char)val : ".") + " "); + } + hexDump.append("| ");ASCIIVals.append("| "); + for (int i = 0; i < 8; i++) { + val = block.get(); + hexDump.append(String.format("%02X ", val)); + ASCIIVals.append(((val > 31 && val < 126) ? (char)val : ".") + " "); + } + hexDump.append("| ");ASCIIVals.append("| "); + System.out.println(hexDump.toString() + " | " + ASCIIVals.toString()); + } + } +} diff --git a/src/BlockGroup.java b/src/BlockGroup.java new file mode 100755 index 0000000..2704c66 --- /dev/null +++ b/src/BlockGroup.java @@ -0,0 +1,176 @@ +/****************************************************************************** + * Benix 0.8 * + * Copyright © 2015 Ben Goldsworthy (rumps) * + * * + * A program to simulate an OS and read a file store. * + * * + * This file is part of Benix. * + * * + * Benix 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. * + * * + * Benix 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 Benix. If not, see . * + ******************************************************************************/ + +/** + ** This class represents a block group. + **/ + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.BufferOverflowException; +import java.nio.BufferUnderflowException; +import java.nio.ReadOnlyBufferException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +/** + ** @author Ben Goldsworthy (rumps) + ** @version 0.8 + **/ +public class BlockGroup { + public final int BLOCK_SIZE = 1024; + public final int INODE_SIZE = 128; + private final int INODES_PER_BLOCK = BLOCK_SIZE/INODE_SIZE; // 8 + private final int INODE_TABLE_SIZE = 218; // inodes per group/inodes per block + + ByteBuffer blockGroup; + private SuperBlock superBlock; + private GroupDesc groupDesc; + private Block inodeTable; + private Inode rootInode; + private Directory rootDir; + + /** + ** Constructor method. + ** + ** @param block The blockgroup byte dump. + ** @param debug Whether debug mode is active or not. + **/ + public BlockGroup(ByteBuffer block, boolean debug) { + this.blockGroup = block; + + // could probably get rid of this, but for now gets blocks holding + // information on rest of volume + this.superBlock = new SuperBlock(this.getBlock(1), debug); + this.groupDesc = new GroupDesc(this.getBlock(2), debug); + + // gets the first block of the inode table, and the inode for root + this.inodeTable = new Block(this.getBlock(this.groupDesc.getInodeTablePointer()), debug); + this.rootInode = getInode(2, debug); + + // gets the root directory + int numofRootBlocks = (int)Math.ceil(this.rootInode.getFileSizeLower()/BLOCK_SIZE); + Block[] rootDirBlocks = new Block[numofRootBlocks]; + for(int i = 0; i < numofRootBlocks; i++) + rootDirBlocks[i] = new Block(this.getBlock(rootInode.getBlockPointer(0)), false); + this.rootDir = new Directory(rootDirBlocks, debug); + } + + /** + * Accessor function. + * + * @param id The index of the block. + * @return A Block. + */ + public ByteBuffer getBlock(int id) { + byte block[] = new byte[BLOCK_SIZE]; + try { + this.blockGroup.position(BLOCK_SIZE * --id); + this.blockGroup.get(block); + + ByteBuffer theBlock = ByteBuffer.allocate(BLOCK_SIZE).order(ByteOrder.LITTLE_ENDIAN); + + theBlock.put(block); + theBlock.flip(); + + return theBlock; + } catch (BufferOverflowException ex) { + System.out.println("BOFE"); + } catch (BufferUnderflowException ex) { + System.out.println("BOFE"); + } catch (ReadOnlyBufferException ex) { + System.out.println("ROBE"); + } + return null; + } + + /** + * Accessor function. + * + * @param id The index of the inode. + * @param debug Whether debug mode is active or not. + * @return An Inode. + */ + public Inode getInode(int id, boolean debug) { + int offset; + Block inodeTableBlock; + // gets the correct block for the inode + if(id <= INODES_PER_BLOCK) { + offset = INODE_SIZE * --id; + inodeTableBlock = inodeTable; + } else { + int blockOffset = (int)Math.floor(id/INODES_PER_BLOCK); + id = id - (8 * blockOffset); + offset = INODE_SIZE * --id; + inodeTableBlock = new Block(this.getBlock(this.groupDesc.getInodeTablePointer() + blockOffset), false); + } + + // gets the data blocks from the inode + int[] blocks = new int[12]; + for (int i = 0; i < 12; i++) blocks[i] = inodeTableBlock.getInt(offset + (40 + (i * 4))); + + return new Inode( inodeTableBlock.getShort(offset+0), + inodeTableBlock.getShort(offset+2), + inodeTableBlock.getInt(offset+4), + inodeTableBlock.getInt(offset+8), + inodeTableBlock.getInt(offset+12), + inodeTableBlock.getInt(offset+16), + inodeTableBlock.getInt(offset+20), + inodeTableBlock.getShort(offset+24), + inodeTableBlock.getShort(offset+26), + blocks, + inodeTableBlock.getInt(offset+88), + inodeTableBlock.getInt(offset+92), + inodeTableBlock.getInt(offset+96), + inodeTableBlock.getInt(offset+108), debug); + } + + /** + * Prints the directory listing. + */ + public void listDir() { + this.rootDir.listDir(); + } + + /** + * Accessor function. + * + * @param fileName The filename. + * @return The file's inode pointer. + */ + public int getFileInodePointer(String fileName) { + int id = this.rootDir.getFileNum(fileName); + if(id != -1) + return this.rootDir.getInodePointer(id); + else return -1; + } + + /** + * Accessor function. + * + * @param fileName The filename. + * @return The file's length. + */ + public int getFileLength(String fileName) { + return this.rootDir.getLength(this.rootDir.getFileNum(fileName)); + } +} diff --git a/src/Directory.java b/src/Directory.java new file mode 100755 index 0000000..40d62fb --- /dev/null +++ b/src/Directory.java @@ -0,0 +1,162 @@ +/****************************************************************************** + * Benix 0.8 * + * Copyright © 2015 Ben Goldsworthy (rumps) * + * * + * A program to simulate an OS and read a file store. * + * * + * This file is part of Benix. * + * * + * Benix 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. * + * * + * Benix 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 Benix. If not, see . * + ******************************************************************************/ + +/** + ** This class represents a directory. + **/ + +import java.lang.StringBuffer; + +/** + ** @author Ben Goldsworthy (rumps) + ** @version 0.8 + **/ +public class Directory extends Ext2File { + public final int INODE_FIELD_SIZE = 4, LENGTH_FIELD_SIZE = 2, + NAME_LENGTH_FIELD_SIZE = 1, TYPE_INDICATOR_FIELD_SIZE = 1, + LENGTH_FIELD_OFFSET = 4, NAME_LENGTH_FIELD_OFFSET = 6, TYPE_INDICATOR_FIELD_OFFSET = 7, NAME_FIELD_OFFSET = 8; + + /** + ** Constructor method. + ** + ** @param content The array of Blocks containing the file. + ** @param debug Whether debug mode is active or not. + **/ + public Directory(Block[] content, boolean debug) { + super(content, debug); + } + + /** + * Accessor function. + * + * @param fileName The name of the file. + * @return The index of the file. + */ + public int getFileNum(String fileName) { + for(int i = 0; i < this.getNumofFiles(); i++) { + if (this.getName(i).equals(fileName)) return i; + } + return -1; + } + + /* + * I don't remember what this does but it breaks when I try to get rid of it. + */ + private int getFileOffset(int fileNum) { + if(fileNum <= 0) return -1; + short val = 0; + for(int i = 0; i < fileNum-1; i++) val += this.getBlock(1).getShort(val+4); + return (val != 1024) ? val : -1; + } + + /** + * Accessor function. + * + * @return The number of files in the directory. + */ + public int getNumofFiles() { + int num; + boolean end = false; + for(num = 1; !end && num < BLOCK_SIZE; num++) + end = (this.getFileOffset(num) != -1) ? false : true; + return num - 2; + } + + /** + * Accessor function. + * + * @param fileNum The index of the file. + * @return The inode pointer of the file. + */ + public int getInodePointer(int fileNum) { + return this.getBlock(1).getInt(getFileOffset(fileNum)); + } + + /** + * Accessor function. + * + * @param fileNum The index of the file. + * @return The length of the file. + */ + public short getLength(int fileNum) { + return this.getBlock(1).getShort(getFileOffset(fileNum) + LENGTH_FIELD_OFFSET); + } + + /** + * Accessor function. + * + * @param fileNum The index of the file. + * @return The length of the name of the file. + */ + public byte getNameLength(int fileNum) { + return this.getBlock(1).get(getFileOffset(fileNum) + NAME_LENGTH_FIELD_OFFSET); + } + + /** + * Accessor function. + * + * @param fileNum The index of the file. + * @return The type character of the file. + */ + public char getType(int fileNum) { + switch(this.getTypeIndicator(fileNum)) { + case 1: return '-'; + case 2: return 'd'; + default: return ' '; + } + } + + /** + * Accessor function. + * + * @param fileNum The index of the file. + * @return The type indicator of the file. + */ + public byte getTypeIndicator(int fileNum) { + return this.getBlock(1).get(getFileOffset(fileNum) + TYPE_INDICATOR_FIELD_OFFSET); + } + + /** + * Accessor function. + * + * @param fileNum The index of the file. + * @return The name of the file. + */ + public String getName(int fileNum) { + StringBuffer fileName = new StringBuffer(); + int offset = this.getFileOffset(fileNum) + NAME_FIELD_OFFSET, + end = offset + this.getNameLength(fileNum); + for(int i = offset; i < end; i++) + fileName.append((char)this.getBlock(1).get(i)); + return fileName.toString(); + } + + /** + * Prints the directory listing. + */ + public void listDir() { + for(int i = 1; i <= this.getNumofFiles(); i++) { + System.out.println(this.getType(i) + "\t" + this.getLength(i) + "\t" + this.getNameLength(i) + "\t" + this.getTypeIndicator(i) + "\t" + this.getName(i)); + + } + } +} diff --git a/src/Ext2File.java b/src/Ext2File.java new file mode 100755 index 0000000..8558dd6 --- /dev/null +++ b/src/Ext2File.java @@ -0,0 +1,73 @@ +/****************************************************************************** + * Benix 0.8 * + * Copyright © 2015 Ben Goldsworthy (rumps) * + * * + * A program to simulate an OS and read a file store. * + * * + * This file is part of Benix. * + * * + * Benix 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. * + * * + * Benix 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 Benix. If not, see . * + ******************************************************************************/ + +/** + ** This class represents a Ext2 file. + **/ + +/** + ** @author Ben Goldsworthy (rumps) + ** @version 0.8 + **/ +public class Ext2File { + public final int BLOCK_SIZE = 1024; + + private Block[] content; + + /** + ** Constructor method. + ** + ** @param blocks The array of Blocks containing the file. + ** @param debug Whether debug mode is active or not. + **/ + public Ext2File(Block[] blocks, boolean debug) { + this.content = new Block[blocks.length]; + for(int i = 0; i < blocks.length; i++) { + this.content[i] = blocks[i]; + } + + if (debug) { + System.out.println("-----Values read from file-----"); + for(int i = 0; i < this.content.length; i++) + this.content[i].hexDump(); + System.out.println("-------------------------------------"); + } + } + + /** + * Accessor function. + * + * @param num The Index of the block. + * @return The Block. + */ + public Block getBlock(int num) { + return content[--num]; + } + + /** + ** Prints a formatted hex dump of the block's contents. + **/ + public void hexDump() { + for(int i = 0; i < this.content.length; i++) + this.content[i].hexDump(); + } +} diff --git a/src/GroupDesc.java b/src/GroupDesc.java new file mode 100755 index 0000000..50180b2 --- /dev/null +++ b/src/GroupDesc.java @@ -0,0 +1,59 @@ +/****************************************************************************** + * Benix 0.8 * + * Copyright © 2015 Ben Goldsworthy (rumps) * + * * + * A program to simulate an OS and read a file store. * + * * + * This file is part of Benix. * + * * + * Benix 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. * + * * + * Benix 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 Benix. If not, see . * + ******************************************************************************/ + +/** + ** This class represents a group descriptor block. + **/ + +import java.nio.ByteBuffer; +import java.lang.StringBuffer; + +/** + ** @author Ben Goldsworthy (rumps) + ** @version 0.8 + **/ +final public class GroupDesc extends Block { + /** + ** Constructor method. + ** + ** @param groupDesc The block byte dump. + ** @param debug Whether debug mode is active or not. + **/ + public GroupDesc(ByteBuffer groupDesc, boolean debug) { + super(groupDesc, false); + + if (debug) { + System.out.println("-----Values read from group desc-----"); + System.out.println("Inode Table Pointer: " + getInodeTablePointer()); + System.out.println("-------------------------------------"); + } + } + + /** + * Accessor function. + * + * @return The inode table pointer of the block group. + */ + public int getInodeTablePointer() { + return block.getInt(8); + } +} diff --git a/src/Inode.java b/src/Inode.java new file mode 100755 index 0000000..5e97021 --- /dev/null +++ b/src/Inode.java @@ -0,0 +1,115 @@ +/****************************************************************************** + * Benix 0.8 * + * Copyright © 2015 Ben Goldsworthy (rumps) * + * * + * A program to simulate an OS and read a file store. * + * * + * This file is part of Benix. * + * * + * Benix 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. * + * * + * Benix 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 Benix. If not, see . * + ******************************************************************************/ + +/** + ** This class represents an inode. + **/ + +import java.util.Date; +/** + ** @author Ben Goldsworthy (rumps) + ** @version 0.8 + **/ +public class Inode { + private short fileMode, uID, gID, hardLinks; + private int fileSizeLower, indirectPointer, dIndirectPointer, + tIndirectPointer, fileSizeUpper; + private Date lastAccessed, creationTime, lastModified, deletionTime; + private int[] blockPointers = new int[12]; + + /** + ** Constructor method. + ** + ** @param fileMode The file mode. + ** @param uID The owner user ID. + ** @param fileSizeLower The lower 32 bits of the file size. + ** @param lastAccessed The time of last access. + ** @param creationTime The time of creation. + ** @param lastModified The time of last modification. + ** @param deletionTime The time of deletion. + ** @param gID The owner group ID. + ** @param hardLinks The number of hard links to the file. + ** @param blockPointers The twelve block pointers. + ** @param indirectPointer The indirect block pointer. + ** @param dIndirectPointer The double indirect block pointer. + ** @param tIndirectPointer The triple indirect block pointer. + ** @param fileSizeUpper The upper 32 bits of the file size. + ** @param debug Whether debug mode is active or not. + **/ + public Inode(short fileMode, short uID, int fileSizeLower, int lastAccessed, + int creationTime, int lastModified, int deletionTime, short gID, + short hardLinks, int blockPointers[], int indirectPointer, + int dIndirectPointer, int tIndirectPointer, int fileSizeUpper, + boolean debug) { + this.fileMode = fileMode; + this.uID = uID; + this.fileSizeLower = fileSizeLower; + this.lastAccessed = new Date((long)lastAccessed * 1000); + this.creationTime = new Date((long)creationTime * 1000); + this.lastModified = new Date((long)lastModified * 1000); + this.deletionTime = (deletionTime != 0) ? new Date((long)deletionTime * 1000) : null; + this.gID = gID; + this.hardLinks = hardLinks; + this.blockPointers = blockPointers; + this.indirectPointer = indirectPointer; + this.dIndirectPointer = dIndirectPointer; + this.tIndirectPointer = tIndirectPointer; + this.fileSizeUpper = fileSizeUpper; + + if (debug) { + System.out.println("-----Values read from inode-----"); + System.out.println("File Mode: " + this.fileMode); + System.out.println("Owner User ID: " + this.uID); + System.out.println("File Size (lower 32-bits): " + this.fileSizeLower); + System.out.println("File Size (upper 32-bits): " + this.fileSizeUpper); + System.out.println("Last Accessed Time: " + this.lastAccessed); + System.out.println("Creation Time: " + this.creationTime); + System.out.println("Last Modify Time: " + this.lastModified); + System.out.println("Deletion Time: " + this.deletionTime); + System.out.println("Owner Group ID: " + this.gID); + for (int i = 0; i < 12; i++) System.out.println("Block Pointer " + i + ": " + this.blockPointers[i]); + System.out.println("Indirect Pointer: " + this.indirectPointer); + System.out.println("Double Indirect Pointer: " + this.dIndirectPointer); + System.out.println("Triple Indirect Pointer: " + this.tIndirectPointer); + System.out.println("-------------------------------------"); + } + } + + /** + * Accessor function. + * + * @param blockID The index of the block. + * @return The block pointer. + */ + public int getBlockPointer(int blockID) { + return this.blockPointers[blockID]; + } + + /** + * Accessor function. + * + * @return The lower 32 bits of the filesize. + */ + public int getFileSizeLower() { + return this.fileSizeLower; + } +} diff --git a/src/SuperBlock.java b/src/SuperBlock.java new file mode 100755 index 0000000..c38b1f4 --- /dev/null +++ b/src/SuperBlock.java @@ -0,0 +1,123 @@ +/****************************************************************************** + * Benix 0.8 * + * Copyright © 2015 Ben Goldsworthy (rumps) * + * * + * A program to simulate an OS and read a file store. * + * * + * This file is part of Benix. * + * * + * Benix 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. * + * * + * Benix 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 Benix. If not, see . * + ******************************************************************************/ + +/** + ** This class represents a superblock. + **/ + +import java.nio.ByteBuffer; +import java.lang.StringBuffer; + +/** + ** @author Ben Goldsworthy (rumps) + ** @version 0.8 + **/ +final public class SuperBlock extends Block { + /** + ** Constructor method. + ** + ** @param superBlock The block byte dump. + ** @param debug Whether debug mode is active or not. + **/ + public SuperBlock(ByteBuffer superBlock, boolean debug) { + super(superBlock, false); + + if (debug) { + System.out.println("-----Values read from superblock-----"); + System.out.println("Number of inodes: " + this.getNumofInodes()); + System.out.println("Number of blocks: " + this.getNumofBlocks()); + System.out.println("Number of blocks per group: " + this.getBlocksPerGroup()); + System.out.println("Number of inodes per group: " + this.getInodesPerGroup()); + System.out.println("Inode size: " + this.getInodeSize() + " bytes"); + System.out.println("Volume label: " + this.getVolumeLabel()); + System.out.println("Size: " + this.getNumofBlocks() * BLOCK_SIZE + " bytes"); + System.out.println("Number of block groups: " + this.getNumofBlockGroups()); + System.out.println("-------------------------------------"); + } + } + + /** + * Accessor function. + * + * @return The number of inodes. + */ + public int getNumofInodes() { + return block.getInt(0); + } + + /** + * Accessor function. + * + * @return The number of blocks. + */ + public int getNumofBlocks() { + return block.getInt(4); + } + + /** + * Accessor function. + * + * @return The number of blocks per block group. + */ + public int getBlocksPerGroup() { + return block.getInt(32); + } + + /** + * Accessor function. + * + * @return The number of inodes per block group. + */ + public int getInodesPerGroup() { + return block.getInt(40); + } + + /** + * Accessor function. + * + * @return The size of inodes in bytes. + */ + public int getInodeSize() { + return block.getInt(88); + } + + /** + * Accessor function. + * + * @return The label of the volume. + */ + public String getVolumeLabel() { + StringBuffer volumeLabel = new StringBuffer(); + for (int i = 120; i < (120 + 16); i++) + volumeLabel.append((char)block.get(i)); + return volumeLabel.toString(); + } + + /** + * Accessor function. + * + * @return The number of of block groups. + */ + public int getNumofBlockGroups() { + return (int)Math.ceil(getNumofBlocks()/getBlocksPerGroup()); + } +} diff --git a/src/Volume.java b/src/Volume.java new file mode 100755 index 0000000..fcafec7 --- /dev/null +++ b/src/Volume.java @@ -0,0 +1,194 @@ +/****************************************************************************** + * Benix 0.8 * + * Copyright © 2015 Ben Goldsworthy (rumps) * + * * + * A program to simulate an OS and read a file store. * + * * + * This file is part of Benix. * + * * + * Benix 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. * + * * + * Benix 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 Benix. If not, see . * + ******************************************************************************/ + +/** + ** This class represents a volume. + **/ + +import java.io.RandomAccessFile; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.BufferOverflowException; +import java.nio.ReadOnlyBufferException; + +/** + ** @author Ben Goldsworthy (rumps) + ** @version 0.8 + **/ +public class Volume { + public final int BLOCK_SIZE = 1024; + public final int INODE_SIZE = 128; + + private RandomAccessFile file; + private SuperBlock superBlock; + private GroupDesc groupDesc; + private Block inodeTable; + private Inode rootInode; + private int numofBlockGroups; + BlockGroup[] blockGroups = new BlockGroup[numofBlockGroups]; + + /** + ** Constructor method. + ** + ** @param fileName The name of the ext2 dump. + **/ + public Volume(String fileName) { + try { + file = new RandomAccessFile(fileName, "r"); + + superBlock = new SuperBlock(getBlock(1), false); + groupDesc = new GroupDesc(getBlock(2), false); + + numofBlockGroups = superBlock.getNumofBlocks()/superBlock.getBlocksPerGroup(); + blockGroups = new BlockGroup[numofBlockGroups]; + for (int i = 0; i < numofBlockGroups; i++) { + byte blockGroup[] = new byte[BLOCK_SIZE * superBlock.getBlocksPerGroup()]; + try { + file.seek(BLOCK_SIZE); + file.read(blockGroup); + + ByteBuffer blockGroupBuf = ByteBuffer.allocate(BLOCK_SIZE * superBlock.getBlocksPerGroup()).order(ByteOrder.LITTLE_ENDIAN); + + blockGroupBuf.put(blockGroup); + blockGroupBuf.flip(); + + blockGroups[i] = new BlockGroup(blockGroupBuf, false); + } catch (IOException ex) { + System.out.println("ACK"); + } catch (BufferOverflowException ex) { + System.out.println("BOFE"); + } catch (ReadOnlyBufferException ex) { + System.out.println("ROBE"); + } + } + } catch (FileNotFoundException ex) { + System.out.println("AWSHIT"); + } + } + + /** + * Accessor function. + * + * @param id The index of the block. + * @return The block's byte dump. + */ + private ByteBuffer getBlock(int id) { + byte block[] = new byte[BLOCK_SIZE]; + try { + file.seek(BLOCK_SIZE * id); + file.read(block); + + ByteBuffer blockBuf = ByteBuffer.allocate(BLOCK_SIZE).order(ByteOrder.LITTLE_ENDIAN); + + blockBuf.put(block); + blockBuf.flip(); + + return blockBuf; + } catch (IOException ex) { + System.out.println("ACK"); + } catch (BufferOverflowException ex) { + System.out.println("BOFE"); + } catch (ReadOnlyBufferException ex) { + System.out.println("ROBE"); + } + return null; + } + + /** + * Accessor function. + * + * @param id The index of the inode. + * @param debug Whether debug mode is active or not. + * @return The Inode. + */ + private Inode getInode(int id, boolean debug) { + int blockgroup = (int)Math.floor((id - 1)/superBlock.getInodesPerGroup()); + // offset by 1 inode as we're after inode #2 + int offset = INODE_SIZE * --id; + int[] blocks = new int[12]; + for (int i = 0; i < 12; i++) blocks[i] = inodeTable.getInt(offset + (40 + (i * 4))); + + return new Inode( inodeTable.getShort(offset+0), + inodeTable.getShort(offset+2), + inodeTable.getInt(offset+4), + inodeTable.getInt(offset+8), + inodeTable.getInt(offset+12), + inodeTable.getInt(offset+16), + inodeTable.getInt(offset+20), + inodeTable.getShort(offset+24), + inodeTable.getShort(offset+26), + blocks, + inodeTable.getInt(offset+88), + inodeTable.getInt(offset+92), + inodeTable.getInt(offset+96), + inodeTable.getInt(offset+108), debug); + } + + /** + * Accessor function. + * + * @param fileName The name of the file. + * @return The array of Blocks the file covers. + */ + public Block[] getFile(String fileName) { + int iP = this.blockGroups[0].getFileInodePointer(fileName); + Inode inode = this.blockGroups[this.getInodeBG(iP)].getInode(iP, false); + int blocks = 0; + for(int i = 0; i < 12; i++) + if (inode.getBlockPointer(i) != 0) + blocks++; + + Block[] contentBlocks = new Block[blocks]; + for(int i = 0; i < blocks; i++) + contentBlocks[i] = new Block(this.getBlock(inode.getBlockPointer(i)), false); + + return contentBlocks; + } + + /** + * Accessor function. + * + * @param iP The inode pointer. + * @return The block group containing the inode. + */ + private int getInodeBG(int iP) { + return (int)Math.ceil(iP / this.superBlock.getInodesPerGroup()); + } + + /** + * Prints the directory listing. + * + * @param dirName The directory name. + */ + public void listDir(String dirName) { + this.blockGroups[0].listDir(); + } + + /** + * Prints the directory listing. + */ + public void listRoot() { + this.blockGroups[0].listDir(); + } +}