pax_global_header00006660000000000000000000000064146005151030014505gustar00rootroot0000000000000052 comment=68aaff5556afe26be749c29a2b7cbd714dce3050 libblockdev-3.1.1-1/000077500000000000000000000000001460051510300141255ustar00rootroot00000000000000libblockdev-3.1.1-1/.github/000077500000000000000000000000001460051510300154655ustar00rootroot00000000000000libblockdev-3.1.1-1/.github/workflows/000077500000000000000000000000001460051510300175225ustar00rootroot00000000000000libblockdev-3.1.1-1/.github/workflows/blivet-tests.yml000066400000000000000000000030151460051510300226710ustar00rootroot00000000000000name: Blivet tests on: pull_request: branches: - master jobs: build: name: blivet-tests runs-on: ubuntu-22.04 env: CI_CONTAINER: libblockdev-ci-blivet-tests steps: - name: Checkout libblockdev repository uses: actions/checkout@v4 - name: Install podman run: | sudo apt -qq update sudo apt -y -qq install podman - name: Build the container run: | podman build --no-cache -t ${{ env.CI_CONTAINER }} -f misc/ci.Dockerfile . - name: Start the container run: | podman run -d -t --name ${{ env.CI_CONTAINER }} --privileged --volume "$(pwd):/app" --workdir "/app" ${{ env.CI_CONTAINER }} - name: Install Blivet test dependencies in the container run: | podman exec -it ${{ env.CI_CONTAINER }} bash -c "ansible-playbook -i "localhost," -c local /blivet/misc/install-test-dependencies.yml" - name: Install libblockdev build dependencies in the container run: | podman exec -it ${{ env.CI_CONTAINER }} bash -c "ansible-playbook -i "localhost," -c local misc/install-test-dependencies.yml -e 'test_dependencies=false'" - name: Build and install libblockdev in the container run: | podman exec -it ${{ env.CI_CONTAINER }} bash -c "./autogen.sh && ./configure --prefix=/usr && make -j && make install" - name: Run Blivet tests in the container run: | podman exec -it ${{ env.CI_CONTAINER }} bash -c "cd /blivet && make check" libblockdev-3.1.1-1/.github/workflows/codeql-analysis.yml000066400000000000000000000020201460051510300233270ustar00rootroot00000000000000name: "CodeQL" on: push: branches: [ "master" ] pull_request: branches: [ "master" ] schedule: - cron: '29 9 * * 4' jobs: analyze: name: Analyze runs-on: ubuntu-22.04 permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: [ 'cpp', 'python' ] steps: - name: Checkout repository uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} - name: Install build dependencies run: | sudo apt -y install ansible ansible-playbook -b -i "localhost," -c local misc/install-test-dependencies.yml - name: Build run: | ./autogen.sh && ./configure --without-nvme && make -j - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 with: category: "/language:${{matrix.language}}" libblockdev-3.1.1-1/.github/workflows/compilation.yml000066400000000000000000000026461460051510300225730ustar00rootroot00000000000000name: Compilation with different compilers on: pull_request: branches: - master jobs: build: name: compilation runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: compiler: ['gcc-9', 'gcc-10', 'gcc-11', 'gcc-12', 'gcc-13', 'clang-13', 'clang-14', 'clang-15', 'clang-16', 'clang-17'] steps: - uses: actions/checkout@v4 - name: Install build dependencies run: | sudo apt -y install ansible ansible-playbook -b -i "localhost," -c local misc/install-test-dependencies.yml -e "test_dependencies=false" - name: Enable additional repositories (gcc) run: | sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa sudo apt update - name: Enable additional repositories (clang) run: | wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" | sudo tee /etc/apt/sources.list.d/llvm.list echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" | sudo tee -a /etc/apt/sources.list.d/llvm.list sudo apt update - name: Install compiler run: | sudo apt -y install ${{ matrix.compiler }} - name: Configure run: | ./autogen.sh && CC=${{ matrix.compiler }} ./configure --without-nvme - name: Make run: | make libblockdev-3.1.1-1/.github/workflows/csmock.yml000066400000000000000000000026541460051510300215330ustar00rootroot00000000000000name: Run static analysis using csmock env: CSMOCK_CHROOTS: "default" CSMOCK_TOOLS: "clang cppcheck gcc" on: pull_request: branches: - master jobs: build: name: csmock runs-on: ubuntu-22.04 env: CI_CONTAINER: libblockdev-ci-csmock steps: - name: Checkout libblockdev repository uses: actions/checkout@v4 - name: Install podman run: | sudo apt -qq update sudo apt -y -qq install podman - name: Build the container run: | podman build --no-cache -t ${{ env.CI_CONTAINER }} -f misc/ci.Dockerfile . - name: Start the container run: | podman run -d -t --name ${{ env.CI_CONTAINER }} --privileged --volume "$(pwd):/app" --workdir "/app" ${{ env.CI_CONTAINER }} - name: Install test dependencies in the container run: | podman exec -it ${{ env.CI_CONTAINER }} bash -c "ansible-playbook -i "localhost," -c local misc/install-test-dependencies.yml -e 'test_dependencies=false'" - name: Run csmock build in the container run: | podman exec -it ${{ env.CI_CONTAINER }} bash -c "/ci/run_csmock_tests -c /ci/copr-builder.conf -p libblockdev-udisks -t ${{ env.CSMOCK_TOOLS }} -r ${{ env.CSMOCK_CHROOTS }}" - name: Upload the csmock logs if: always() uses: actions/upload-artifact@v3 with: name: csmock_logs path: csmock_*/* libblockdev-3.1.1-1/.github/workflows/udisks-build.yml000066400000000000000000000030251460051510300226440ustar00rootroot00000000000000name: UDisks build on: pull_request: branches: - master jobs: build: name: udisks-build runs-on: ubuntu-22.04 env: CI_CONTAINER: libblockdev-ci-udisks-build steps: - name: Checkout libblockdev repository uses: actions/checkout@v4 - name: Install podman run: | sudo apt -qq update sudo apt -y -qq install podman - name: Build the container run: | podman build --no-cache -t ${{ env.CI_CONTAINER }} -f misc/ci.Dockerfile . - name: Start the container run: | podman run -d -t --name ${{ env.CI_CONTAINER }} --privileged --volume "$(pwd):/app" --workdir "/app" ${{ env.CI_CONTAINER }} - name: Install UDisks build dependencies in the container run: | podman exec -it ${{ env.CI_CONTAINER }} bash -c "dnf -y builddep --skip-unavailable /udisks/packaging/udisks2.spec" - name: Install libblockdev build dependencies in the container run: | podman exec -it ${{ env.CI_CONTAINER }} bash -c "ansible-playbook -i "localhost," -c local misc/install-test-dependencies.yml -e 'test_dependencies=false'" - name: Build and install libblockdev in the container run: | podman exec -it ${{ env.CI_CONTAINER }} bash -c "./autogen.sh && ./configure --prefix=/usr && make -j && make install" - name: Build UDisks in the container run: | podman exec -it ${{ env.CI_CONTAINER }} bash -c "cd /udisks && ./autogen.sh --enable-modules && make -j" libblockdev-3.1.1-1/.gitignore000066400000000000000000000016041460051510300161160ustar00rootroot00000000000000*.log .*.swp .coverage coverage-report.log tests/error_occurred **/*.pyc *libblockdev*.tar.gz src/lib/plugin_apis/*.[ch] src/plugins/.dirstamp BlockDev-*.gir BlockDev-*.typelib Makefile Makefile.in aclocal.m4 ar-lib compile py-compile config.guess config.log config.status config.sub configure depcomp install-sh libtool ltmain.sh m4/ autom4te.cache/ missing src/lib/.deps/ src/lib/blockdev.c src/lib/blockdev.pc src/utils/blockdev-utils.pc **/*.deps **/*.libs **/*.la **/*.lo **/*.o **/Makefile **/Makefile.in **/*.stamp **/*.bak include/blockdev/*.h include/blockdev/fs docs/libblockdev-decl-list.txt docs/libblockdev-decl.txt docs/libblockdev-overrides.txt docs/libblockdev-undeclared.txt docs/libblockdev-undocumented.txt docs/libblockdev-unused.txt docs/libblockdev.types docs/xml/ docs/html/ docs/libblockdev-docs.xml dist/libblockdev.spec tools/lvm-cache-stats tools/vfat-resize misc/.vagrant libblockdev-3.1.1-1/.packit.yaml000066400000000000000000000032401460051510300163410ustar00rootroot00000000000000actions: post-upstream-clone: - 'cp dist/libblockdev.spec.in dist/libblockdev.spec' - 'sed -i -E "s/@WITH_.+@/1/g" dist/libblockdev.spec' create-archive: - './autogen.sh' - './configure' - 'make' - 'make local' - 'bash -c "ls *.tar*"' jobs: - job: copr_build metadata: targets: - fedora-rawhide-aarch64 - fedora-rawhide-ppc64le - fedora-rawhide-x86_64 - fedora-latest-aarch64 - fedora-latest-ppc64le - fedora-latest-x86_64 - fedora-latest-stable-aarch64 - fedora-latest-stable-ppc64le - fedora-latest-stable-x86_64 trigger: pull_request - job: copr_build trigger: commit owner: "@storage" project: blivet-daily branch: master preserve_project: true - job: copr_build trigger: commit owner: "@storage" project: udisks-daily branch: master preserve_project: true - job: propose_downstream trigger: release dist_git_branches: - fedora-development - fedora-latest - job: koji_build trigger: commit dist_git_branches: - fedora-development - fedora-latest - job: bodhi_update trigger: commit dist_git_branches: - fedora-branched srpm_build_deps: - make - gcc - libtool - autoconf - autoconf-archive - automake - cryptsetup-devel - device-mapper-devel - e2fsprogs-devel - glib2-devel - glib2-doc - gobject-introspection-devel - gtk-doc - keyutils-libs-devel - kmod-devel - libblkid-devel - libbytesize-devel - libfdisk-devel - libmount-devel - libnvme-devel - libuuid-devel - ndctl-devel - nss-devel - parted-devel - python3-devel - systemd-devel - volume_key-devel downstream_package_name: libblockdev specfile_path: dist/libblockdev.spec libblockdev-3.1.1-1/LICENSE000066400000000000000000000635201460051510300151400ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey 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 library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it!libblockdev-3.1.1-1/Makefile.am000066400000000000000000000135351460051510300161700ustar00rootroot00000000000000SHELL = /bin/bash .SHELLFLAGS = -o pipefail -c ACLOCAL_AMFLAGS = -I m4 DISTCHECK_CONFIGURE_FLAGS = --enable-introspection if !WITH_BTRFS DISTCHECK_CONFIGURE_FLAGS += --without-btrfs endif if !WITH_CRYPTO DISTCHECK_CONFIGURE_FLAGS += --without-crypto endif if !WITH_DM DISTCHECK_CONFIGURE_FLAGS += --without-dm endif if !WITH_LOOP DISTCHECK_CONFIGURE_FLAGS += --without-loop endif if !WITH_LVM DISTCHECK_CONFIGURE_FLAGS += --without-lvm endif if !WITH_LVM_DBUS DISTCHECK_CONFIGURE_FLAGS += --without-lvm-dbus endif if !WITH_MDRAID DISTCHECK_CONFIGURE_FLAGS += --without-mdraid endif if !WITH_MPATH DISTCHECK_CONFIGURE_FLAGS += --without-mpath endif if !WITH_NVDIMM DISTCHECK_CONFIGURE_FLAGS += --without-nvdimm endif if !WITH_NVME DISTCHECK_CONFIGURE_FLAGS += --without-nvme endif if !WITH_SWAP DISTCHECK_CONFIGURE_FLAGS += --without-swap endif if !WITH_PART DISTCHECK_CONFIGURE_FLAGS += --without-part endif if !WITH_S390 DISTCHECK_CONFIGURE_FLAGS += --without-s390 endif SUBDIRS = include src dist scripts data tools if WITH_GTK_DOC SUBDIRS += docs endif dist_noinst_DATA = LICENSE tests MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.sub \ configure depcomp install-sh ltmain.sh missing py-compile compile ar-lib \ m4/*.m4 LIBDIRS = src/utils/.libs:src/plugins/.libs:src/plugins/fs/.libs:src/plugins/nvme/.libs:src/lib/.libs GIDIR = src/lib if WITH_PYTHON3 PYTHON = python3 else PYTHON = python endif TEST_PYTHON ?= $(PYTHON) COVERAGE ?= coverage TEST_SUITE_LOG ?= test-suite-$(TEST_PYTHON).log PYLINT_LOG ?= pylint.log PLUGINS = btrfs \ crypto \ dm \ fs \ loop \ lvm \ mdraid \ mpath \ nvdimm \ nvme \ part \ s390 \ swap ALT_PLUGINS = lvm-dbus LIBRARY_TESTS = library UTILS_TESTS = utils run-ipython: all GI_TYPELIB_PATH=${GIDIR} LD_LIBRARY_PATH=${LIBDIRS} PYTHONPATH=src/python G_MESSAGES_DEBUG=all LIBBLOCKDEV_CONFIG_DIR=data/conf.d/ i${PYTHON} run-root-ipython: all sudo env GI_TYPELIB_PATH=${GIDIR} LD_LIBRARY_PATH=${LIBDIRS} PYTHONPATH=src/python G_MESSAGES_DEBUG=all LIBBLOCKDEV_CONFIG_DIR=data/conf.d/ i${PYTHON} pylint: @$(PYTHON) -m pylint --version >/dev/null 2>&1; \ if test $$? != 0 ; then \ echo "pylint not available, skipping" ; \ else \ $(PYTHON) -m pylint -E src/python/gi/overrides/BlockDev.py ; \ fi if TESTS_ENABLED test: all pylint sudo $(TEST_PYTHON) tests/run_tests.py $(TEST_ARGS) fast-test: all pylint sudo $(TEST_PYTHON) tests/run_tests.py --fast test-all: all pylint sudo $(TEST_PYTHON) tests/run_tests.py --lucky test-plugin-%: all sudo $(TEST_PYTHON) tests/run_tests.py $*_test fast-test-plugin-%: all sudo $(TEST_PYTHON) tests/run_tests.py --fast $*_test test-lvm-dbus: all sudo $(TEST_PYTHON) tests/run_tests.py lvm_dbus_tests fast-test-lvm-dbus: all sudo $(TEST_PYTHON) tests/run_tests.py --fast lvm_dbus_tests endif # TESTS_ENABLED coverage: all @rm -f $(TEST_SUITE_LOG) @sudo env GI_TYPELIB_PATH=${GIDIR} LD_LIBRARY_PATH=${LIBDIRS} PYTHONPATH=.:tests/:src/python LIBBLOCKDEV_CONFIG_DIR=tests/test_configs/default_config \ $(COVERAGE) run --branch -m unittest discover -v -s tests/ -p '*_test.py' 2>&1 | tee -a $(TEST_SUITE_LOG) @sudo env GI_TYPELIB_PATH=${GIDIR} LD_LIBRARY_PATH=${LIBDIRS} PYTHONPATH=.:tests/:src/python LIBBLOCKDEV_CONFIG_DIR=tests/lvm_dbus_config \ $(COVERAGE) run --branch -m unittest discover -v -s tests/ -p 'lvm_dbus_tests.py' 2>&1 | tee -a $(TEST_SUITE_LOG) $(COVERAGE) report --show-missing --include="src/*" $(COVERAGE) report --include="src/*" > coverage-report.log coverage-all: all @sudo env FEELING_LUCKY= GI_TYPELIB_PATH=${GIDIR} LD_LIBRARY_PATH=${LIBDIRS} PYTHONPATH=.:tests/:src/python LIBBLOCKDEV_CONFIG_DIR=tests/test_configs/default_config \ $(COVERAGE) run --branch -m unittest discover -v -s tests/ -p '*_test.py' @sudo env GI_TYPELIB_PATH=${GIDIR} LD_LIBRARY_PATH=${LIBDIRS} PYTHONPATH=.:tests/:src/python LIBBLOCKDEV_CONFIG_DIR=tests/lvm_dbus_config \ $(COVERAGE) run --branch -m unittest discover -v -s tests/ -p 'lvm_dbus_tests.py' $(COVERAGE) report --show-missing --include="src/*" $(COVERAGE) report --include="src/*" > coverage-report.log tag: TAG="$(PACKAGE_VERSION)-1" ; \ git tag -a -s -m "Tag as $$TAG" -f "$$TAG" && \ echo "Tagged as $$TAG" rpmlog: @cl=`grep -n %changelog dist/libblockdev.spec.in |cut -d : -f 1 |head -1` ; \ version_release=`tail --lines=+$$(($$cl + 1)) dist/libblockdev.spec.in|head -1|cut -d- -f2-3|sed 's/ //g'` ; \ git log --no-merges --pretty="format:- %s (%ae)" "$$version_release.." |sed -e 's/@.*)/)/' ; \ echo shortlog: git shortlog -r --no-merges --format="- %s" -w76,0,2 $$(git tag -l --sort=taggerdate | tail -n 1)..HEAD | sed 's/"):$"/"):\n"/g' bumpver: @VERSION=`echo $(PACKAGE_VERSION)|sed -r 's/(.*)\.([0-9]+)/\1/'` ; \ SUBVERSION=`echo $(PACKAGE_VERSION)|sed -r 's/.*\.([0-9]+)/\1/'` ; \ NEWSUBVERSION=$$(($$SUBVERSION + 1)) ; \ DATELINE="* `date "+%a %b %d %Y"` `git config user.name` <`git config user.email`> - $$VERSION.$$NEWSUBVERSION-1" ; \ cl=`grep -n %changelog dist/libblockdev.spec.in |cut -d : -f 1 |head -1` ; \ tail --lines=+$$(($$cl + 1)) dist/libblockdev.spec.in > speclog ; \ (head -n $$cl dist/libblockdev.spec.in ; echo "$$DATELINE" ; make --quiet rpmlog 2>/dev/null ; echo ""; cat speclog) > dist/libblockdev.spec.in.new ; \ mv dist/libblockdev.spec.in.new dist/libblockdev.spec.in ; rm -f speclog ; \ sed -ri "s/(AC_INIT\(\[$(PACKAGE_NAME)\], \[)[0-9.]+(\],.*)/\1$$VERSION.$$NEWSUBVERSION\2/" configure.ac ; \ sed -ri "s/Version:(\\s+)[-0-9.]+/Version:\\1$$VERSION.$$NEWSUBVERSION/" dist/libblockdev.spec.in ; archive: distcheck local: dist srpm: local rpmbuild -ts --nodeps $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz rm -f $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz rpm: local rpmbuild -tb --nodeps $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz rm -f $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz release: tag $(MAKE) archive ci: all distcheck $(MAKE) pylint > $(PYLINT_LOG) $(MAKE) --quiet test libblockdev-3.1.1-1/NEWS.rst000066400000000000000000001160641460051510300154430ustar00rootroot00000000000000Libblockdev 3.1.1 ------------------ New bugfix release of the libblockdev library with multiple fixes. See below for details. **Full list of changes** Giulio Benetti (1): - Use glib2 G_GNUC_UNUSED in place of UNUSED locally defined Tomas Bzatek (5): - Port to G_GNUC_INTERNAL for controlling symbols visibility - Fix some more occurrences of missing port to G_GNUC_UNUSED - dm_logging: Annotate redirect_dm_log() printf format - tests: Add NVMe persistent discovery controller tests - tests: Add NVMe controller type checks Vojtech Trefny (6): - Makefile: Fix bumpver to work with micro versions - tests: Manually remove removed PVs from LVM devices file - tests: Ignore LVM devices file for non-LVM tests - tests: Fix removing custom LVM devices file - nvme: Add bd_nvme_is_tech_avail to the API file - lvm-dbus: Fix passing size for pvresize over DBus Libblockdev 3.1.0 ------------------ New minor release of the libblockdev library with multiple fixes. See below for details. **Full list of changes** Tomas Bzatek (7): - tests: Default to /tmp for create_sparse_tempfile() - tests: Avoid setting up intermediary loop device for the nvme target - tests: Remove unreliable nvme attribute checks - lvm-dbus: Fix leaking error - lvm-dbus: Avoid using already-freed memory - utils: Add expected printf string annotation - fs: Report reason for open() and ioctl() failures Vojtech Trefny (18): - ci: Add an action to compile libblockdev with different compilers - Sync spec with downstream - Add BDPluginSpec constructor and use it in plugin_specs_from_names - overrides: Remove unused 'sys' import - ci: Manually prepare spec file for Packit - ci: Remove the custom version command for Packit - swap: Add support for checking label and UUID format - fs: Add a function to check label format for F2FS - fs: Add a generic function to check for fs info availability - fs: Fix allowed UUID for generic mkfs with VFAT - fs: Add support for getting filesystem min size for NTFS and Ext - tests: Remove some obsolete rules to skip tests - Mark NVDIMM plugin as deprecated since 3.1 - part: Fix potential double free when getting parttype - tests: Use BDPluginSpec constructor in LVM DBus plugin tests - python: Add a deepcopy function to our structs - Fix missing progress initialization in bd_crypto_luks_add_key - tests: Skip some checks for btrfs errors with btrfs-progs 6.6.3 Libblockdev 3.0.4 ------------------ New bugfix release of the libblockdev library with multiple fixes. See below for details. **Full list of changes** Jelle van der Waa (3): - plugins: use g_autofree for free'ing g_char's - plugins: btrfs: use g_autofree where possible for g_free - fs: correct btrfs set label description Tomas Bzatek (1): - nvme: Rework memory allocation for device ioctls Vojtech Trefny (11): - spec: Obsolete vdo plugin packages - spec: Move obsoleted devel subpackages to libblockdev-devel - ci: Bump actions/checkout from v3 to v4 - part: Do not open disk read-write for read only operations - fs: Disable progress for ntfsresize - packit: Add configuration for downstream builds - logging: Default to DEBUG log level if compiled with --enable-debug - Use log function when calling a plugin function that is not loaded - lvm-dbus: Replace g_critical calls with bd_utils_log_format - tests: Fail early when recompilation fails in library_test - tests: Fix "invalid escape sequence '\#'" warning from Python 3.12 Libblockdev 3.0.3 ------------------ New bugfix release of the libblockdev library with multiple fixes. See below for details. **Full list of changes** Marius Vollmer (1): - Always use "--fs ignore" with lvresize Michael Biebl (1): - tests: Specificy required versions when importing GLib and BlockDev introspection Tomas Bzatek (3): - nvme: Use interim buffer for nvme_get_log_sanitize() - nvme: Generate HostID when missing - tests: Minor NVMe HostNQN fixes Vojtech Trefny (4): - tests: Replace deprecated unittest assert calls - fs: Fix leaking directories with temporary mounts - fs: Fix memory leak - crypto: Correctly convert passphrases from Python to C Libblockdev 3.0.2 ------------------ New bugfix release of the libblockdev library with multiple fixes. See below for details. **Full list of changes** Alexis Murzeau (1): - Use ntfsinfo instead of ntfscluster for faster bd_fs_ntfs_get_info Marek Szuba (1): - docs: Fix test quotation Michael Biebl (1): - Restrict list of exported symbols via -export-symbols-regex Tomas Bzatek (2): - lib: Silence the missing DEFAULT_CONF_DIR_PATH - loop: Report BD_LOOP_ERROR_DEVICE on empty loop devices Vojtech Trefny (5): - Fix formatting in NEWS.rst - fs: Fix unused error in extract_e2fsck_progress - fs: Use read-only mount where possible for generic FS functions - fs: Document that generic functions can mount filesystems - fs: Avoid excess logging in extract_e2fsck_progress Libblockdev 3.0.1 ------------------ New bugfix release of the libblockdev library with multiple fixes. See below for details. **Full list of changes** Giulio Benetti (1): - loop: define LOOP_SET_BLOCK_SIZE is not defined Tomas Bzatek (6): - nvme: Mark private symbols as hidden - build: Exit before AC_OUTPUT on error - loop: Remove unused variable - crypto: Remove stray struct redefinition - boilerplate_generator: Annotate stub func args as G_GNUC_UNUSED - fs: Simplify struct BDFSInfo Vojtech Trefny (11): - vdo_stats: Remove unused libparted include - lvm: Make _vglock_start_stop static - lvm: Fix declaration for bd_lvm_vdolvpoolname - loop: Remove bd_loop_get_autoclear definition - lvm: Add bd_lvm_segdata_copy/free to the header file - fs: Add missing copy and free functions to the header file - misc: Update steps and Dockerfile for Python documentation - dist: Sync spec with downstream - spec: Add dependency on libblockdev-utils to the s390 plugin - configure: Fix MAJOR_VER macro - Make the conf.d directory versioned Libblockdev 3.0 --------------- New major release of the libblockdev library. This release contains a large API overhaul, please check the documentation for full list of API changes. **Notable changes** - VDO a KBD plugins were removed. - New NVMe plugin was added. - Runtime dependencies are no longer checked during plugin initialization. - Part plugin was rewritten to use libfdisk instead of libparted. - Crypto plugin API went through an extensive rewrite. - Support for new technologies was added to the crypto plugin: FileVault2 encryption, DM Integrity, LUKS2 tokens. - Filesystem plugin adds support for btrfs, F2FS, NILFS2, exFAT and UDF. - Support for new filesystem operations was added to the plugin: setting label and UUID, generic mkfs function and API for getting feature support for filesystems. - dmraid support was removed from the DM plugin. - Python 2 support was dropped. Libblockdev 2.28 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Full list of changes** Michael Biebl (1): - Fix typos Vojtech Trefny (17): - lvm: Fix bd_lvm_get_supported_pe_sizes in Python on 32bit - tests: Create bigger devices for XFS tests - tests: Use ext instead of xfs in MountTestCase.test_mount_ro_device - mpath: Memory leak fix - spec: Require the same version utils from plugins - mdraid: Try harder to get container UUID in bd_md_detail - Add a test case for DDF arrays/containers - mdraid: Do not ignore errors from bd_md_canonicalize_uuid in bd_md_examine - mdraid: Try harder to get container UUID in bd_md_examine - mdraid: Fix copy-paste error when checking return value - tests: Wait for raid and mirrored LVs to be synced before removing - tests: Make smaller images for test_lvcreate_type - dm: Fix comparing DM RAID member devices UUID - mdraid: Fix use after free - ci: Add .lgtm.yaml config for LGTM - ci: Add GitHub actions for running rpmbuilds and csmock - mpath: Fix potential NULL pointer dereference zhanghongtao (1): - Fix mismatched functions return value type Libblockdev 2.27 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Full list of changes** Tomas Bzatek (1): - fs: Return BD_FS_ERROR_UNKNOWN_FS on mounting unknown filesystem Vojtech Trefny (21): - overrides: Fix translating exceptions in ErrorProxy - tests: Do not check that swap flag is not supported on DOS table - tests: Lower expected free space on newly created Ext filesystems - tests: Remove test for NTFS read-only mounting - vdo_stats: Default to 100 % savings for invalid savings values - lvm: Fix reading statistics for VDO pools with VDO 8 - tests: Fix creating loop device for CryptoTestLuksSectorSize - tests: Use losetup to create 4k sector size loop device for testing - s390: Remove double fclose in bd_s390_dasd_online (#2045784) - lvm-dbus: Add support for changing compression and deduplication - tests: Skip test_lvcreate_type on CentOS/RHEL 9 - tests: Fix expected extended partition flags with new parted - lvm: Do not set global config to and empty string - lvm: Do not include duplicate entries in bd_lvm_lvs output - lvm: Use correct integer type in for comparison - crypto: Remove useless comparison in progress report in luks_format - boilerplate_generator: Remove unused variable assignment - kbd: Add missing progress reporting to bd_kbd_bcache_create - kbd: Fix leaking error in bd_kbd_bcache_detach - kbd: Fix potential NULL pointer dereference in bd_kbd_bcache_create - crypto: Remove unused and leaking error in write_escrow_data_file Libblockdev 2.26 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Full list of changes** Manuel Wassermann (1): - exec: Fix deprecated glib function call Glib will rename "g_spawn_check_exit_status()" to "g_spawn_check_wait_status()" in version 2.69. Tomasz PaweÅ‚ Gajc (1): - remove unused variable and fix build with LLVM/clang Vojtech Trefny (22): - NEWS.rts: Fix markup - crypto: Fix default key size for non XTS ciphers - vdo: Do not use g_memdup in bd_vdo_stats_copy - fs: Allow using empty label for vfat with newest dosfstools - tests: Call fs_vfat_mkfs with "--mbr=n" extra option in tests - kbd: Fix memory leak - crypto: Fix memory leak - dm: Fix memory leak in the DM plugin and DM logging redirect function - fs: Fix memory leak - kbd: Fix memory leak - lvm-dbus: Fix memory leak - mdraid: Fix memory leak - swap: Fix memory leak - tests: Make sure the test temp mount is always unmounted - tests: Do not check that XFS shrink fails with xfsprogs >= 5.12 - tests: Temporarily skip test_snapshotcreate_lvorigin_snapshotmerge - Fix skipping tests on Debian testing - crypto: Let cryptsetup autodect encryption sector size when not specified - tests: Do not try to remove VG before removing the VDO pool - tests: Force remove LVM VG /dev/ entry not removed by vgremove - tests: Tag LvmPVVGLVcachePoolCreateRemoveTestCase as unstable - Add missing plugins to the default config Libblockdev 2.25 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Full list of changes** Tomas Bzatek (6): - exec: Fix polling for stdout and stderr - exec: Use non-blocking read and process the buffer manually - exec: Clarify the BDUtilsProgExtract callback documentation - tests: Add bufferbloat exec tests - tests: Add null-byte exec tests - lvm: Fix bd_lvm_vdopooldata_* symbols Vojtech Trefny (10): - exec: Fix setting locale for util calls - fs: Do not report error when errors were fixed by e2fsck - README: Use CI status image for 2.x-branch on 2.x - fs: Fix compile error in ext_repair caused by cherry pick from master - Mark all GIR file constants as guint64 - lvm: Set thin metadata limits to match limits LVM uses in lvcreate - lvm: Do not use thin_metadata_size to recommend thin metadata size - lvm: Use the UNUSED macro instead of __attribute__((unused)) - Fix max size limit for LVM thinpool metadata - loop: Retry LOOP_SET_STATUS64 on EAGAIN Libblockdev 2.24 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Notable changes** - vdo - VDO plugin has been deprecated in this release (functionality replaced by LVM VDO) - lvm - support for creating and managing LVM VDO volumes added - crypto - support for unlocking of BitLocker-compatible format BITLK added (requires cryptsetup 2.3.0) **Full list of changes** Lars Wendler (1): - configure.ac: Avoid bashisms Matt Thompson (1): - Fixed a number of memory leaks in lvm-dbus plugin Matt Whitlock (1): - configure.ac: Avoid more bashisms Tomas Bzatek (4): - utils: Add functions to get and check current linux kernel version - vdo: Fix a memleak - exec: Fix a memleak - mount: Fix a memleak Vojtech Trefny (47): - Sync spec with downstream - Use 'explicit_bzero' to erase passphrases from key files - Add new function 'bd_fs_wipe_force' to control force wipe - Fix linking against utils on Debian - exec.c: Fix reading outputs with null bytes - fs: Fix checking for UID/GID == 0 - Fix expected cache pool name with newest LVM - Fix memory leak in LVM DBus plugin - Manually remove symlinks not removed by udev in tests - Add a helper function for closing an active crypto device - Add support for BitLocker encrypted devices using cryptsetup - ext: Return empty string instead of "" for empty UUID - Fix typo in (un)mount error messages - vdo: Run "vdo create" with "--force" - lvm-dbus: Do not activate LVs during pvscan --cache - lvm-dbus: Fix memory leak in bd_lvm_thlvpoolname - tests: Specify loader for yaml.load in VDO tests - Add a function to check if a tool supports given feature - Do not hardcode pylint executable name in Makefile - Fix LVM plugin so names in tests - Add support for creating and managing VDO LVs with LVM - Add some helper functions to get LVM VDO mode and state strings - Fix converting to VDO pool without name for the VDO LV - Add write policy and index size to LVM VDO data - Fix getting string representation of unknown VDO state index - Fix getting VDO data in the LVM DBus plugin - Allow calling LVM functions without locking global_config_lock - Add extra parameters for creating LVM VDO volumes - Add function to get LVM VDO write policy from a string - exec: Disable encoding when reading data from stdout/stderr - Fix copy-paste bug in lvm.api - Move VDO statistics code to a separate file - Add functions to get VDO stats for LVM VDO volumes - lvm-dbus: Get data LV name for LVM VDO pools too - lvm: Add a function to get VDO pool name for a VDO LV - lvm-dbus: Add LVM VDO pools to bd_lvm_lvs - tests: Skip LVM VDO tests if kvdo module cannot be loaded - Do not skip LVM VDO tests when the kvdo module is already loaded - lvm: Fix getting cache stats for cache thinpools - Create a common function to get label and uuid of a filesystem - Do not open devices as read-write for read-only fs operations - Use libblkid to get label and UUID for XFS filesystems - Do not check VDO saving percent value in LVM DBus tests - utils: Remove deadcode in exec.c - fs: Fix potential NULL pointer dereference in mount.c - Fix multiple uninitialized values discovered by coverity - Mark VDO plugin as deprecated since 2.24 Libblockdev 2.23 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Notable changes** - fs - new functions for (un)freezing filesystems added - tests - test suite can now be run against installed version of libblockdev **Full list of changes** Vojtech Trefny (28): - Skip bcache tests on all Debian versions - Add a function to check whether a path is a mounpoint or not - Add function for (un)freezing filesystems - Add a decorator for "tagging" tests - Use test tags for skipping tests - Use the new test tags in tests - Remove duplicate test case - Allow running tests against installed libblockdev - Add a special test tag for library tests that recompile plugins - Force LVM cli plugin in lvm_test - Mark 'test_set_bitmap_location' as unstable - Add ability to read tests to skip from a config file - Skip bcache tests if make-bcache is not installed - Use the new config file for skipping tests - Ignore coverity deadcode warnings in the generated code - Ignore coverity deadcode warning in 'bd_fs_is_tech_avail' - Mark 'private' plugin management functions as static - Remove unused 'get_PLUGIN_num_functions' and 'get_PLUGIN_functions' functions - Mark LVM global config locks as static - Hide filesystem-specific is_tech_available functions - Use 'kmod_module_probe_insert_module' function for loading modules - Fix parsing distro version from CPE name - Move the NTFS read-only device test to a separate test case - Print skipped test "results" to stderr instead of stdout - Fix LVM_MAX_LV_SIZE in the GIR file - Fix skipping NTFS read-only test case on systems without NTFS - Skip tests for old-style LVM snapshots on recent Fedora - Fix how we get process exit code from g_spawn_sync Libblockdev 2.22 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Notable changes** - nvdimm - new function for getting list of supported sector sizes for namespaces - fixes - multiple memory leaks fixed **Full list of changes** Adam Williamson (1): - Sync spec file with python2 obsoletion added downstream Tomas Bzatek (17): - bd_fs_xfs_get_info: Allow passing error == NULL - lvm: Fix some obvious memory leaks - lvm: Use g_ptr_array_free() for creating lists - lvm: Fix leaking BDLVMPVdata.vg_uuid - exec: Fix some memory leaks - mdraid: Fix g_strsplit() leaks - s390: Fix g_strsplit() leaks - ext: Fix g_strsplit() leaks - ext: Fix g_match_info_fetch() leaks - kbd: Fix g_match_info_fetch() leaks - part: Fix leaking objects - ext: Fix leaking string - part: Fix leaking string in args - mdraid: Fix leaking error - mdraid: Fix leaking BDMDExamineData.metadata - btrfs: Fix number of memory leaks - module: Fix libkmod related leak Vojtech Trefny (7): - Sync spec with downstream - Allow skiping tests only based on architecture - New function to get supported sector sizes for NVDIMM namespaces - Use existing cryptsetup API for changing keyslot passphrase - tests: Fix removing targetcli lun - Remove device-mapper-multipath dependency from fs and part plugins - tests: Fix Debian testing "version" for skipping Libblockdev 2.21 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Notable changes** - crypto - default key size for LUKS was changed to 512bit - tools - new simple cli tools that use libblockdev - first tool is ``lvm-cache-stats`` for displaying stats for LVM cache devices - use configure option ``--without-tools`` to disable building these **Full list of changes** Vojtech Trefny (19): - Use libblkid to check swap status before swapon - Add error codes and Python exceptions for swapon fails - Add libblkid-devel as a build dependency for the swap plugin - Skip VDO grow physical test - crypto_test.py: Use blkid instead of lsblk to check luks label - Use major/minor macros from sys/sysmacros.h instead of linux/kdev_t.h - Add custom error message for wrong passphrase for open - Skip LUKS2+integrity test on systems without dm-integrity module - Use cryptsetup to check LUKS2 label - Fix LUKS2 resize password test - crypto: Do not try to use keyring on systems without keyring support - lvm-dbus: Do not pass extra arguments enclosed in a tuple - Enable cryptsetup debug messages when compiled using --enable-debug - vagrant: install 'autoconf-archive' on Ubuntu - vagrant: remove F27 and add F29 - Add 'autoconf-archive' to build requires - tests: Remove some old/irrelevant skips - tests: Stop skipping some tests on Debian testing - Fix checking swap status on lvm/md Vratislav Podzimek (6): - Discard messages from libdevmapper in the LVM plugins - Add a tool for getting cached LVM statistics - Make building tools optional - Document what the 'tools' directory contains - Add a new subpackage with the tool(s) - Use 512bit keys in LUKS by default Libblockdev 2.20 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Notable changes** - fixes - Fix parsing extra arguments for LVM methods calls in the LVM DBus plugin. - Multiple fixes for running tests on Debian testing. - development - Vagrantfile template was added for easy development machine setup. **Full list of changes** Dennis Schridde (1): - Fix build of plugins by changing linking order Vojtech Trefny (17): - Fix spacing in NEWS.rst - Fix licence header in dbus.c - Do not require 'dmraid' package if built without dmraid support - Always build the VDO plugin - kbd: Check for zram module availability in 'bd_kbd_is_tech_avail' - Fix skipping zram tests on Fedora 27 - Build the dm plugin without dmraid support on newer RHEL - tests: Try harder to get distribution version - Skip bcache tests on Debian testing - Skip NTFS mount test on Debian testing - Skip MDTestAddRemove on Debian - lvm-dbus: Fix parsing extra arguments for LVM methods calls - Fix how we check zram stats from /sys/block/zram0/stat - Add some missing test dependencies to the vagrant template - Add Ubuntu 18.04 VM configuration to the vagrant template - Skip nvdimm tests on systems without ndctl - Require newer version of cryptsetup for LUKS2 tests Vratislav Podzimek (6): - Mark the function stubs as static - Fix the error message when deleting partition fails - Add a Vagrantfile template - Document what the 'misc' directory contains - Fix how/where the bcache tests are skipped - Use unsafe caching for storage for devel/testing VMs Libblockdev 2.19 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Notable changes** - features - vdo: new functions to get statistical data for existing VDO volumes (`bd_vdo_get_stats`) - crypto: support for passing extra arguments for key derivation function when creating LUKS2 format **Full list of changes** Max Kellermann (8): - fix -Wstrict-prototypes - exec: make `msg` parameters const - plugins/check_deps: make all strings and `UtilDep` instances `const` - plugins/crypto: work around -Wdiscarded-qualifiers - plugins/dm: add explicit cast to work around -Wdiscarded-qualifiers - plugins/lvm{,-dbus}: get_lv_type_from_flags() returns const string - plugins/kbd: make wait_for_file() static - pkg-config: add -L${libdir} and -I${includedir} Tom Briden (1): - Re-order libbd_crypto_la_LIBADD to fix libtool issue Tomas Bzatek (2): - vdo: Properly destroy the yaml parser - fs: Properly close both ends of the pipe Vojtech Trefny (33): - Sync spec with downstream - Do not build VDO plugin on non-x86_64 architectures - Show simple summary after configure - Add Python override for bd_crypto_tc_open_full - Add a simple test case for bd_crypto_tc_open - Use libblkid in bd_crypto_is_luks - Make sure all our free and copy functions work with NULL - Fix few wrong names in doc strings - Use versioned command for Python 2 - Reintroduce python2 support for Fedora 29 - Allow specifying extra options for PBKDF when creating LUKS2 - configure.ac: Fix missing parenthesis in blkid version check - acinclude.m4: Use AS_EXIT to fail in LIBBLOCKDEV_FAILURES - Skip 'test_cache_pool_create_remove' on CentOS 7 - BlockDev.py Convert dictionary keys to set before using them - Make sure library tests properly clean after themselves - Make sure library_test works after fixing -Wstrict-prototypes - Do not build btrfs plugin on newer RHEL - Do not build KBD plugin with bcache support on RHEL - Skip btrfs tests if btrfs module is not available - Add version to tests that should be skipped on CentOS/RHEL 7 - Skip VDO tests also when the 'kvdo' module is not available - Fix how we check zram stats from /sys/block/zram0/mm_stat - Fix calling BlockDev.reinit in swap tests - Fix vdo configuration options definition in spec file - Fix running pylint in tests - Ignore "bad-super-call" pylint warning in BlockDev.py - Fix three memory leaks in lvm-dbus.c - Fix licence headers in sources - lvm.c: Check for 'lvm' dependency in 'bd_lvm_is_tech_avail' - lvm-dbus.c: Check for 'lvmdbus' dependency in 'bd_lvm_is_tech_avail' - Add test for is_tech_available with multiple dependencies - Use python interpreter explicitly when running boilerplate_generator.py Libblockdev 2.18 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Notable changes** - features - New plugin: vdo - support for creating and managing VDO volumes - Support for building dm plugin without libdmraid support -- configure option ``--without-dmraid``. **Full list of changes** Kai Lüke (2): - Correct arguments for ext4 repair with progress - Introduce reporting function per thread Tomas Bzatek (3): - vdo: Resolve real device file path - vdo: Implement bd_vdo_grow_physical() - vdo: Add tests for bd_vdo_grow_physical() Vojtech Trefny (14): - Update specs.rst and features.rst - Fix release number in NEWS.rst - Add 'bd_dm_is_tech_avail' to header file - Always check for error when (un)mounting - Add the VDO plugin - Add basic VDO plugin functionality - Add decimal units definition to utils/sizes.h - Add tests for VDO plugin - Only require plugins we really need in LVM dbus tests - Allow compiling libblockdev without libdmraid - Adjust to new NVDIMM namespace modes - Do not try to build VDO plugin on Fedora - Remove roadmap.rst - Add VDO to features.rst Vratislav Podzimek (2): - Use xfs_repair instead of xfs_db in bd_fs_xfs_check() - Clarify that checking an RW-mounted XFS file system is impossible segfault (1): - Fix off-by-one error when counting TCRYPT keyfiles Libblockdev 2.17 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Notable changes** - features - New plugin: nvdimm - support for NVDIMM namespaces management - requires *libndctl* >= 58.4 - LUKS2 support - support for creating LUKS2 format including authenticated disk encryption - multiple new functions for working with LUKS devices (suspend/resume, header backup, metadata size...) - Extended support for opening TrueCrypt/VeraCrypt volumes - Support for building crypto plugin without escrow device support (removes build dependency on *libvolume_key* and *libnss*) -- configure option ``--without-escrow``. - Support for building libblockdev without Python 2 support -- configure option ``--without-python2``. **Full list of changes** Bjorn Pagen (3): - Fix build against musl libc - Fix build with clang - Enforce ZERO_INIT gcc backwards compatibility Florian Klink (1): - s390: don't hardcode paths, search PATH Jan Pokorny (1): - New function for luks metadata size Vojtech Trefny (24): - Sync the spec file with downstream - Fix python2-gobject-base dependency on Fedora 26 and older - Add the NVDIMM plugin - Add tests for the NVDIMM plugin - Add --without-xyz to DISTCHECK_CONFIGURE_FLAGS for disabled plugins - Add function for getting NVDIMM namespace name from devname or path - Fix memory leaks discovered by clang - Get sector size for non-block NVDIMM namespaces too - lvm-dbus: Check returned job object for error - Add functions to suspend and resume a LUKS device - Add function for killing keyslot on a LUKS device - Add functions to backup and restore LUKS header - Require at least libndctl 58.4 - Allow compiling libblockdev crypto plugin without escrow support - Allow building libblockdev without Python 2 support - Skip bcache tests on Rawhide - Add support for creating LUKS 2 format - Use libblockdev function to create LUKS 2 in tests - Add a basic test for creating LUKS 2 format - Add function to get information about a LUKS device - Add function to get information about LUKS 2 integrity devices - Add functions to resize LUKS 2 - Add a generic logging function for libblockdev - Redirect cryptsetup log to libblockdev log Vratislav Podzimek (1): - Use '=' instead of '==' to compare using 'test' segfault (10): - Support unlocking VeraCrypt volumes - Support TCRYPT keyfiles - Support TCRYPT hidden containers - Support TCRYPT system volumes - Support VeraCrypt PIM - Add function bd_crypto_device_seems_encrypted - Make keyfiles parameter to bd_crypto_tc_open_full zero terminated - Don't use VeraCrypt PIM if compiled against libcryptsetup < 2.0 - Make a link point to the relevant section - Add new functions to docs/libblockdev-sections.txt Libblockdev 2.16 ---------------- New minor release of the libblockdev library with multiple fixes. See below for details. **Notable changes** - features - LUKS 2 support for luks_open/close and luks_add/remove/change_key - Progress report support for ext filesystem checks **Full list of changes** Jan Tulak (4): - Add a function to test if prog. reporting was initialized - Add progress reporting infrastructure for Ext fsck - Add e2fsck progress - Add tests for progress report Vojtech Trefny (5): - Fix link to online documentation - Update 'Testing libblockdev' section in documentation - Check if 'journalctl' is available before trying to use it in tests - Fix few more links for project and documentation website - Add support for LUKS 2 opening and key management Vratislav Podzimek (2): - Fix how the new kernel module functions are added to docs - Sync the spec file with downstream Libblockdev 2.15 ---------------- New minor release of the libblockdev library with multiple fixes and quite big refactorization changes (in the file system plugin). See below for details. **Notable changes** - fixes - Fix bd_s390_dasd_format() and bd_s390_dasd_is_ldl(). - Fix how GPT patition flags are set. - Check the *btrfs* module availability as part of checking the *btrfs* plugin's dependencies. - Fix memory leaks in bd_fs_vfat_get_info() - Fix the file system plugin's dependency checking mechanisms. - features - Mark some of the tests as unstable so that their failures are reported, but ignored in the overall test suite status. - The file system plugin is now split into multiple source files making it easier to add support for more file systems and technologies. **Full list of changes** Vendula Poncova (2): - bd_s390_dasd_is_ldl should be true only for LDL DADSs - Fix bd_s390_dasd_format Vojtech Trefny (5): - Use only sgdisk to set flags on GPT - Add test for setting partition flags on GPT - Free locale struct in kbd plugin - Move kernel modules (un)loading and checking into utils - Check for btrfs module availability in btrfs module Vratislav Podzimek (11): - Do not lie about tag creation - Mark unstable tests as such - Split the FS plugin source into multiple files - Split the bd_fs_is_tech_avail() implementation - Revert the behaviour of bd_fs_check_deps() - Fix memory leaks in bd_fs_vfat_get_info() - Mark bcache tests as unstable - Add a HACKING.rst file - Move the fs.h file to its original place - Do not use the btrfs plugin in library tests - Do not use the 'btrfs' plugin in overrides tests Libblockdev 2.14 ---------------- New minor release of the libblockdev library with important fixes and a few new features, in particular support for the NTFS file system. See below for details. **Notable changes** - fixes - Fix BSSize memory leaks - Fixes for issues discovered by coverity - Support for the 'Legacy boot' GPT flag - features - Added function to get DM device subsystem - Support for the NTFS file system - pkg-config definitions improvements **Full list of changes** Jan Pokorny (1): - Added function to get DM device subsystem Kai Lüke (2): - Add function wrappers for NTFS tools - Add some test cases for NTFS Vojtech Trefny (29): - Skip btrfs subvolume tests with btrfs-progs 4.13.2 - Fix BSSize memory leaks in btrfs and mdraid plugins - Use system values in KbdTestBcacheStatusTest - Use libbytesize to parse bcache block size - blockdev.c.in: Fix unused variables - fs.c: Fix resource leaks in 'bd_fs_get_fstype' - fs.c: Check sscanf return value in 'bd_fs_vfat_get_info' - fs.c: Fix for loop condition in 'bd_fs_get_fstype' - lvm.c: Fix "use after free" in 'bd_lvm_get_thpool_meta_size' - mdraid.c: Fix resource leaks - part.c: Check if file discriptor is >= 0 before closing it - kbd.c: Fix double free in 'bd_kbd_zram_get_stats' - exec.c: Fix "use after free" in 'bd_utils_check_util_version' - crypto.c: Use right key buffer in 'bd_crypto_luks_add_key' - part.c: Fix possible NULL pointer dereference - fs.c: Fix "forward null" in 'do_mount' and 'bd_fs_xfs_get_info' - exec.c: Fix resource leaks in 'bd_utils_exec_and_report_progress' - kbd.c: Fix potential string overflow in 'bd_kbd_bcache_create' - part.c: Check if we've found a place to put new logical partitions - exec.c: Ignore errors from 'g_io_channel_shutdown' - Ignore some coverity false positive errors - crypto.c: Fix waiting for enough entropy - exec.c: Fix error message in 'bd_utils_exec_and_report_progress' - Fix duplicate 'const' in generated functions - lvm-dbus.c: Fix multiple "use after free" coverity warnings - fs.c: Fix multiple "forward NULL" warnings in 'bd_fs_ntfs_get_info' - dm.c: Check return values of dm_task_set_name/run/get_info functions - dm.c: Fix uninitialized values in various dm plugin functions - fs.c: Fix potential NULL pointer dereference Vratislav Podzimek (3): - Sync spec with downstream - Add pkgconfig definitions for the utils library - Respect the version in the blockdev.pc file intrigeri (1): - Support the legacy boot GPT flag Thanks to all our contributors. Vratislav Podzimek, 2017-10-31 Libblockdev 2.13 ---------------- New minor release of the libblockdev library. Most of the changes are bugfixes related to building and running tests on the s390 architecture and CentOS 7 aarch64. Other than that a support for checking runtime dependencies (utilities) on demand and querying available technologies was implemented. **Notable changes** - builds - various fixes for building on s390 - tests - various changes allowing running the test suite on s390 - various changes allowing running the test suite on CentOS7 aarch64 - features - checking for runtime dependencies on demand - querying available technologies **Full list of changes** Vojtech Trefny (14): - Allow compiling libblockdev without s390 plugin - Do not run g_clear_error after setting it - Fix zFCP LUN max length - Bypass error proxy in s390 test - Use "AC_CANONICAL_BUILD" to check architecture instead of "uname" - Do not include s390utils/vtoc.h in s390 plugin - Add NEWS.rst file - Fix source URL in spec file - Use only one git tag for new releases - Add new function for setting swap label - Skip btrfs tests on CentOS 7 aarch64 - Better handle old and new zram sysfs api in tests - Try harder when waiting for lio device to show up - Use shorter prefix for tempfiles Vratislav Podzimek (9): - Add a function for getting plugin name - Dynamically check for the required utilities - Add functions for querying available technologies - Simplify what WITH_BD_BCACHE changes in the KBD plugin - Add a basic test for the runtime dependency checking - Add missing items to particular sections in the documentation - Assign functions to tech-mode categories - Add a function for enabling/disabling plugins' init checks - Fix the rpmlog and shortlog targets Thanks to all our contributors. Vratislav Podzimek, 2017-09-29 Libblockdev 2.12 ---------------- New minor release of libblockdev library. Most changes in this release are related to improving our test suite and fixing new issues and bugs. **Notable changes** - tests - various changes allowing running the test suite on Debian **Full list of changes** Kai Lüke (1): - Wait for resized partition Vojtech Trefny (20): - Try to get distribution info from "PrettyName" if "CPEName" isn't available - Require only plugins that are needed for given test - Try harder to unmount devices in test cleanup - Fix redirecting command output to /dev/null in tests - Skip free region tests on Debian too - Skip the test for device escrow on Debian too - Skip zRAM tests on Debian - Skip dependency checking in mpath tests on Debian - Fix checking for available locales - Fix names of backing files in tests - Skip vgremove tests on 32bit Debian - Use libmount cache when parsing /proc/mounts - Use mountpoint for "xfs_info" calls - Close filesystem before closing the partition during FAT resize - Stop skipping FAT resize tests on rawhide - Tests: Move library initialization to setUpClass method - Add a script for running tests - Use "run_tests" script for running tests from Makefile - Fix label check in swap_test - Own directories /etc/libblockdev and /etc/libblockdev/conf.d Vratislav Podzimek (6): - Sync spec with downstream - Use -ff when creating PVs in FS tests - Confirm the force when creating PVs in FS tests - Add some space for the CI status - Make sure the device is opened for libparted - New version - 2.12 Thanks to all our contributors. Vratislav Podzimek, 2017-08-30 Libblockdev 2.11 ---------------- New minor release of libblockdev library. **Notable changes** - library - added option to skip dependecy check during library initialization **Full list of changes** Kai Lüke (2): - Link to GObject even if no plugin is activated - Allow non-source directory builds Vojtech Trefny (1): - Use new libmount function to get (un)mount error message Vratislav Podzimek (6): - Update the documentation URL - Keep most utilities available for tests - Skip zram tests on Rawhide - Add a way to disable runtime dependency checks - Make the KbdZRAMDevicesTestCase inherit from KbdZRAMTestCase - New version - 2.11 Thanks to all our contributors. Vratislav Podzimek, 2017-07-31 Libblockdev 2.10 ---------------- New minor release of libblockdev library adding some new functionality in the crypto, fs and part plugins and fixing various issues and bugs. **Notable changes** - crypto - support for opening and closing TrueCrypt/VeraCrypt volumes: ``bd_crypto_tc_open`` and ``bd_crypto_tc_close`` - fs - new functions for checking of filesystem functions availability: ``bd_fs_can_resize``, ``bd_fs_can_check`` and ``bd_fs_can_repair`` - new generic function for filesystem repair and check: ``bd_fs_repair`` and ``bd_fs_check`` - part - newly added support for partition resizing: ``bd_part_resize_part`` **Full list of changes** Kai Lüke (6): - Size in bytes for xfs_resize_device - Query functions for FS resize and repair support - Generic Check and Repair Functions - Add partition resize function - Query setting FS label support and generic relabeling - Specify tolerance for partition size Tony Asleson (3): - kbd.c: Make bd_kbd_bcache_create work without abort - kbd.c: Code review corrections - bcache tests: Remove FEELINGLUCKY checks Tristan Van Berkom (2): - Fixed include for libvolume_key.h - src/plugins/Makefile.am: Remove hard coded include path in /usr prefix Vratislav Podzimek (12): - Try RO mount also if we get EACCES - Adapt to a change in behaviour in new libmount - Add functions for opening/closing TrueCrypt/VeraCrypt volumes - Update the project/source URL in the spec file - Compile everything with the C99 standard - Do not strictly require all FS utilities - Check resulting FS size in tests for generic FS resize - Only use the exact constraint if not using any other - Do not verify vfat FS' size after generic resize - Limit the requested partition size to maximum possible - Only enable partition size tolerance with alignment - New version - 2.10 squimrel (1): - Ignore parted warnings if possible Thanks to all our contributors. Vratislav Podzimek, 2017-07-05 libblockdev-3.1.1-1/README.DEVEL.md000066400000000000000000000163571460051510300162560ustar00rootroot00000000000000libblockdev developer documentation ==================================== The purpose of this document is to describe the internals of the *libblockdev* library for future developers and maintainers. The library itself (the ``src/lib/blockdev.c.in`` and ``src/lib/plugins.c`` files) is just a thin wrapper around its plugins which take care about the actual functionality. Each plugin is defined by an ``.api`` file in the ``src/lib/plugin_apis`` directory. There might be multiple implementations for each plugin like for example the ``lvm.c`` and ``lvm-dbus.c`` files both providing implementations of the *LVM* plugin. Each implementation of some plugin is compiled as a standalone shared library and can be used separately without the *libblockdev* library itself if desired. However, it is strongly recommended to use the library and use one or more of its initialization functions to either load all the plugins or just a desired subset. That takes care of the plugins' check and initialization code to be executed as well as resolution of priorities and fallback-based loading of multiple implementations for plugins (if that's the case). As was already mentioned above, the library is just a thin wrapper so there's no point in trying to bypass it and use the plugins directly as standalone libraries. Coding style ------------- - Please follow the coding style already used. - Spaces, not tabs, are used (except for Makefiles). Language bindings ------------------ Though the library uses the so called *GObject introspection* (*GI*) framework to provide bindings for languages other than *C*, it's not an object-oriented library and it makes little to no use of the *GObject* type system. The only exception are a few structures registered as *GBoxedType* types which are structures together with related ``free()`` and ``copy()`` functions defined. The framework itself provides an interface for all the other (basic) types being used like strings, numbers, etc. as well as for error reporting based on the *GError* mechanism (translated to language-native error/exception reporting and handling). In order to make the *GObject introspection* work together with dynamic loading and fail-safe execution of functions that are not provided by any loaded plugin, the library defines its own stub functions that just report an error if called. Such functions are generated automatically from the ``.api`` files by the ``scripts/boilerplate_generator.py`` script and when plugins are loaded, these stubs are replaced by the real functions provided by the plugins. The helper script also generates functions used for loading plugins (all their functions have to be loaded one by one). Adding a new function ---------------------- Thus if a new function is being added to any of the plugins: 1. the definition of the function has to be added to the particular ``.api`` file 2. the function prototype has to be added to the particular header file 3. implementation(s) of the function have to be added to one or more plugins 4. plugin's soname version has to be adapted to the change(s) 5. the function has to be added to the particular place in the documentation (the ``docs/libblockdev-sections.txt`` file) Adding a new plugin -------------------- If a new plugin is being added: 1. the definitions of its functions have to be put into a new ``.api`` file 2. code in ``src/lib/blockdev.c.in`` has to be adapted to load the plugin's implementation and report its state 3. related definitions have to be added to the related autotools files 4. the plugin has to be added to the particular place in the documentation (the ``docs/libblockdev-sections.txt`` file) See e.g. the commit a5847cd9c266d1116b87356aa1816ddb0bfc194e for more details. If a new struct field is being added, it has to be added to the end of the structure so that original fields stay in their places from the ABI point of view. Directory structure -------------------- The directory structure is as follows: ``` libblockdev ├── data -- data files │ └── conf.d -- configuration files ├── dist -- packaging files ├── docs -- files used to generate documentation ├── misc -- miscellaneous files easing development ├── scripts -- helper scripts ├── src -- source files │ ├── lib -- library sources │ │ └── plugin_apis -- plugins definitions │ ├── plugins -- plugins implementations │ ├── python -- python bindings │ │ └── gi -- just needed for GI overrides to work │ │ └── overrides -- ditto, actual sources of the GI overrides │ └── utils -- sources of the utility library ├── tests -- tests └── tools -- sources of various nice tools ``` Making releases ================ - [ ] ``sudo git clean -xdf`` - [ ] ``./autogen.sh && ./configure`` - [ ] ``make bumpver`` - [ ] Add a new entry to the *NEWS.rst* file (full list of changes should be generated with ``make shortlog``). - [ ] Commit all the changes as *New version - $VERSION*. - [ ] ``make release`` (requires a GPG key to sign the tag) - [ ] ``git push && git push --tags`` - [ ] Edit the new release (for the new tag) at GitHub and: - [ ] add some detailed information about it (from the *NEWS.rst*) file to it, - [ ] upload the tarball created above (``make release``) to the release. - [ ] Generate documentation for the Python bindings as described below and copy it to *docs/html* - [ ] Update the documentation by rsyncing the contents of the *docs/html* folder elsewhere, switching to the *gh-pages* branch, rsyncing the contents back and committing it as an update of the docs for the new release. Generating Python bindings documentation ----------------------------------------- Documentation for Python bindings is generated using [pgi-docgen](https://github.com/pygobject/pgi-docgen). This unfortunately works only on Debian so we are using a custom Docker image to build the documentation: 1. Go to the *misc* directory. 1. Build new image using the provided *Dockerfile* `$ buildah bud --tag debian-docs-builder -f PythonDocs.Dockerfile .` This will create a new Debian Testing based image and build the documentation in it from latest libblockdev. 1. Create container from the created image `$ buildah from localhost/debian-docs-builder` 1. Mount the container `$ buildah unshare` `# mnt=$(buildah mount debian-docs-builder-working-container)` 1. Copy generated documentation from the container to *docs/html* `# cp -R $mnt/root/pgi-docgen/_docs/_build/BlockDev-3.0 /docs/html` `# cp -R $mnt/root/pgi-docgen/_docs/_build/_static /docs/html` 1. Manually fix few issues in the *BlockDev-3.0/index.html* - Fix version of libblockdev (pgi-docgen can't detect it so it uses version from Debian package). - Remove link to dependencies (we are not copying documentation generated for GLib and GObject because it more than 100 MB). libblockdev-3.1.1-1/README.md000066400000000000000000000056561460051510300154200ustar00rootroot00000000000000### CI status CI status ### Introduction libblockdev is a C library supporting GObject introspection for manipulation of block devices. It has a plugin-based architecture where each technology (like LVM, Btrfs, MD RAID, Swap,...) is implemented in a separate plugin, possibly with multiple implementations (e.g. using LVM CLI or the new LVM DBus API). #### Features Following storage technologies are supported by libblockdev - partitions - MSDOS, GPT - filesystem operations - ext2, ext3, ext4, xfs, vfat, ntfs, exfat, btrfs, f2fs, nilfs2, udf - mounting - LVM - thin provisioning, LVM RAID, cache, LVM VDO - BTRFS - multi-device volumes, subvolumes, snapshots - swap - encryption - LUKS, TrueCrypt/VeraCrypt, BitLocker, FileVault2 - integrity - DM (device mapper) - loop devices - MD RAID - multipath - s390 - DASD, zFCP - NVDIMM namespaces - NVMe #### Architecture The library itself is only a thin wrapper around a set of plugins, each for a particular technology listed above. The library provides an API consisting of sets of functions provided by its plugins. For example, there is a symbol/function called ``bd_lvm_lvcreate`` provided by the library which is dynamically loaded from the LVM plugin when the library's ``bd_init`` function will be called. Initially all those functions are no-ops just printing a warning on stderr and doing nothing. This way applications using the library won't crash, the operations just won't be run. Of course, the library has ``bd_is_plugin_available``, which allows applications to check if something is provided/implemented or not. #### Technologies behind the library The library is written in C using the GLib library. The GLib library provides a lot of handy utilities that may be used by the library (no need for a new implementation of hash tables, lists, etc.) and moreover, it should be really easy to create bindings for the library via GObject introspection that works even with "not OOP" code. However, instead of returning links to structs (e.g. as a return value of the ``bd_lvm_vginfo`` function) it will return references to GObjects with attributes/properties and access methods. The reason is again an easy way to create bindings which we get for free. ### License The libblockdev code is licensed under LGPL 2.1 or later, see [LICENSE](LICENSE) for full text of the license. ### Development For developer documentation see [README.DEVEL.md](README.DEVEL.md). API documentation is available at [https://storaged.org/libblockdev](https://storaged.org/libblockdev). #### Branches and supported versions The currently actively developed and supported version is 3.x on the *main* branch. New features should target this release. The older 2.x version available on the *2.x-branch* is still supported but new features are not planned for this release. libblockdev-3.1.1-1/acinclude.m4000066400000000000000000000100571460051510300163210ustar00rootroot00000000000000dnl autoconf macros for libblockdev dnl dnl Copyright (C) 2014 Red Hat, Inc. dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU Lesser General Public License as published dnl by the Free Software Foundation; either version 2.1 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU Lesser General Public License for more details. dnl dnl You should have received a copy of the GNU Lesser General Public License dnl along with this program. If not, see . dnl dnl THIS IS A MODIFIED VERSION OF THE ANACONDA'S acinclude.m4 FILE. dnl dnl Author: David Shea dnl Vratislav Podzimek dnl LIBBLOCKDEV_SOFT_FAILURE(MESSAGE) dnl dnl Store a message that in some contexts could be considered indicative dnl of a failure, but in other contexts could be indicative of who cares. dnl dnl Any message sent to this macro will be stored, and they can all be dnl displayed at the end of configure using the LIBBLOCKDEV_FAILURES macro. AC_DEFUN([LIBBLOCKDEV_SOFT_FAILURE], [dnl AS_IF([test x"$libblockdev_failure_messages" = x], [libblockdev_failure_messages="[$1]"], [libblockdev_failure_messages="$libblockdev_failure_messages [$1]" ])])dnl dnl LIBBLOCKDEV_PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES) dnl dnl Check whether a module is available, using pkg-config. Instead of failing dnl if a module is not found, store the failure in a message that can be dnl printed using the LIBBLOCKDEV_FAILURES macro. dnl dnl The syntax and behavior of VARIABLE-PREFIX and MODULES is the same as for dnl PKG_CHECK_MODULES. AC_DEFUN([LIBBLOCKDEV_PKG_CHECK_MODULES], [dnl PKG_CHECK_MODULES([$1], [$2], [], [LIBBLOCKDEV_SOFT_FAILURE($[$1]_PKG_ERRORS)]) ])dnl dnl LIBBLOCKDEV_PKG_CHECK_EXISTS(MODULES) dnl dnl Check whether a module exists, using pkg-config. Instead of failing dnl if a module is not found, store the failure in a message that can be dnl printed using the LIBBLOCKDEV_FAILURES macro. dnl dnl The syntax and behavior of MODULES is the same as for dnl PKG_CHECK_EXISTS. AC_DEFUN([LIBBLOCKDEV_PKG_CHECK_EXISTS], [dnl PKG_CHECK_EXISTS([$1], [], [LIBBLOCKDEV_SOFT_FAILURE([Check for $1 failed])]) ])dnl dnl LIBBLOCKDEV_CHECK_HEADER(HEADER, CFLAGS, ERR_MSG) dnl dnl Check if the given HEADER exists and is usable -- gcc can compile a source dnl file that just includes the HEADER using the given CFLAGS. In case of dnl failure, the ERR_MSG will be printed using the LIBBLOCKDEV_FAILURES macro. AC_DEFUN([LIBBLOCKDEV_CHECK_HEADER], [dnl echo -n "Checking header [$1] existence and usability..." temp_file=$(mktemp --tmpdir XXXXX.c) echo "#include <$1>" > $temp_file ${CC} -c [$2] $temp_file status=$? rm -f $temp_file rm -f $(basename ${temp_file%%.c}.o) if test $status = 0; then echo yes else echo no libblockdev_failure_messages="$libblockdev_failure_messages [$3]" fi ])dnl dnl LIBBLOCKDEV_PLUGIN(NAME, name) dnl dnl Define things needed in Makefile.am`s as well as sources for making dnl compilation and build modular. AC_DEFUN([LIBBLOCKDEV_PLUGIN], [dnl AC_ARG_WITH([$2], AS_HELP_STRING([--with-$2], [support $2 @<:@default=yes@:>@]), [], [with_$2=yes]) AC_SUBST([WITH_$1], [0]) AM_CONDITIONAL(WITH_$1, test "x$with_$2" != "xno") AS_IF([test "x$with_$2" != "xno"], [AC_DEFINE([WITH_BD_$1], [], [Define if $2 is supported]) AC_SUBST([WITH_$1], [1])], []) ])dnl dnl LIBBLOCKDEV_FAILURES dnl dnl Print the failure messages collected by LIBBLOCKDEV_SOFT_FAILURE, dnl LIBBLOCKDEV_PKG_CHECK_MODULES and LIBBLOCKDEV_CHECK_HEADER AC_DEFUN([LIBBLOCKDEV_FAILURES], [dnl AS_IF([test x"$libblockdev_failure_messages" = x], [], [dnl echo "" echo "*** Libblockdev encountered the following issues during configuration:" echo "$libblockdev_failure_messages" echo "" echo "*** Libblockdev will not successfully build without these missing dependencies" AS_EXIT(1) ])])dnl libblockdev-3.1.1-1/autogen.sh000077500000000000000000000006311460051510300161260ustar00rootroot00000000000000#!/bin/bash -e test -n "$srcdir" || srcdir=`dirname "$0"` test -n "$srcdir" || srcdir=. pushd $srcdir (test -f configure.ac) || { echo "*** ERROR: Directory "\`$srcdir\'" does not look like the top-level project directory ***" exit 1 } PKG_NAME=`autoconf --trace 'AC_INIT:$1' configure.ac` aclocal --install || exit 1 autoreconf --verbose --force --install -Wno-portability || exit 1 popd libblockdev-3.1.1-1/configure.ac000066400000000000000000000261031460051510300164150ustar00rootroot00000000000000# configure.ac for libblockdev AC_INIT([libblockdev], [3.1.1], [], [], [https://github.com/storaged-project/libblockdev]) # Disable building static libraries. # This needs to be set before initializing automake AC_DISABLE_STATIC AM_INIT_AUTOMAKE([foreign -Wall -Werror -Wno-syntax -Wno-portability]) AC_CONFIG_MACRO_DIR([m4]) AM_PATH_PYTHON AX_CHECK_ENABLE_DEBUG([no], [DEBUG], [NDEBUG]) AM_PROG_AR AC_PROG_CC LT_INIT AC_CONFIG_FILES([Makefile src/Makefile \ src/plugins/Makefile \ src/plugins/fs/Makefile \ src/plugins/nvme/Makefile \ src/utils/Makefile \ src/utils/blockdev-utils.pc \ src/lib/Makefile \ src/lib/plugin_apis/Makefile \ src/lib/blockdev.c \ src/lib/blockdev.pc \ src/python/Makefile \ src/python/gi/Makefile \ src/python/gi/overrides/Makefile \ include/Makefile \ include/blockdev/Makefile \ docs/Makefile \ docs/libblockdev-docs.xml \ dist/Makefile \ dist/libblockdev.spec \ scripts/Makefile \ tools/Makefile \ data/Makefile \ data/conf.d/Makefile]) m4_ifdef([GOBJECT_INTROSPECTION_CHECK], [GOBJECT_INTROSPECTION_CHECK([1.3.0])], [found_introspection=no AM_CONDITIONAL(HAVE_INTROSPECTION, false)]) AS_IF([test "x$found_introspection" = xyes], [AC_SUBST(WITH_GI, 1)], [AC_SUBST(WITH_GI, 0)]) AC_CANONICAL_HOST case $host_cpu in s390|s390x) on_s390=yes ;; *) on_s390=no ;; esac AC_ARG_WITH([s390], AS_HELP_STRING([--with-s390], [support s390 @<:@default=check@:>@]), [], [with_s390=check]) AC_SUBST(WITH_S390, 0) if test "x$with_s390" != "xno"; then AS_IF([test "x$on_s390" = "xno" -a "x$with_s390" = "xyes"], [LIBBLOCKDEV_SOFT_FAILURE([s390 support requested, but not on s390 arch]) AM_CONDITIONAL(WITH_S390, false)], [test "x$on_s390" = "xyes" -a "x$with_s390" != "xno"], [AC_SUBST(WITH_S390, 1) AM_CONDITIONAL(WITH_S390, true) ], [AC_SUBST(WITH_S390, 0) AM_CONDITIONAL(WITH_S390, false) ]) else AM_CONDITIONAL(WITH_S390, false) fi AC_ARG_WITH([python3], AS_HELP_STRING([--with-python3], [support python3 @<:@default=check@:>@]), [], [with_python3=check]) AC_SUBST(WITH_PYTHON3, 0) if test "x$with_python3" != "xno"; then AC_PATH_PROG([python3], [python3], [no]) AS_IF([test "x$python3" = "xno"], [if test "x$with_python3" = "xyes"; then LIBBLOCKDEV_SOFT_FAILURE([Python3 support requested, but python3 is not available]) fi], [AC_SUBST(WITH_PYTHON3, 1)]) fi AM_CONDITIONAL(WITH_PYTHON3, test "x$with_python3" != "xno" -a "x$python3" != "xno") AC_ARG_WITH([gtk-doc], AS_HELP_STRING([--with-gtk-doc], [generate documentation with gtk-doc @<:@default=check@:>@]), [], [with_gtk_doc=check]) AC_SUBST(WITH_GTK_DOC, 0) if test "x$with_gtk_doc" != "xno"; then AC_PATH_PROG([gtkdoc_scan], [gtkdoc-scan], [no]) AS_IF([test "x$gtkdoc_scan" = "xno"], [if test "x$with_gtk_doc" = "xyes"; then LIBBLOCKDEV_SOFT_FAILURE([Building documentation with gtk-doc requested, but not available]) fi], [AC_SUBST(WITH_GTK_DOC, 1)]) fi AM_CONDITIONAL(WITH_GTK_DOC, test "x$with_gtk_doc" != "xno" -a "x$gtkdoc_scan" != "xno") # Run tests on build? AC_ARG_ENABLE([tests], AS_HELP_STRING([--enable-tests], [Run tests at compile time (default=yes)])) test "x$enable_tests" = "x" && enable_tests="yes" AM_CONDITIONAL([TESTS_ENABLED], [test "x$enable_tests" = "xyes"]) AC_CHECK_HEADERS([dlfcn.h string.h unistd.h sys/fcntl.h sys/ioctl.h linux/random.h glob.h syslog.h math.h], [], [LIBBLOCKDEV_SOFT_FAILURE([Header file $ac_header not found.])], []) AC_ARG_WITH([escrow], AS_HELP_STRING([--with-escrow], [support escrow @<:@default=yes@:>@]), [], [with_escrow=yes]) AC_SUBST([WITH_ESCROW], [0]) AM_CONDITIONAL(WITH_ESCROW, test "x$with_escrow" != "xno") AS_IF([test "x$with_escrow" != "xno"], [AC_DEFINE([WITH_BD_ESCROW], [], [Define if escrow is supported]) AC_SUBST([WITH_ESCROW], [1])], []) AC_ARG_WITH([tools], AS_HELP_STRING([--with-tools], [build tools @<:@default=yes@:>@]), [], [with_tools=yes]) AC_SUBST([WITH_TOOLS], [0]) AM_CONDITIONAL(WITH_TOOLS, test "x$with_tools" != "xno") AS_IF([test "x$with_tools" != "xno"], [AC_SUBST([WITH_TOOLS], [1])], []) AC_ARG_WITH([nvme], AS_HELP_STRING([--with-nvme], [support nvme @<:@default=yes@:>@]), [], [with_nvme=yes]) AC_SUBST([WITH_NVME], [0]) AM_CONDITIONAL(WITH_NVME, test "x$with_nvme" != "xno") AS_IF([test "x$with_nvme" != "xno"], [AC_DEFINE([WITH_BD_NVME], [], [Define if nvme is supported]) AC_SUBST([WITH_NVME], [1])], []) LIBBLOCKDEV_PLUGIN([BTRFS], [btrfs]) LIBBLOCKDEV_PLUGIN([CRYPTO], [crypto]) LIBBLOCKDEV_PLUGIN([DM], [dm]) LIBBLOCKDEV_PLUGIN([LOOP], [loop]) LIBBLOCKDEV_PLUGIN([LVM], [lvm]) LIBBLOCKDEV_PLUGIN([LVM_DBUS], [lvm_dbus]) LIBBLOCKDEV_PLUGIN([MDRAID], [mdraid]) LIBBLOCKDEV_PLUGIN([MPATH], [mpath]) LIBBLOCKDEV_PLUGIN([SWAP], [swap]) LIBBLOCKDEV_PLUGIN([PART], [part]) LIBBLOCKDEV_PLUGIN([FS], [fs]) LIBBLOCKDEV_PLUGIN([NVDIMM], [nvdimm]) LIBBLOCKDEV_PLUGIN([NVME], [nvme]) dnl these packages/modules are always needed LIBBLOCKDEV_PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.42.2]) LIBBLOCKDEV_PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.42.2]) LIBBLOCKDEV_PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.42.2]) LIBBLOCKDEV_PKG_CHECK_MODULES([UDEV], [libudev >= 216]) LIBBLOCKDEV_PKG_CHECK_MODULES([KMOD], [libkmod >= 19]) AS_IF([test "x$with_crypto" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([CRYPTSETUP], [libcryptsetup >= 2.3.0]) AS_IF([$PKG_CONFIG --atleast-version=2.4.0 libcryptsetup], [AC_DEFINE([LIBCRYPTSETUP_24])], []) AS_IF([$PKG_CONFIG --atleast-version=2.6.0 libcryptsetup], [AC_DEFINE([LIBCRYPTSETUP_26])], []) AS_IF([test "x$with_escrow" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([NSS], [nss >= 3.18.0]) LIBBLOCKDEV_CHECK_HEADER([volume_key/libvolume_key.h], [$GLIB_CFLAGS $NSS_CFLAGS], [libvolume_key.h not available])], []) dnl pkg-config support was added in keyutils 1.6 but CentOS/RHEL 8 has only 1.5 LIBBLOCKDEV_CHECK_HEADER([keyutils.h], [], [keyutils.h not available]) ], []) AS_IF([test "x$with_dm" != "xno" -o "x$with_lvm" != "xno" -o "x$with_lvm_dbus" != "xno" -o "x$with_mpath" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.93])], []) AS_IF([test "x$with_part" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([FDISK], [fdisk >= 2.31.0])], []) AS_IF([test "x$with_swap" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([UUID], [uuid])], []) AS_IF([test "x$with_fs" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([UUID], [uuid]) LIBBLOCKDEV_PKG_CHECK_MODULES([MOUNT], [mount >= 2.23.0]) # new versions of libmount has some new functions we can use AS_IF([$PKG_CONFIG --atleast-version=2.30.0 mount], [AC_DEFINE([LIBMOUNT_NEW_ERR_API])], []) LIBBLOCKDEV_PKG_CHECK_MODULES([EXT2FS], [ext2fs e2p])] []) AS_IF([test "x$with_tools" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([PARTED], [libparted >= 3.1]) # older versions of parted don't provide the libparted-fs-resize.pc file AS_IF([$PKG_CONFIG libparted-fs-resize], [LIBBLOCKDEV_PKG_CHECK_MODULES([PARTED_FS], [libparted-fs-resize >= 3.2])], [AC_SUBST([PARTED_FS_LIBS], [-lparted-fs-resize]) AC_SUBST([PARTED_FS_CFLAGS], [])])], []) AS_IF([test "x$with_fs" != "xno" -o "x$with_crypto" != "xno" -o "x$with_swap" != "xno" -o "x$with_part" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([BLKID], [blkid >= 2.23.0]) # older versions of libblkid don't support BLKID_SUBLKS_BADCSUM so let's just # define it as 0 (neutral value for bit combinations of flags) AS_IF([$PKG_CONFIG --atleast-version=2.27.0 blkid], [], [AC_DEFINE([BLKID_SUBLKS_BADCSUM], [0], [Define as neutral value if libblkid doesn't provide the definition])])] []) AS_IF([test "x$with_btrfs" != "xno" -o "x$with_mdraid" != "xno" -o "x$with_tools" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([BYTESIZE], [bytesize >= 0.1])], []) AS_IF([test "x$with_nvdimm" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([UUID], [uuid]) LIBBLOCKDEV_PKG_CHECK_MODULES([NDCTL], [libndctl >= 58.4]) # new versions of libndctl new modes AS_IF([$PKG_CONFIG --atleast-version=60 libndctl], [AC_DEFINE([LIBNDCTL_NEW_MODES])], [])] []) AS_IF([test "x$with_nvme" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([NVME], [libnvme >= 1.3]) AS_IF([$PKG_CONFIG --atleast-version=1.4 libnvme], [AC_DEFINE([HAVE_LIBNVME_1_4])], []) ], []) AC_SUBST([MAJOR_VER], [3]) CFLAGS="$CFLAGS -std=gnu99" LIBBLOCKDEV_FAILURES AC_OUTPUT if test "x$with_python3" != "xno" -a "x$python3" != "xno"; then python3_info=yes else python3_info=no fi if test "x$with_s390" != "xno" -a "x$on_s390" = "xyes"; then s390_info=yes else s390_info=no fi dnl ========================================================================== echo " libblockdev $VERSION ==================== prefix: ${prefix} libdir: ${libdir} libexecdir: ${libexecdir} bindir: ${bindir} sbindir: ${sbindir} datadir: ${datadir} sysconfdir: ${sysconfdir} localstatedir: ${localstatedir} docdir: ${docdir} compiler: ${CC} cflags: ${CFLAGS} cppflags: ${CPPFLAGS} ldflags: ${LDFLAGS} BTRFS plugin: ${with_btrfs} Crypto plugin: ${with_crypto} escrow support: ${with_escrow} DM plugin: ${with_dm} FS plugin: ${with_fs} Loop plugin: ${with_loop} LVM plugin: ${with_lvm} LVM DBus plugin: ${with_lvm_dbus} MDRAID plugin: ${with_mdraid} MPath plugin ${with_mpath} NVDIMM plugin (deprecated): ${with_nvdimm} NVMe plugin: ${with_nvme} Part plugin: ${with_part} S390 plugin: ${s390_info} Swap plugin: ${with_swap} GObject introspection: ${found_introspection} Python 3 bindings: ${python3_info} tools: ${with_tools} " libblockdev-3.1.1-1/data/000077500000000000000000000000001460051510300150365ustar00rootroot00000000000000libblockdev-3.1.1-1/data/Makefile.am000066400000000000000000000000651460051510300170730ustar00rootroot00000000000000SUBDIRS = conf.d MAINTAINERCLEANFILES = Makefile.in libblockdev-3.1.1-1/data/conf.d/000077500000000000000000000000001460051510300162055ustar00rootroot00000000000000libblockdev-3.1.1-1/data/conf.d/00-default.cfg000066400000000000000000000017271460051510300205360ustar00rootroot00000000000000# This is the default configuration for the libblockdev library. For # each supported technology/plugin there is a separate section/group # with the 'sonames' key. The value of the key has to be a list of # sonames of shared objects that should be attempted to be loaded for # the plugin falling back to the next one in the list. # # So this example: # [lvm] # sonames=libbd_lvm-dbus.so.0;libbd_lvm.so.0 # # would result in the libbd_lvm-dbus.so.0 shared object attempted to # be loaded and if that failed, the libbd_lvm.so.0 would be attempted # to be loaded. [btrfs] sonames=libbd_btrfs.so.3 [crypto] sonames=libbd_crypto.so.3 [dm] sonames=libbd_dm.so.3 [fs] sonames=libbd_fs.so.3 [loop] sonames=libbd_loop.so.3 [lvm] sonames=libbd_lvm.so.3 [mdraid] sonames=libbd_mdraid.so.3 [mpath] sonames=libbd_mpath.so.3 [nvdimm] sonames=libbd_nvdimm.so.3 [nvme] sonames=libbd_nvme.so.3 [part] sonames=libbd_part.so.3 [swap] sonames=libbd_swap.so.3 [s390] sonames=libbd_s390.so.3 libblockdev-3.1.1-1/data/conf.d/10-lvm-dbus.cfg000066400000000000000000000000421460051510300206310ustar00rootroot00000000000000[lvm] sonames=libbd_lvm-dbus.so.3 libblockdev-3.1.1-1/data/conf.d/Makefile.am000066400000000000000000000003301460051510300202350ustar00rootroot00000000000000libbdconfdir = $(sysconfdir)/libblockdev/@MAJOR_VER@/conf.d dist_libbdconf_DATA = ${srcdir}/00-default.cfg if WITH_LVM_DBUS dist_libbdconf_DATA += ${srcdir}/10-lvm-dbus.cfg endif MAINTAINERCLEANFILES = Makefile.in libblockdev-3.1.1-1/dist/000077500000000000000000000000001460051510300150705ustar00rootroot00000000000000libblockdev-3.1.1-1/dist/Makefile.am000066400000000000000000000001311460051510300171170ustar00rootroot00000000000000dist_noinst_DATA = libblockdev.spec MAINTAINERCLEANFILES = Makefile.in libblockdev.spec libblockdev-3.1.1-1/dist/libblockdev.spec.in000066400000000000000000000675001460051510300206410ustar00rootroot00000000000000%define with_python3 @WITH_PYTHON3@ %define with_gtk_doc @WITH_GTK_DOC@ %define with_btrfs @WITH_BTRFS@ %define with_crypto @WITH_CRYPTO@ %define with_dm @WITH_DM@ %define with_loop @WITH_LOOP@ %define with_lvm @WITH_LVM@ %define with_lvm_dbus @WITH_LVM_DBUS@ %define with_mdraid @WITH_MDRAID@ %define with_mpath @WITH_MPATH@ %define with_swap @WITH_SWAP@ %define with_part @WITH_PART@ %define with_fs @WITH_FS@ %define with_nvdimm @WITH_NVDIMM@ %define with_gi @WITH_GI@ %define with_escrow @WITH_ESCROW@ %define with_tools @WITH_TOOLS@ %define with_nvme @WITH_NVME@ # btrfs is not available on RHEL > 7 %if 0%{?rhel} > 7 || %{with_btrfs} == 0 %define with_btrfs 0 %define btrfs_copts --without-btrfs %endif %if %{with_btrfs} != 1 %define btrfs_copts --without-btrfs %endif %if %{with_crypto} != 1 %define crypto_copts --without-crypto %else %if %{with_escrow} != 1 %define crypto_copts --without-escrow %endif %endif %if %{with_dm} != 1 %define dm_copts --without-dm %else %endif %if %{with_loop} != 1 %define loop_copts --without-loop %endif %if %{with_lvm} != 1 %define lvm_copts --without-lvm %endif %if %{with_lvm_dbus} != 1 %define lvm_dbus_copts --without-lvm_dbus %endif %if %{with_mdraid} != 1 %define mdraid_copts --without-mdraid %endif %if %{with_mpath} != 1 %define mpath_copts --without-mpath %endif %if %{with_swap} != 1 %define swap_copts --without-swap %endif %if %{with_part} != 1 %define part_copts --without-part %endif %if %{with_fs} != 1 %define fs_copts --without-fs %endif %if %{with_nvdimm} != 1 %define nvdimm_copts --without-nvdimm %endif %if %{with_tools} != 1 %define tools_copts --without-tools %endif %if %{with_gi} != 1 %define gi_copts --disable-introspection %endif %if %{with_nvme} != 1 %define nvme_copts --without-nvme %endif %define configure_opts %{?python3_copts} %{?lvm_dbus_copts} %{?btrfs_copts} %{?crypto_copts} %{?dm_copts} %{?loop_copts} %{?lvm_copts} %{?lvm_dbus_copts} %{?mdraid_copts} %{?mpath_copts} %{?swap_copts} %{?part_copts} %{?fs_copts} %{?nvdimm_copts} %{?tools_copts} %{?gi_copts} %{?nvme_copts} Name: libblockdev Version: 3.1.1 Release: 1%{?dist} Summary: A library for low-level manipulation with block devices License: LGPL-2.1-or-later URL: https://github.com/storaged-project/libblockdev Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-%{release}/%{name}-%{version}.tar.gz BuildRequires: make BuildRequires: glib2-devel %if %{with_gi} BuildRequires: gobject-introspection-devel %endif %if %{with_python3} BuildRequires: python3-devel %endif %if %{with_gtk_doc} BuildRequires: gtk-doc %endif BuildRequires: glib2-doc BuildRequires: autoconf-archive # obsolete removed subpackages to allow upgrades Provides: libblockdev-kbd = %{version}-%{release} Obsoletes: libblockdev-kbd < %{version}-%{release} Provides: libblockdev-vdo = %{version}-%{release} Obsoletes: libblockdev-vdo < %{version}-%{release} Requires: %{name}-utils%{?_isa} = %{version}-%{release} %description The libblockdev is a C library with GObject introspection support that can be used for doing low-level operations with block devices like setting up LVM, BTRFS, LUKS or MD RAID. The library uses plugins (LVM, BTRFS,...) and serves as a thin wrapper around its plugins' functionality. All the plugins, however, can be used as standalone libraries. One of the core principles of libblockdev is that it is stateless from the storage configuration's perspective (e.g. it has no information about VGs when creating an LV). %package devel Summary: Development files for libblockdev Requires: %{name}%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel # obsolete removed devel subpackages to allow upgrades Provides: libblockdev-kbd-devel = %{version}-%{release} Obsoletes: libblockdev-kbd-devel < %{version}-%{release} Provides: libblockdev-vdo-devel = %{version}-%{release} Obsoletes: libblockdev-vdo-devel < %{version}-%{release} %description devel This package contains header files and pkg-config files needed for development with the libblockdev library. %if %{with_python3} %package -n python3-blockdev Summary: Python3 gobject-introspection bindings for libblockdev Requires: %{name}%{?_isa} = %{version}-%{release} Requires: python3-gobject-base Requires: python3-bytesize %{?python_provide:%python_provide python3-blockdev} %description -n python3-blockdev This package contains enhancements to the gobject-introspection bindings for libblockdev in Python3. %endif %package utils BuildRequires: kmod-devel Summary: A library with utility functions for the libblockdev library %description utils The libblockdev-utils is a library providing utility functions used by the libblockdev library and its plugins. %package utils-devel Summary: Development files for libblockdev-utils Requires: %{name}-utils%{?_isa} = %{version}-%{release} Requires: glib2-devel %description utils-devel This package contains header files and pkg-config files needed for development with the libblockdev-utils library. %if %{with_btrfs} %package btrfs BuildRequires: libbytesize-devel Summary: The BTRFS plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} Requires: btrfs-progs %description btrfs The libblockdev library plugin (and in the same time a standalone library) providing the BTRFS-related functionality. %package btrfs-devel Summary: Development files for the libblockdev-btrfs plugin/library Requires: %{name}-btrfs%{?_isa} = %{version}-%{release} Requires: glib2-devel Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} %description btrfs-devel This package contains header files and pkg-config files needed for development with the libblockdev-btrfs plugin/library. %endif %if %{with_crypto} %package crypto Requires: %{name}-utils%{?_isa} = %{version}-%{release} BuildRequires: cryptsetup-devel >= 2.3.0 BuildRequires: libblkid-devel BuildRequires: keyutils-libs-devel %if %{with_escrow} BuildRequires: volume_key-devel >= 0.3.9-7 BuildRequires: nss-devel %endif Summary: The crypto plugin for the libblockdev library %description crypto The libblockdev library plugin (and in the same time a standalone library) providing the functionality related to encrypted devices (LUKS). %package crypto-devel Summary: Development files for the libblockdev-crypto plugin/library Requires: %{name}-crypto%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel %description crypto-devel This package contains header files and pkg-config files needed for development with the libblockdev-crypto plugin/library. %endif %if %{with_dm} %package dm BuildRequires: device-mapper-devel BuildRequires: systemd-devel Summary: The Device Mapper plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} Requires: device-mapper %description dm The libblockdev library plugin (and in the same time a standalone library) providing the functionality related to Device Mapper. %package dm-devel Summary: Development files for the libblockdev-dm plugin/library Requires: %{name}-dm%{?_isa} = %{version}-%{release} Requires: glib2-devel Requires: device-mapper-devel Requires: systemd-devel Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} %description dm-devel This package contains header files and pkg-config files needed for development with the libblockdev-dm plugin/library. %endif %if %{with_fs} %package fs BuildRequires: libblkid-devel BuildRequires: libmount-devel BuildRequires: libuuid-devel BuildRequires: e2fsprogs-devel Summary: The FS plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} %description fs The libblockdev library plugin (and in the same time a standalone library) providing the functionality related to operations with file systems. %package fs-devel Summary: Development files for the libblockdev-fs plugin/library Requires: %{name}-fs%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel %description fs-devel This package contains header files and pkg-config files needed for development with the libblockdev-fs plugin/library. %endif %if %{with_loop} %package loop Summary: The loop plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} %description loop The libblockdev library plugin (and in the same time a standalone library) providing the functionality related to loop devices. %package loop-devel Summary: Development files for the libblockdev-loop plugin/library Requires: %{name}-loop%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel %description loop-devel This package contains header files and pkg-config files needed for development with the libblockdev-loop plugin/library. %endif %if %{with_lvm} %package lvm BuildRequires: device-mapper-devel Summary: The LVM plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} Requires: lvm2 %description lvm The libblockdev library plugin (and in the same time a standalone library) providing the LVM-related functionality. %package lvm-devel Summary: Development files for the libblockdev-lvm plugin/library Requires: %{name}-lvm%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel %description lvm-devel This package contains header files and pkg-config files needed for development with the libblockdev-lvm plugin/library. %endif %if %{with_lvm_dbus} %package lvm-dbus BuildRequires: device-mapper-devel Summary: The LVM plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} Requires: lvm2-dbusd >= 2.02.156 %description lvm-dbus The libblockdev library plugin (and in the same time a standalone library) providing the LVM-related functionality utilizing the LVM DBus API. %package lvm-dbus-devel Summary: Development files for the libblockdev-lvm-dbus plugin/library Requires: %{name}-lvm-dbus%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel %description lvm-dbus-devel This package contains header files and pkg-config files needed for development with the libblockdev-lvm-dbus plugin/library. %endif %if %{with_mdraid} %package mdraid BuildRequires: libbytesize-devel Summary: The MD RAID plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} Requires: mdadm %description mdraid The libblockdev library plugin (and in the same time a standalone library) providing the functionality related to MD RAID. %package mdraid-devel Summary: Development files for the libblockdev-mdraid plugin/library Requires: %{name}-mdraid%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel %description mdraid-devel This package contains header files and pkg-config files needed for development with the libblockdev-mdraid plugin/library. %endif %if %{with_mpath} %package mpath BuildRequires: device-mapper-devel Summary: The multipath plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} Recommends: device-mapper-multipath %description mpath The libblockdev library plugin (and in the same time a standalone library) providing the functionality related to multipath devices. %package mpath-devel Summary: Development files for the libblockdev-mpath plugin/library Requires: %{name}-mpath%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel %description mpath-devel This package contains header files and pkg-config files needed for development with the libblockdev-mpath plugin/library. %endif %if %{with_nvdimm} %package nvdimm BuildRequires: ndctl-devel BuildRequires: libuuid-devel Summary: The NVDIMM plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} Requires: ndctl %description nvdimm The libblockdev library plugin (and in the same time a standalone library) providing the functionality related to operations with NVDIMM devices. %package nvdimm-devel Summary: Development files for the libblockdev-nvdimm plugin/library Requires: %{name}-nvdimm%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel %description nvdimm-devel This package contains header files and pkg-config files needed for development with the libblockdev-nvdimm plugin/library. %endif %if %{with_nvme} %package nvme BuildRequires: libnvme-devel BuildRequires: libuuid-devel Summary: The NVMe plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} %description nvme The libblockdev library plugin (and in the same time a standalone library) providing the functionality related to operations with NVMe devices. %package nvme-devel Summary: Development files for the libblockdev-nvme plugin/library Requires: %{name}-nvme%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel %description nvme-devel This package contains header files and pkg-config files needed for development with the libblockdev-nvme plugin/library. %endif %if %{with_part} %package part BuildRequires: libfdisk-devel Summary: The partitioning plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} Requires: util-linux %description part The libblockdev library plugin (and in the same time a standalone library) providing the functionality related to partitioning. %package part-devel Summary: Development files for the libblockdev-part plugin/library Requires: %{name}-part%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel %description part-devel This package contains header files and pkg-config files needed for development with the libblockdev-part plugin/library. %endif %if %{with_swap} %package swap BuildRequires: libblkid-devel Summary: The swap plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} Requires: util-linux %description swap The libblockdev library plugin (and in the same time a standalone library) providing the functionality related to swap devices. %package swap-devel Summary: Development files for the libblockdev-swap plugin/library Requires: %{name}-swap%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel %description swap-devel This package contains header files and pkg-config files needed for development with the libblockdev-swap plugin/library. %endif %if %{with_tools} %package tools Summary: Various nice tools based on libblockdev Requires: %{name} = %{version}-%{release} Requires: %{name}-lvm = %{version}-%{release} BuildRequires: libbytesize-devel BuildRequires: parted-devel %if %{with_lvm_dbus} == 1 Recommends: %{name}-lvm-dbus %endif %description tools Various nice storage-related tools based on libblockdev. %endif %ifarch s390 s390x %package s390 Summary: The s390 plugin for the libblockdev library Requires: %{name}-utils%{?_isa} = %{version}-%{release} Requires: s390utils %description s390 The libblockdev library plugin (and in the same time a standalone library) providing the functionality related to s390 devices. %package s390-devel Summary: Development files for the libblockdev-s390 plugin/library Requires: %{name}-s390%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release} Requires: glib2-devel %description s390-devel This package contains header files and pkg-config files needed for development with the libblockdev-s390 plugin/library. %endif %package plugins-all Summary: Meta-package that pulls all the libblockdev plugins as dependencies Requires: %{name}%{?_isa} = %{version}-%{release} %if %{with_btrfs} Requires: %{name}-btrfs%{?_isa} = %{version}-%{release} %endif %if %{with_crypto} Requires: %{name}-crypto%{?_isa} = %{version}-%{release} %endif %if %{with_dm} Requires: %{name}-dm%{?_isa} = %{version}-%{release} %endif %if %{with_fs} Requires: %{name}-fs%{?_isa} = %{version}-%{release} %endif %if %{with_loop} Requires: %{name}-loop%{?_isa} = %{version}-%{release} %endif %if %{with_lvm} Requires: %{name}-lvm%{?_isa} = %{version}-%{release} %endif %if %{with_mdraid} Requires: %{name}-mdraid%{?_isa} = %{version}-%{release} %endif %if %{with_mpath} Requires: %{name}-mpath%{?_isa} = %{version}-%{release} %endif %if %{with_nvdimm} Requires: %{name}-nvdimm%{?_isa} = %{version}-%{release} %endif %if %{with_nvme} Requires: %{name}-nvme%{?_isa} = %{version}-%{release} %endif %if %{with_part} Requires: %{name}-part%{?_isa} = %{version}-%{release} %endif %if %{with_swap} Requires: %{name}-swap%{?_isa} = %{version}-%{release} %endif %ifarch s390 s390x Requires: %{name}-s390%{?_isa} = %{version}-%{release} %endif %description plugins-all A meta-package that pulls all the libblockdev plugins as dependencies. %prep %autosetup -n %{name}-%{version} -p1 %build autoreconf -ivf %configure %{?configure_opts} %{__make} %{?_smp_mflags} %install %{make_install} find %{buildroot} -type f -name "*.la" | xargs %{__rm} %ldconfig_scriptlets %ldconfig_scriptlets utils %if %{with_btrfs} %ldconfig_scriptlets btrfs %endif %if %{with_crypto} %ldconfig_scriptlets crypto %endif %if %{with_dm} %ldconfig_scriptlets dm %endif %if %{with_fs} %ldconfig_scriptlets fs %endif %if %{with_loop} %ldconfig_scriptlets loop %endif %if %{with_lvm} %ldconfig_scriptlets lvm %endif %if %{with_lvm_dbus} %ldconfig_scriptlets lvm-dbus %endif %if %{with_mdraid} %ldconfig_scriptlets mdraid %endif %if %{with_mpath} %ldconfig_scriptlets mpath %endif %if %{with_nvdimm} %ldconfig_scriptlets nvdimm %endif %if %{with_nvme} %ldconfig_scriptlets nvme %endif %if %{with_part} %ldconfig_scriptlets part %endif %if %{with_swap} %ldconfig_scriptlets swap %endif %ifarch s390 s390x %ldconfig_scriptlets s390 %endif %files %{!?_licensedir:%global license %%doc} %license LICENSE %{_libdir}/libblockdev.so.* %if %{with_gi} %{_libdir}/girepository*/BlockDev*.typelib %endif %dir %{_sysconfdir}/libblockdev %dir %{_sysconfdir}/libblockdev/@MAJOR_VER@/conf.d %config %{_sysconfdir}/libblockdev/@MAJOR_VER@/conf.d/00-default.cfg %files devel %{_libdir}/libblockdev.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/blockdev.h %{_includedir}/blockdev/plugins.h %{_libdir}/pkgconfig/blockdev.pc %if %{with_gtk_doc} %{_datadir}/gtk-doc/html/libblockdev %endif %if %{with_gi} %{_datadir}/gir*/BlockDev*.gir %endif %if %{with_python3} %files -n python3-blockdev %{python3_sitearch}/gi/overrides/BlockDev* %{python3_sitearch}/gi/overrides/__pycache__/BlockDev* %endif %files utils %{_libdir}/libbd_utils.so.* %files utils-devel %{_libdir}/libbd_utils.so %{_libdir}/pkgconfig/blockdev-utils.pc %dir %{_includedir}/blockdev %{_includedir}/blockdev/utils.h %{_includedir}/blockdev/sizes.h %{_includedir}/blockdev/exec.h %{_includedir}/blockdev/extra_arg.h %{_includedir}/blockdev/dev_utils.h %{_includedir}/blockdev/module.h %{_includedir}/blockdev/dbus.h %{_includedir}/blockdev/logging.h %if %{with_btrfs} %files btrfs %{_libdir}/libbd_btrfs.so.* %files btrfs-devel %{_libdir}/libbd_btrfs.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/btrfs.h %endif %if %{with_crypto} %files crypto %{_libdir}/libbd_crypto.so.* %files crypto-devel %{_libdir}/libbd_crypto.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/crypto.h %endif %if %{with_dm} %files dm %{_libdir}/libbd_dm.so.* %files dm-devel %{_libdir}/libbd_dm.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/dm.h %endif %if %{with_fs} %files fs %{_libdir}/libbd_fs.so.* %files fs-devel %{_libdir}/libbd_fs.so %dir %{_includedir}/blockdev %dir %{_includedir}/blockdev/fs %{_includedir}/blockdev/fs.h %{_includedir}/blockdev/fs/*.h %endif %if %{with_loop} %files loop %{_libdir}/libbd_loop.so.* %files loop-devel %{_libdir}/libbd_loop.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/loop.h %endif %if %{with_lvm} %files lvm %{_libdir}/libbd_lvm.so.* %files lvm-devel %{_libdir}/libbd_lvm.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/lvm.h %endif %if %{with_lvm_dbus} %files lvm-dbus %{_libdir}/libbd_lvm-dbus.so.* %config %{_sysconfdir}/libblockdev/@MAJOR_VER@/conf.d/10-lvm-dbus.cfg %files lvm-dbus-devel %{_libdir}/libbd_lvm-dbus.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/lvm.h %endif %if %{with_mdraid} %files mdraid %{_libdir}/libbd_mdraid.so.* %files mdraid-devel %{_libdir}/libbd_mdraid.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/mdraid.h %endif %if %{with_mpath} %files mpath %{_libdir}/libbd_mpath.so.* %files mpath-devel %{_libdir}/libbd_mpath.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/mpath.h %endif %if %{with_nvdimm} %files nvdimm %{_libdir}/libbd_nvdimm.so.* %files nvdimm-devel %{_libdir}/libbd_nvdimm.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/nvdimm.h %endif %if %{with_nvme} %files nvme %{_libdir}/libbd_nvme.so.* %files nvme-devel %{_libdir}/libbd_nvme.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/nvme.h %endif %if %{with_part} %files part %{_libdir}/libbd_part.so.* %files part-devel %{_libdir}/libbd_part.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/part.h %endif %if %{with_swap} %files swap %{_libdir}/libbd_swap.so.* %files swap-devel %{_libdir}/libbd_swap.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/swap.h %endif %if %{with_tools} %files tools %{_bindir}/lvm-cache-stats %{_bindir}/vfat-resize %endif %ifarch s390 s390x %files s390 %{_libdir}/libbd_s390.so.* %files s390-devel %{_libdir}/libbd_s390.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/s390.h %endif %files plugins-all %changelog * Tue Mar 26 2024 Vojtech Trefny - 3.1.1-1 - lvm-dbus: Fix passing size for pvresize over DBus (vtrefny) - nvme: Add bd_nvme_is_tech_avail to the API file (vtrefny) - tests: Add NVMe controller type checks (tbzatek) - tests: Add NVMe persistent discovery controller tests (tbzatek) - tests: Fix removing custom LVM devices file (vtrefny) - tests: Ignore LVM devices file for non-LVM tests (vtrefny) - tests: Manually remove removed PVs from LVM devices file (vtrefny) - dm_logging: Annotate redirect_dm_log() printf format (tbzatek) - Fix some more occurrences of missing port to G_GNUC_UNUSED (tbzatek) - Port to G_GNUC_INTERNAL for controlling symbols visibility (tbzatek) - Use glib2 G_GNUC_UNUSED in place of UNUSED locally defined (giulio.benetti) - Makefile: Fix bumpver to work with micro versions (vtrefny) * Fri Jan 19 2024 Vojtech Trefny - 3.1.0-1 - tests: Skip some checks for btrfs errors with btrfs-progs 6.6.3 (vtrefny) - Fix missing progress initialization in bd_crypto_luks_add_key (vtrefny) - fs: Report reason for open() and ioctl() failures (tbzatek) - utils: Add expected printf string annotation (tbzatek) - lvm-dbus: Avoid using already-freed memory (tbzatek) - lvm-dbus: Fix leaking error (tbzatek) - python: Add a deepcopy function to our structs (vtrefny) - tests: Remove unreliable nvme attribute checks (tbzatek) - tests: Use BDPluginSpec constructor in LVM DBus plugin tests (vtrefny) - tests: Avoid setting up intermediary loop device for the nvme target (tbzatek) - tests: Default to /tmp for create_sparse_tempfile() (tbzatek) - part: Fix potential double free when getting parttype (vtrefny) - Mark NVDIMM plugin as deprecated since 3.1 (vtrefny) - tests: Remove some obsolete rules to skip tests (vtrefny) - fs: Add support for getting filesystem min size for NTFS and Ext (vtrefny) - fs: Fix allowed UUID for generic mkfs with VFAT (vtrefny) - fs: Add a generic function to check for fs info availability (vtrefny) - fs: Add a function to check label format for F2FS (vtrefny) - swap: Add support for checking label and UUID format (vtrefny) - ci: Remove the custom version command for Packit (vtrefny) - ci: Manually prepare spec file for Packit (vtrefny) - overrides: Remove unused 'sys' import (vtrefny) - Add BDPluginSpec constructor and use it in plugin_specs_from_names (vtrefny) - Sync spec with downstream (vtrefny) - ci: Add an action to compile libblockdev with different compilers (vtrefny) * Fri Oct 13 2023 Vojtech Trefny - 3.0.4-1 - tests: Fix "invalid escape sequence '\#'" warning from Python 3.12 (vtrefny) - tests: Fail early when recompilation fails in library_test (vtrefny) - lvm-dbus: Replace g_critical calls with bd_utils_log_format (vtrefny) - Use log function when calling a plugin function that is not loaded (vtrefny) - logging: Default to DEBUG log level if compiled with --enable-debug (vtrefny) - nvme: Rework memory allocation for device ioctls (tbzatek) - packit: Add configuration for downstream builds (vtrefny) - fs: correct btrfs set label description (jvanderwaa) - fs: Disable progress for ntfsresize (vtrefny) - part: Do not open disk read-write for read only operations (vtrefny) - ci: Bump actions/checkout from v3 to v4 (vtrefny) - plugins: btrfs: use g_autofree where possible for g_free (jvanderwaa) - plugins: use g_autofree for free'ing g_char's (jvanderwaa) - spec: Move obsoleted devel subpackages to libblockdev-devel (vtrefny) - spec: Obsolete vdo plugin packages (vtrefny) * Wed Sep 06 2023 Vojtech Trefny - 3.0.3-2 - Obsolete vdo plugin packages (#2237477) * Thu Aug 31 2023 Vojtech Trefny - 3.0.3-1 - crypto: Correctly convert passphrases from Python to C (vtrefny) - tests: Minor NVMe HostNQN fixes (tbzatek) - nvme: Generate HostID when missing (tbzatek) - Always use "--fs ignore" with lvresize (mvollmer) - nvme: Use interim buffer for nvme_get_log_sanitize() (tbzatek) - fs: Fix memory leak (vtrefny) - fs: Fix leaking directories with temporary mounts (vtrefny) - tests: Specificy required versions when importing GLib and BlockDev introspection (biebl) - tests: Replace deprecated unittest assert calls (vtrefny) * Thu Jul 20 2023 Vojtech Trefny - 3.0.2-1 - fs: Avoid excess logging in extract_e2fsck_progress (vtrefny) - loop: Report BD_LOOP_ERROR_DEVICE on empty loop devices (tbzatek) - lib: Silence the missing DEFAULT_CONF_DIR_PATH (tbzatek) - fs: Document that generic functions can mount filesystems (vtrefny) - fs: Use read-only mount where possible for generic FS functions (vtrefny) - docs: Fix test quotation (marecki) - fs: Fix unused error in extract_e2fsck_progress (vtrefny) - Use ntfsinfo instead of ntfscluster for faster bd_fs_ntfs_get_info (amubtdx) - Restrict list of exported symbols via -export-symbols-regex (biebl) - Fix formatting in NEWS.rst (vtrefny) * Tue Jul 04 2023 Python Maint - 3.0.1-2 - Rebuilt for Python 3.12 * Tue Jul 04 2023 Vojtech Trefny - 3.0.1-1 - fs: Simplify struct BDFSInfo (tbzatek) - boilerplate_generator: Annotate stub func args as G_GNUC_UNUSED (tbzatek) - crypto: Remove stray struct redefinition (tbzatek) - loop: Remove unused variable (tbzatek) - build: Exit before AC_OUTPUT on error (tbzatek) - loop: define LOOP_SET_BLOCK_SIZE is not defined (giulio.benetti) - Make the conf.d directory versioned (vtrefny) - configure: Fix MAJOR_VER macro (vtrefny) - spec: Add dependency on libblockdev-utils to the s390 plugin (vtrefny) - nvme: Mark private symbols as hidden (tbzatek) - dist: Sync spec with downstream (vtrefny) - misc: Update steps and Dockerfile for Python documentation (vtrefny) - fs: Add missing copy and free functions to the header file (vtrefny) - lvm: Add bd_lvm_segdata_copy/free to the header file (vtrefny) - loop: Remove bd_loop_get_autoclear definition (vtrefny) - lvm: Fix declaration for bd_lvm_vdolvpoolname (vtrefny) - lvm: Make _vglock_start_stop static (vtrefny) - vdo_stats: Remove unused libparted include (vtrefny) * Thu Jun 29 2023 Python Maint - 3.0-2 - Rebuilt for Python 3.12 * Fri Jun 23 2023 Vojtech Trefny - 3.0-1 - Libblockdev 3.0 release libblockdev-3.1.1-1/docs/000077500000000000000000000000001460051510300150555ustar00rootroot00000000000000libblockdev-3.1.1-1/docs/3.0-api-changes.xml000066400000000000000000000217561460051510300202670ustar00rootroot00000000000000 API changes in libblockdev 3.0 This is a list of API changes in libblockdev 3.0 with suggested replacements. Library bd_switch_init_checks() has been removed. Checks for runtime dependencies during libblockdev initialization are now disabled and plugins will be loaded even if a runtime dependency is missing. bd_"plugin"_check_deps functions have been removed from all plugins. Use bd_"plugin"_is_tech_avail to check for plugin dependencies. LVM plugin bd_lvm_data_lv_name() has been removed, use data_lv from BDLVMLVdata instead. bd_lvm_metadadata_lv_name() has been removed, use metadata_lv from BDLVMLVdata instead. BD_LVM_MAX_LV_SIZE constant has been removed, use bd_lvm_get_max_lv_size() instead. Multiple thinpool and cache metadata size related constants have been removed without replacement. We recommend using functions like bd_lvm_get_thpool_meta_size instead. Removed constants: BD_LVM_MIN_THPOOL_MD_SIZE, BD_LVM_MAX_THPOOL_MD_SIZE, BD_LVM_MIN_THPOOL_CHUNK_SIZE, BD_LVM_MIN_CACHE_MD_SIZE, BD_LVM_DEFAULT_CHUNK_SIZE, BD_LVM_MAX_PE_SIZE, BD_LVM_MIN_PE_SIZE, BD_LVM_DEFAULT_PE_START and BD_LVM_DEFAULT_PE_SIZE. bd_lvm_lvactivate() has a new parameter shared, use FALSE to preserve the original behaviour. VDO plugin VDO plugin has been removed. Crypto plugin bd_crypto_luks_uuid() has been removed, use uuid from BDCryptoLUKSInfo instead. bd_crypto_luks_get_metadata_size() has been removed, use metadata_size from BDCryptoLUKSInfo instead. LUKS2-specific functions were removed. The "generic" LUKS functions which now support both LUKSv1 and LUKSv2 should be used instead. Affected functions: bd_crypto_luks_format_luks2 and bd_crypto_luks_resize_luks2. bd_crypto_luks_open_keyring has been removed, bd_crypto_luks_open with the keyring context (see below) can be used instead. bd_crypto_tc_open_full has been removed, bd_crypto_tc_open can be used instead. bd_crypto_tc_open arguments have been changed to match the "full" function. Functions that allowed using arbitrary binary data for passphrases were removed. The "generic" functions should be used instead, see the key slot context information below. Affected functions: bd_crypto_luks_format_blob, bd_crypto_luks_format_luks2_blob, bd_crypto_luks_open_blob, bd_crypto_luks_add_key_blob, bd_crypto_luks_remove_key_blob, bd_crypto_luks_change_key_blob, and bd_crypto_luks_resume_blob. All functions that require some type of passphrase or key as an input now expect BDCryptoKeyslotContext instead. This is a private opaque context that needs to be set by one of the bd_crypto_keyslot_context_new_* functions based on the type of the context required. NVDIMM plugin bd_nvdimm_namepace_get_supported_sector_sizes has been removed, use bd_nvdimm_namespace_get_supported_sector_sizes instead. FS plugin bd_fs_clean and bd_fs_wipe have new parameter force that allows controlling whether the signatures will be removed from a mounted device or not. Use TRUE to preserve the original behaviour. Following functions have a new parameter fstype that allows to skip scanning the device for signature. Use NULL to preserve the original behaviour. Affected functions: bd_fs_resize, bd_fs_repair, bd_fs_check, bd_fs_set_label, bd_fs_set_uuid, bd_fs_get_size and bd_fs_get_free_space Type-specific bd_fs_..._wipe functions have been removed. Use bd_fs_wipe or bd_fs_clean instead. Affected functions: bd_fs_btrfs_wipe, bd_fs_ext2_wipe, bd_fs_ext3_wipe, bd_fs_ext4_wipe, bd_fs_exfat_wipe, bd_fs_f2fs_wipe, bd_fs_nilfs2_wipe, bd_fs_ntfs_wipe, bd_fs_vfat_wipe, bd_fs_udf_wipe, bd_fs_xfs_wipe bd_fs_ntfs_check, bd_fs_ntfs_repair and bd_fs_xfs_check have a new parameter extra that allows specifying extra options for the fsck tools. This makes the functionality consistent with the other filesystems. BDFsResizeFlags enum was renamed to BDFSResizeFlags. BDFsError enum was renamed to BDFSError. Part plugin The part plugin has been rewritten to use libfdisk library instead of libparted. The following functions, enums and definitions related to partition and disk flags have been removed. bd_part_set_part_flag, bd_part_get_flag_str, bd_part_set_disk_flag, bd_part_set_part_flags, BDPartFlag and BDPartDiskFlag. We recommend using the bd_part_set_part_type and bd_part_set_part_id functions to set partition GUID (GPT) or ID (MSDOS) to set the required type/id instead. New functions bd_part_set_part_bootable and bd_part_set_part_attributes have been added to allow controlling the bootable flag (MSDOS) and partition attributes (GPT). The bd_part_get_part_id function has been removed. The partition id parameter is now available in BDPartSpec. KBD plugin KBD plugin (providing support for bcache and zRAM devices) has been removed. Loop plugin bd_loop_setup and bd_loop_setup_from_fd has a new parameter sector_size. Use 0 to preserve the original behaviour. bd_loop_get_backing_file and bd_loop_get_autoclear have been removed. Use bd_loop_info instead. DM plugin Support for DM RAID (BD_DM_TECH_RAID technology) was removed from the plugin. Following functions were removed without replacement: bd_dm_get_member_raid_sets, bd_dm_activate_raid_set, bd_dm_deactivate_raid_set and bd_dm_get_raid_set_type. MDRAID plugin The bitmap argument of the bd_md_create function now accepts arbitrary string instead of a boolean value. Previous value of FALSE is now represented by NULL, i.e. letting mdadm decide itself whether to create an internal bitmap or not. Swap plugin bd_swap_mkswap has a new optional parameter uuid. libblockdev-3.1.1-1/docs/Makefile.am000066400000000000000000000041261460051510300171140ustar00rootroot00000000000000all-local: html-doc.stamp html-doc.stamp: ${srcdir}/libblockdev-docs.xml ${srcdir}/libblockdev-sections.txt ${srcdir}/3.0-api-changes.xml $(wildcard ${srcdir}/../src/plugins/*.[ch]) $(wildcard ${srcdir}/../src/lib/*.[ch]) $(wildcard ${srcdir}/../src/utils/*.[ch]) touch ${builddir}/html-doc.stamp test "${builddir}" = "${srcdir}" || cp ${srcdir}/libblockdev-sections.txt ${srcdir}/libblockdev-docs.xml ${builddir} gtkdoc-scan --rebuild-types --module=libblockdev --source-dir=${srcdir}/../src/plugins/ --source-dir=${srcdir}/../src/lib/ --source-dir=${srcdir}/../src/utils/ --ignore-headers="${srcdir}/../src/plugins/check_deps.h ${srcdir}/../src/plugins/dm_logging.h ${srcdir}/../src/plugins/vdo_stats.h ${srcdir}/../src/plugins/fs/common.h" gtkdoc-mkdb --module=libblockdev --output-format=xml --source-dir=${srcdir}/../src/plugins/ --source-dir=${srcdir}/../src/lib/ --source-dir=${srcdir}/../src/utils/ --source-suffixes=c,h test -d ${builddir}/html || mkdir ${builddir}/html (cd ${builddir}/html; gtkdoc-mkhtml libblockdev ${builddir}/../libblockdev-docs.xml) gtkdoc-fixxref --module=libblockdev --module-dir=html --html-dir=/usr/share/gtk-doc/html clean-local: -rm -rf ${builddir}/html -rm -rf ${builddir}/xml test ! -f ${builddir}/html-doc.stamp || rm ${builddir}/html-doc.stamp test "${builddir}" = "${srcdir}" || rm -f ${builddir}/libblockdev-sections.txt ${builddir}/libblockdev-docs.xml ${builddir}/3.0-api-changes.xml install-data-local: test -d ${DESTDIR}${datadir}/gtk-doc/html/libblockdev || mkdir -p ${DESTDIR}${datadir}/gtk-doc/html/libblockdev install -m0644 ${builddir}/html/* ${DESTDIR}${datadir}/gtk-doc/html/libblockdev/ uninstall-local: -rm -rf ${DESTDIR}${datadir}/gtk-doc/html/libblockdev/ dist_noinst_DATA = ${srcdir}/libblockdev-sections.txt ${srcdir}/libblockdev-docs.xml ${srcdir}/3.0-api-changes.xml CLEANFILES = html.stamp sgml.stamp \ libblockdev-decl-list.txt \ libblockdev-decl.txt \ libblockdev-overrides.txt \ libblockdev-undeclared.txt \ libblockdev-undocumented.txt \ libblockdev-unused.txt \ libblockdev.types MAINTAINERCLEANFILES = Makefile.in libblockdev-docs.xml libblockdev-3.1.1-1/docs/libblockdev-docs.xml.in000066400000000000000000000144021460051510300214130ustar00rootroot00000000000000 ]> libblockdev Reference Manual for libblockdev @VERSION@. The latest version of this documentation can be found on-line at http://storaged.org/libblockdev/. The latest version of the code can be found at https://github.com/storaged-project/libblockdev Documentation for Python bindings is available here libblockdev Reference Manual GI Overrides The libblockdev library supports GObject introspection and thus can be used from a variety of languages. To make such use even easier and to make the code using libblockdev from different languages than C feel more natural the library also provides so-called overrides — pieces of code that usually wrap the original libblockdev functions with language-native objects (usually functions) that provide language-specific features like default values for parameters etc. The overrides are not documented here (yet), but it should be easy to directly check the sources for anybody who understands their language of choice. The overrides are located in the src/LANG_NAME directory in the source tree. The only language that libblockdev provides overrides for right now is Python (under the src/python directory). Testing libblockdev libblockdev's test suite is written using the standard unittest.TestCase framework in Python. Tests are separated in modules, usually one per libblockdev plugin - e.g. BTRFS, LVM, Crypto. There are one or more base classes in each module used to setup the environment and perform some testing. More specific test scenarios inherit from these base classes. Before running the tests you have to prepare your system so that libblockdev can be built from source. Install all build requirements. On Fedora this can be done with cat dist/libblockdev.spec.in | grep BuildRequires: | cut -f2 -d: | cut -f2 -d' ' | xargs dnf -y install Configure the build scripts ./autogen.sh ./configure To execute the Pylint code analysis tool run: make check The check target is a dependency of all test targets and you don't have to execute it explicitly when testing. To execute the test suite from inside the source directory run one of these commands: make test executes all safe tests or make fast-test executes all fast tests or make test-all executes all tests, including ones which may result in kernel panic or take more time to complete or make test-plugin-NAME executes only tests for given plugin and similarly make fast-test-plugin-NAME executes only fast tests for given plugin. It is also possible to run only subset of available tests or only one test using the `run_tests.py` script: # python3 tests/run_tests.py fs_test.GenericResize executes all tests from the GenericResize test class from filesystem plugin test cases and # python3 tests/run_tests.py fs_test.GenericResize.test_ext2_generic_resize executes only test_ext2_generic_resize from this class. This script also allows skipping slow tests or running potentially dangerous tests. Use: $ python3 tests/run_tests.py --help to see all available options. It is also possible to generate test coverage reports using the Python coverage tool: make coverage is equivalent to `make test'. make coverage-all is equivalent to `make test-all'. API Index Index of deprecated API libblockdev-3.1.1-1/docs/libblockdev-sections.txt000066400000000000000000000371071460051510300217330ustar00rootroot00000000000000
blockdev BD_INIT_ERROR BDInitError bd_init bd_ensure_init bd_try_init bd_reinit bd_try_reinit bd_is_initialized bd_init_error_quark
btrfs bd_btrfs_init bd_btrfs_close BD_BTRFS_MAIN_VOLUME_ID BD_BTRFS_MIN_MEMBER_SIZE bd_btrfs_error_quark BD_BTRFS_ERROR BDBtrfsError BDBtrfsDeviceInfo bd_btrfs_device_info_free bd_btrfs_device_info_copy BDBtrfsSubvolumeInfo bd_btrfs_subvolume_info_free bd_btrfs_subvolume_info_copy BDBtrfsFilesystemInfo bd_btrfs_filesystem_info_free bd_btrfs_filesystem_info_copy bd_btrfs_create_volume bd_btrfs_add_device bd_btrfs_remove_device bd_btrfs_create_subvolume bd_btrfs_delete_subvolume bd_btrfs_get_default_subvolume_id bd_btrfs_set_default_subvolume bd_btrfs_create_snapshot bd_btrfs_list_devices bd_btrfs_list_subvolumes bd_btrfs_filesystem_info bd_btrfs_mkfs bd_btrfs_resize bd_btrfs_check bd_btrfs_repair bd_btrfs_change_label BDBtrfsTech BDBtrfsTechMode bd_btrfs_is_tech_avail
crypto bd_crypto_close bd_crypto_init bd_crypto_error_quark BD_CRYPTO_ERROR BDCryptoError BD_CRYPTO_BACKUP_PASSPHRASE_CHARSET BD_CRYPTO_BACKUP_PASSPHRASE_LENGTH bd_crypto_generate_backup_passphrase bd_crypto_device_is_luks bd_crypto_device_seems_encrypted bd_crypto_luks_status bd_crypto_luks_format bd_crypto_luks_extra_free bd_crypto_luks_extra_copy bd_crypto_luks_extra_new BDCryptoLUKSExtra bd_crypto_luks_pbkdf_free bd_crypto_luks_pbkdf_copy bd_crypto_luks_pbkdf_new BDCryptoLUKSPBKDF BDCryptoLUKSVersion BDCryptoKeyslotContext bd_crypto_keyslot_context_free bd_crypto_keyslot_context_copy bd_crypto_keyslot_context_new_passphrase bd_crypto_keyslot_context_new_keyfile bd_crypto_keyslot_context_new_keyring bd_crypto_keyslot_context_new_volume_key bd_crypto_luks_open bd_crypto_luks_close bd_crypto_luks_add_key bd_crypto_luks_remove_key bd_crypto_luks_change_key bd_crypto_luks_resize bd_crypto_luks_suspend bd_crypto_luks_resume bd_crypto_luks_kill_slot bd_crypto_luks_header_backup bd_crypto_luks_header_restore bd_crypto_luks_set_label bd_crypto_luks_set_uuid BDCryptoLUKSInfo bd_crypto_luks_info_free bd_crypto_luks_info_copy bd_crypto_luks_info BDCryptoIntegrityInfo bd_crypto_integrity_info_free bd_crypto_integrity_info_copy bd_crypto_integrity_info BDCryptoIntegrityExtra bd_crypto_integrity_extra_copy bd_crypto_integrity_extra_free bd_crypto_integrity_extra_new bd_crypto_integrity_format BDCryptoIntegrityOpenFlags bd_crypto_integrity_open bd_crypto_integrity_close BDCryptoLUKSTokenInfo bd_crypto_luks_token_info_free bd_crypto_luks_token_info_copy bd_crypto_luks_token_info bd_crypto_keyring_add_key bd_crypto_tc_open bd_crypto_tc_close bd_crypto_escrow_device BDCryptoBITLKInfo bd_crypto_bitlk_info bd_crypto_bitlk_info_copy bd_crypto_bitlk_info_free bd_crypto_bitlk_open bd_crypto_bitlk_close bd_crypto_fvault2_open bd_crypto_fvault2_close BDCryptoTech BDCryptoTechMode bd_crypto_is_tech_avail
dm bd_dm_close bd_dm_init bd_dm_error_quark BD_DM_ERROR BDDMError bd_dm_create_linear bd_dm_remove bd_dm_name_from_node bd_dm_node_from_name bd_dm_map_exists bd_dm_get_subsystem_from_name BDDMTech BDDMTechMode bd_dm_is_tech_avail
utils BDUtilsProgExtract BDUtilsProgFunc BDUtilsProgStatus BDUtilsLogFunc bd_utils_exec_error_quark BD_UTILS_EXEC_ERROR BDUtilsExecError BDUtilsDevUtilsError BDUtilsDBusError BDUtilsModuleError BD_UTILS_DEV_UTILS_ERROR BD_UTILS_DBUS_ERROR BD_UTILS_MODULE_ERROR BDUtilsLinuxVersion bd_utils_dev_utils_error_quark bd_utils_exec_and_report_error bd_utils_exec_and_report_status_error bd_utils_exec_and_capture_output bd_utils_exec_and_report_error_no_progress bd_utils_exec_and_report_progress bd_utils_exec_with_input bd_utils_prog_reporting_initialized bd_utils_init_logging bd_utils_init_prog_reporting bd_utils_init_prog_reporting_thread bd_utils_mute_prog_reporting_thread bd_utils_report_finished bd_utils_report_progress bd_utils_report_started bd_utils_get_next_task_id bd_utils_log_task_status bd_utils_log bd_utils_log_format bd_utils_log_stdout bd_utils_echo_str_to_file bd_utils_set_log_level bd_utils_check_util_version bd_utils_version_cmp BDExtraArg bd_extra_arg_new bd_extra_arg_copy bd_extra_arg_free bd_extra_arg_list_free bd_extra_arg_get_type bd_utils_resolve_device bd_utils_get_device_symlinks bd_utils_have_kernel_module bd_utils_load_kernel_module bd_utils_unload_kernel_module bd_utils_get_linux_version bd_utils_check_linux_version bd_utils_dbus_service_available bd_utils_dbus_error_quark bd_utils_module_error_quark EXBIBYTE EiB GIBIBYTE GiB KIBIBYTE KiB MEBIBYTE MiB PEBIBYTE PiB TEBIBYTE TiB EB EXABYTE GB GIGABYTE KB KILOBYTE MB MEGABYTE PB PETABYTE TB TERABYTE BD_UTILS_LOG_EMERG BD_UTILS_LOG_ALERT BD_UTILS_LOG_CRIT BD_UTILS_LOG_ERR BD_UTILS_LOG_WARNING BD_UTILS_LOG_NOTICE BD_UTILS_LOG_INFO BD_UTILS_LOG_DEBUG
loop bd_loop_init bd_loop_close bd_loop_error_quark BD_LOOP_ERROR BDLoopError BDLoopInfo bd_loop_info bd_loop_info_copy bd_loop_info_free bd_loop_get_loop_name bd_loop_setup bd_loop_setup_from_fd bd_loop_teardown bd_loop_set_autoclear BDLoopTech BDLoopTechMode bd_loop_is_tech_avail
lvm bd_lvm_close bd_lvm_init bd_lvm_error_quark BD_LVM_ERROR BDLVMError BDLVMPVdata bd_lvm_pvdata_free bd_lvm_pvdata_copy BDLVMVGdata bd_lvm_vgdata_free bd_lvm_vgdata_copy BDLVMSEGdata bd_lvm_segdata_free bd_lvm_segdata_copy BDLVMLVdata bd_lvm_lvdata_free bd_lvm_lvdata_copy BDLVMCacheMode BDLVMCachePoolFlags BDLVMCacheStats bd_lvm_cache_stats_copy bd_lvm_cache_stats_free BDLVMVDOStats BDLVMVDOCompressionState BDLVMVDOIndexState BDLVMVDOOperatingMode BDLVMVDOPooldata BDLVMVDOWritePolicy bd_lvm_vdo_stats_free bd_lvm_vdo_stats_copy bd_lvm_is_supported_pe_size bd_lvm_get_supported_pe_sizes bd_lvm_get_max_lv_size bd_lvm_round_size_to_pe bd_lvm_get_lv_physical_size bd_lvm_get_thpool_padding bd_lvm_get_thpool_meta_size bd_lvm_is_valid_thpool_md_size bd_lvm_is_valid_thpool_chunk_size bd_lvm_pvcreate bd_lvm_pvresize bd_lvm_pvremove bd_lvm_pvmove bd_lvm_pvscan bd_lvm_add_pv_tags bd_lvm_delete_pv_tags bd_lvm_pvinfo bd_lvm_pvs bd_lvm_vgcreate bd_lvm_vgremove bd_lvm_vgrename bd_lvm_vgactivate bd_lvm_vgdeactivate bd_lvm_vgextend bd_lvm_vgreduce bd_lvm_vglock_start bd_lvm_vglock_stop bd_lvm_add_vg_tags bd_lvm_delete_vg_tags bd_lvm_vginfo bd_lvm_vgs bd_lvm_lvorigin bd_lvm_lvcreate bd_lvm_lvremove bd_lvm_lvrename bd_lvm_lvresize bd_lvm_lvrepair bd_lvm_lvactivate bd_lvm_lvdeactivate bd_lvm_lvsnapshotcreate bd_lvm_lvsnapshotmerge bd_lvm_add_lv_tags bd_lvm_delete_lv_tags bd_lvm_lvinfo bd_lvm_lvinfo_tree bd_lvm_lvs bd_lvm_lvs_tree bd_lvm_thpoolcreate bd_lvm_thpool_convert bd_lvm_thlvcreate bd_lvm_thlvpoolname bd_lvm_thsnapshotcreate bd_lvm_set_global_config bd_lvm_get_global_config bd_lvm_cache_attach bd_lvm_cache_create_cached_lv bd_lvm_cache_create_pool bd_lvm_cache_pool_convert bd_lvm_cache_detach bd_lvm_cache_get_default_md_size bd_lvm_cache_get_mode_from_str bd_lvm_cache_get_mode_str bd_lvm_cache_pool_name bd_lvm_cache_stats bd_lvm_vdolvpoolname bd_lvm_get_vdo_operating_mode_str bd_lvm_get_vdo_compression_state_str bd_lvm_get_vdo_index_state_str bd_lvm_get_vdo_write_policy_from_str bd_lvm_vdo_get_stats bd_lvm_vdo_get_stats_full bd_lvm_vdo_disable_compression bd_lvm_vdo_disable_deduplication bd_lvm_vdo_enable_compression bd_lvm_vdo_enable_deduplication bd_lvm_vdo_info bd_lvm_vdo_pool_convert bd_lvm_vdo_pool_create bd_lvm_vdo_pool_resize bd_lvm_vdo_resize bd_lvm_vdopooldata_copy bd_lvm_vdopooldata_free bd_lvm_devices_add bd_lvm_devices_delete bd_lvm_get_devices_filter bd_lvm_get_vdo_write_policy_str bd_lvm_set_devices_filter bd_lvm_writecache_attach bd_lvm_writecache_create_cached_lv bd_lvm_writecache_detach BDLVMTech BDLVMTechMode bd_lvm_is_tech_avail
mdraid bd_md_init bd_md_close BD_MD_SUPERBLOCK_SIZE BD_MD_CHUNK_SIZE bd_md_error_quark BD_MD_ERROR BDMDError BDMDExamineData bd_md_examine_data_copy bd_md_examine_data_free BDMDDetailData bd_md_detail_data_free bd_md_detail_data_copy bd_md_get_superblock_size bd_md_create bd_md_destroy bd_md_deactivate bd_md_activate bd_md_run bd_md_nominate bd_md_denominate bd_md_add bd_md_remove bd_md_examine bd_md_canonicalize_uuid bd_md_get_md_uuid bd_md_detail bd_md_node_from_name bd_md_name_from_node bd_md_get_status bd_md_set_bitmap_location bd_md_get_bitmap_location bd_md_request_sync_action BDMDTech BDMDTechMode bd_md_is_tech_avail
mpath bd_mpath_init bd_mpath_close bd_mpath_error_quark BD_MPATH_ERROR BDMpathError bd_mpath_flush_mpaths bd_mpath_is_mpath_member bd_mpath_get_mpath_members bd_mpath_set_friendly_names BDMpathTech BDMpathTechMode bd_mpath_is_tech_avail
plugins BDPlugin bd_plugin_spec_copy bd_plugin_spec_free bd_plugin_spec_new bd_is_plugin_available bd_get_available_plugin_names bd_get_plugin_soname bd_get_plugin_name BDPluginSpec BD_TYPE_PLUGIN_SPEC bd_plugin_spec_get_type
swap bd_swap_init bd_swap_close bd_swap_error_quark BD_SWAP_ERROR BDSwapError bd_swap_mkswap bd_swap_swapon bd_swap_swapoff bd_swap_swapstatus bd_swap_check_label bd_swap_set_label bd_swap_check_uuid bd_swap_set_uuid BDSwapTech BDSwapTechMode bd_swap_is_tech_avail
part bd_part_init bd_part_close BD_PART_ERROR BD_PART_TYPE_SPEC BDPartAlign BDPartSpec BDPartType BDPartTypeReq BDPartError BDPartTableType BDPartDiskSpec bd_part_create_table bd_part_create_part bd_part_delete_part bd_part_resize_part bd_part_get_disk_parts bd_part_get_part_spec bd_part_spec_copy bd_part_spec_free bd_part_spec_get_type bd_part_get_part_table_type_str bd_part_get_type_str bd_part_get_best_free_region bd_part_get_disk_free_regions bd_part_get_disk_spec bd_part_get_part_by_pos bd_part_set_part_name bd_part_set_part_type bd_part_set_part_id bd_part_set_part_bootable bd_part_set_part_attributes bd_part_set_part_uuid bd_part_error_quark BDPartTech BDPartTechMode bd_part_is_tech_avail bd_part_disk_spec_copy bd_part_disk_spec_free
fs bd_fs_init bd_fs_close BDFSExt2Info BDFSExt3Info BDFSExt4Info BDFSError BD_FS_ERROR bd_fs_error_quark bd_fs_wipe bd_fs_clean bd_fs_get_fstype bd_fs_freeze bd_fs_unfreeze bd_fs_mount bd_fs_unmount bd_fs_get_mountpoint bd_fs_is_mountpoint bd_fs_resize bd_fs_repair bd_fs_check bd_fs_set_label bd_fs_check_label bd_fs_get_size bd_fs_get_free_space bd_fs_get_min_size bd_fs_can_resize bd_fs_can_check bd_fs_can_repair bd_fs_can_set_label bd_fs_can_get_size bd_fs_can_get_free_space bd_fs_can_get_min_size bd_fs_can_get_info bd_fs_can_set_uuid bd_fs_set_uuid bd_fs_check_uuid BDFSConfigureFlags BDFSFeatureFlags BDFSFeatures bd_fs_features bd_fs_features_copy bd_fs_features_free BDFSFsckFlags BDFSMkfsOptions BDFSMkfsOptionsFlags bd_fs_can_mkfs bd_fs_mkfs bd_fs_mkfs_options_copy bd_fs_mkfs_options_free bd_fs_supported_filesystems bd_fs_ext2_check bd_fs_ext2_get_info bd_fs_ext2_info_copy bd_fs_ext2_info_free bd_fs_ext2_mkfs bd_fs_ext2_repair bd_fs_ext2_resize bd_fs_ext2_set_label bd_fs_ext2_check_label bd_fs_ext2_set_uuid bd_fs_ext2_check_uuid bd_fs_ext2_get_min_size bd_fs_ext3_check bd_fs_ext3_get_info bd_fs_ext3_info_copy bd_fs_ext3_info_free bd_fs_ext3_mkfs bd_fs_ext3_repair bd_fs_ext3_resize bd_fs_ext3_set_label bd_fs_ext3_check_label bd_fs_ext3_set_uuid bd_fs_ext3_check_uuid bd_fs_ext3_get_min_size bd_fs_ext4_check bd_fs_ext4_get_info bd_fs_ext4_info_copy bd_fs_ext4_info_free bd_fs_ext4_mkfs bd_fs_ext4_repair bd_fs_ext4_resize bd_fs_ext4_set_label bd_fs_ext4_check_label bd_fs_ext4_set_uuid bd_fs_ext4_check_uuid bd_fs_ext4_get_min_size BDFSXfsInfo bd_fs_xfs_check bd_fs_xfs_get_info bd_fs_xfs_info_copy bd_fs_xfs_info_free bd_fs_xfs_mkfs bd_fs_xfs_repair bd_fs_xfs_resize bd_fs_xfs_set_label bd_fs_xfs_check_label bd_fs_xfs_set_uuid bd_fs_xfs_check_uuid BDFSVfatInfo bd_fs_vfat_check bd_fs_vfat_get_info bd_fs_vfat_info_copy bd_fs_vfat_info_free bd_fs_vfat_mkfs bd_fs_vfat_repair bd_fs_vfat_resize bd_fs_vfat_set_label bd_fs_vfat_check_label bd_fs_vfat_set_uuid bd_fs_vfat_check_uuid BDFSTech BDFSTechMode BDFSResizeFlags bd_fs_is_tech_avail BDFSNtfsInfo bd_fs_ntfs_check bd_fs_ntfs_get_info bd_fs_ntfs_mkfs bd_fs_ntfs_repair bd_fs_ntfs_resize bd_fs_ntfs_set_label bd_fs_ntfs_check_label bd_fs_ntfs_info_copy bd_fs_ntfs_info_free bd_fs_ntfs_set_uuid bd_fs_ntfs_check_uuid bd_fs_ntfs_get_min_size BDFSF2FSInfo BDFSF2FSFeature bd_fs_f2fs_info_copy bd_fs_f2fs_info_free bd_fs_f2fs_mkfs bd_fs_f2fs_check bd_fs_f2fs_repair bd_fs_f2fs_get_info bd_fs_f2fs_resize bd_fs_f2fs_check_label BDFSNILFS2Info bd_fs_nilfs2_get_info bd_fs_nilfs2_info_copy bd_fs_nilfs2_info_free bd_fs_nilfs2_mkfs bd_fs_nilfs2_resize bd_fs_nilfs2_set_label bd_fs_nilfs2_check_label bd_fs_nilfs2_set_uuid bd_fs_nilfs2_check_uuid BDFSExfatInfo bd_fs_exfat_check bd_fs_exfat_get_info bd_fs_exfat_info_copy bd_fs_exfat_info_free bd_fs_exfat_mkfs bd_fs_exfat_repair bd_fs_exfat_set_label bd_fs_exfat_check_label bd_fs_exfat_set_uuid bd_fs_exfat_check_uuid BDFSBtrfsInfo bd_fs_btrfs_get_info bd_fs_btrfs_info_copy bd_fs_btrfs_info_free bd_fs_btrfs_mkfs bd_fs_btrfs_check bd_fs_btrfs_repair bd_fs_btrfs_set_label bd_fs_btrfs_check_label bd_fs_btrfs_set_uuid bd_fs_btrfs_check_uuid bd_fs_btrfs_resize BDFSUdfInfo bd_fs_udf_get_info bd_fs_udf_info_copy bd_fs_udf_info_free bd_fs_udf_mkfs bd_fs_udf_set_label bd_fs_udf_check_label bd_fs_udf_set_uuid bd_fs_udf_check_uuid
s390 bd_s390_init bd_s390_close bd_s390_error_quark BDS390Error BD_S390_ERROR bd_s390_dasd_format bd_s390_dasd_needs_format bd_s390_sanitize_dev_input bd_s390_dasd_online bd_s390_dasd_is_ldl bd_s390_dasd_is_fba bd_s390_zfcp_sanitize_wwpn_input bd_s390_zfcp_sanitize_lun_input bd_s390_zfcp_online bd_s390_zfcp_scsi_offline bd_s390_zfcp_offline BDS390Tech BDS390TechMode bd_s390_is_tech_avail
nvdimm bd_nvdimm_close bd_nvdimm_init bd_nvdimm_error_quark BD_NVDIMM_ERROR BDNVDIMMError BDNVDIMMNamespaceMode BDNVDIMMNamespaceInfo bd_nvdimm_namespace_get_mode_from_str bd_nvdimm_namespace_get_mode_str bd_nvdimm_namespace_get_devname bd_nvdimm_namespace_enable bd_nvdimm_namespace_disable bd_nvdimm_namespace_info bd_nvdimm_list_namespaces bd_nvdimm_namespace_reconfigure bd_nvdimm_namespace_get_supported_sector_sizes bd_nvdimm_namespace_info_copy bd_nvdimm_namespace_info_free BDNVDIMMTech BDNVDIMMTechMode bd_nvdimm_is_tech_avail
nvme bd_nvme_close bd_nvme_init bd_nvme_error_quark BD_NVME_ERROR BDNVMEError BDNVMETech BDNVMETechMode bd_nvme_is_tech_avail BDNVMEControllerFeature BDNVMEControllerType BDNVMEControllerInfo bd_nvme_get_controller_info bd_nvme_controller_info_free bd_nvme_controller_info_copy BDNVMELBAFormatRelativePerformance BDNVMELBAFormat bd_nvme_lba_format_free bd_nvme_lba_format_copy BDNVMENamespaceFeature BDNVMENamespaceInfo bd_nvme_get_namespace_info bd_nvme_namespace_info_free bd_nvme_namespace_info_copy BDNVMESmartCriticalWarning BDNVMESmartLog bd_nvme_get_smart_log bd_nvme_smart_log_free bd_nvme_smart_log_copy BDNVMETransportType BDNVMEErrorLogEntry bd_nvme_get_error_log_entries bd_nvme_error_log_entry_free bd_nvme_error_log_entry_copy BDNVMESelfTestLog BDNVMESelfTestLogEntry BDNVMESelfTestAction BDNVMESelfTestResult bd_nvme_get_self_test_log bd_nvme_self_test_log_free bd_nvme_self_test_log_copy bd_nvme_self_test_log_entry_free bd_nvme_self_test_log_entry_copy bd_nvme_self_test_result_to_string bd_nvme_device_self_test BDNVMEFormatSecureErase bd_nvme_format BDNVMESanitizeStatus BDNVMESanitizeLog bd_nvme_get_sanitize_log bd_nvme_sanitize_log_free bd_nvme_sanitize_log_copy BDNVMESanitizeAction bd_nvme_sanitize bd_nvme_get_host_nqn bd_nvme_get_host_id bd_nvme_generate_host_nqn bd_nvme_set_host_nqn bd_nvme_set_host_id bd_nvme_connect bd_nvme_disconnect bd_nvme_disconnect_by_path bd_nvme_find_ctrls_for_ns
libblockdev-3.1.1-1/include/000077500000000000000000000000001460051510300155505ustar00rootroot00000000000000libblockdev-3.1.1-1/include/Makefile.am000066400000000000000000000000671460051510300176070ustar00rootroot00000000000000SUBDIRS = blockdev MAINTAINERCLEANFILES = Makefile.in libblockdev-3.1.1-1/include/blockdev/000077500000000000000000000000001460051510300173415ustar00rootroot00000000000000libblockdev-3.1.1-1/include/blockdev/Makefile.am000066400000000000000000000007661460051510300214060ustar00rootroot00000000000000all-local: for header in ${srcdir}/../../src/plugins/*.h; do ln -sf $${header} ./; done for header in ${srcdir}/../../src/plugins/nvme/nvme.h; do ln -sf $${header} ./; done for header in ${srcdir}/../../src/utils/*.h; do ln -sf $${header} ./; done for header in ${srcdir}/../../src/lib/*.h; do ln -sf $${header} ./; done mkdir -p fs; cd fs; for header in ${srcdir}/../../../src/plugins/fs/*.h; do ln -sf $${header} ./; done clean-local: rm -f *.h rm -rf fs MAINTAINERCLEANFILES = Makefile.in libblockdev-3.1.1-1/misc/000077500000000000000000000000001460051510300150605ustar00rootroot00000000000000libblockdev-3.1.1-1/misc/PythonDocs.Dockerfile000066400000000000000000000023121460051510300211410ustar00rootroot00000000000000# image for building documentation for Python bindings, see README.DEVEL.md for more details FROM debian:testing LABEL maintainer Vojtech Trefny # add deb-src repo RUN echo "deb-src http://deb.debian.org/debian testing main" >> /etc/apt/sources.list RUN apt-get update # pgi-docgen dependencies RUN apt-get -y install python3 python3-pip python3-jinja2 python3-sphinx python3-bs4 python3-graphviz libgirepository-1.0-1 gir1.2-glib-2.0 RUN apt-get -y install git # latest pgi from git RUN pip3 install "git+https://github.com/pygobject/pgi.git" --break-system-packages WORKDIR /root # install latest libblockdev RUN git clone https://github.com/storaged-project/libblockdev WORKDIR /root/libblockdev # install libblockdev build dependencies RUN apt-get -y install ansible RUN apt-get -y install libnvme-dev RUN ansible-playbook -K -i "localhost," -c local misc/install-test-dependencies.yml RUN ./autogen.sh && ./configure --prefix=/usr && make -j6 && DEB_PYTHON_INSTALL_LAYOUT="deb" make install WORKDIR /root # get latest pgi-docgen and generate documentation for libblockdev RUN git clone https://github.com/pygobject/pgi-docgen WORKDIR /root/pgi-docgen RUN ./tools/build.sh BlockDev-3.0 libblockdev-3.1.1-1/misc/Vagrantfile000066400000000000000000000040751460051510300172530ustar00rootroot00000000000000# -*- mode: ruby -*- # vi: set ft=ruby : # # A Vagrantfile template that can be used for creating machines for libblockdev # development/testing. # # Use 'vagrant up && vagrant ssh' to spawn the default machine (most recent # Fedora) and ssh into it or e.g. 'vagrant up bd-f29 && vagrant ssh bd-f29' to # use a Fedora 29 based machine, etc. # def os_cpu_cores case RbConfig::CONFIG['host_os'] when /darwin/ Integer(`sysctl -n hw.ncpu`) when /linux/ Integer(`getconf _NPROCESSORS_ONLN`) else raise StandardError, "Unsupported platform" end end Vagrant.configure("2") do |config| # common configuration config.vm.synced_folder "../", "/home/vagrant/libblockdev/", type: "rsync", rsync__args: ["-a", "-l", "--exclude=misc"] # override the default args # CHECK THAT THE BELOW OPTIONS ARE OKAY FOR YOUR HW config.vm.provider :libvirt do |v| v.memory = "2048" v.cpus = os_cpu_cores v.disk_driver :cache => "unsafe" end # just some handy stuff to have in shell OOTB config.vm.provision :shell, inline: <<-SHELL echo 'alias make="make -j -l4"' >> /home/vagrant/.bashrc echo 'cd libblockdev' >> /home/vagrant/.bash_history echo './autogen.sh && ./configure' >> /home/vagrant/.bash_history SHELL # install all test dependencies using ansible config.vm.provision "ansible" do |ansible| ansible.playbook = "install-test-dependencies.yml" ansible.extra_vars = { ansible_python_interpreter:"/usr/bin/python3" } end config.vm.define "bd-f38", primary: true, autostart: true do |f38| f38.vm.box = "fedora/38-cloud-base" end config.vm.define "bd-f37", primary: false, autostart: false do |f37| f37.vm.box = "fedora/37-cloud-base" end config.vm.define "bd-cs8", primary: false, autostart: false do |cs8| cs8.vm.box = "centos/stream8" end config.vm.define "bd-u2204", primary: false, autostart: false do |u2204| u2204.vm.box = "generic/ubuntu2204" end config.vm.define "bd-debiant", primary: false, autostart: false do |debiant| debiant.vm.box = "debian/testing64" end end libblockdev-3.1.1-1/misc/ci.Dockerfile000066400000000000000000000007171460051510300174510ustar00rootroot00000000000000# latest fedora image for running some of our tests in GH actions FROM registry.fedoraproject.org/fedora:latest RUN set -e; \ dnf install -y ansible python3-pip rpm-build mock csmock git dnf-plugins-core; \ pip3 install copr-builder; \ git clone --depth 1 https://github.com/storaged-project/ci.git; \ git clone --depth 1 https://github.com/storaged-project/udisks.git; \ git clone --depth 1 https://github.com/storaged-project/blivet.git; WORKDIR / libblockdev-3.1.1-1/misc/install-test-dependencies.yml000066400000000000000000000135611460051510300226600ustar00rootroot00000000000000# This is a simple ansible playbook for installing packages needed by the # libblockdev test suite. # You can do this by using 'make install-requires' or manually using # 'ansible-playbook -K -i "localhost," -c local install-test-dependencies.yml' # Currently only Fedora, CentOS 8 and Debian/Ubuntu are supported by this playbook. --- - hosts: all become: true vars: test_dependencies: true # whether to install test dependencies or not tasks: ####### Fedora - name: Install basic build tools (Fedora) package: name={{item}} state=present with_items: - gcc - make - libtool - autoconf - automake when: ansible_distribution == 'Fedora' - name: Install dnf-plugins-core for dnf builddep (Fedora) package: name=dnf-plugins-core state=present when: ansible_distribution == 'Fedora' - name: Install build dependencies (Fedora) command: "dnf -y builddep libblockdev --nogpgcheck" when: ansible_distribution == 'Fedora' - name: Install build dependencies not covered by dnf builddep (Fedora) package: name={{item}} state=present with_items: - libfdisk-devel - keyutils-libs-devel - libnvme-devel - e2fsprogs-devel when: ansible_distribution == 'Fedora' - name: Install test dependencies (Fedora) package: name={{item}} state=present with_items: - btrfs-progs - cryptsetup - device-mapper-multipath - dosfstools - e2fsprogs - exfatprogs - f2fs-tools - glibc-all-langpacks - lvm2-dbusd - mdadm - ndctl - nilfs-utils - nss-tools - ntfsprogs - nvme-cli - nvmetcli - python3-bytesize - python3-dbus - python3-packaging - python3-pylint - python3-yaml - targetcli - udftools - volume_key - xfsprogs when: ansible_distribution == 'Fedora' and test_dependencies|bool ####### CentOS 8 - name: Install basic build tools (CentOS 8) package: name={{item}} state=present with_items: - gcc - make - libtool - autoconf - automake when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' - name: Enable EPEL repository (CentOS 8) package: name=epel-release state=present when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' - name: Enable powertools repository (CentOS 8) command: yum config-manager --set-enabled powertools when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' - name: Install dnf-plugins-core for dnf builddep (CentOS 8) package: name=dnf-plugins-core state=present when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' - name: Install build dependencies (CentOS 8) command: "dnf -y builddep libblockdev --nogpgcheck" when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' - name: Install build dependencies not covered by dnf builddep (CentOS 8) package: name={{item}} state=present with_items: - libfdisk-devel - keyutils-libs-devel - e2fsprogs-devel when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' - name: Install test dependencies (CentOS 8) package: name={{item}} state=present with_items: - cryptsetup - device-mapper-multipath - dosfstools - e2fsprogs - glibc-all-langpacks - kmod-kvdo - lvm2-dbusd - mdadm - ndctl - nss-tools - ntfsprogs - nvme-cli - nvmetcli - python3-bytesize - python3-dbus - python3-packaging - python3-pylint - python3-yaml - targetcli - vdo - volume_key - xfsprogs when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' and test_dependencies|bool ####### Debian/Ubuntu - name: Update apt cache (Debian/Ubuntu) apt: update_cache: yes when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - name: Install basic build tools (Debian/Ubuntu) package: name={{item}} state=present with_items: - gcc - make when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - name: Add source repositories (Debian/Ubuntu) shell: "grep '^deb ' /etc/apt/sources.list | perl -pe 's/deb /deb-src /' >> /etc/apt/sources.list" when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - name: Update apt cache (Debian/Ubuntu) apt: update_cache: yes when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - name: Install build dependencies (Debian/Ubuntu) apt: name: libblockdev state: build-dep when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - name: Install build dependencies not covered by apt build-dep (Debian/Ubuntu) package: name={{item}} state=present with_items: - libfdisk-dev - libkeyutils-dev - libext2fs-dev when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - name: Install test dependencies (Debian/Ubuntu) package: name={{item}} state=present with_items: - btrfs-progs - cryptsetup - dosfstools - e2fsprogs - exfatprogs - f2fs-tools - libnss3-tools - locales-all - lvm2-dbusd - mdadm - ndctl - nilfs-tools - ntfs-3g - pylint - python3-bytesize - python3-packaging - python3-pydbus - python3-yaml - targetcli-fb - udftools - volume-key - xfsprogs when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' and test_dependencies|bool ####### Common actions - name: Start LVM DBus service service: name=lvm2-lvmdbusd state=started ignore_errors: yes when: test_dependencies|bool libblockdev-3.1.1-1/scripts/000077500000000000000000000000001460051510300156145ustar00rootroot00000000000000libblockdev-3.1.1-1/scripts/Makefile.am000066400000000000000000000001231460051510300176440ustar00rootroot00000000000000dist_noinst_SCRIPTS = boilerplate_generator.py MAINTAINERCLEANFILES = Makefile.in libblockdev-3.1.1-1/scripts/boilerplate_generator.py000077500000000000000000000262101460051510300225420ustar00rootroot00000000000000#!/usr/bin/python """ Simple helper script generating boilerplate code for a set of functions in order to make them dynamically loaded and GObject-introspectable. """ from collections import namedtuple import re import sys import os FuncInfo = namedtuple("FuncInfo", ["name", "doc", "rtype", "args", "body"]) FUNC_SPEC_RE = re.compile(r'(?P(const\s+)?\**\s*\w+\s*\**)' r'\s*' r'(?P\w+)' r'\s*\(' r'(?P[\w*\s,]*)' r'\)(;| \{)') SIZE_CONST_DEF_RE = re.compile(r'^(?P#define\s+\w+\s*\(\s*\d+\s+)(?P[kmgtpeKMGTPE]i?[bB])\s*\)\s*$') KiB = 1024 MiB = 1024 * KiB GiB = 1024 * MiB TiB = 1024 * GiB PiB = 1024 * TiB EiB = 1024 * PiB KB = 1000 MB = 1000 * KB GB = 1000 * MB TB = 1000 * GB PB = 1000 * TB EB = 1000 * PB UNIT_MULTS = {"KiB": KiB, "MiB": MiB, "GiB": GiB, "TiB": TiB, "PiB": PiB, "EiB": EiB, "KB": KB, "MB": MB, "GB": GB, "TB": TB, "PB": PB, "EB": EB} # overrides for function prefixes not matching the modules' names MOD_FNAME_OVERRIDES = {"mdraid": "md"} def expand_size_constants(definitions): """ Expand macros that define size constants (e.g. '#define DEFAULT_PE_SIZE (4 MiB)'). :param str definitions: lines from a source file potentially containing definitions of size constants. :returns: definitions with size constants expanded """ ret = "" for def_line in definitions.splitlines(): match = SIZE_CONST_DEF_RE.match(def_line) if match: fields = match.groupdict() unit = fields["unit"] if unit in UNIT_MULTS: name_num = fields["name_num"] ret += (name_num + "* " + "%dULL" % UNIT_MULTS[unit] + ")\n") else: # unknown unit, cannot expand it, just leave it as it is ret += (def_line + "\n") else: ret += (def_line + "\n") return ret def gather_defs_and_func_info(line_iter, includes): name = doc = rtype = args = "" defs = "" body = "" in_body = False in_doc = False in_skip = False for line in line_iter: if in_skip and line.strip().startswith("/* BpG-skip-end"): in_skip = False elif in_skip or line.strip().startswith("/* BpG-skip"): in_skip = True elif line.rstrip() == "}" and in_body: # nothing more for this function break elif in_body: body += line elif line.strip().startswith("#include"): includes.append(line.strip()[8:]) elif line.strip().startswith("/**"): doc += line in_doc = True elif line.strip().endswith("*/") and in_doc: doc += line in_doc = False else: match = FUNC_SPEC_RE.match(line.strip()) if match: fields = match.groupdict() name = fields["name"] rtype = fields["rtype"] args = fields["args"] if line.strip().endswith("{"): in_body = True else: # nothing more for this function break elif in_doc: doc += line else: defs += line else: return (expand_size_constants(defs), None) return (expand_size_constants(defs), FuncInfo(name, doc, rtype, args, body)) def process_file(fobj): includes = [] line_iter = iter(fobj) items = list() defs, fn_info = gather_defs_and_func_info(line_iter, includes) while fn_info: if defs: items.append(defs) if fn_info: items.append(fn_info) defs, fn_info = gather_defs_and_func_info(line_iter, includes) if defs: # definitions after the last function items.append(defs) return includes, items def get_arg_names(args): if not args.strip(): return [] typed_args = args.split(",") starred_names = (typed_arg.split()[-1] for typed_arg in typed_args) return [starred_name.strip("* ") for starred_name in starred_names] def get_func_boilerplate(fn_info): call_args_str = ", ".join(get_arg_names(fn_info.args)) args_ann_unused = fn_info.args.replace(",", " G_GNUC_UNUSED,") if "int" in fn_info.rtype: default_ret = "0" elif "float" in fn_info.rtype: default_ret = "0.0" elif "bool" in fn_info.rtype: default_ret = "FALSE" elif fn_info.rtype.endswith("*"): # a pointer default_ret = "NULL" else: # enum or whatever default_ret = 0 # first add the stub function doing nothing and just reporting error ret = ("static {0.rtype} {0.name}_stub ({2}) {{\n" + " bd_utils_log_format (BD_UTILS_LOG_CRIT, \"The function '{0.name}' called, but not implemented!\");\n" + " g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,\n"+ " \"The function '{0.name}' called, but not implemented!\");\n" " return {1};\n" "}}\n\n").format(fn_info, default_ret, args_ann_unused) # then add a variable holding a reference to the dynamically loaded function # (if any) initialized to the stub ret += "static {0.rtype} (*_{0.name}) ({0.args}) = {0.name}_stub;\n\n".format(fn_info) # then add a documented function calling the dynamically loaded one via the # reference ret += ("{0.doc}{0.rtype} {0.name} ({0.args}) {{\n" + " return _{0.name} ({1});\n" + "}}\n\n\n").format(fn_info, call_args_str) return ret def get_includes_str(includes): if not includes: return "" ret = "" for include in includes: ret += "#include%s\n" % include ret += "\n" return ret def get_loading_func(fn_infos, module_name): # TODO: only error on functions provided by the plugin that fail to load # TODO: implement the 'gchar **errors' argument ret = 'static gpointer load_{0}_from_plugin(const gchar *so_name) {{\n'.format(module_name) ret += ' void *handle = NULL;\n' ret += ' char *error = NULL;\n' ret += ' gboolean (*init_fn) (void) = NULL;\n\n' ret += ' handle = dlopen(so_name, RTLD_LAZY);\n' ret += ' if (!handle) {\n' ret += ' bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load module {0}: %s", dlerror());\n'.format(module_name) ret += ' return NULL;\n' ret += ' }\n\n' ret += ' dlerror();\n' ret += ' * (void**) (&init_fn) = dlsym(handle, "bd_{0}_init");\n'.format(MOD_FNAME_OVERRIDES.get(module_name, module_name)) ret += ' if ((error = dlerror()) != NULL)\n' ret += ' bd_utils_log_format (BD_UTILS_LOG_DEBUG, "failed to load the init() function for {0}: %s", error);\n'.format(module_name) ret += ' /* coverity[dead_error_condition] */\n' # coverity doesn't understand dlsym and thinks init_fn is NULL ret += ' if (init_fn && !init_fn()) {\n' ret += ' dlclose(handle);\n' ret += ' return NULL;\n' ret += ' }\n' ret += ' init_fn = NULL;\n\n' for info in fn_infos: # clear any previous error and load the function ret += ' dlerror();\n' ret += ' * (void**) (&_{0.name}) = dlsym(handle, "{0.name}");\n'.format(info) ret += ' if ((error = dlerror()) != NULL)\n' ret += ' bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load {0.name}: %s", error);\n\n'.format(info) ret += ' return handle;\n' ret += '}\n\n' return ret def get_unloading_func(fn_infos, module_name): ret = 'static gboolean unload_{0} (gpointer handle) {{\n'.format(module_name) ret += ' char *error = NULL;\n' ret += ' gboolean (*close_fn) (void) = NULL;\n\n' # revert the functions to stubs for info in fn_infos: ret += ' _{0.name} = {0.name}_stub;\n'.format(info) ret += '\n' ret += ' dlerror();\n' ret += ' * (void**) (&close_fn) = dlsym(handle, "bd_{0}_close");\n'.format(MOD_FNAME_OVERRIDES.get(module_name, module_name)) ret += ' if (((error = dlerror()) != NULL) || !close_fn)\n' ret += ' bd_utils_log_format (BD_UTILS_LOG_DEBUG, "failed to load the close_plugin() function for {0}: %s", error);\n'.format(module_name) ret += ' /* coverity[dead_error_condition] */\n' # coverity doesn't understand dlsym and thinks close_fn is NULL ret += ' if (close_fn) {\n' ret += ' close_fn();\n' ret += ' }\n\n' ret += ' return dlclose(handle) == 0;\n' ret += '}\n\n' return ret def get_fn_code(fn_info): ret = ("{0.doc}{0.rtype} {0.name} ({0.args}) {{\n" + " {0.body}" + "}}\n\n").format(fn_info) return ret def get_fn_header(fn_info): return "{0.doc}{0.rtype} {0.name} ({0.args});\n\n".format(fn_info) def generate_source_header(api_file, out_dir, skip_patterns=None): skip_patterns = skip_patterns or list() file_name = os.path.basename(api_file) mod_name, dot, ext = file_name.partition(".") if not dot or ext != "api": print("Invalid file given, needs to be in MODNAME.api format") return 1 includes, items = process_file(open(api_file, "r")) filtered = list() for item in items: if isinstance(item, FuncInfo): if not any(re.search(pattern, item.name) for pattern in skip_patterns): filtered.append(item) elif not any(re.search(pattern, item) for pattern in skip_patterns): filtered.append(item) items = filtered nonapi_fn_infos = [item for item in items if isinstance(item, FuncInfo) and item.body] api_fn_infos = [item for item in items if isinstance(item, FuncInfo) and not item.body and item.doc] with open(os.path.join(out_dir, mod_name + ".c"), "w") as src_f: for info in nonapi_fn_infos: src_f.write(get_fn_code(info)) for info in api_fn_infos: src_f.write(get_func_boilerplate(info)) src_f.write(get_loading_func(api_fn_infos, mod_name)) src_f.write(get_unloading_func(api_fn_infos, mod_name)) written_fns = set() with open(os.path.join(out_dir, mod_name + ".h"), "w") as hdr_f: hdr_f.write(get_includes_str(includes)) for item in items: if isinstance(item, FuncInfo): if item.name not in written_fns: hdr_f.write(get_fn_header(item)) written_fns.add(item.name) else: hdr_f.write(item) return 0 if __name__ == "__main__": if len(sys.argv) < 3: print("Needs a file name and output directory, exiting.") print("Usage: %s FILE_NAME OUTPUT_DIR [SKIP_PATTERNS]" % sys.argv[0]) sys.exit(1) if not os.path.exists(sys.argv[1]): print("Input file '%s' doesn't exist" % sys.argv[1]) sys.exit(1) skip_patterns = None if len(sys.argv) > 3: skip_patterns = sys.argv[3:] out_dir = sys.argv[2] if not os.path.exists (out_dir): os.makedirs(out_dir) status = generate_source_header(sys.argv[1], out_dir, skip_patterns) sys.exit(status) libblockdev-3.1.1-1/src/000077500000000000000000000000001460051510300147145ustar00rootroot00000000000000libblockdev-3.1.1-1/src/Makefile.am000066400000000000000000000001071460051510300167460ustar00rootroot00000000000000SUBDIRS = utils plugins lib python MAINTAINERCLEANFILES = Makefile.in libblockdev-3.1.1-1/src/lib/000077500000000000000000000000001460051510300154625ustar00rootroot00000000000000libblockdev-3.1.1-1/src/lib/Makefile.am000066400000000000000000000042131460051510300175160ustar00rootroot00000000000000-include $(INTROSPECTION_MAKEFILE) SUBDIRS = plugin_apis lib_LTLIBRARIES = libblockdev.la libblockdev_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) libblockdev_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) $(GOBJECT_LIBS) -ldl if WITH_BTRFS libblockdev_la_CFLAGS += $(GOBJECT_CFLAGS) libblockdev_la_LIBADD += $(GOBJECT_LIBS) endif if WITH_LVM libblockdev_la_CFLAGS += $(GOBJECT_CFLAGS) libblockdev_la_LIBADD += $(GOBJECT_LIBS) endif libblockdev_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libblockdev_la_CPPFLAGS = -I${builddir}/../../include/ libblockdev_la_SOURCES = blockdev.c blockdev.h plugins.c plugins.h if HAVE_INTROSPECTION GIHEADERS = ${builddir}/plugin_apis/mdraid.h \ ${builddir}/plugin_apis/swap.h \ ${builddir}/plugin_apis/btrfs.h \ ${builddir}/plugin_apis/lvm.h \ ${builddir}/plugin_apis/crypto.h \ ${builddir}/plugin_apis/dm.h \ ${builddir}/plugin_apis/loop.h \ ${builddir}/plugin_apis/mpath.h \ ${builddir}/plugin_apis/part.h \ ${builddir}/plugin_apis/fs.h \ ${builddir}/plugin_apis/nvdimm.h \ ${builddir}/plugin_apis/nvme.h GIHEADERS += $(wildcard ${srcdir}/../utils/*.[ch]) GIHEADERS += blockdev.c blockdev.h plugins.c plugins.h if WITH_S390 GIHEADERS += ${builddir}/plugin_apis/s390.h endif BlockDev-3.0.gir: libblockdev.la BlockDev_3_0_gir_FILES = $(GIHEADERS) BlockDev_3_0_gir_LIBS = libblockdev.la BlockDev_3_0_gir_INCLUDES = GObject-2.0 Gio-2.0 BlockDev_3_0_gir_CFLAGS = -I${builddir}/../../include/ BlockDev_3_0_gir_LDFLAGS = -L${builddir}/../utils/ -lbd_utils BlockDev_3_0_gir_SCANNERFLAGS = --warn-error --warn-all --identifier-prefix=BD --symbol-prefix=bd BlockDev_3_0_gir_EXPORT_PACKAGES = blockdev INTROSPECTION_GIRS = BlockDev-3.0.gir typelibdir = $(libdir)/girepository-1.0 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) CLEANFILES = BlockDev-3.0.gir $(typelib_DATA) endif pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = ${builddir}/blockdev.pc libincludedir = $(includedir)/blockdev libinclude_HEADERS = blockdev.h plugins.h MAINTAINERCLEANFILES = Makefile.in blockdev.pc blockdev.c libblockdev-3.1.1-1/src/lib/blockdev.c.in000066400000000000000000000707301460051510300200330ustar00rootroot00000000000000#include #include #include "blockdev.h" #include "plugins.h" #include "plugin_apis/lvm.h" #include "plugin_apis/lvm.c" #include "plugin_apis/btrfs.h" #include "plugin_apis/btrfs.c" #include "plugin_apis/swap.h" #include "plugin_apis/swap.c" #include "plugin_apis/loop.h" #include "plugin_apis/loop.c" #include "plugin_apis/crypto.h" #include "plugin_apis/crypto.c" #include "plugin_apis/mpath.h" #include "plugin_apis/mpath.c" #include "plugin_apis/dm.h" #include "plugin_apis/dm.c" #include "plugin_apis/mdraid.h" #include "plugin_apis/mdraid.c" #include "plugin_apis/part.h" #include "plugin_apis/part.c" #include "plugin_apis/fs.h" #include "plugin_apis/fs.c" #include "plugin_apis/nvdimm.h" #include "plugin_apis/nvdimm.c" #include "plugin_apis/nvme.h" #include "plugin_apis/nvme.c" #if defined(__s390__) || defined(__s390x__) #include "plugin_apis/s390.h" #include "plugin_apis/s390.c" #endif /** * SECTION: blockdev * @short_description: a library for doing low-level operations with block devices * @title: blockdev library * @include: blockdev.h * */ #define DEFAULT_CONF_DIR_PATH "/etc/libblockdev/@MAJOR_VER@/conf.d/" static GMutex init_lock; static gboolean initialized = FALSE; typedef struct BDPluginStatus { BDPluginSpec spec; gpointer handle; } BDPluginStatus; typedef void* (*LoadFunc) (const gchar *so_name); /* KEEP THE ORDERING OF THESE ARRAYS MATCHING THE BDPluginName ENUM! */ static gchar * default_plugin_so[BD_PLUGIN_UNDEF] = { "libbd_lvm.so.@MAJOR_VER@", "libbd_btrfs.so.@MAJOR_VER@", "libbd_swap.so.@MAJOR_VER@", "libbd_loop.so.@MAJOR_VER@", "libbd_crypto.so.@MAJOR_VER@", "libbd_mpath.so.@MAJOR_VER@", "libbd_dm.so.@MAJOR_VER@", "libbd_mdraid.so.@MAJOR_VER@", "libbd_s390.so.@MAJOR_VER@", "libbd_part.so.@MAJOR_VER@", "libbd_fs.so.@MAJOR_VER@", "libbd_nvdimm.so.@MAJOR_VER@", "libbd_nvme.so.@MAJOR_VER@" }; static BDPluginStatus plugins[BD_PLUGIN_UNDEF] = { {{BD_PLUGIN_LVM, NULL}, NULL}, {{BD_PLUGIN_BTRFS, NULL}, NULL}, {{BD_PLUGIN_SWAP, NULL}, NULL}, {{BD_PLUGIN_LOOP, NULL}, NULL}, {{BD_PLUGIN_CRYPTO, NULL}, NULL}, {{BD_PLUGIN_MPATH, NULL}, NULL}, {{BD_PLUGIN_DM, NULL}, NULL}, {{BD_PLUGIN_MDRAID, NULL}, NULL}, {{BD_PLUGIN_S390, NULL}, NULL}, {{BD_PLUGIN_PART, NULL}, NULL}, {{BD_PLUGIN_FS, NULL}, NULL}, {{BD_PLUGIN_NVDIMM, NULL}, NULL}, {{BD_PLUGIN_NVME, NULL}, NULL}, }; static gchar* plugin_names[BD_PLUGIN_UNDEF] = { "lvm", "btrfs", "swap", "loop", "crypto", "mpath", "dm", "mdraid", "s390", "part", "fs", "nvdimm", "nvme" }; static void set_plugin_so_name (BDPlugin name, const gchar *so_name) { plugins[name].spec.so_name = so_name; } static gint config_file_cmp (gconstpointer a, gconstpointer b, gpointer user_data G_GNUC_UNUSED) { const gchar *name1 = (const gchar *) a; const gchar *name2 = (const gchar *) b; return g_strcmp0 (name1, name2); } static GSequence* get_config_files (GError **error) { GDir *dir = NULL; GSequence *ret = NULL; gchar *conf_dir_path = NULL; const gchar *dirent = NULL; conf_dir_path = g_strdup (g_getenv("LIBBLOCKDEV_CONFIG_DIR")); if (!conf_dir_path) conf_dir_path = g_strdup (DEFAULT_CONF_DIR_PATH); dir = g_dir_open (conf_dir_path, 0, error); if (!dir) { g_prefix_error (error, "Failed to get contents of the config dir (%s)", conf_dir_path); g_free (conf_dir_path); return NULL; } ret = g_sequence_new ((GDestroyNotify) g_free); dirent = g_dir_read_name(dir); while (dirent) { /* only process .cfg files from the directory */ if (g_str_has_suffix (dirent, ".cfg")) { dirent = g_build_filename (conf_dir_path, dirent, NULL); g_sequence_insert_sorted (ret, (gpointer) dirent, config_file_cmp, NULL); } dirent = g_dir_read_name(dir); } g_free (conf_dir_path); g_dir_close (dir); return ret; } static gboolean process_config_file (const gchar *config_file, GSList **plugins_sonames, GError **error) { GKeyFile *config = NULL; BDPlugin i = 0; gchar **sonames = NULL; gsize n_sonames = 0; config = g_key_file_new (); if (!g_key_file_load_from_file (config, config_file, G_KEY_FILE_NONE, error)) return FALSE; /* get sonames for each plugin (if specified) */ for (i=0; (i < BD_PLUGIN_UNDEF); i++) { sonames = g_key_file_get_string_list (config, plugin_names[i], "sonames", &n_sonames, error); if (!sonames) { /* no sonames specified or an error occurred */ if (*error) g_clear_error (error); } else { /* go through the sonames in the reversed order (because we prepend them to the list) */ for (; n_sonames > 0; n_sonames--) { plugins_sonames[i] = g_slist_prepend (plugins_sonames[i], sonames[n_sonames-1]); } /* we need to free only the array here not its items because those were put into the list above as pointers */ g_free (sonames); } } g_key_file_free (config); return TRUE; } static gboolean load_config (GSequence *config_files, GSList **plugins_sonames, GError **error) { GSequenceIter *config_file_iter = NULL; gchar *config_file = NULL; /* process config files one after another in order */ config_file_iter = g_sequence_get_begin_iter (config_files); while (!g_sequence_iter_is_end (config_file_iter)) { config_file = (gchar *) g_sequence_get (config_file_iter); if (!process_config_file (config_file, plugins_sonames, error)) { bd_utils_log_format (BD_UTILS_LOG_WARNING, "Cannot process the config file '%s': %s. Skipping.", config_file, (*error)->message); g_clear_error (error); } config_file_iter = g_sequence_iter_next (config_file_iter); } return TRUE; } static void unload_plugins (void) { if (plugins[BD_PLUGIN_LVM].handle && !unload_lvm (plugins[BD_PLUGIN_LVM].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the lvm plugin"); plugins[BD_PLUGIN_LVM].handle = NULL; if (plugins[BD_PLUGIN_BTRFS].handle && !unload_btrfs (plugins[BD_PLUGIN_BTRFS].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the btrfs plugin"); plugins[BD_PLUGIN_BTRFS].handle = NULL; if (plugins[BD_PLUGIN_SWAP].handle && !unload_swap (plugins[BD_PLUGIN_SWAP].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the swap plugin"); plugins[BD_PLUGIN_SWAP].handle = NULL; if (plugins[BD_PLUGIN_LOOP].handle && !unload_loop (plugins[BD_PLUGIN_LOOP].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the loop plugin"); plugins[BD_PLUGIN_LOOP].handle = NULL; if (plugins[BD_PLUGIN_CRYPTO].handle && !unload_crypto (plugins[BD_PLUGIN_CRYPTO].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the crypto plugin"); plugins[BD_PLUGIN_CRYPTO].handle = NULL; if (plugins[BD_PLUGIN_MPATH].handle && !unload_mpath (plugins[BD_PLUGIN_MPATH].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the mpath plugin"); plugins[BD_PLUGIN_MPATH].handle = NULL; if (plugins[BD_PLUGIN_DM].handle && !unload_dm (plugins[BD_PLUGIN_DM].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the dm plugin"); plugins[BD_PLUGIN_DM].handle = NULL; if (plugins[BD_PLUGIN_MDRAID].handle && !unload_mdraid (plugins[BD_PLUGIN_MDRAID].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the mdraid plugin"); plugins[BD_PLUGIN_MDRAID].handle = NULL; #if defined(__s390__) || defined(__s390x__) if (plugins[BD_PLUGIN_S390].handle && !unload_s390 (plugins[BD_PLUGIN_S390].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the s390 plugin"); plugins[BD_PLUGIN_S390].handle = NULL; #endif if (plugins[BD_PLUGIN_PART].handle && !unload_part (plugins[BD_PLUGIN_PART].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the part plugin"); plugins[BD_PLUGIN_PART].handle = NULL; if (plugins[BD_PLUGIN_FS].handle && !unload_fs (plugins[BD_PLUGIN_FS].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the fs plugin"); plugins[BD_PLUGIN_FS].handle = NULL; if (plugins[BD_PLUGIN_NVDIMM].handle && !unload_nvdimm (plugins[BD_PLUGIN_NVDIMM].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the nvdimm plugin"); plugins[BD_PLUGIN_NVDIMM].handle = NULL; if (plugins[BD_PLUGIN_NVME].handle && !unload_nvme (plugins[BD_PLUGIN_NVME].handle)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to close the nvme plugin"); plugins[BD_PLUGIN_NVME].handle = NULL; } static void load_plugin_from_sonames (BDPlugin plugin, LoadFunc load_fn, void **handle, GSList *sonames) { while (!(*handle) && sonames) { *handle = load_fn (sonames->data); if (*handle) set_plugin_so_name(plugin, g_strdup (sonames->data)); sonames = g_slist_next (sonames); } } static void do_load (GSList **plugins_sonames) { if (!plugins[BD_PLUGIN_LVM].handle && plugins_sonames[BD_PLUGIN_LVM]) load_plugin_from_sonames (BD_PLUGIN_LVM, load_lvm_from_plugin, &(plugins[BD_PLUGIN_LVM].handle), plugins_sonames[BD_PLUGIN_LVM]); if (!plugins[BD_PLUGIN_BTRFS].handle && plugins_sonames[BD_PLUGIN_BTRFS]) load_plugin_from_sonames (BD_PLUGIN_BTRFS, load_btrfs_from_plugin, &(plugins[BD_PLUGIN_BTRFS].handle), plugins_sonames[BD_PLUGIN_BTRFS]); if (!plugins[BD_PLUGIN_SWAP].handle && plugins_sonames[BD_PLUGIN_SWAP]) load_plugin_from_sonames (BD_PLUGIN_SWAP,load_swap_from_plugin, &(plugins[BD_PLUGIN_SWAP].handle), plugins_sonames[BD_PLUGIN_SWAP]); if (!plugins[BD_PLUGIN_LOOP].handle && plugins_sonames[BD_PLUGIN_LOOP]) load_plugin_from_sonames (BD_PLUGIN_LOOP, load_loop_from_plugin, &(plugins[BD_PLUGIN_LOOP].handle), plugins_sonames[BD_PLUGIN_LOOP]); if (!plugins[BD_PLUGIN_CRYPTO].handle && plugins_sonames[BD_PLUGIN_CRYPTO]) load_plugin_from_sonames (BD_PLUGIN_CRYPTO, load_crypto_from_plugin, &(plugins[BD_PLUGIN_CRYPTO].handle), plugins_sonames[BD_PLUGIN_CRYPTO]); if (!plugins[BD_PLUGIN_MPATH].handle && plugins_sonames[BD_PLUGIN_MPATH]) load_plugin_from_sonames (BD_PLUGIN_MPATH, load_mpath_from_plugin, &(plugins[BD_PLUGIN_MPATH].handle), plugins_sonames[BD_PLUGIN_MPATH]); if (!plugins[BD_PLUGIN_DM].handle && plugins_sonames[BD_PLUGIN_DM]) load_plugin_from_sonames (BD_PLUGIN_DM, load_dm_from_plugin, &(plugins[BD_PLUGIN_DM].handle), plugins_sonames[BD_PLUGIN_DM]); if (!plugins[BD_PLUGIN_MDRAID].handle && plugins_sonames[BD_PLUGIN_MDRAID]) load_plugin_from_sonames (BD_PLUGIN_MDRAID, load_mdraid_from_plugin, &(plugins[BD_PLUGIN_MDRAID].handle), plugins_sonames[BD_PLUGIN_MDRAID]); #if defined(__s390__) || defined(__s390x__) if (!plugins[BD_PLUGIN_S390].handle && plugins_sonames[BD_PLUGIN_S390]) load_plugin_from_sonames (BD_PLUGIN_S390, load_s390_from_plugin, &(plugins[BD_PLUGIN_S390].handle), plugins_sonames[BD_PLUGIN_S390]); #endif if (!plugins[BD_PLUGIN_PART].handle && plugins_sonames[BD_PLUGIN_PART]) load_plugin_from_sonames (BD_PLUGIN_PART, load_part_from_plugin, &(plugins[BD_PLUGIN_PART].handle), plugins_sonames[BD_PLUGIN_PART]); if (!plugins[BD_PLUGIN_FS].handle && plugins_sonames[BD_PLUGIN_FS]) load_plugin_from_sonames (BD_PLUGIN_FS, load_fs_from_plugin, &(plugins[BD_PLUGIN_FS].handle), plugins_sonames[BD_PLUGIN_FS]); if (!plugins[BD_PLUGIN_NVDIMM].handle && plugins_sonames[BD_PLUGIN_NVDIMM]) load_plugin_from_sonames (BD_PLUGIN_NVDIMM, load_nvdimm_from_plugin, &(plugins[BD_PLUGIN_NVDIMM].handle), plugins_sonames[BD_PLUGIN_NVDIMM]); if (!plugins[BD_PLUGIN_NVME].handle && plugins_sonames[BD_PLUGIN_NVME]) load_plugin_from_sonames (BD_PLUGIN_NVME, load_nvme_from_plugin, &(plugins[BD_PLUGIN_NVME].handle), plugins_sonames[BD_PLUGIN_NVME]); } static gboolean load_plugins (BDPluginSpec **require_plugins, gboolean reload, guint64 *num_loaded) { guint8 i = 0; gboolean requested_loaded = TRUE; GError *error = NULL; GSequence *config_files = NULL; GSList *plugins_sonames[BD_PLUGIN_UNDEF] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; BDPlugin plugin_name = BD_PLUGIN_UNDEF; guint64 required_plugins_mask = 0; /* load config files first */ config_files = get_config_files (&error); if (config_files) { if (!load_config (config_files, plugins_sonames, &error)) bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to load config files: %s. Using the built-in config", error->message); g_sequence_free (config_files); } else bd_utils_log_format (BD_UTILS_LOG_INFO, "Failed to load config files: %s. Using the built-in config", error->message); g_clear_error (&error); /* populate missing items with the built-in defaults */ for (i=0; i < BD_PLUGIN_UNDEF; i++) if (!plugins_sonames[i]) plugins_sonames[i] = g_slist_prepend (plugins_sonames[i], g_strdup (default_plugin_so[i])); #if !defined(__s390__) && !defined(__s390x__) /* do not load the s390 plugin by default if not on s390(x) */ g_slist_free_full (plugins_sonames[BD_PLUGIN_S390], (GDestroyNotify) g_free); plugins_sonames[BD_PLUGIN_S390] = NULL; #endif /* unload the previously loaded plugins if requested */ if (reload) { unload_plugins (); /* clean all so names and populate back those that are requested or the defaults */ for (i=0; i < BD_PLUGIN_UNDEF; i++) plugins[i].spec.so_name = NULL; } if (require_plugins) { /* set requested sonames */ for (i=0; *(require_plugins + i); i++) { plugin_name = require_plugins[i]->name; required_plugins_mask |= (1 << plugin_name); if (require_plugins[i]->so_name) { g_slist_free_full (plugins_sonames[plugin_name], (GDestroyNotify) g_free); plugins_sonames[plugin_name] = NULL; plugins_sonames[plugin_name] = g_slist_prepend(plugins_sonames[plugin_name], g_strdup (require_plugins[i]->so_name)); } } /* now remove the defaults for plugins that are not required */ for (i=0; (i < BD_PLUGIN_UNDEF); i++) if (!(required_plugins_mask & (1 << i))) { /* plugin not required */ g_slist_free_full (plugins_sonames[i], (GDestroyNotify) g_free); plugins_sonames[i] = NULL; } } do_load (plugins_sonames); *num_loaded = 0; for (i=0; (i < BD_PLUGIN_UNDEF); i++) { /* if this plugin was required or all plugins were required, check if it was successfully loaded or not */ if (!require_plugins || (required_plugins_mask & (1 << i))) { #if !defined(__s390__) && !defined(__s390x__) if (!require_plugins && (i == BD_PLUGIN_S390)) /* do not check the s390 plugin on different archs unless explicitly required */ continue; #endif if (plugins[i].handle) (*num_loaded)++; else requested_loaded = FALSE; } } /* clear/free the config */ for (i=0; (i < BD_PLUGIN_UNDEF); i++) { if (plugins_sonames[i]) { g_slist_free_full (plugins_sonames[i], (GDestroyNotify) g_free); plugins_sonames[i] = NULL; } } return requested_loaded; } GQuark bd_init_error_quark (void) { return g_quark_from_static_string ("g-bd-init-error-quark"); } /** * bd_init: * @require_plugins: (nullable) (array zero-terminated=1): %NULL-terminated list * of plugins that should be loaded (if no so_name is specified * for the plugin, the default is used) or %NULL to load all * plugins * @log_func: (nullable) (scope notified): logging function to use * @error: (out) (optional): place to store error (if any) * * Returns: whether the library was successfully initialized with all the * required or default (see @require_plugins) plugins or not * * Example of libblockdev initialization with 'fs' and 'lvm' plugins. Specific * version of the lvm plugin is required: * * |[ * GError *error = NULL; * gboolean ret = FALSE; * BDPluginSpec fs_plugin = {BD_PLUGIN_FS, NULL}; * BDPluginSpec lvm_plugin = {BD_PLUGIN_LVM, "libbd_lvm.so.3"}; * * BDPluginSpec *plugins[] = {&fs_plugin, &lvm_plugin, NULL}; * * ret = bd_init (plugins, NULL, &error); * ]| */ gboolean bd_init (BDPluginSpec **require_plugins, BDUtilsLogFunc log_func, GError **error) { gboolean success = TRUE; guint64 num_loaded = 0; g_mutex_lock (&init_lock); if (initialized) { bd_utils_log_format (BD_UTILS_LOG_WARNING, "bd_init() called more than once! Use bd_reinit() to reinitialize " "or bd_is_initialized() to get the current state."); g_mutex_unlock (&init_lock); return FALSE; } if (log_func && !bd_utils_init_logging (log_func, error)) { /* the error is already populated */ g_mutex_unlock (&init_lock); return FALSE; } if (!load_plugins (require_plugins, FALSE, &num_loaded)) { g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_PLUGINS_FAILED, "Failed to load plugins"); success = FALSE; } if (num_loaded == 0) { if (require_plugins && (*require_plugins == NULL)) /* requested to load no plugins (NULL is the first item in the array), none loaded -> OK */ initialized = TRUE; else initialized = FALSE; } else initialized = TRUE; g_mutex_unlock (&init_lock); return success; } /** * bd_ensure_init: * @require_plugins: (nullable) (array zero-terminated=1): %NULL-terminated list * of plugins that should be loaded (if no so_name is specified * for the plugin, the default is used) or %NULL to load all * plugins * @log_func: (nullable) (scope notified): logging function to use * @error: (out) (optional): place to store error (if any) * * Checks the state of the library and if it is uninitialized or not all the * @require_plugins plugins are available, tries to (re)initialize it. Otherwise * just returns early. The difference between: * * |[ * if (!bd_is_initialized()) * bd_init(None, None, &error); * ]| * * and this function is that this function does the check and init in an atomic * way (holding the lock preventing other threads from doing changes in * between). * * Returns: whether the library was successfully initialized with all the * required or default (see @require_plugins) plugins or not either * before or by this call */ gboolean bd_ensure_init (BDPluginSpec **require_plugins, BDUtilsLogFunc log_func, GError **error) { gboolean success = TRUE; BDPluginSpec **check_plugin = NULL; gboolean missing = FALSE; guint64 num_loaded = 0; BDPlugin plugin = BD_PLUGIN_UNDEF; g_mutex_lock (&init_lock); if (initialized) { if (require_plugins) for (check_plugin=require_plugins; !missing && *check_plugin; check_plugin++) missing = !bd_is_plugin_available((*check_plugin)->name); else /* all plugins requested */ for (plugin=BD_PLUGIN_LVM; plugin != BD_PLUGIN_UNDEF; plugin++) missing = !bd_is_plugin_available(plugin); if (!missing) { g_mutex_unlock (&init_lock); return TRUE; } } if (log_func && !bd_utils_init_logging (log_func, error)) { /* the error is already populated */ g_mutex_unlock (&init_lock); return FALSE; } if (!load_plugins (require_plugins, FALSE, &num_loaded)) { g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_PLUGINS_FAILED, "Failed to load plugins"); success = FALSE; } if (num_loaded == 0) { if (require_plugins && (*require_plugins == NULL)) /* requested to load no plugins (NULL is the first item in the array), none loaded -> OK */ initialized = TRUE; else initialized = FALSE; } else initialized = TRUE; g_mutex_unlock (&init_lock); return success; } /** * bd_try_init: * @request_plugins: (nullable) (array zero-terminated=1): %NULL-terminated list * of plugins that should be loaded (if no so_name is specified * for the plugin, the default is used) or %NULL to load all * plugins * @log_func: (nullable) (scope notified): logging function to use * @loaded_plugin_names: (optional) (out) (transfer container) (array zero-terminated=1): names * of the successfully loaded plugins * @error: (out) (optional): place to store error (if any) * * Returns: whether the library was successfully initialized with all the * required or default (see @require_plugins) plugins or not * * *UNLIKE IN CASE OF bd_init() AND bd_ensure_init(), FAILURE TO LOAD A PLUGIN * IS NOT CONSIDERED ERROR* */ gboolean bd_try_init(BDPluginSpec **request_plugins, BDUtilsLogFunc log_func, gchar ***loaded_plugin_names, GError **error) { gboolean success = TRUE; guint64 num_loaded = 0; g_mutex_lock (&init_lock); if (initialized) { bd_utils_log_format (BD_UTILS_LOG_WARNING, "bd_try_init() called more than once! Use bd_reinit() " "to reinitialize or bd_is_initialized() to get the current state."); g_mutex_unlock (&init_lock); return FALSE; } if (log_func && !bd_utils_init_logging (log_func, error)) { /* the error is already populated */ g_mutex_unlock (&init_lock); return FALSE; } success = load_plugins (request_plugins, FALSE, &num_loaded); if (num_loaded == 0) { if (request_plugins && (*request_plugins == NULL)) /* requested to load no plugins (NULL is the first item in the array), none loaded -> OK */ initialized = TRUE; else initialized = FALSE; } else initialized = TRUE; if (loaded_plugin_names) *loaded_plugin_names = bd_get_available_plugin_names (); g_mutex_unlock (&init_lock); return success; } /** * bd_reinit: * @require_plugins: (nullable) (array zero-terminated=1): %NULL-terminated list * of plugins that should be loaded (if no so_name is specified * for the plugin, the default is used) or %NULL to load all * plugins * @reload: whether to reload the already loaded plugins or not * @log_func: (nullable) (scope notified): logging function to use or %NULL * to keep the old one * @error: (out) (optional): place to store error (if any) * * Returns: whether the library was successfully initialized or not * * If @reload is %TRUE all the plugins are closed and reloaded otherwise only * the missing plugins are loaded. */ gboolean bd_reinit (BDPluginSpec **require_plugins, gboolean reload, BDUtilsLogFunc log_func, GError **error) { gboolean success = TRUE; guint64 num_loaded = 0; g_mutex_lock (&init_lock); if (log_func && !bd_utils_init_logging (log_func, error)) { /* the error is already populated */ g_mutex_unlock (&init_lock); return FALSE; } if (!load_plugins (require_plugins, reload, &num_loaded)) { g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_PLUGINS_FAILED, "Failed to load plugins"); success = FALSE; } else if (require_plugins && (*require_plugins == NULL) && reload) /* requested to just unload all plugins */ success = (num_loaded == 0); if (num_loaded == 0) { if (require_plugins && (*require_plugins == NULL)) /* requested to load no plugins (NULL is the first item in the array), none loaded -> OK */ initialized = TRUE; else initialized = FALSE; } else initialized = TRUE; g_mutex_unlock (&init_lock); return success; } /** * bd_try_reinit: * @require_plugins: (nullable) (array zero-terminated=1): %NULL-terminated list * of plugins that should be loaded (if no so_name is specified * for the plugin, the default is used) or %NULL to load all * plugins * @reload: whether to reload the already loaded plugins or not * @log_func: (nullable) (scope notified): logging function to use or %NULL * to keep the old one * @loaded_plugin_names: (optional) (out) (transfer container) (array zero-terminated=1): names of the successfully * loaded plugins * @error: (out) (optional): place to store error (if any) * * Returns: whether the library was successfully initialized or not * * If @reload is %TRUE all the plugins are closed and reloaded otherwise only * the missing plugins are loaded. * * *UNLIKE IN CASE OF bd_init() AND bd_ensure_init(), FAILURE TO LOAD A PLUGIN * IS NOT CONSIDERED ERROR* */ gboolean bd_try_reinit (BDPluginSpec **require_plugins, gboolean reload, BDUtilsLogFunc log_func, gchar ***loaded_plugin_names, GError **error) { gboolean success = TRUE; guint64 num_loaded = 0; g_mutex_lock (&init_lock); if (log_func && !bd_utils_init_logging (log_func, error)) { /* the error is already populated */ g_mutex_unlock (&init_lock); return FALSE; } success = load_plugins (require_plugins, reload, &num_loaded); if (success && require_plugins && (*require_plugins == NULL) && reload) /* requested to just unload all plugins */ success = (num_loaded == 0); if (num_loaded == 0) { if (require_plugins && (*require_plugins == NULL)) /* requested to load no plugins (NULL is the first item in the array), none loaded -> OK */ initialized = TRUE; else initialized = FALSE; } else initialized = TRUE; if (loaded_plugin_names) *loaded_plugin_names = bd_get_available_plugin_names (); g_mutex_unlock (&init_lock); return success; } /** * bd_is_initialized: * * Returns: whether the library is initialized or not * * The library is considered initialized if some of the *init*() functions * was/were called and either at least one plugin is loaded or 0 plugins are * loaded after an explicit call that requested 0 plugins to be loaded. */ gboolean bd_is_initialized (void) { gboolean is = FALSE; g_mutex_lock (&init_lock); is = initialized; g_mutex_unlock (&init_lock); return is; } /** * bd_get_available_plugin_names: * * Returns: (transfer container) (array zero-terminated=1): an array of string * names of plugins that are available */ gchar** bd_get_available_plugin_names (void) { guint8 i = 0; guint8 num_loaded = 0; guint8 next = 0; for (i=0; i < BD_PLUGIN_UNDEF; i++) if (plugins[i].handle) num_loaded++; gchar **ret_plugin_names = g_new0 (gchar*, num_loaded + 1); for (i=0; i < BD_PLUGIN_UNDEF; i++) if (plugins[i].handle) { ret_plugin_names[next] = plugin_names[i]; next++; } ret_plugin_names[next] = NULL; return ret_plugin_names; } /** * bd_is_plugin_available: * @plugin: the queried plugin * * Returns: whether the given plugin is available or not */ gboolean bd_is_plugin_available (BDPlugin plugin) { if (plugin < BD_PLUGIN_UNDEF) return plugins[plugin].handle != NULL; else return FALSE; } /** * bd_get_plugin_soname: * @plugin: the queried plugin * * Returns: (transfer full): name of the shared object loaded for the plugin or * %NULL if none is loaded */ gchar* bd_get_plugin_soname (BDPlugin plugin) { if (plugins[plugin].handle) return g_strdup (plugins[plugin].spec.so_name); return NULL; } /** * bd_get_plugin_name: * @plugin: the queried plugin * * Returns: (transfer none): name of the plugin */ gchar* bd_get_plugin_name (BDPlugin plugin) { return plugin_names[plugin]; } libblockdev-3.1.1-1/src/lib/blockdev.h000066400000000000000000000017731460051510300174340ustar00rootroot00000000000000#include #include #ifndef BD_LIB #define BD_LIB #include "plugins.h" /** * bd_init_error_quark: (skip) */ GQuark bd_init_error_quark (void); #define BD_INIT_ERROR bd_init_error_quark () typedef enum { BD_INIT_ERROR_FAILED, BD_INIT_ERROR_PLUGINS_FAILED, BD_INIT_ERROR_NOT_IMPLEMENTED, } BDInitError; gboolean bd_init (BDPluginSpec **require_plugins, BDUtilsLogFunc log_func, GError **error); gboolean bd_ensure_init (BDPluginSpec **require_plugins, BDUtilsLogFunc log_func, GError **error); gboolean bd_reinit (BDPluginSpec **require_plugins, gboolean reload, BDUtilsLogFunc log_func, GError **error); gboolean bd_try_init(BDPluginSpec **request_plugins, BDUtilsLogFunc log_func, gchar ***loaded_plugin_names, GError **error); gboolean bd_try_reinit (BDPluginSpec **require_plugins, gboolean reload, BDUtilsLogFunc log_func, gchar ***loaded_plugin_names, GError **error); gboolean bd_is_initialized (void); #endif /* BD_LIB */ libblockdev-3.1.1-1/src/lib/blockdev.pc.in000066400000000000000000000004711460051510300202060ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ includedir=@includedir@ libdir=@libdir@ Name: BlockDev Description: Library for doing low-level operations with block devices URL: https://github.com/storaged-project/libblockdev Version: @VERSION@ Requires: glib-2.0 Libs: -L${libdir} -lblockdev Cflags: -I${includedir} libblockdev-3.1.1-1/src/lib/plugin_apis/000077500000000000000000000000001460051510300177745ustar00rootroot00000000000000libblockdev-3.1.1-1/src/lib/plugin_apis/Makefile.am000066400000000000000000000010501460051510300220240ustar00rootroot00000000000000API_FILES := $(wildcard ${srcdir}/*.api) SOURCE_FILES := $(patsubst %.api,%.c,${API_FILES}) HEADER_FILES := $(patsubst %.api,%.h,${API_FILES}) all-local: generate_boilerplate %.c %.h: %.api ${srcdir}/../../../scripts/boilerplate_generator.py ${PYTHON} ${srcdir}/../../../scripts/boilerplate_generator.py $*.api ./ generate_boilerplate: ${SOURCE_FILES} ${HEADER_FILES} dist_noinst_HEADERS = ${API_FILES} ${SOURCE_FILES} ${HEADER_FILES} CLEANFILES = ${SOURCE_FILES} ${HEADER_FILES} MAINTAINERCLEANFILES = Makefile.in .PHONY: generate_boilerplate libblockdev-3.1.1-1/src/lib/plugin_apis/btrfs.api000066400000000000000000000376351460051510300216250ustar00rootroot00000000000000#include #include #include #ifndef BD_BTRFS_API #define BD_BTRFS_API #define BD_BTRFS_MAIN_VOLUME_ID 5 #define BD_BTRFS_MIN_MEMBER_SIZE G_GUINT64_CONSTANT (134217728ULL) /* 128 MiB */ GQuark bd_btrfs_error_quark (void) { return g_quark_from_static_string ("g-bd-btrfs-error-quark"); } #define BD_BTRFS_ERROR bd_btrfs_error_quark () typedef enum { BD_BTRFS_ERROR_TECH_UNAVAIL, BD_BTRFS_ERROR_DEVICE, BD_BTRFS_ERROR_PARSE, } BDBtrfsError; #define BD_BTRFS_TYPE_DEVICE_INFO (bd_btrfs_device_info_get_type ()) GType bd_btrfs_device_info_get_type(); /** * BDBtrfsDeviceInfo: * @id: ID of the device * @path: path of the device * @size: size of the device * @used: size of the used space */ typedef struct BDBtrfsDeviceInfo { guint64 id; gchar *path; guint64 size; guint64 used; } BDBtrfsDeviceInfo; /** * bd_btrfs_device_info_copy: (skip) * @info: (nullable): %BDBtrfsDeviceInfo to copy * * Creates a new copy of @info. */ BDBtrfsDeviceInfo* bd_btrfs_device_info_copy (BDBtrfsDeviceInfo *info) { if (info == NULL) return NULL; BDBtrfsDeviceInfo *new_info = g_new0 (BDBtrfsDeviceInfo, 1); new_info->id = info->id; new_info->path = g_strdup (info->path); new_info->size = info->size; new_info->used = info->used; return new_info; } /** * bd_btrfs_device_info_free: (skip) * @info: (nullable): %BDBtrfsDeviceInfo to free * * Frees @info. */ void bd_btrfs_device_info_free (BDBtrfsDeviceInfo *info) { if (info == NULL) return; g_free (info->path); g_free (info); } GType bd_btrfs_device_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDBtrfsDeviceInfo", (GBoxedCopyFunc) bd_btrfs_device_info_copy, (GBoxedFreeFunc) bd_btrfs_device_info_free); } return type; } #define BD_BTRFS_TYPE_SUBVOLUME_INFO (bd_btrfs_subvolume_info_get_type ()) GType bd_btrfs_subvolume_info_get_type(); /** * BDBtrfsSubvolumeInfo: * @id: ID of the subvolume * @parent_id: ID of the parent (sub)volume * @path: path of the subvolume */ typedef struct BDBtrfsSubvolumeInfo { guint64 id; guint64 parent_id; gchar *path; } BDBtrfsSubvolumeInfo; /** * bd_btrfs_subvolume_info_copy: (skip) * @info: (nullable): %BDBtrfsSubvolumeInfo to copy * * Creates a new copy of @info. */ BDBtrfsSubvolumeInfo* bd_btrfs_subvolume_info_copy (BDBtrfsSubvolumeInfo *info) { if (info == NULL) return NULL; BDBtrfsSubvolumeInfo *new_info = g_new0 (BDBtrfsSubvolumeInfo, 1); new_info->id = info->id; new_info->parent_id = info->parent_id; new_info->path = g_strdup (info->path); return new_info; } /** * bd_btrfs_subvolume_info_free: (skip) * @info: (nullable): %BDBtrfsSubvolumeInfo to free * * Frees @info. */ void bd_btrfs_subvolume_info_free (BDBtrfsSubvolumeInfo *info) { if (info == NULL) return; g_free (info->path); g_free (info); } GType bd_btrfs_subvolume_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDBtrfsSubvolumeInfo", (GBoxedCopyFunc) bd_btrfs_subvolume_info_copy, (GBoxedFreeFunc) bd_btrfs_subvolume_info_free); } return type; } #define BD_BTRFS_TYPE_FILESYSTEM_INFO (bd_btrfs_filesystem_info_get_type ()) GType bd_btrfs_filesystem_info_get_type(); /** * BDBtrfsFilesystemInfo: * @label: label of the filesystem * @uuid: uuid of the filesystem * @num_devices: number of device in the filesystem * @used: size of the used space */ typedef struct BDBtrfsFilesystemInfo { gchar *label; gchar *uuid; guint64 num_devices; guint64 used; } BDBtrfsFilesystemInfo; /** * bd_btrfs_filesystem_info_copy: (skip) * @info: (nullable): %BDBtrfsFilesystemInfo to copy * * Creates a new copy of @info. */ BDBtrfsFilesystemInfo* bd_btrfs_filesystem_info_copy (BDBtrfsFilesystemInfo *info) { if (info == NULL) return NULL; BDBtrfsFilesystemInfo *new_info = g_new0 (BDBtrfsFilesystemInfo, 1); new_info->label = g_strdup (info->label); new_info->uuid = g_strdup (info->uuid); new_info->num_devices = info->num_devices; new_info->used = info->used; return new_info; } /** * bd_btrfs_filesystem_info_free: (skip) * @info: (nullable): %BDBtrfsFilesystemInfo to free * * Frees @info. */ void bd_btrfs_filesystem_info_free (BDBtrfsFilesystemInfo *info) { if (info == NULL) return; g_free (info->label); g_free (info->uuid); g_free (info); } GType bd_btrfs_filesystem_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDBtrfsFilesystemInfo", (GBoxedCopyFunc) bd_btrfs_filesystem_info_copy, (GBoxedFreeFunc) bd_btrfs_filesystem_info_free); } return type; } typedef enum { BD_BTRFS_TECH_FS = 0, BD_BTRFS_TECH_MULTI_DEV, BD_BTRFS_TECH_SUBVOL, BD_BTRFS_TECH_SNAPSHOT, } BDBtrfsTech; typedef enum { BD_BTRFS_TECH_MODE_CREATE = 1 << 0, BD_BTRFS_TECH_MODE_DELETE = 1 << 1, BD_BTRFS_TECH_MODE_MODIFY = 1 << 2, BD_BTRFS_TECH_MODE_QUERY = 1 << 3, } BDBtrfsTechMode; /** * bd_btrfs_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDBtrfsTechMode) for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_btrfs_is_tech_avail (BDBtrfsTech tech, guint64 mode, GError **error); /** * bd_btrfs_create_volume: * @devices: (array zero-terminated=1): list of devices to create btrfs volume from * @label: (nullable): label for the volume * @data_level: (nullable): RAID level for the data or %NULL to use the default * @md_level: (nullable): RAID level for the metadata or %NULL to use the default * @extra: (nullable) (array zero-terminated=1): extra options for the volume creation (right now * passed to the 'mkfs.btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the new btrfs volume was created from @devices or not * * See mkfs.btrfs(8) for details about @data_level, @md_level and btrfs in general. * * Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_CREATE */ gboolean bd_btrfs_create_volume (const gchar **devices, const gchar *label, const gchar *data_level, const gchar *md_level, const BDExtraArg **extra, GError **error); /** * bd_btrfs_add_device: * @mountpoint: mountpoint of the btrfs volume to add new device to * @device: a device to add to the btrfs volume * @extra: (nullable) (array zero-terminated=1): extra options for the addition (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @device was successfully added to the @mountpoint btrfs volume or not * * Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_MODIFY */ gboolean bd_btrfs_add_device (const gchar *mountpoint, const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_btrfs_remove_device: * @mountpoint: mountpoint of the btrfs volume to remove device from * @device: a device to remove from the btrfs volume * @extra: (nullable) (array zero-terminated=1): extra options for the removal (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @device was successfully removed from the @mountpoint btrfs volume or not * * Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_MODIFY */ gboolean bd_btrfs_remove_device (const gchar *mountpoint, const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_btrfs_create_subvolume: * @mountpoint: mountpoint of the btrfs volume to create subvolume under * @name: name of the subvolume * @extra: (nullable) (array zero-terminated=1): extra options for the subvolume creation (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @mountpoint/@name subvolume was successfully created or not * * Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_CREATE */ gboolean bd_btrfs_create_subvolume (const gchar *mountpoint, const gchar *name, const BDExtraArg **extra, GError **error); /** * bd_btrfs_delete_subvolume: * @mountpoint: mountpoint of the btrfs volume to delete subvolume from * @name: name of the subvolume * @extra: (nullable) (array zero-terminated=1): extra options for the subvolume deletion (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @mountpoint/@name subvolume was successfully deleted or not * * Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_DELETE */ gboolean bd_btrfs_delete_subvolume (const gchar *mountpoint, const gchar *name, const BDExtraArg **extra, GError **error); /** * bd_btrfs_get_default_subvolume_id: * @mountpoint: mountpoint of the volume to get the default subvolume ID of * @error: (out) (optional): place to store error (if any) * * Returns: ID of the @mountpoint volume's default subvolume. If 0, * @error may be set to indicate error * * Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_QUERY */ guint64 bd_btrfs_get_default_subvolume_id (const gchar *mountpoint, GError **error); /** * bd_btrfs_set_default_subvolume: * @mountpoint: mountpoint of the volume to set the default subvolume ID of * @subvol_id: ID of the subvolume to be set as the default subvolume * @extra: (nullable) (array zero-terminated=1): extra options for the setting (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @mountpoint volume's default subvolume was correctly set * to @subvol_id or not * * Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_MODIFY */ gboolean bd_btrfs_set_default_subvolume (const gchar *mountpoint, guint64 subvol_id, const BDExtraArg **extra, GError **error); /** * bd_btrfs_create_snapshot: * @source: path to source subvolume * @dest: path to new snapshot volume * @ro: whether the snapshot should be read-only * @extra: (nullable) (array zero-terminated=1): extra options for the snapshot creation (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @dest snapshot of @source was successfully created or not * * Tech category: %BD_BTRFS_TECH_SNAPSHOT-%BD_BTRFS_TECH_MODE_CREATE */ gboolean bd_btrfs_create_snapshot (const gchar *source, const gchar *dest, gboolean ro, const BDExtraArg **extra, GError **error); /** * bd_btrfs_list_devices: * @device: a device that is part of the queried btrfs volume * @error: (out) (optional): place to store error (if any) * * Returns: (array zero-terminated=1): information about the devices that are part of the btrfs volume * containing @device or %NULL in case of error * * Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_QUERY */ BDBtrfsDeviceInfo** bd_btrfs_list_devices (const gchar *device, GError **error); /** * bd_btrfs_list_subvolumes: * @mountpoint: a mountpoint of the queried btrfs volume * @snapshots_only: whether to list only snapshot subvolumes or not * @error: (out) (optional): place to store error (if any) * * Returns: (array zero-terminated=1): information about the subvolumes that are part of the btrfs volume * mounted at @mountpoint or %NULL in case of error * * The subvolumes are sorted in a way that no child subvolume appears in the * list before its parent (sub)volume. * * Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_QUERY */ BDBtrfsSubvolumeInfo** bd_btrfs_list_subvolumes (const gchar *mountpoint, gboolean snapshots_only, GError **error); /** * bd_btrfs_filesystem_info: * @device: a device that is part of the queried btrfs volume * @error: (out) (optional): place to store error (if any) * * Returns: information about the @device's volume's filesystem or %NULL in case of error * * Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_QUERY */ BDBtrfsFilesystemInfo* bd_btrfs_filesystem_info (const gchar *device, GError **error); /** * bd_btrfs_mkfs: * @devices: (array zero-terminated=1): list of devices to create btrfs volume from * @label: (nullable): label for the volume * @data_level: (nullable): RAID level for the data or %NULL to use the default * @md_level: (nullable): RAID level for the metadata or %NULL to use the default * @extra: (nullable) (array zero-terminated=1): extra options for the volume creation (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the new btrfs volume was created from @devices or not * * See mkfs.btrfs(8) for details about @data_level, @md_level and btrfs in general. * * Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_CREATE */ gboolean bd_btrfs_mkfs (const gchar **devices, const gchar *label, const gchar *data_level, const gchar *md_level, const BDExtraArg **extra, GError **error); /** * bd_btrfs_resize: * @mountpoint: a mountpoint of the to be resized btrfs filesystem * @size: requested new size * @extra: (nullable) (array zero-terminated=1): extra options for the volume resize (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @mountpoint filesystem was successfully resized to @size * or not * * Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_MODIFY */ gboolean bd_btrfs_resize (const gchar *mountpoint, guint64 size, const BDExtraArg **extra, GError **error); /** * bd_btrfs_check: * @device: a device that is part of the checked btrfs volume * @extra: (nullable) (array zero-terminated=1): extra options for the check (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the filesystem was successfully checked or not * * Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_QUERY */ gboolean bd_btrfs_check (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_btrfs_repair: * @device: a device that is part of the to be repaired btrfs volume * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the filesystem was successfully checked and repaired or not * * Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_MODIFY */ gboolean bd_btrfs_repair (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_btrfs_change_label: * @mountpoint: a mountpoint of the btrfs filesystem to change label of * @label: new label for the filesystem * @error: (out) (optional): place to store error (if any) * * Returns: whether the label of the @mountpoint filesystem was successfully set * to @label or not * * Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_MODIFY */ gboolean bd_btrfs_change_label (const gchar *mountpoint, const gchar *label, GError **error); #endif /* BD_BTRFS_API */ libblockdev-3.1.1-1/src/lib/plugin_apis/crypto.api000066400000000000000000001333031460051510300220120ustar00rootroot00000000000000#include #include #ifndef BD_CRYPTO_API #define BD_CRYPTO_API GQuark bd_crypto_error_quark (void) { return g_quark_from_static_string ("g-bd-crypto-error-quark"); } #define BD_CRYPTO_ERROR bd_crypto_error_quark () typedef enum { BD_CRYPTO_ERROR_TECH_UNAVAIL, BD_CRYPTO_ERROR_DEVICE, BD_CRYPTO_ERROR_STATE, BD_CRYPTO_ERROR_INVALID_SPEC, BD_CRYPTO_ERROR_FORMAT_FAILED, BD_CRYPTO_ERROR_RESIZE_FAILED, BD_CRYPTO_ERROR_RESIZE_PERM, BD_CRYPTO_ERROR_ADD_KEY, BD_CRYPTO_ERROR_REMOVE_KEY, BD_CRYPTO_ERROR_NO_KEY, BD_CRYPTO_ERROR_KEY_SLOT, BD_CRYPTO_ERROR_NSS_INIT_FAILED, BD_CRYPTO_ERROR_CERT_DECODE, BD_CRYPTO_ERROR_ESCROW_FAILED, BD_CRYPTO_ERROR_INVALID_PARAMS, BD_CRYPTO_ERROR_KEYRING, BD_CRYPTO_ERROR_KEYFILE_FAILED, BD_CRYPTO_ERROR_INVALID_CONTEXT, } BDCryptoError; typedef enum { BD_CRYPTO_TECH_LUKS = 0, BD_CRYPTO_TECH_TRUECRYPT, BD_CRYPTO_TECH_ESCROW, BD_CRYPTO_TECH_INTEGRITY, BD_CRYPTO_TECH_BITLK, BD_CRYPTO_TECH_KEYRING, BD_CRYPTO_TECH_FVAULT2, } BDCryptoTech; typedef enum { BD_CRYPTO_TECH_MODE_CREATE = 1 << 0, BD_CRYPTO_TECH_MODE_OPEN_CLOSE = 1 << 1, BD_CRYPTO_TECH_MODE_QUERY = 1 << 2, BD_CRYPTO_TECH_MODE_ADD_KEY = 1 << 3, BD_CRYPTO_TECH_MODE_REMOVE_KEY = 1 << 4, BD_CRYPTO_TECH_MODE_RESIZE = 1 << 5, BD_CRYPTO_TECH_MODE_SUSPEND_RESUME = 1 << 6, BD_CRYPTO_TECH_MODE_BACKUP_RESTORE = 1 << 7, BD_CRYPTO_TECH_MODE_MODIFY = 1 << 8, } BDCryptoTechMode; typedef enum { BD_CRYPTO_LUKS_VERSION_LUKS1 = 0, BD_CRYPTO_LUKS_VERSION_LUKS2, } BDCryptoLUKSVersion; #define BD_CRYPTO_TYPE_LUKS_PBKDF (bd_crypto_luks_pbkdf_get_type ()) GType bd_crypto_luks_pbkdf_get_type(); /** * BDCryptoLUKSPBKDF * @type: PBKDF algorithm * @hash: hash for LUKS header or NULL * @max_memory_kb: requested memory cost (in KiB) or 0 for default (benchmark) * @iterations: requested iterations or 0 for default (benchmark) * @time_ms: requested time cost or 0 for default (benchmark) * @parallel_threads: requested parallel cost (threads) or 0 for default (benchmark) */ typedef struct BDCryptoLUKSPBKDF { gchar *type; gchar *hash; guint32 max_memory_kb; guint32 iterations; guint32 time_ms; guint32 parallel_threads; } BDCryptoLUKSPBKDF; /** * bd_crypto_luks_pbkdf_copy: (skip) * @pbkdf: (nullable): %BDCryptoLUKSPBKDF to copy * * Creates a new copy of @pbkdf. */ BDCryptoLUKSPBKDF* bd_crypto_luks_pbkdf_copy (BDCryptoLUKSPBKDF *pbkdf) { if (pbkdf == NULL) return NULL; BDCryptoLUKSPBKDF *new_pbkdf = g_new0 (BDCryptoLUKSPBKDF, 1); new_pbkdf->type = g_strdup (pbkdf->type); new_pbkdf->hash = g_strdup (pbkdf->hash); new_pbkdf->max_memory_kb = pbkdf->max_memory_kb; new_pbkdf->iterations = pbkdf->iterations; new_pbkdf->time_ms = pbkdf->time_ms; new_pbkdf->parallel_threads = pbkdf->parallel_threads; return new_pbkdf; } /** * bd_crypto_luks_pbkdf_free: (skip) * @pbkdf: (nullable): %BDCryptoLUKSPBKDF to free * * Frees @pbkdf. */ void bd_crypto_luks_pbkdf_free (BDCryptoLUKSPBKDF *pbkdf) { if (pbkdf == NULL) return; g_free (pbkdf->type); g_free (pbkdf->hash); g_free (pbkdf); } /** * bd_crypto_luks_pbkdf_new: (constructor) * @type: (nullable): PBKDF algorithm * @hash: (nullable): hash for LUKS header or NULL for default * @max_memory_kb: requested memory cost (in KiB) or 0 for default (benchmark) * @iterations: requested iterations or 0 for default (benchmark) * @time_ms: requested time cost or 0 for default (benchmark) * @parallel_threads: requested parallel cost (threads) or 0 for default (benchmark) * * Returns: (transfer full): a new pbkdf argument */ BDCryptoLUKSPBKDF* bd_crypto_luks_pbkdf_new (const gchar *type, const gchar *hash, guint32 max_memory_kb, guint32 iterations, guint32 time_ms, guint32 parallel_threads) { BDCryptoLUKSPBKDF *ret = g_new0 (BDCryptoLUKSPBKDF, 1); ret->type = g_strdup (type); ret->hash = g_strdup (hash); ret->max_memory_kb = max_memory_kb; ret->iterations = iterations; ret->time_ms = time_ms; ret->parallel_threads = parallel_threads; return ret; } GType bd_crypto_luks_pbkdf_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDCryptoLUKSPBKDF", (GBoxedCopyFunc) bd_crypto_luks_pbkdf_copy, (GBoxedFreeFunc) bd_crypto_luks_pbkdf_free); } return type; } #define BD_CRYPTO_TYPE_LUKS_EXTRA (bd_crypto_luks_extra_get_type ()) GType bd_crypto_luks_extra_get_type(); /** * BDCryptoLUKSExtra: * @data_alignment: data alignment in sectors, 0 for default/auto detection * @data_device: detached encrypted data device or NULL * @integrity: integrity algorithm (e.g. "hmac-sha256") or NULL for no integrity support * Note: this field is valid only for LUKS 2 * @sector_size: encryption sector size, 0 for default (512) * Note: this field is valid only for LUKS 2 * @label: LUKS header label or NULL * Note: this field is valid only for LUKS 2 * @subsystem: LUKS header subsystem or NULL * Note: this field is valid only for LUKS 2 * @pbkdf: key derivation function specification or NULL for default * Note: this field is valid only for LUKS 2 */ typedef struct BDCryptoLUKSExtra { guint64 data_alignment; gchar *data_device; gchar *integrity; guint32 sector_size; gchar *label; gchar *subsystem; BDCryptoLUKSPBKDF *pbkdf; } BDCryptoLUKSExtra; /** * bd_crypto_luks_extra_copy: (skip) * @extra: (nullable): %BDCryptoLUKSExtra to copy * * Creates a new copy of @extra. */ BDCryptoLUKSExtra* bd_crypto_luks_extra_copy (BDCryptoLUKSExtra *extra) { if (extra == NULL) return NULL; BDCryptoLUKSExtra *new_extra = g_new0 (BDCryptoLUKSExtra, 1); new_extra->integrity = g_strdup (extra->integrity); new_extra->data_alignment = extra->data_alignment; new_extra->data_device = g_strdup (extra->data_device); new_extra->sector_size = extra->sector_size; new_extra->label = g_strdup (extra->label); new_extra->subsystem = g_strdup (extra->subsystem); new_extra->pbkdf = bd_crypto_luks_pbkdf_copy (extra->pbkdf); return new_extra; } /** * bd_crypto_luks_extra_free: (skip) * @extra: (nullable): %BDCryptoLUKSExtra to free * * Frees @extra. */ void bd_crypto_luks_extra_free (BDCryptoLUKSExtra *extra) { if (extra == NULL) return; g_free (extra->integrity); g_free (extra->data_device); g_free (extra->label); g_free (extra->subsystem); bd_crypto_luks_pbkdf_free (extra->pbkdf); g_free (extra); } /** * bd_crypto_luks_extra_new: (constructor) * @data_alignment: data alignment in sectors, 0 for default/auto detection * @data_device: (nullable): detached encrypted data device or NULL * @integrity: (nullable): integrity algorithm (e.g. "hmac-sha256") or NULL for no integrity support * @sector_size: encryption sector size, 0 for default (512) * @label: (nullable): LUKS header label or NULL * @subsystem: (nullable): LUKS header subsystem or NULL * @pbkdf: (nullable): key derivation function specification or NULL for default * * Returns: (transfer full): a new LUKS extra argument */ BDCryptoLUKSExtra* bd_crypto_luks_extra_new (guint64 data_alignment, const gchar *data_device, const gchar *integrity, guint32 sector_size, const gchar *label, const gchar *subsystem, BDCryptoLUKSPBKDF *pbkdf) { BDCryptoLUKSExtra *ret = g_new0 (BDCryptoLUKSExtra, 1); ret->integrity = g_strdup (integrity); ret->data_alignment = data_alignment; ret->data_device = g_strdup (data_device); ret->sector_size = sector_size; ret->label = g_strdup (label); ret->subsystem = g_strdup (subsystem); ret->pbkdf = bd_crypto_luks_pbkdf_copy (pbkdf); return ret; } GType bd_crypto_luks_extra_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDCryptoLUKSExtra", (GBoxedCopyFunc) bd_crypto_luks_extra_copy, (GBoxedFreeFunc) bd_crypto_luks_extra_free); } return type; } #define BD_CRYPTO_TYPE_INTEGRITY_EXTRA (bd_crypto_integrity_extra_get_type ()) GType bd_crypto_integrity_extra_get_type(); /** * BDCryptoIntegrityExtra: * @sector_size: integrity sector size * @journal_size: size of journal in bytes * @journal_watermark: journal flush watermark in percents; in bitmap mode sectors-per-bit * @journal_commit_time: journal commit time (or bitmap flush time) in ms * @interleave_sectors: number of interleave sectors (power of two) * @tag_size: tag size per-sector in bytes * @buffer_sectors: number of sectors in one buffer */ typedef struct BDCryptoIntegrityExtra { guint32 sector_size; guint64 journal_size; guint journal_watermark; guint journal_commit_time; guint32 interleave_sectors; guint32 tag_size; guint32 buffer_sectors; } BDCryptoIntegrityExtra; /** * bd_crypto_integrity_extra_copy: (skip) * @extra: (nullable): %BDCryptoIntegrityExtra to copy * * Creates a new copy of @extra. */ BDCryptoIntegrityExtra* bd_crypto_integrity_extra_copy (BDCryptoIntegrityExtra *extra) { if (extra == NULL) return NULL; BDCryptoIntegrityExtra *new_extra = g_new0 (BDCryptoIntegrityExtra, 1); new_extra->sector_size = extra->sector_size; new_extra->journal_size = extra->journal_size; new_extra->journal_watermark = extra->journal_watermark; new_extra->journal_commit_time = extra->journal_commit_time; new_extra->interleave_sectors = extra->interleave_sectors; new_extra->tag_size = extra->tag_size; new_extra->buffer_sectors = extra->buffer_sectors; return new_extra; } /** * bd_crypto_integrity_extra_free: (skip) * @extra: (nullable): %BDCryptoIntegrityExtra to free * * Frees @extra. */ void bd_crypto_integrity_extra_free (BDCryptoIntegrityExtra *extra) { if (extra == NULL) return; g_free (extra); } /** * bd_crypto_integrity_extra_new: (constructor) * @sector_size: integrity sector size, 0 for default (512) * @journal_size: size of journal in bytes * @journal_watermark: journal flush watermark in percents; in bitmap mode sectors-per-bit * @journal_commit_time: journal commit time (or bitmap flush time) in ms * @interleave_sectors: number of interleave sectors (power of two) * @tag_size: tag size per-sector in bytes * @buffer_sectors: number of sectors in one buffer * * Returns: (transfer full): a new Integrity extra argument */ BDCryptoIntegrityExtra* bd_crypto_integrity_extra_new (guint32 sector_size, guint64 journal_size, guint journal_watermark, guint journal_commit_time, guint64 interleave_sectors, guint64 tag_size, guint64 buffer_sectors) { BDCryptoIntegrityExtra *ret = g_new0 (BDCryptoIntegrityExtra, 1); ret->sector_size = sector_size; ret->journal_size = journal_size; ret->journal_watermark = journal_watermark; ret->journal_commit_time = journal_commit_time; ret->interleave_sectors = interleave_sectors; ret->tag_size = tag_size; ret->buffer_sectors = buffer_sectors; return ret; } GType bd_crypto_integrity_extra_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDCryptoIntegrityExtra", (GBoxedCopyFunc) bd_crypto_integrity_extra_copy, (GBoxedFreeFunc) bd_crypto_integrity_extra_free); } return type; } typedef enum { BD_CRYPTO_INTEGRITY_OPEN_NO_JOURNAL = 1 << 0, BD_CRYPTO_INTEGRITY_OPEN_RECOVERY = 1 << 1, BD_CRYPTO_INTEGRITY_OPEN_NO_JOURNAL_BITMAP = 1 << 2, BD_CRYPTO_INTEGRITY_OPEN_RECALCULATE = 1 << 3, BD_CRYPTO_INTEGRITY_OPEN_RECALCULATE_RESET = 1 << 4, BD_CRYPTO_INTEGRITY_OPEN_ALLOW_DISCARDS = 1 << 5, } BDCryptoIntegrityOpenFlags; #define BD_CRYPTO_TYPE_LUKS_INFO (bd_crypto_luks_info_get_type ()) GType bd_crypto_luks_info_get_type(); /** * BDCryptoLUKSInfo: * @version: LUKS version * @cipher: used cipher (e.g. "aes") * @mode: used cipher mode (e.g. "xts-plain") * @uuid: UUID of the LUKS device * @backing_device: name of the underlying block device * @sector_size: size (in bytes) of encryption sector * Note: sector size is valid only for LUKS 2 * @metadata_size: LUKS metadata size * @label: label of the LUKS device (valid only for LUKS 2) * @subsystem: subsystem of the LUKS device (valid only for LUKS 2) */ typedef struct BDCryptoLUKSInfo { BDCryptoLUKSVersion version; gchar *cipher; gchar *mode; gchar *uuid; gchar *backing_device; guint32 sector_size; guint64 metadata_size; gchar *label; gchar *subsystem; } BDCryptoLUKSInfo; /** * bd_crypto_luks_info_free: (skip) * @info: (nullable): %BDCryptoLUKSInfo to free * * Frees @info. */ void bd_crypto_luks_info_free (BDCryptoLUKSInfo *info) { if (info == NULL) return; g_free (info->cipher); g_free (info->mode); g_free (info->uuid); g_free (info->backing_device); g_free (info->label); g_free (info->subsystem); g_free (info); } /** * bd_crypto_luks_info_copy: (skip) * @info: (nullable): %BDCryptoLUKSInfo to copy * * Creates a new copy of @info. */ BDCryptoLUKSInfo* bd_crypto_luks_info_copy (BDCryptoLUKSInfo *info) { if (info == NULL) return NULL; BDCryptoLUKSInfo *new_info = g_new0 (BDCryptoLUKSInfo, 1); new_info->version = info->version; new_info->cipher = g_strdup (info->cipher); new_info->mode = g_strdup (info->mode); new_info->uuid = g_strdup (info->uuid); new_info->backing_device = g_strdup (info->backing_device); new_info->sector_size = info->sector_size; new_info->metadata_size = info->metadata_size; new_info->label = g_strdup (info->label); new_info->subsystem = g_strdup (info->subsystem); return new_info; } GType bd_crypto_luks_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDCryptoLUKSInfo", (GBoxedCopyFunc) bd_crypto_luks_info_copy, (GBoxedFreeFunc) bd_crypto_luks_info_free); } return type; } #define BD_CRYPTO_TYPE_BITLK_INFO (bd_crypto_bitlk_info_get_type ()) GType bd_crypto_bitlk_info_get_type(); /** * BDCryptoBITLKInfo: * @cipher: used cipher (e.g. "aes") * @mode: used cipher mode (e.g. "xts-plain") * @uuid: UUID of the BITLK device * @backing_device: name of the underlying block device * @sector_size: size (in bytes) of encryption sector */ typedef struct BDCryptoBITLKInfo { gchar *cipher; gchar *mode; gchar *uuid; gchar *backing_device; guint32 sector_size; } BDCryptoBITLKInfo; /** * bd_crypto_bitlk_info_free: (skip) * @info: (nullable): %BDCryptoBITLKInfo to free * * Frees @info. */ void bd_crypto_bitlk_info_free (BDCryptoBITLKInfo *info) { if (info == NULL) return; g_free (info->cipher); g_free (info->mode); g_free (info->uuid); g_free (info->backing_device); g_free (info); } /** * bd_crypto_bitlk_info_copy: (skip) * @info: (nullable): %BDCryptoBITLKInfo to copy * * Creates a new copy of @info. */ BDCryptoBITLKInfo* bd_crypto_bitlk_info_copy (BDCryptoBITLKInfo *info) { if (info == NULL) return NULL; BDCryptoBITLKInfo *new_info = g_new0 (BDCryptoBITLKInfo, 1); new_info->cipher = g_strdup (info->cipher); new_info->mode = g_strdup (info->mode); new_info->uuid = g_strdup (info->uuid); new_info->backing_device = g_strdup (info->backing_device); new_info->sector_size = info->sector_size; return new_info; } GType bd_crypto_bitlk_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDCryptoBITLKInfo", (GBoxedCopyFunc) bd_crypto_bitlk_info_copy, (GBoxedFreeFunc) bd_crypto_bitlk_info_free); } return type; } #define BD_CRYPTO_TYPE_INTEGRITY_INFO (bd_crypto_integrity_info_get_type ()) GType bd_crypto_integrity_info_get_type(); /** * BDCryptoIntegrityInfo: * @algorithm: integrity algorithm * @key_size: integrity key size in bytes * @sector_size: sector size in bytes * @tag_size: tag size per-sector in bytes * @interleave_sectors: number of interleave sectors * @journal_size: size of journal in bytes * @journal_crypt: journal encryption algorithm * @journal_integrity: journal integrity algorithm */ typedef struct BDCryptoIntegrityInfo { gchar *algorithm; guint32 key_size; guint32 sector_size; guint32 tag_size; guint32 interleave_sectors; guint64 journal_size; gchar *journal_crypt; gchar *journal_integrity; } BDCryptoIntegrityInfo; /** * bd_crypto_integrity_info_free: (skip) * @info: (nullable): %BDCryptoIntegrityInfo to free * * Frees @info. */ void bd_crypto_integrity_info_free (BDCryptoIntegrityInfo *info) { if (info == NULL) return; g_free (info->algorithm); g_free (info->journal_crypt); g_free (info->journal_integrity); g_free (info); } /** * bd_crypto_integrity_info_copy: (skip) * @info: (nullable): %BDCryptoIntegrityInfo to copy * * Creates a new copy of @info. */ BDCryptoIntegrityInfo* bd_crypto_integrity_info_copy (BDCryptoIntegrityInfo *info) { if (info == NULL) return NULL; BDCryptoIntegrityInfo *new_info = g_new0 (BDCryptoIntegrityInfo, 1); new_info->algorithm = g_strdup (info->algorithm); new_info->key_size = info->key_size; new_info->sector_size = info->sector_size; new_info->tag_size = info->tag_size; new_info->interleave_sectors = info->interleave_sectors; new_info->journal_size = info->journal_size; new_info->journal_crypt = g_strdup (info->journal_crypt); new_info->journal_integrity = g_strdup (info->journal_integrity); return new_info; } GType bd_crypto_integrity_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDCryptoIntegrityInfo", (GBoxedCopyFunc) bd_crypto_integrity_info_copy, (GBoxedFreeFunc) bd_crypto_integrity_info_free); } return type; } #define BD_CRYPTO_TYPE_LUKS_TOKEN_INFO (bd_crypto_luks_token_info_get_type ()) GType bd_crypto_luks_token_info_get_type(); /** * BDCryptoLUKSTokenInfo: * @id: ID of the token * @type: type of the token * @keyslot: keyslot this token is assigned to or -1 for inactive/unassigned tokens */ typedef struct BDCryptoLUKSTokenInfo { guint id; gchar *type; gint keyslot; } BDCryptoLUKSTokenInfo; /** * bd_crypto_luks_token_info_free: (skip) * @info: (nullable): %BDCryptoLUKSTokenInfo to free * * Frees @info. */ void bd_crypto_luks_token_info_free (BDCryptoLUKSTokenInfo *info) { if (info == NULL) return; g_free (info->type); g_free (info); } /** * bd_crypto_luks_token_info_copy: (skip) * @info: (nullable): %BDCryptoLUKSTokenInfo to copy * * Creates a new copy of @info. */ BDCryptoLUKSTokenInfo* bd_crypto_luks_token_info_copy (BDCryptoLUKSTokenInfo *info) { if (info == NULL) return NULL; BDCryptoLUKSTokenInfo *new_info = g_new0 (BDCryptoLUKSTokenInfo, 1); new_info->id = info->id; new_info->type = g_strdup (info->type); new_info->keyslot = info->keyslot; return new_info; } GType bd_crypto_luks_token_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDCryptoLUKSTokenInfo", (GBoxedCopyFunc) bd_crypto_luks_token_info_copy, (GBoxedFreeFunc) bd_crypto_luks_token_info_free); } return type; } /** * bd_crypto_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDCryptoTechMode) for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_crypto_is_tech_avail (BDCryptoTech tech, guint64 mode, GError **error); /** * bd_crypto_generate_backup_passphrase: * @error: (out) (optional): place to store error (if any) * * Returns: A newly generated %BD_CRYPTO_BACKUP_PASSPHRASE_LENGTH-long passphrase. * * See %BD_CRYPTO_BACKUP_PASSPHRASE_CHARSET for the definition of the charset used for the passphrase. * * Tech category: always available */ gchar* bd_crypto_generate_backup_passphrase(GError **error); /** * bd_crypto_device_is_luks: * @device: the queried device * @error: (out) (optional): place to store error (if any) * * Returns: %TRUE if the given @device is a LUKS device or %FALSE if not or * failed to determine (the @error) is populated with the error in such * cases) * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_QUERY */ gboolean bd_crypto_device_is_luks (const gchar *device, GError **error); /** * bd_crypto_luks_status: * @luks_device: the queried LUKS device * @error: (out) (optional): place to store error (if any) * * Returns: (transfer none): one of "invalid", "inactive", "active" or "busy" or * %NULL if failed to determine (@error is populated with the error in * such cases) * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_QUERY */ const gchar* bd_crypto_luks_status (const gchar *luks_device, GError **error); typedef enum { BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_NONE = 0, BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_PASSPHRASE, BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYFILE, BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYRING, BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_VOLUME_KEY, } BDCryptoKeyslotContextType; struct _BDCryptoKeyslotContext { BDCryptoKeyslotContextType type; union { struct { guint8 *pass_data; gsize data_len; } passphrase; struct { gchar *keyfile; guint64 keyfile_offset; gsize key_size; } keyfile; struct { gchar *key_desc; } keyring; struct { guint8 *volume_key; gsize volume_key_size; } volume_key; } u; }; typedef struct _BDCryptoKeyslotContext BDCryptoKeyslotContext; #define BD_CRYPTO_KEYSLOT_CONTEXT (bd_crypto_keyslot_context_get_type ()) GType bd_crypto_keyslot_context_get_type(); /** * bd_crypto_keyslot_context_free: (skip) * @context: (nullable): %BDCryptoKeyslotContext to free * * Frees @context. */ void bd_crypto_keyslot_context_free (BDCryptoKeyslotContext *context) { if (context == NULL) return; if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_PASSPHRASE) g_free (context->u.passphrase.pass_data); else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYFILE) g_free (context->u.keyfile.keyfile); else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYRING) g_free (context->u.keyring.key_desc); else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_VOLUME_KEY) g_free (context->u.volume_key.volume_key); g_free (context); } /** * bd_crypto_keyslot_context_copy: (skip) * @context: (nullable): %BDCryptoKeyslotContext to copy * * Creates a new copy of @context. */ BDCryptoKeyslotContext* bd_crypto_keyslot_context_copy (BDCryptoKeyslotContext *context) { if (context == NULL) return NULL; BDCryptoKeyslotContext *new_context = g_new0 (BDCryptoKeyslotContext, 1); new_context->type = context->type; if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_PASSPHRASE) { new_context->u.passphrase.pass_data = g_new0 (guint8, context->u.passphrase.data_len); memcpy (new_context->u.passphrase.pass_data, context->u.passphrase.pass_data, context->u.passphrase.data_len); new_context->u.passphrase.data_len = context->u.passphrase.data_len; } else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYFILE) { new_context->u.keyfile.keyfile = g_strdup (context->u.keyfile.keyfile); new_context->u.keyfile.keyfile_offset = context->u.keyfile.keyfile_offset; new_context->u.keyfile.key_size = context->u.keyfile.key_size; } else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYRING) new_context->u.keyring.key_desc = g_strdup (context->u.keyring.key_desc); else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_VOLUME_KEY) { new_context->u.volume_key.volume_key = g_new0 (guint8, context->u.volume_key.volume_key_size); memcpy (new_context->u.volume_key.volume_key, context->u.volume_key.volume_key, context->u.volume_key.volume_key_size); new_context->u.volume_key.volume_key_size = context->u.volume_key.volume_key_size; } return new_context; } GType bd_crypto_keyslot_context_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDCryptoKeyslotContext", (GBoxedCopyFunc) bd_crypto_keyslot_context_copy, (GBoxedFreeFunc) bd_crypto_keyslot_context_free); } return type; } /** * bd_crypto_keyslot_context_new_passphrase: * @pass_data: (array length=data_len): a passphrase for the new context (may contain arbitrary binary data) * @data_len: length of the @pass_data buffer * @error: (out) (optional): place to store error (if any) * * Returns (transfer full): new %BDCryptoKeyslotContext initialized by passphrase or * %NULL in case of error * * Tech category: always available */ BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_passphrase (const guint8 *pass_data, gsize data_len, GError **error); /** * bd_crypto_keyslot_context_new_keyfile: * @keyfile: a key file for the new context * @keyfile_offset: number of bytes to read from @keyfile or 0 for unlimited * @key_size: number of bytes to skip at start of @keyfile * @error: (out) (optional): place to store error (if any) * * Returns (transfer full): new %BDCryptoKeyslotContext initialized by key file or * %NULL in case of error * * Tech category: always available */ BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_keyfile (const gchar *keyfile, guint64 keyfile_offset, gsize key_size, GError **error); /** * bd_crypto_keyslot_context_new_keyring: * @key_desc: kernel keyring key description * @error: (out) (optional): place to store error (if any) * * Returns (transfer full): new %BDCryptoKeyslotContext initialized by @key_desc or * %NULL in case of error * * Note: Keyslot passphrase must be stored in 'user' key type and the key has to be reachable * by process context on behalf of which this function is called. * * Tech category: always available */ BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_keyring (const gchar *key_desc, GError **error); /** * bd_crypto_keyslot_context_new_volume_key: * @volume_key: (array length=volume_key_size): a volume key for the new context (may contain arbitrary binary data) * @volume_key_size: length of the @volume_key_size buffer * @error: (out) (optional): place to store error (if any) * * Returns (transfer full): new %BDCryptoKeyslotContext initialized by volume key or * %NULL in case of error * * Tech category: always available */ BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_volume_key (const guint8 *volume_key, gsize volume_key_size, GError **error); /** * bd_crypto_luks_format: * @device: a device to format as LUKS * @cipher: (nullable): cipher specification (type-mode, e.g. "aes-xts-plain64") or %NULL to use the default * @key_size: size of the volume key in bits or 0 to use the default * @context: key slot context (passphrase/keyfile/token...) for this LUKS device * @min_entropy: minimum random data entropy (in bits) required to format @device as LUKS * @luks_version: whether to use LUKS v1 or LUKS v2 * @extra: (nullable): extra arguments for LUKS format creation * @error: (out) (optional): place to store error (if any) * * Formats the given @device as LUKS according to the other parameters given. If * @min_entropy is specified (greater than 0), the function waits for enough * entropy to be available in the random data pool (WHICH MAY POTENTIALLY TAKE * FOREVER). * * Supported @context types for this function: passphrase, key file * * Returns: whether the given @device was successfully formatted as LUKS or not * (the @error) contains the error in such cases) * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_CREATE */ gboolean bd_crypto_luks_format (const gchar *device, const gchar *cipher, guint64 key_size, BDCryptoKeyslotContext *context, guint64 min_entropy, BDCryptoLUKSVersion luks_version, BDCryptoLUKSExtra *extra,GError **error); /** * bd_crypto_luks_open: * @device: the device to open * @name: name for the LUKS device * @context: key slot context (passphrase/keyfile/token...) to open this LUKS @device * @read_only: whether to open as read-only or not (meaning read-write) * @error: (out) (optional): place to store error (if any) * * Supported @context types for this function: passphrase, key file, keyring * * Returns: whether the @device was successfully opened or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE * * Example of using %bd_crypto_luks_open with %BDCryptoKeyslotContext: * * |[ * BDCryptoKeyslotContext *context = NULL; * * context = bd_crypto_keyslot_context_new_passphrase ("passphrase", 10, NULL); * bd_crypto_luks_open ("/dev/vda1", "luks-device", context, FALSE, NULL); * ]| */ gboolean bd_crypto_luks_open (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, gboolean read_only, GError **error); /** * bd_crypto_luks_close: * @luks_device: LUKS device to close * @error: (out) (optional): place to store error (if any) * * Returns: whether the given @luks_device was successfully closed or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE */ gboolean bd_crypto_luks_close (const gchar *luks_device, GError **error); /** * bd_crypto_luks_add_key: * @device: device to add new key to * @context: key slot context (passphrase/keyfile/token...) to for this LUKS @device * @ncontext: new key slot context (passphrase/keyfile/token...) to add to this LUKS @device * @error: (out) (optional): place to store error (if any) * * Supported @context types for this function: passphrase, key file * * Returns: whether the @ncontext was successfully added to @device * or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_ADD_KEY */ gboolean bd_crypto_luks_add_key (const gchar *device, BDCryptoKeyslotContext *context, BDCryptoKeyslotContext *ncontext, GError **error); /** * bd_crypto_luks_remove_key: * @device: device to add new key to * @context: key slot context (passphrase/keyfile/token...) to remove from this LUKS @device * @error: (out) (optional): place to store error (if any) * * Supported @context types for this function: passphrase, key file * * Returns: whether the key was successfully removed or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_REMOVE_KEY */ gboolean bd_crypto_luks_remove_key (const gchar *device, BDCryptoKeyslotContext *context, GError **error); /** * bd_crypto_luks_change_key: * @device: device to change key of * @context: key slot context (passphrase/keyfile/token...) for this LUKS @device * @ncontext: new key slot context (passphrase/keyfile/token...) to add to this LUKS @device * @error: (out) (optional): place to store error (if any) * * Supported @context types for this function: passphrase, key file * * Returns: whether the key was successfully changed or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_ADD_KEY&%BD_CRYPTO_TECH_MODE_REMOVE_KEY */ gboolean bd_crypto_luks_change_key (const gchar *device, BDCryptoKeyslotContext *context, BDCryptoKeyslotContext *ncontext, GError **error); /** * bd_crypto_luks_resize: * @luks_device: opened LUKS device to resize * @size: requested size in sectors or 0 to adapt to the backing device * @context: (nullable): key slot context (passphrase/keyfile/token...) for this LUKS @device * @error: (out) (optional): place to store error (if any) * * Supported @context types for this function: passphrase, key file * * Returns: whether the @luks_device was successfully resized or not * * You need to specify either @context for LUKS 2 devices that * don't have verified key loaded in kernel. * For LUKS 1 devices you can set @context %NULL. * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_RESIZE */ gboolean bd_crypto_luks_resize (const gchar *luks_device, guint64 size, BDCryptoKeyslotContext *context, GError **error); /** * bd_crypto_luks_suspend: * @luks_device: LUKS device to suspend * @error: (out) (optional): place to store error (if any) * * Returns: whether the given @luks_device was successfully suspended or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_SUSPEND_RESUME */ gboolean bd_crypto_luks_suspend (const gchar *luks_device, GError **error); /** * bd_crypto_luks_resume: * @luks_device: LUKS device to resume * @context: (nullable): key slot context (passphrase/keyfile/token...) for @luks_device * @error: (out) (optional): place to store error (if any) * * Supported @context types for this function: passphrase, key file * * Returns: whether the given @luks_device was successfully resumed or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_SUSPEND_RESUME */ gboolean bd_crypto_luks_resume (const gchar *luks_device, BDCryptoKeyslotContext *context, GError **error); /** * bd_crypto_luks_kill_slot: * @device: device to kill slot on * @slot: keyslot to destroy * @error: (out) (optional): place to store error (if any) * * Note: This can destroy last remaining keyslot without confirmation making * the LUKS device permanently inaccessible. * * Returns: whether the given @slot was successfully destroyed or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_REMOVE_KEY */ gboolean bd_crypto_luks_kill_slot (const gchar *device, gint slot, GError **error); /** * bd_crypto_luks_header_backup: * @device: device to backup the LUKS header * @backup_file: file to save the header backup to * @error: (out) (optional): place to store error (if any) * * Returns: whether the given backup of @device was successfully written to * @backup_file or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_BACKUP_RESTORE */ gboolean bd_crypto_luks_header_backup (const gchar *device, const gchar *backup_file, GError **error); /** * bd_crypto_luks_header_restore: * @device: device to restore the LUKS header to * @backup_file: existing file with a LUKS header backup * @error: (out) (optional): place to store error (if any) * * Returns: whether the given @device LUKS header was successfully restored * from @backup_file * * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_BACKUP_RESTORE */ gboolean bd_crypto_luks_header_restore (const gchar *device, const gchar *backup_file, GError **error); /** * bd_crypto_luks_set_label: * @device: device to set label on * @label: (nullable): label to set * @subsystem: (nullable): subsystem to set * @error: (out) (optional): place to store error (if any) * * Returns: whether the given @label and @subsystem were successfully set or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_MODIFY */ gboolean bd_crypto_luks_set_label (const gchar *device, const gchar *label, const gchar *subsystem, GError **error); /** * bd_crypto_luks_set_uuid: * @device: device to set UUID on * @uuid: (nullable): UUID to set or %NULL to generate a new one * @error: (out) (optional): place to store error (if any) * * Returns: whether the given @uuid was successfully set or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_MODIFY */ gboolean bd_crypto_luks_set_uuid (const gchar *device, const gchar *uuid, GError **error); /** * bd_crypto_luks_info: * @device: a device to get information about * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the @device or %NULL in case of error * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_QUERY */ BDCryptoLUKSInfo* bd_crypto_luks_info (const gchar *device, GError **error); /** * bd_crypto_bitlk_info: * @device: a device to get information about * @error: (out) (optional): place to store error (if any) * * Returns (transfer full): information about the @device or %NULL in case of error * * Tech category: %BD_CRYPTO_TECH_BITLK-%BD_CRYPTO_TECH_MODE_QUERY */ BDCryptoBITLKInfo* bd_crypto_bitlk_info (const gchar *device, GError **error); /** * bd_crypto_integrity_info: * @device: a device to get information about * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the @device or %NULL in case of error * * Tech category: %BD_CRYPTO_TECH_INTEGRITY-%BD_CRYPTO_TECH_MODE_QUERY */ BDCryptoIntegrityInfo* bd_crypto_integrity_info (const gchar *device, GError **error); /** * bd_crypto_luks_token_info: * @device: a device to get LUKS2 token information about * @error: (out) (optional): place to store error (if any) * * Returns: (array zero-terminated=1) (transfer full): information about tokens on @device * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_QUERY */ BDCryptoLUKSTokenInfo** bd_crypto_luks_token_info (const gchar *device, GError **error); /** * bd_crypto_integrity_format: * @device: a device to format as integrity * @algorithm: integrity algorithm specification (e.g. "crc32c" or "sha256") * @wipe: whether to wipe the device after format; a device that is not initially wiped will contain invalid checksums * @context: (nullable): key slot context (passphrase/keyfile/token...) for this device * @extra: (nullable): extra arguments for integrity format creation * @error: (out) (optional): place to store error (if any) * * Formats the given @device as integrity according to the other parameters given. * * Supported @context types for this function: volume key * * Returns: whether the given @device was successfully formatted as integrity or not * (the @error) contains the error in such cases) * * Tech category: %BD_CRYPTO_TECH_INTEGRITY-%BD_CRYPTO_TECH_MODE_CREATE */ gboolean bd_crypto_integrity_format (const gchar *device, const gchar *algorithm, gboolean wipe, BDCryptoKeyslotContext *context, BDCryptoIntegrityExtra *extra, GError **error); /** * bd_crypto_integrity_open: * @device: integrity device to open * @name: name for the opened @device * @algorithm: integrity algorithm specification (e.g. "crc32c" or "sha256") * @context: (nullable): key slot context (passphrase/keyfile/token...) for this device * @flags: flags for the integrity device activation * @extra: (nullable): extra arguments for integrity open * @error: (out) (optional): place to store error (if any) * * Supported @context types for this function: volume key * * Returns: whether the @device was successfully opened or not * * Tech category: %BD_CRYPTO_TECH_INTEGRITY-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE */ gboolean bd_crypto_integrity_open (const gchar *device, const gchar *name, const gchar *algorithm, BDCryptoKeyslotContext *context, BDCryptoIntegrityOpenFlags flags, BDCryptoIntegrityExtra *extra, GError **error); /** * bd_crypto_integrity_close: * @integrity_device: integrity device to close * @error: (out) (optional): place to store error (if any) * * Returns: whether the given @integrity_device was successfully closed or not * * Tech category: %BD_CRYPTO_TECH_INTEGRITY-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE */ gboolean bd_crypto_integrity_close (const gchar *integrity_device, GError **error); /** * bd_crypto_keyring_add_key: * @key_desc: kernel keyring key description * @key_data: (array length=data_len): a key to add to kernel keyring (may contain arbitrary binary data) * @data_len: length of the @key_data buffer * @error: (out) (optional): place to store error (if any) * * * Returns: whether the given key was successfully saved to kernel keyring or not * * Tech category: %BD_CRYPTO_TECH_KEYRING-%BD_CRYPTO_TECH_MODE_ADD_KEY */ gboolean bd_crypto_keyring_add_key (const gchar *key_desc, const guint8 *key_data, gsize data_len, GError **error); /** * bd_crypto_device_seems_encrypted: * @device: the queried device * @error: (out) (optional): place to store error (if any) * * Determines whether a block device seems to be encrypted. * * TCRYPT volumes are not easily identifiable, because they have no * cleartext header, but are completely encrypted. This function is * used to determine whether a block device is a candidate for being * TCRYPT encrypted. * * To achieve this, we calculate the chi square value of the first * 512 Bytes and treat devices with a chi square value between 136 * and 426 as candidates for being encrypted. * For the reasoning, see: https://tails.boum.org/blueprint/veracrypt/ * * Returns: %TRUE if the given @device seems to be encrypted or %FALSE if not or * failed to determine (the @error) is populated with the error in such * cases) * * Tech category: %BD_CRYPTO_TECH_TRUECRYPT-%BD_CRYPTO_TECH_MODE_QUERY */ gboolean bd_crypto_device_seems_encrypted (const gchar *device, GError **error); /** * bd_crypto_tc_open: * @device: the device to open * @name: name for the TrueCrypt/VeraCrypt device * @context: (nullable): passphrase key slot context for this TrueCrypt/VeraCrypt volume * @read_only: whether to open as read-only or not (meaning read-write) * @keyfiles: (nullable) (array zero-terminated=1): paths to the keyfiles for the TrueCrypt/VeraCrypt volume * @hidden: whether a hidden volume inside the volume should be opened * @system: whether to try opening as an encrypted system (with boot loader) * @veracrypt: whether to try VeraCrypt modes (TrueCrypt modes are tried anyway) * @veracrypt_pim: VeraCrypt PIM value (only used if @veracrypt is %TRUE) * @error: (out) (optional): place to store error (if any) * * Supported @context types for this function: passphrase * * Returns: whether the @device was successfully opened or not * * Tech category: %BD_CRYPTO_TECH_TRUECRYPT-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE */ gboolean bd_crypto_tc_open (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, const gchar **keyfiles, gboolean hidden, gboolean system, gboolean veracrypt, guint32 veracrypt_pim, gboolean read_only, GError **error); /** * bd_crypto_tc_close: * @tc_device: TrueCrypt/VeraCrypt device to close * @error: (out) (optional): place to store error (if any) * * Returns: whether the given @tc_device was successfully closed or not * * Tech category: %BD_CRYPTO_TECH_TRUECRYPT-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE */ gboolean bd_crypto_tc_close (const gchar *tc_device, GError **error); /** * bd_crypto_escrow_device: * @device: path of the device to create escrow data for * @passphrase: passphrase used for the device * @cert_data: (array zero-terminated=1) (element-type gchar): certificate data to use for escrow * @directory: directory to put escrow data into * @backup_passphrase: (nullable): backup passphrase for the device or %NULL * @error: (out) (optional): place to store error (if any) * * Returns: whether the escrow data was successfully created for @device or not * * Tech category: %BD_CRYPTO_TECH_ESCROW-%BD_CRYPTO_TECH_MODE_CREATE */ gboolean bd_crypto_escrow_device (const gchar *device, const gchar *passphrase, const gchar *cert_data, const gchar *directory, const gchar *backup_passphrase, GError **error); /** * bd_crypto_bitlk_open: * @device: the device to open * @name: name for the BITLK device * @context: key slot context (passphrase/keyfile/token...) for this BITLK device * @read_only: whether to open as read-only or not (meaning read-write) * @error: (out) (optional): place to store error (if any) * * Supported @context types for this function: passphrase, key file * * Returns: whether the @device was successfully opened or not * * Tech category: %BD_CRYPTO_TECH_BITLK-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE */ gboolean bd_crypto_bitlk_open (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, gboolean read_only, GError **error); /** * bd_crypto_bitlk_close: * @bitlk_device: BITLK device to close * @error: (out) (optional): place to store error (if any) * * Returns: whether the given @bitlk_device was successfully closed or not * * Tech category: %BD_CRYPTO_TECH_BITLK-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE */ gboolean bd_crypto_bitlk_close (const gchar *bitlk_device, GError **error); /** * bd_crypto_fvault2_open: * @device: the device to open * @name: name for the FVAULT2 device * @context: key slot context (passphrase/keyfile/token...) for this FVAULT2 volume * @read_only: whether to open as read-only or not (meaning read-write) * @error: (out) (optional): place to store error (if any) * * Supported @context types for this function: passphrase, key file * * Returns: whether the @device was successfully opened or not * * Tech category: %BD_CRYPTO_TECH_FVAULT2-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE */ gboolean bd_crypto_fvault2_open (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, gboolean read_only, GError **error); /** * bd_crypto_fvault2_close: * @fvault2_device: FVAULT2 device to close * @error: (out) (optional): place to store error (if any) * * Returns: whether the given @fvault2_device was successfully closed or not * * Tech category: %BD_CRYPTO_TECH_FVAULT2-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE */ gboolean bd_crypto_fvault2_close (const gchar *fvault2_device, GError **error); #endif /* BD_CRYPTO_API */ libblockdev-3.1.1-1/src/lib/plugin_apis/dm.api000066400000000000000000000072321460051510300210730ustar00rootroot00000000000000#include #include #ifndef BD_DM_API #define BD_DM_API GQuark bd_dm_error_quark (void) { return g_quark_from_static_string ("g-bd-dm-error-quark"); } #define BD_DM_ERROR bd_dm_error_quark () typedef enum { BD_DM_ERROR_TECH_UNAVAIL, BD_DM_ERROR_SYS, BD_DM_ERROR_NOT_ROOT, BD_DM_ERROR_TASK, BD_DM_ERROR_RAID_FAIL, BD_DM_ERROR_RAID_NO_DEVS, BD_DM_ERROR_RAID_NO_EXIST, } BDDMError; typedef enum { BD_DM_TECH_MAP = 0, } BDDMTech; typedef enum { BD_DM_TECH_MODE_CREATE_ACTIVATE = 1 << 0, BD_DM_TECH_MODE_REMOVE_DEACTIVATE = 1 << 1, BD_DM_TECH_MODE_QUERY = 1 << 2, } BDDMTechMode; /** * bd_dm_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDDMTechMode) for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_dm_is_tech_avail (BDDMTech tech, guint64 mode, GError **error); /** * bd_dm_create_linear: * @map_name: name of the map * @device: device to create map for * @length: length of the mapping in sectors * @uuid: (nullable): UUID for the new dev mapper device or %NULL if not specified * @error: (out) (optional): place to store error (if any) * * Returns: whether the new linear mapping @map_name was successfully created * for the @device or not * * Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_CREATE_ACTIVATE */ gboolean bd_dm_create_linear (const gchar *map_name, const gchar *device, guint64 length, const gchar *uuid, GError **error); /** * bd_dm_remove: * @map_name: name of the map to remove * @error: (out) (optional): place to store error (if any) * * Returns: whether the @map_name map was successfully removed or not * * Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_REMOVE_DEACTIVATE */ gboolean bd_dm_remove (const gchar *map_name, GError **error); /** * bd_dm_name_from_node: * @dm_node: name of the DM node (e.g. "dm-0") * @error: (out) (optional): place to store error (if any) * * Returns: map name of the map providing the @dm_node device or %NULL * (@error) contains the error in such cases * * Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_QUERY */ gchar* bd_dm_name_from_node (const gchar *dm_node, GError **error); /** * bd_dm_node_from_name: * @map_name: name of the queried DM map * @error: (out) (optional): place to store error (if any) * * Returns: DM node name for the @map_name map or %NULL (@error) contains * the error in such cases * * Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_QUERY */ gchar* bd_dm_node_from_name (const gchar *map_name, GError **error); /** * bd_dm_get_subsystem_from_name: * @device_name: name of the device * @error: (out) (optional): place to store error (if any) * * Returns: subsystem of the given device * * Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_QUERY */ gchar* bd_dm_get_subsystem_from_name (const gchar *device_name, GError **error); /** * bd_dm_map_exists: * @map_name: name of the queried map * @live_only: whether to go through the live maps only or not * @active_only: whether to ignore suspended maps or not * @error: (out) (optional): place to store error (if any) * * Returns: whether the given @map_name exists (and is live if @live_only is * %TRUE (and is active if @active_only is %TRUE)). * * Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_QUERY */ gboolean bd_dm_map_exists (const gchar *map_name, gboolean live_only, gboolean active_only, GError **error); #endif /* BD_DM_API */ libblockdev-3.1.1-1/src/lib/plugin_apis/fs.api000066400000000000000000002713531460051510300211120ustar00rootroot00000000000000#include #include #include #ifndef BD_FS_API #define BD_FS_API GQuark bd_fs_error_quark (void) { return g_quark_from_static_string ("g-bd-fs-error-quark"); } #define BD_FS_ERROR bd_fs_error_quark () typedef enum { BD_FS_ERROR_TECH_UNAVAIL, BD_FS_ERROR_INVAL, BD_FS_ERROR_PARSE, BD_FS_ERROR_FAIL, BD_FS_ERROR_NOFS, BD_FS_ERROR_PIPE, BD_FS_ERROR_UNMOUNT_FAIL, BD_FS_ERROR_NOT_SUPPORTED, BD_FS_ERROR_NOT_MOUNTED, BD_FS_ERROR_AUTH, BD_FS_ERROR_LABEL_INVALID, BD_FS_ERROR_UUID_INVALID, BD_FS_ERROR_UNKNOWN_FS, } BDFSError; /** * BDFSMkfsOptions: * @label: label of the filesystem * @uuid: uuid of the filesystem * @dry_run: whether to run mkfs in dry run mode (no changes written to the device) * @no_discard: whether to avoid discarding blocks at mkfs time * @force: whether to run mkfs with the `--force` (or similar) option, the behaviour of this * option depends on the filesystem, but in general it allows overwriting other * preexisting formats detected on the device * @no_pt: whether to disable (protective) partition table creation during mkfs * @reserve: reserve for future expansion */ typedef struct BDFSMkfsOptions { const gchar *label; const gchar *uuid; gboolean dry_run; gboolean no_discard; gboolean force; gboolean no_pt; guint8 reserve[32]; } BDFSMkfsOptions; /** * bd_fs_mkfs_options_copy: (skip) * @data: (nullable): %BDFSMkfsOptions to copy * * Creates a new copy of @data. */ BDFSMkfsOptions* bd_fs_mkfs_options_copy (BDFSMkfsOptions *data) { if (data == NULL) return NULL; BDFSMkfsOptions *ret = g_new0 (BDFSMkfsOptions, 1); ret->label = data->label; ret->uuid = data->uuid; ret->dry_run = data->dry_run; ret->no_discard = data->no_discard; ret->force = data->force; ret->no_pt = data->no_pt; return ret; } /** * bd_fs_mkfs_options_free: (skip) * @data: (nullable): %BDFSMkfsOptions to free * * Frees @data. */ void bd_fs_mkfs_options_free (BDFSMkfsOptions *data) { if (data == NULL) return; g_free (data); } #define BD_FS_TYPE_MKFS_OPTIONS (bd_fs_mkfs_options_get_type ()) GType bd_fs_mkfs_options_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSMkfsOptions", (GBoxedCopyFunc) bd_fs_mkfs_options_copy, (GBoxedFreeFunc) bd_fs_mkfs_options_free); } return type; } #define BD_FS_TYPE_EXT2_INFO (bd_fs_ext2_info_get_type ()) GType bd_fs_ext2_info_get_type(); #define BD_FS_TYPE_EXT3_INFO (bd_fs_ext3_info_get_type ()) GType bd_fs_ext3_info_get_type(); #define BD_FS_TYPE_EXT4_INFO (bd_fs_ext4_info_get_type ()) GType bd_fs_ext4_info_get_type(); /** * BDFSExtInfo: * @label: label of the filesystem * @uuid: uuid of the filesystem * @state: state of the filesystem (e.g. "clean") * @block_size: block size used by the filesystem * @block_count: number of blocks in the filesystem * @free_blocks: number of free blocks in the filesystem */ typedef struct BDFSExtInfo { gchar *label; gchar *uuid; gchar *state; guint64 block_size; guint64 block_count; guint64 free_blocks; } BDFSExtInfo; typedef struct BDFSExtInfo BDFSExt4Info; typedef struct BDFSExtInfo BDFSExt3Info; typedef struct BDFSExtInfo BDFSExt2Info; /** * bd_fs_ext2_info_copy: (skip) * @data: (nullable): %BDFSExt2Info to copy * * Creates a new copy of @data. */ BDFSExt2Info* bd_fs_ext2_info_copy (BDFSExt2Info *data) { if (data == NULL) return NULL; BDFSExt2Info *ret = g_new0 (BDFSExt2Info, 1); ret->label = g_strdup (data->label); ret->uuid = g_strdup (data->uuid); ret->state = g_strdup (data->state); ret->block_size = data->block_size; ret->block_count = data->block_count; ret->free_blocks = data->free_blocks; return ret; } /** * bd_fs_ext3_info_copy: (skip) * @data: (nullable): %BDFSExt3Info to copy * * Creates a new copy of @data. */ BDFSExt3Info* bd_fs_ext3_info_copy (BDFSExt3Info *data) { return (BDFSExt3Info*) bd_fs_ext2_info_copy (data); } /** * bd_fs_ext4_info_copy: (skip) * @data: (nullable): %BDFSExt4Info to copy * * Creates a new copy of @data. */ BDFSExt4Info* bd_fs_ext4_info_copy (BDFSExt4Info *data) { return (BDFSExt4Info*) bd_fs_ext2_info_copy (data); }; /** * bd_fs_ext2_info_free: (skip) * @data: (nullable): %BDFSExt2Info to free * * Frees @data. */ void bd_fs_ext2_info_free (BDFSExt2Info *data) { if (data == NULL) return; g_free (data->label); g_free (data->uuid); g_free (data->state); g_free (data); } /** * bd_fs_ext3_info_free: (skip) * @data: (nullable): %BDFSExt3Info to free * * Frees @data. */ void bd_fs_ext3_info_free (BDFSExt3Info *data) { bd_fs_ext2_info_free ((BDFSExt2Info*) data); } /** * bd_fs_ext4_info_free: (skip) * @data: (nullable): %BDFSExt4Info to free * * Frees @data. */ void bd_fs_ext4_info_free (BDFSExt4Info *data) { bd_fs_ext2_info_free ((BDFSExt2Info*) data); } GType bd_fs_ext2_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSExt2Info", (GBoxedCopyFunc) bd_fs_ext2_info_copy, (GBoxedFreeFunc) bd_fs_ext2_info_free); } return type; } GType bd_fs_ext3_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSExt3Info", (GBoxedCopyFunc) bd_fs_ext3_info_copy, (GBoxedFreeFunc) bd_fs_ext3_info_free); } return type; } GType bd_fs_ext4_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSExt4Info", (GBoxedCopyFunc) bd_fs_ext4_info_copy, (GBoxedFreeFunc) bd_fs_ext4_info_free); } return type; } #define BD_FS_TYPE_XFS_INFO (bd_fs_xfs_info_get_type ()) GType bd_fs_xfs_info_get_type(); /** * BDFSXfsInfo: * @label: label of the filesystem * @uuid: uuid of the filesystem * @block_size: block size used by the filesystem * @block_count: number of blocks in the filesystem */ typedef struct BDFSXfsInfo { gchar *label; gchar *uuid; guint64 block_size; guint64 block_count; } BDFSXfsInfo; /** * bd_fs_xfs_info_copy: (skip) * @data: (nullable): %BDFSXfsInfo to copy * * Creates a new copy of @data. */ BDFSXfsInfo* bd_fs_xfs_info_copy (BDFSXfsInfo *data) { if (data == NULL) return NULL; BDFSXfsInfo *ret = g_new0 (BDFSXfsInfo, 1); ret->label = g_strdup (data->label); ret->uuid = g_strdup (data->uuid); ret->block_size = data->block_size; ret->block_count = data->block_count; return ret; } /** * bd_fs_xfs_info_free: (skip) * @data: (nullable): %BDFSXfsInfo to free * * Frees @data. */ void bd_fs_xfs_info_free (BDFSXfsInfo *data) { if (data == NULL) return; g_free (data->label); g_free (data->uuid); g_free (data); } GType bd_fs_xfs_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSXfsInfo", (GBoxedCopyFunc) bd_fs_xfs_info_copy, (GBoxedFreeFunc) bd_fs_xfs_info_free); } return type; } #define BD_FS_TYPE_VFAT_INFO (bd_fs_vfat_info_get_type ()) GType bd_fs_vfat_info_get_type(); /** * BDFSVfatInfo: * @label: label of the filesystem * @uuid: uuid of the filesystem * @cluster_size: cluster size used by the filesystem * @cluster_count: number of clusters in the filesystem * @free_cluster_count: number of free clusters in the filesystem */ typedef struct BDFSVfatInfo { gchar *label; gchar *uuid; guint64 cluster_size; guint64 cluster_count; guint64 free_cluster_count; } BDFSVfatInfo; /** * bd_fs_vfat_info_copy: (skip) * @data: (nullable): %BDFSVfatInfo to copy * * Creates a new copy of @data. */ BDFSVfatInfo* bd_fs_vfat_info_copy (BDFSVfatInfo *data) { if (data == NULL) return NULL; BDFSVfatInfo *ret = g_new0 (BDFSVfatInfo, 1); ret->label = g_strdup (data->label); ret->uuid = g_strdup (data->uuid); ret->cluster_size = data->cluster_size; ret->cluster_count = data->cluster_count; return ret; } /** * bd_fs_vfat_info_free: (skip) * @data: (nullable): %BDFSVfatInfo to free * * Frees @data. */ void bd_fs_vfat_info_free (BDFSVfatInfo *data) { if (data == NULL) return; g_free (data->label); g_free (data->uuid); g_free (data); } GType bd_fs_vfat_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSVfatInfo", (GBoxedCopyFunc) bd_fs_vfat_info_copy, (GBoxedFreeFunc) bd_fs_vfat_info_free); } return type; } /** * BDFSNtfsInfo: * @label: label of the filesystem * @uuid: uuid of the filesystem * @size: size of the filesystem in bytes * @free_space: number of free space in the filesystem in bytes */ typedef struct BDFSNtfsInfo { gchar *label; gchar *uuid; guint64 size; guint64 free_space; } BDFSNtfsInfo; /** * bd_fs_ntfs_info_copy: (skip) * @data: (nullable): %BDFSNtfsInfo to copy * * Creates a new copy of @data. */ BDFSNtfsInfo* bd_fs_ntfs_info_copy (BDFSNtfsInfo *data) { if (data == NULL) return NULL; BDFSNtfsInfo *ret = g_new0 (BDFSNtfsInfo, 1); ret->label = g_strdup (data->label); ret->uuid = g_strdup (data->uuid); ret->size = data->size; ret->free_space = data->free_space; return ret; } /** * bd_fs_ntfs_info_free: (skip) * @data: (nullable): %BDFSNtfsInfo to free * * Frees @data. */ void bd_fs_ntfs_info_free (BDFSNtfsInfo *data) { if (data == NULL) return; g_free (data->label); g_free (data->uuid); g_free (data); } GType bd_fs_ntfs_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSNtfsInfo", (GBoxedCopyFunc) bd_fs_ntfs_info_copy, (GBoxedFreeFunc) bd_fs_ntfs_info_free); } return type; } #define BD_FS_TYPE_F2FS_INFO (bd_fs_f2fs_info_get_type ()) GType bd_fs_f2fs_info_get_type(); /** * BDFSF2FSInfo: * @label: label of the filesystem * @uuid: uuid of the filesystem * @sector_size: sector size used by the filesystem * @sector_count: number of sectors in the filesystem * @features: features enabled for this filesystem, see #BDFSF2FSFeature */ typedef struct BDFSF2FSInfo { gchar *label; gchar *uuid; guint64 sector_size; guint64 sector_count; guint64 features; } BDFSF2FSInfo; /** * bd_fs_f2fs_info_copy: (skip) * @data: (nullable): %BDFSF2FSInfo to copy * * Creates a new copy of @data. */ BDFSF2FSInfo* bd_fs_f2fs_info_copy (BDFSF2FSInfo *data) { if (data == NULL) return NULL; BDFSF2FSInfo *ret = g_new0 (BDFSF2FSInfo, 1); ret->label = g_strdup (data->label); ret->uuid = g_strdup (data->uuid); ret->sector_size = data->sector_size; ret->sector_count = data->sector_count; ret->features = data->features; return ret; } /** * bd_fs_f2fs_info_free: (skip) * @data: (nullable): %BDFSF2FSInfo to free * * Frees @data. */ void bd_fs_f2fs_info_free (BDFSF2FSInfo *data) { if (data == NULL) return; g_free (data->label); g_free (data->uuid); g_free (data); } GType bd_fs_f2fs_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSF2FSInfo", (GBoxedCopyFunc) bd_fs_f2fs_info_copy, (GBoxedFreeFunc) bd_fs_f2fs_info_free); } return type; } typedef enum { BD_FS_F2FS_FEATURE_ENCRYPT = 1 << 0, BD_FS_F2FS_FEATURE_BLKZONED = 1 << 1, BD_FS_F2FS_FEATURE_ATOMIC_WRITE = 1 << 2, BD_FS_F2FS_FEATURE_EXTRA_ATTR = 1 << 3, BD_FS_F2FS_FEATURE_PRJQUOTA = 1 << 4, BD_FS_F2FS_FEATURE_INODE_CHKSUM = 1 << 5, BD_FS_F2FS_FEATURE_FLEXIBLE_INLINE_XATTR = 1 << 6, BD_FS_F2FS_FEATURE_QUOTA_INO = 1 << 7, BD_FS_F2FS_FEATURE_INODE_CRTIME = 1 << 8, BD_FS_F2FS_FEATURE_LOST_FOUND = 1 << 9, BD_FS_F2FS_FEATURE_VERITY = 1 << 10, BD_FS_F2FS_FEATURE_SB_CHKSUM = 1 << 11, } BDFSF2FSFeature; typedef enum { BD_FS_TECH_GENERIC = 0, BD_FS_TECH_MOUNT, BD_FS_TECH_EXT2, BD_FS_TECH_EXT3, BD_FS_TECH_EXT4, BD_FS_TECH_XFS, BD_FS_TECH_VFAT, BD_FS_TECH_NTFS, BD_FS_TECH_F2FS, BD_FS_TECH_NILFS2, BD_FS_TECH_EXFAT, BD_FS_TECH_BTRFS, BD_FS_TECH_UDF, } BDFSTech; typedef enum { BD_FS_TECH_MODE_MKFS = 1 << 0, BD_FS_TECH_MODE_WIPE = 1 << 1, BD_FS_TECH_MODE_CHECK = 1 << 2, BD_FS_TECH_MODE_REPAIR = 1 << 3, BD_FS_TECH_MODE_SET_LABEL = 1 << 4, BD_FS_TECH_MODE_QUERY = 1 << 5, BD_FS_TECH_MODE_RESIZE = 1 << 6, BD_FS_TECH_MODE_SET_UUID = 1 << 7, } BDFSTechMode; #define BD_FS_TYPE_NILFS_INFO (bd_fs_nilfs2_info_get_type ()) GType bd_fs_nilfs2_info_get_type(); /** * BDFSNILFS2Info: * @label: label of the filesystem * @uuid: uuid of the filesystem * @block_size: block size used by the filesystem * @size: size of the filesystem * @free_blocks: number of free blocks in the filesystem */ typedef struct BDFSNILFS2Info { gchar *label; gchar *uuid; guint64 size; guint64 block_size; guint64 free_blocks; } BDFSNILFS2Info; /** * bd_fs_nilfs2_info_copy: (skip) * @data: (nullable): %BDFSNILFS2Info to copy * * Creates a new copy of @data. */ BDFSNILFS2Info* bd_fs_nilfs2_info_copy (BDFSNILFS2Info *data) { if (data == NULL) return NULL; BDFSNILFS2Info *ret = g_new0 (BDFSNILFS2Info, 1); ret->label = g_strdup (data->label); ret->uuid = g_strdup (data->uuid); ret->size = data->size; ret->block_size = data->block_size; ret->free_blocks = data->free_blocks; return ret; } /** * bd_fs_nilfs2_info_free: (skip) * @data: (nullable): %BDFSNILFS2Info to free * * Frees @data. */ void bd_fs_nilfs2_info_free (BDFSNILFS2Info *data) { if (data == NULL) return; g_free (data->label); g_free (data->uuid); g_free (data); } GType bd_fs_nilfs2_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSNILFS2Info", (GBoxedCopyFunc) bd_fs_nilfs2_info_copy, (GBoxedFreeFunc) bd_fs_nilfs2_info_free); } return type; } #define BD_FS_TYPE_EXFAT_INFO (bd_fs_exfat_info_get_type ()) GType bd_fs_exfat_info_get_type(); /** * BDFSExfatInfo: * @label: label of the filesystem * @uuid: uuid of the filesystem * @sector_size: sector size used by the filesystem * @sector_count: number of sectors in the filesystem * @cluster_count: number of clusters in the filesystem */ typedef struct BDFSExfatInfo { gchar *label; gchar *uuid; guint64 sector_size; guint64 sector_count; guint64 cluster_count; } BDFSExfatInfo; /** * bd_fs_exfat_info_free: (skip) * @data: (nullable): %BDFSExfatInfo to free * * Frees @data. */ void bd_fs_exfat_info_free (BDFSExfatInfo *data) { if (data == NULL) return; g_free (data->label); g_free (data->uuid); g_free (data); } /** * bd_fs_exfat_info_copy: (skip) * @data: (nullable): %BDFSExfatInfo to copy * * Creates a new copy of @data. */ BDFSExfatInfo* bd_fs_exfat_info_copy (BDFSExfatInfo *data) { if (data == NULL) return NULL; BDFSExfatInfo *ret = g_new0 (BDFSExfatInfo, 1); ret->label = g_strdup (data->label); ret->uuid = g_strdup (data->uuid); ret->sector_size = data->sector_size; ret->sector_count = data->sector_count; ret->cluster_count = data->cluster_count; return ret; } GType bd_fs_exfat_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSExfatInfo", (GBoxedCopyFunc) bd_fs_exfat_info_copy, (GBoxedFreeFunc) bd_fs_exfat_info_free); } return type; } /** * BDFSBtrfsInfo: * @label: label of the filesystem * @uuid: uuid of the filesystem * @size: size of the filesystem in bytes * @free_space: free space on the filesystem in bytes */ typedef struct BDFSBtrfsInfo { gchar *label; gchar *uuid; guint64 size; guint64 free_space; } BDFSBtrfsInfo; /** * bd_fs_btrfs_info_copy: (skip) * @data: (nullable): %BDFSBtrfsInfo to copy * * Creates a new copy of @data. */ BDFSBtrfsInfo* bd_fs_btrfs_info_copy (BDFSBtrfsInfo *data) { if (data == NULL) return NULL; BDFSBtrfsInfo *ret = g_new0 (BDFSBtrfsInfo, 1); ret->label = g_strdup (data->label); ret->uuid = g_strdup (data->uuid); ret->size = data->size; ret->free_space = data->free_space; return ret; } /** * bd_fs_btrfs_info_free: (skip) * @data: (nullable): %BDFSBtrfsInfo to free * * Frees @data. */ void bd_fs_btrfs_info_free (BDFSBtrfsInfo *data) { if (data == NULL) return; g_free (data->label); g_free (data->uuid); g_free (data); } GType bd_fs_btrfs_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSBtrfsInfo", (GBoxedCopyFunc) bd_fs_btrfs_info_copy, (GBoxedFreeFunc) bd_fs_btrfs_info_free); } return type; } /** * BDFSUdfInfo: * @label: label of the filesystem * @uuid: uuid of the filesystem * @revision: UDF revision * @lvid: Logical Volume Identifier (most UDF implementations use this identifier as a disk label) * @vid: Volume Identifier * @block_size: block size used by the filesystem * @block_count: number of blocks in the filesystem * @free_blocks: number of free blocks in the filesystem */ typedef struct BDFSUdfInfo { gchar *label; gchar *uuid; gchar *revision; gchar *lvid; gchar *vid; guint64 block_size; guint64 block_count; guint64 free_blocks; } BDFSUdfInfo; /** * bd_fs_udf_info_free: (skip) * @data: (nullable): %BDFSUdfInfo to free * * Frees @data. */ void bd_fs_udf_info_free (BDFSUdfInfo *data) { if (data == NULL) return; g_free (data->label); g_free (data->uuid); g_free (data->revision); g_free (data->lvid); g_free (data->vid); g_free (data); } /** * bd_fs_udf_info_copy: (skip) * @data: (nullable): %BDFSUdfInfo to copy * * Creates a new copy of @data. */ BDFSUdfInfo* bd_fs_udf_info_copy (BDFSUdfInfo *data) { if (data == NULL) return NULL; BDFSUdfInfo *ret = g_new0 (BDFSUdfInfo, 1); ret->label = g_strdup (data->label); ret->uuid = g_strdup (data->uuid); ret->revision = g_strdup (data->revision); ret->lvid = g_strdup (data->lvid); ret->vid = g_strdup (data->vid); ret->block_size = data->block_size; ret->block_count = data->block_count; ret->free_blocks = data->free_blocks; return ret; } GType bd_fs_udf_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSUdfInfo", (GBoxedCopyFunc) bd_fs_udf_info_copy, (GBoxedFreeFunc) bd_fs_udf_info_free); } return type; } /** * bd_fs_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDFSTechMode) for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_fs_is_tech_avail (BDFSTech tech, guint64 mode, GError **error); /** * bd_fs_supported_filesystems: * @error: (out) (optional): currently unused * * Returns: (transfer container) (array zero-terminated=1): list of filesystems supported by this plugin * * Note: This returns filesystems supported by libblockdev, but not necessarily * by the systems this is running on, for this information you need to * run one of the `bd_fs_can_` functions. * * Tech category: always available */ const gchar** bd_fs_supported_filesystems (GError **error); /** * bd_fs_wipe: * @device: the device to wipe signatures from * @all: whether to wipe all (%TRUE) signatures or just the first (%FALSE) one * @force: whether to wipe signatures on a mounted @device * @error: (out) (optional): place to store error (if any) * * Returns: whether signatures were successfully wiped on @device or not * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_WIPE */ gboolean bd_fs_wipe (const gchar *device, gboolean all, gboolean force, GError **error); /** * bd_fs_clean: * @device: the device to clean * @force: whether to wipe signatures on a mounted @device * @error: (out) (optional): place to store error (if any) * * Clean all signatures from @device. * Difference between this and bd_fs_wipe() is that this function doesn't * return error if @device is already empty. This will also always remove * all signatures from @device, not only the first one. * * Returns: whether @device was successfully cleaned or not * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_WIPE */ gboolean bd_fs_clean (const gchar *device, gboolean force, GError **error); /** * bd_fs_get_fstype: * @device: the device to probe * @error: (out) (optional): place to store error (if any) * * Get first signature on @device as a string. * * Returns: (transfer full): type of filesystem found on @device, %NULL in case * no signature has been detected or in case of error * (@error is set in this case) * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ gchar* bd_fs_get_fstype (const gchar *device, GError **error); /** * bd_fs_freeze: * @mountpoint: mountpoint of the device (filesystem) to freeze * @error: (out) (optional): place to store error (if any) * * Freezes filesystem mounted on @mountpoint. The filesystem must * support freezing. * * Returns: whether @mountpoint was successfully freezed or not * */ gboolean bd_fs_freeze (const gchar *mountpoint, GError **error); /** * bd_fs_unfreeze: * @mountpoint: mountpoint of the device (filesystem) to un-freeze * @error: (out) (optional): place to store error (if any) * * Un-freezes filesystem mounted on @mountpoint. The filesystem must * support freezing. * * Returns: whether @mountpoint was successfully unfreezed or not * */ gboolean bd_fs_unfreeze (const gchar *mountpoint, GError **error); /** * bd_fs_unmount: * @spec: mount point or device to unmount * @lazy: enable/disable lazy unmount * @force: enable/disable force unmount * @extra: (nullable) (array zero-terminated=1): extra options for the unmount; * currently only 'run_as_uid' * and 'run_as_gid' are supported; * value must be a valid non zero * uid (gid), if you specify one of * these, the function will run in * a child process with real user * @error: (out) (optional): place to store error (if any) * * Returns: whether @spec was successfully unmounted or not * * Tech category: %BD_FS_TECH_MOUNT (no mode, ignored) */ gboolean bd_fs_unmount (const gchar *spec, gboolean lazy, gboolean force, const BDExtraArg **extra, GError **error); /** * bd_fs_mount: * @device: (nullable): device to mount, if not specified @mountpoint entry * from fstab will be used * @mountpoint: (nullable): mountpoint for @device, if not specified @device * entry from fstab will be used * @fstype: (nullable): filesystem type * @options: (nullable): comma delimited options for mount * @extra: (nullable) (array zero-terminated=1): extra options for the mount; * currently only 'run_as_uid' * and 'run_as_gid' are supported; * value must be a valid non zero * uid (gid), if you specify one of * these, the function will run in * a child process with real user * @error: (out) (optional): place to store error (if any) * * Returns: whether @device (or @mountpoint) was successfully mounted or not * * Tech category: %BD_FS_TECH_MOUNT (no mode, ignored) */ gboolean bd_fs_mount (const gchar *device, const gchar *mountpoint, const gchar *fstype, const gchar *options, const BDExtraArg **extra, GError **error); /** * bd_fs_get_mountpoint: * @device: device to find mountpoint for * @error: (out) (optional): place to store error (if any) * * Get mountpoint for @device. If @device is mounted multiple times only * one mountpoint will be returned. * * Returns: (transfer full): mountpoint for @device, %NULL in case device is * not mounted or in case of an error (@error is set * in this case) * * Tech category: %BD_FS_TECH_MOUNT (no mode, ignored) */ gchar* bd_fs_get_mountpoint (const gchar *device, GError **error); /** * bd_fs_is_mountpoint: * @path: path (folder) to check * @error: (out) (optional): place to store error (if any) * * Returns: whether @path is a mountpoint or not * * Tech category: %BD_FS_TECH_MOUNT (no mode, ignored) */ gboolean bd_fs_is_mountpoint (const gchar *path, GError **error); /** * bd_fs_resize: * @device: the device the file system of which to resize * @new_size: new requested size for the file system (if 0, the file system is * adapted to the underlying block device) * @fstype: (nullable): the filesystem type on @device or %NULL to detect * @error: (out) (optional): place to store error (if any) * * Resize filesystem on @device. This calls other fs resize functions from this * plugin based on provides or detected filesystem (e.g. bd_fs_xfs_resize for XFS). * This function will return an error for unknown/unsupported filesystems. * * Note: This function will mount @device for filesystems that can be resized only * when mounted (like XFS or Btrfs). * * Returns: whether the file system on @device was successfully resized or not * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_RESIZE */ gboolean bd_fs_resize (const gchar *device, guint64 new_size, const gchar *fstype, GError **error); /** * bd_fs_repair: * @device: the device the file system of which to repair * @fstype: (nullable): the filesystem type on @device or %NULL to detect * @error: (out) (optional): place to store error (if any) * * Repair filesystem on @device. This calls other fs repair functions from this * plugin based on detected filesystem (e.g. bd_fs_xfs_repair for XFS). This * function will return an error for unknown/unsupported filesystems. * * Most filesystem tools typically require the filesystem not to be mounted. * * Returns: whether the file system on @device was successfully repaired or not * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_REPAIR */ gboolean bd_fs_repair (const gchar *device, const gchar *fstype, GError **error); /** * bd_fs_check: * @device: the device the file system of which to check * @fstype: (nullable): the filesystem type on @device or %NULL to detect * @error: (out) (optional): place to store error (if any) * * Check filesystem on @device avoiding any modifications or repairs. * This calls other fs check functions from this plugin based on detected * filesystem (e.g. bd_fs_xfs_check for XFS). This function will return * an error for unknown/unsupported filesystems. * * Note that depending on a corresponding filesystem type and configured * features running this function on a mounted filesystem may result * in false errors reported. * * Returns: whether the file system on @device passed the consistency check or not * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_CHECK */ gboolean bd_fs_check (const gchar *device, const gchar *fstype, GError **error); /** * bd_fs_check_label: * @fstype: the filesystem type to check @label for * @label: label to check * @error: (out) (optional): place to store error (if any) * * This calls other fs check label functions from this plugin based on the provided * filesystem (e.g. bd_fs_xfs_check_label for XFS). This function will return * an error for unknown/unsupported filesystems. * * Returns: whether @label is a valid label for the @fstype file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_check_label (const gchar *fstype, const gchar *label, GError **error); /** * bd_fs_set_label: * @device: the device with file system to set the label for * @label: label to set * @fstype: (nullable): the filesystem type on @device or %NULL to detect * @error: (out) (optional): place to store error (if any) * * Set label for filesystem on @device. This calls other fs label functions from this * plugin based on detected filesystem (e.g. bd_fs_xfs_set_label for XFS). This * function will return an error for unknown/unsupported filesystems. * * Note: This function will mount @device for filesystems that need to be mounted * to set label (like btrfs). * * Returns: whether the file system on @device was successfully relabeled or not * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_SET_LABEL */ gboolean bd_fs_set_label (const gchar *device, const gchar *label, const gchar *fstype, GError **error); /** * bd_fs_check_uuid: * @fstype: the filesystem type to check @uuid for * @uuid: uuid to check * @error: (out) (optional): place to store error (if any) * * This calls other fs check uuid functions from this plugin based on the provided * filesystem (e.g. bd_fs_xfs_check_uuid for XFS). This function will return * an error for unknown/unsupported filesystems. * * Returns: whether @uuid is a valid UUID for the @fstype file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_check_uuid (const gchar *fstype, const gchar *uuid, GError **error); /** * bd_fs_set_uuid: * @device: the device with file system to set the UUID for * @uuid: (nullable): UUID to set or %NULL to generate a new one * @fstype: (nullable): the filesystem type on @device or %NULL to detect * @error: (out) (optional): place to store error (if any) * * Set UUID for filesystem on @device. This calls other fs UUID functions from this * plugin based on detected filesystem (e.g. bd_fs_xfs_set_uuid for XFS). This * function will return an error for unknown/unsupported filesystems. * * Returns: whether the UUID on the file system on @device was successfully changed or not * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_SET_UUID */ gboolean bd_fs_set_uuid (const gchar *device, const gchar *uuid, const gchar *fstype, GError **error); /** * bd_fs_xfs_check_uuid: * @uuid: UUID to check * @error: (out) (optional): place to store error * * Returns: whether @uuid is a valid UUID for the xfs file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_xfs_check_uuid (const gchar *uuid, GError **error); /** * bd_fs_get_size: * @device: the device with file system to get size for * @fstype: (nullable): the filesystem type on @device or %NULL to detect * @error: (out) (optional): place to store error (if any) * * Get size for filesystem on @device. This calls other fs info functions from this * plugin based on detected filesystem (e.g. bd_fs_xfs_get_info for XFS). This * function will return an error for unknown/unsupported filesystems. * * Note: This function will mount @device for filesystems that need to be mounted * to gather information (like btrfs). * * Returns: size of filesystem on @device, 0 in case of error. * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ guint64 bd_fs_get_size (const gchar *device, const gchar *fstype, GError **error); /** * bd_fs_get_free_space: * @device: the device with file system to get free space for * @fstype: (nullable): the filesystem type on @device or %NULL to detect * @error: (out) (optional): place to store error (if any) * * Get free space for filesystem on @device. This calls other fs info functions from this * plugin based on detected filesystem (e.g. bd_fs_ext4_get_info for ext4). This * function will return an error for unknown/unsupported filesystems. * * Returns: free space of filesystem on @device, 0 in case of error. * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ guint64 bd_fs_get_free_space (const gchar *device, const gchar *fstype, GError **error); /** * bd_fs_get_min_size: * @device: the device with file system to get minimum size for * @fstype: (nullable): the filesystem type on @device or %NULL to detect * @error: (out) (optional): place to store error (if any) * * Get minimum size for filesystem on @device. This calls other fs info functions from this * plugin based on detected filesystem (e.g. bd_fs_ext4_get_min_size for ext4). This * function will return an error for unknown/unsupported filesystems. * * Returns: minimum size of filesystem on @device, 0 in case of error. * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_RESIZE */ guint64 bd_fs_get_min_size (const gchar *device, const gchar *fstype, GError **error); /** * bd_fs_can_get_info: * @type: the filesystem type to be tested for info querying support * @required_utility: (out) (transfer full): the utility binary which is required * for info querying (if missing i.e. return FALSE but no error) * @error: (out) (optional): place to store error (if any) * * Searches for the required utility to get info of the given filesystem and * returns whether it is installed. * Unknown filesystems or filesystems which do not support info querying result in errors. * * Returns: whether getting filesystem info is available * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ gboolean bd_fs_can_get_info (const gchar *type, gchar **required_utility, GError **error); /** * BDFSMkfsOptionsFlags: * Flags indicating mkfs options are available for given filesystem type. */ typedef enum { BD_FS_MKFS_LABEL = 1 << 0, BD_FS_MKFS_UUID = 1 << 1, BD_FS_MKFS_DRY_RUN = 1 << 2, BD_FS_MKFS_NODISCARD = 1 << 3, BD_FS_MKFS_FORCE = 1 << 4, BD_FS_MKFS_NOPT = 1 << 5, } BDFSMkfsOptionsFlags; /** * bd_fs_can_mkfs: * @type: the filesystem type to be tested for installed mkfs support * @options: (out): flags for allowed mkfs options (i.e. support for setting label or UUID when creating the filesystem) * @required_utility: (out) (transfer full): the utility binary which is required for creating (if missing returns %FALSE but no @error) * @error: (out) (optional): place to store error (if any) * * Searches for the required utility to create the given filesystem and returns whether * it is installed. The options flags indicate what additional options can be specified for @type. * Unknown filesystems result in errors. * * Returns: whether filesystem mkfs tool is available * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ gboolean bd_fs_can_mkfs (const gchar *type, BDFSMkfsOptionsFlags *options, gchar **required_utility, GError **error); /** * BDFSResizeFlags: * Flags indicating whether a filesystem resize action supports growing and/or * shrinking if mounted or unmounted. */ typedef enum { BD_FS_OFFLINE_SHRINK = 1 << 1, BD_FS_OFFLINE_GROW = 1 << 2, BD_FS_ONLINE_SHRINK = 1 << 3, BD_FS_ONLINE_GROW = 1 << 4 } BDFSResizeFlags; /** * bd_fs_can_resize: * @type: the filesystem type to be tested for installed resize support * @mode: (out): flags for allowed resizing (i.e. growing/shrinking support for online/offline) * @required_utility: (out) (transfer full): the utility binary which is required for resizing (if missing i.e. returns FALSE but no error) * @error: (out) (optional): place to store error (if any) * * Searches for the required utility to resize the given filesystem and returns whether * it is installed. The mode flags indicate if growing and/or shrinking resize is available if * mounted/unmounted. * Unknown filesystems or filesystems which do not support resizing result in errors. * * Returns: whether filesystem resize is available * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ gboolean bd_fs_can_resize (const gchar *type, BDFSResizeFlags *mode, gchar **required_utility, GError **error); /** * bd_fs_can_check: * @type: the filesystem type to be tested for installed consistency check support * @required_utility: (out) (transfer full): the utility binary which is required for checking (if missing i.e. returns FALSE but no error) * @error: (out) (optional): place to store error (if any) * * Searches for the required utility to check the given filesystem and returns whether * it is installed. * Unknown filesystems or filesystems which do not support checking result in errors. * * Returns: whether filesystem check is available * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ gboolean bd_fs_can_check (const gchar *type, gchar **required_utility, GError **error); /** * bd_fs_can_repair: * @type: the filesystem type to be tested for installed repair support * @required_utility: (out) (transfer full): the utility binary which is required for repairing (if missing i.e. return FALSE but no error) * @error: (out) (optional): place to store error (if any) * * Searches for the required utility to repair the given filesystem and returns whether * it is installed. * Unknown filesystems or filesystems which do not support reparing result in errors. * * Returns: whether filesystem repair is available * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ gboolean bd_fs_can_repair (const gchar *type, gchar **required_utility, GError **error); /** * bd_fs_can_set_label: * @type: the filesystem type to be tested for installed label support * @required_utility: (out) (transfer full): the utility binary which is required for relabeling (if missing i.e. return FALSE but no error) * @error: (out) (optional): place to store error (if any) * * Searches for the required utility to set the label of the given filesystem and returns whether * it is installed. * Unknown filesystems or filesystems which do not support setting the label result in errors. * * Returns: whether setting filesystem label is available * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ gboolean bd_fs_can_set_label (const gchar *type, gchar **required_utility, GError **error); /** * bd_fs_can_set_uuid: * @type: the filesystem type to be tested for installed UUID support * @required_utility: (out) (transfer full): the utility binary which is required for setting UUID (if missing i.e. return FALSE but no error) * @error: (out) (optional): place to store error (if any) * * Searches for the required utility to set the UUID of the given filesystem and returns whether * it is installed. * Unknown filesystems or filesystems which do not support setting the UUID result in errors. * * Returns: whether setting filesystem UUID is available * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ gboolean bd_fs_can_set_uuid (const gchar *type, gchar **required_utility, GError **error); /** * bd_fs_can_get_size: * @type: the filesystem type to be tested for installed size querying support * @required_utility: (out) (transfer full): the utility binary which is required * for size querying (if missing i.e. return FALSE but no error) * @error: (out) (optional): place to store error (if any) * * Searches for the required utility to get size of the given filesystem and * returns whether it is installed. * Unknown filesystems or filesystems which do not support size querying result in errors. * * Returns: whether getting filesystem size is available * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ gboolean bd_fs_can_get_size (const gchar *type, gchar **required_utility, GError **error); /** * bd_fs_can_get_free_space: * @type: the filesystem type to be tested for installed free space querying support * @required_utility: (out) (transfer full): the utility binary which is required * for free space querying (if missing i.e. return FALSE but no error) * @error: (out) (optional): place to store error (if any) * * Searches for the required utility to get free space of the given filesystem and * returns whether it is installed. * Unknown filesystems or filesystems which do not support free space querying result in errors. * * Returns: whether getting filesystem free space is available * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ gboolean bd_fs_can_get_free_space (const gchar *type, gchar **required_utility, GError **error); /** * bd_fs_can_get_min_size: * @type: the filesystem type to be tested for installed minimum size querying support * @required_utility: (out) (transfer full): the utility binary which is required * for size querying (if missing i.e. return FALSE but no error) * @error: (out) (optional): place to store error (if any) * * Searches for the required utility to get minimum size of the given filesystem and * returns whether it is installed. * Unknown filesystems or filesystems which do not support minimum size querying result in errors. * * Returns: whether getting filesystem size is available * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_QUERY */ gboolean bd_fs_can_get_min_size (const gchar *type, gchar **required_utility, GError **error); /** * bd_fs_mkfs: * @device: the device to create the new filesystem on * @fstype: name of the filesystem to create (e.g. "ext4") * @options: additional options like label or UUID for the filesystem * @extra: (nullable) (array zero-terminated=1): extra mkfs options not provided in @options * @error: (out) (optional): place to store error (if any) * * This is a helper function for creating filesystems with extra options. * This is the same as running a filesystem-specific function like %bd_fs_ext4_mkfs * and manually specifying the extra command line options. %BDFSMkfsOptions * removes the need to specify supported options for selected filesystems, * make sure to check whether @fstype supports these options (see %bd_fs_can_mkfs) * for details. * * When specifying additional mkfs options using @extra, it's caller's * responsibility to make sure these options do not conflict with options * specified using @options. Extra options are added after the @options and * there are no additional checks for duplicate and/or conflicting options. * * Returns: whether @fstype was successfully created on @device or not. * * Tech category: %BD_FS_TECH_GENERIC-%BD_FS_TECH_MODE_MKFS * */ gboolean bd_fs_mkfs (const gchar *device, const gchar *fstype, BDFSMkfsOptions *options, const BDExtraArg **extra, GError **error); /** * bd_fs_ext2_mkfs: * @device: the device to create a new ext2 fs on * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mke2fs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether a new ext2 fs was successfully created on @device or not * * Tech category: %BD_FS_TECH_EXT2-%BD_FS_TECH_MODE_MKFS */ gboolean bd_fs_ext2_mkfs (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_ext3_mkfs: * @device: the device to create a new ext3 fs on * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mke2fs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether a new ext3 fs was successfully created on @device or not * * Tech category: %BD_FS_TECH_EXT3-%BD_FS_TECH_MODE_MKFS */ gboolean bd_fs_ext3_mkfs (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_ext4_mkfs: * @device: the device to create a new ext4 fs on * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkfs.ext4' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether a new ext4 fs was successfully created on @device or not * * Tech category: %BD_FS_TECH_EXT4-%BD_FS_TECH_MODE_MKFS */ gboolean bd_fs_ext4_mkfs (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_ext2_check: * @device: the device the file system on which to check * @extra: (nullable) (array zero-terminated=1): extra options for the check (right now * passed to the 'e2fsck' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an ext2 file system on the @device is clean or not * * Tech category: %BD_FS_TECH_EXT2-%BD_FS_TECH_MODE_CHECK */ gboolean bd_fs_ext2_check (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_ext3_check: * @device: the device the file system on which to check * @extra: (nullable) (array zero-terminated=1): extra options for the check (right now * passed to the 'e2fsck' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an ext3 file system on the @device is clean or not * * Tech category: %BD_FS_TECH_EXT3-%BD_FS_TECH_MODE_CHECK */ gboolean bd_fs_ext3_check (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_ext4_check: * @device: the device the file system on which to check * @extra: (nullable) (array zero-terminated=1): extra options for the check (right now * passed to the 'e2fsck' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an ext4 file system on the @device is clean or not * * Tech category: %BD_FS_TECH_EXT4-%BD_FS_TECH_MODE_CHECK */ gboolean bd_fs_ext4_check (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_ext2_repair: * @device: the device the file system on which to repair * @unsafe: whether to do unsafe operations too * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'e2fsck' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an ext2 file system on the @device was successfully repaired * (if needed) or not (error is set in that case) * * Tech category: %BD_FS_TECH_EXT2-%BD_FS_TECH_MODE_REPAIR */ gboolean bd_fs_ext2_repair (const gchar *device, gboolean unsafe, const BDExtraArg **extra, GError **error); /** * bd_fs_ext3_repair: * @device: the device the file system on which to repair * @unsafe: whether to do unsafe operations too * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'e2fsck' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an ext3 file system on the @device was successfully repaired * (if needed) or not (error is set in that case) * * Tech category: %BD_FS_TECH_EXT3-%BD_FS_TECH_MODE_REPAIR */ gboolean bd_fs_ext3_repair (const gchar *device, gboolean unsafe, const BDExtraArg **extra, GError **error); /** * bd_fs_ext4_repair: * @device: the device the file system on which to repair * @unsafe: whether to do unsafe operations too * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'e2fsck' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an ext4 file system on the @device was successfully repaired * (if needed) or not (error is set in that case) * * Tech category: %BD_FS_TECH_EXT4-%BD_FS_TECH_MODE_REPAIR */ gboolean bd_fs_ext4_repair (const gchar *device, gboolean unsafe, const BDExtraArg **extra, GError **error); /** * bd_fs_ext2_set_label: * @device: the device the file system on which to set label for * @label: label to set * @error: (out) (optional): place to store error (if any) * * Returns: whether the label of ext2 file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_EXT2-%BD_FS_TECH_MODE_SET_LABEL */ gboolean bd_fs_ext2_set_label (const gchar *device, const gchar *label, GError **error); /** * bd_fs_ext3_set_label: * @device: the device the file system on which to set label for * @label: label to set * @error: (out) (optional): place to store error (if any) * * Returns: whether the label of ext3 file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_EXT3-%BD_FS_TECH_MODE_SET_LABEL */ gboolean bd_fs_ext3_set_label (const gchar *device, const gchar *label, GError **error); /** * bd_fs_ext4_set_label: * @device: the device the file system on which to set label for * @label: label to set * @error: (out) (optional): place to store error (if any) * * Returns: whether the label of ext4 file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_EXT3-%BD_FS_TECH_MODE_SET_LABEL */ gboolean bd_fs_ext4_set_label (const gchar *device, const gchar *label, GError **error); /** * bd_fs_ext2_check_label: * @label: label to check * @error: (out) (optional): place to store error * * Returns: whether @label is a valid label for the ext2 file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_ext2_check_label (const gchar *label, GError **error); /** * bd_fs_ext3_check_label: * @label: label to check * @error: (out) (optional): place to store error (if any) * * Returns: whether @label is a valid label for the ext3 file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_ext3_check_label (const gchar *label, GError **error); /** * bd_fs_ext4_check_label: * @label: label to check * @error: (out) (optional): place to store error (if any) * * Returns: whether @label is a valid label for the ext4 file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_ext4_check_label (const gchar *label, GError **error); /** * bd_fs_ext2_set_uuid: * @device: the device the file system on which to set UUID for * @uuid: (nullable): UUID to set %NULL to generate a new one * UUID can also be one of "clear", "random" and "time" to clear, * generate a new random/time-based UUID * @error: (out) (optional): place to store error (if any) * * Returns: whether the UUID of ext2 file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_EXT2-%BD_FS_TECH_MODE_SET_UUID */ gboolean bd_fs_ext2_set_uuid (const gchar *device, const gchar *uuid, GError **error); /** * bd_fs_ext3_set_uuid: * @device: the device the file system on which to set UUID for * @uuid: (nullable): UUID to set %NULL to generate a new one * UUID can also be one of "clear", "random" and "time" to clear, * generate a new random/time-based UUID * @error: (out) (optional): place to store error (if any) * * Returns: whether the UUID of ext3 file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_EXT3-%BD_FS_TECH_MODE_SET_UUID */ gboolean bd_fs_ext3_set_uuid (const gchar *device, const gchar *uuid, GError **error); /** * bd_fs_ext4_set_uuid: * @device: the device the file system on which to set UUID for * @uuid: (nullable): UUID to set %NULL to generate a new one * UUID can also be one of "clear", "random" and "time" to clear, * generate a new random/time-based UUID * @error: (out) (optional): place to store error (if any) * * Returns: whether the UUID of ext4 file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_EXT4-%BD_FS_TECH_MODE_SET_UUID */ gboolean bd_fs_ext4_set_uuid (const gchar *device, const gchar *uuid, GError **error); /** * bd_fs_ext2_check_uuid: * @uuid: UUID to check * @error: (out) (optional): place to store error * * Returns: whether @uuid is a valid UUID for the ext2 file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_ext2_check_uuid (const gchar *uuid, GError **error); /** * bd_fs_ext3_check_uuid: * @uuid: UUID to check * @error: (out) (optional): place to store error * * Returns: whether @uuid is a valid UUID for the ext3 file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_ext3_check_uuid (const gchar *uuid, GError **error); /** * bd_fs_ext4_check_uuid: * @uuid: UUID to check * @error: (out) (optional): place to store error * * Returns: whether @uuid is a valid UUID for the ext4 file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_ext4_check_uuid (const gchar *uuid, GError **error); /** * bd_fs_ext2_get_info: * @device: the device the file system of which to get info for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the file system on @device or * %NULL in case of error * * Tech category: %BD_FS_TECH_EXT2-%BD_FS_TECH_MODE_QUERY */ BDFSExt2Info* bd_fs_ext2_get_info (const gchar *device, GError **error); /** * bd_fs_ext3_get_info: * @device: the device the file system of which to get info for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the file system on @device or * %NULL in case of error * * Tech category: %BD_FS_TECH_EXT3-%BD_FS_TECH_MODE_QUERY */ BDFSExt3Info* bd_fs_ext3_get_info (const gchar *device, GError **error); /** * bd_fs_ext4_get_info: * @device: the device the file system of which to get info for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the file system on @device or * %NULL in case of error * * Tech category: %BD_FS_TECH_EXT3-%BD_FS_TECH_MODE_QUERY */ BDFSExt4Info* bd_fs_ext4_get_info (const gchar *device, GError **error); /** * bd_fs_ext2_resize: * @device: the device the file system of which to resize * @new_size: new requested size for the file system (if 0, the file system is * adapted to the underlying block device) * @extra: (nullable) (array zero-terminated=1): extra options for the resize (right now * passed to the 'resize2fs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the file system on @device was successfully resized or not * * Tech category: %BD_FS_TECH_EXT2-%BD_FS_TECH_MODE_RESIZE */ gboolean bd_fs_ext2_resize (const gchar *device, guint64 new_size, const BDExtraArg **extra, GError **error); /** * bd_fs_ext3_resize: * @device: the device the file system of which to resize * @new_size: new requested size for the file system (if 0, the file system is * adapted to the underlying block device) * @extra: (nullable) (array zero-terminated=1): extra options for the resize (right now * passed to the 'resize2fs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the file system on @device was successfully resized or not * * Tech category: %BD_FS_TECH_EXT3-%BD_FS_TECH_MODE_RESIZE */ gboolean bd_fs_ext3_resize (const gchar *device, guint64 new_size, const BDExtraArg **extra, GError **error); /** * bd_fs_ext4_resize: * @device: the device the file system of which to resize * @new_size: new requested size for the file system (if 0, the file system is * adapted to the underlying block device) * @extra: (nullable) (array zero-terminated=1): extra options for the resize (right now * passed to the 'resize2fs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the file system on @device was successfully resized or not * * Tech category: %BD_FS_TECH_EXT4-%BD_FS_TECH_MODE_RESIZE */ gboolean bd_fs_ext4_resize (const gchar *device, guint64 new_size, const BDExtraArg **extra, GError **error); /** * bd_fs_ext2_get_min_size: * @device: the device containing the file system to get min size for * @error: (out) (optional): place to store error (if any) * * Returns: smallest shrunken filesystem size as reported by ntfsresize * in case of error 0 is returned and @error is set * * Tech category: %BD_FS_TECH_EXT2-%BD_FS_TECH_MODE_RESIZE */ guint64 bd_fs_ext2_get_min_size (const gchar *device, GError **error); /** * bd_fs_ext3_get_min_size: * @device: the device containing the file system to get min size for * @error: (out) (optional): place to store error (if any) * * Returns: smallest shrunken filesystem size as reported by ntfsresize * in case of error 0 is returned and @error is set * * Tech category: %BD_FS_TECH_EXT3-%BD_FS_TECH_MODE_RESIZE */ guint64 bd_fs_ext3_get_min_size (const gchar *device, GError **error); /** * bd_fs_ext4_get_min_size: * @device: the device containing the file system to get min size for * @error: (out) (optional): place to store error (if any) * * Returns: smallest shrunken filesystem size as reported by ntfsresize * in case of error 0 is returned and @error is set * * Tech category: %BD_FS_TECH_EXT4-%BD_FS_TECH_MODE_RESIZE */ guint64 bd_fs_ext4_get_min_size (const gchar *device, GError **error); /** * bd_fs_xfs_mkfs: * @device: the device to create a new xfs fs on * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkfs.xfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether a new xfs fs was successfully created on @device or not * * Tech category: %BD_FS_TECH_XFS-%BD_FS_TECH_MODE_MKFS */ gboolean bd_fs_xfs_mkfs (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_xfs_check: * @device: the device containing the file system to check * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'xfs_repair' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an xfs file system on the @device is clean or not * * Note: If the file system is mounted RW, it will always be reported as not * clean! * * Tech category: %BD_FS_TECH_XFS-%BD_FS_TECH_MODE_CHECK */ gboolean bd_fs_xfs_check (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_xfs_repair: * @device: the device containing the file system to repair * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'xfs_repair' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an xfs file system on the @device was successfully repaired * (if needed) or not (error is set in that case) * * Tech category: %BD_FS_TECH_XFS-%BD_FS_TECH_MODE_REPAIR */ gboolean bd_fs_xfs_repair (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_xfs_set_label: * @device: the device containing the file system to set label for * @label: label to set * @error: (out) (optional): place to store error (if any) * * Returns: whether the label of xfs file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_XFS-%BD_FS_TECH_MODE_SET_LABEL */ gboolean bd_fs_xfs_set_label (const gchar *device, const gchar *label, GError **error); /** * bd_fs_xfs_check_label: * @label: label to check * @error: (out) (optional): place to store error * * Returns: whether @label is a valid label for the xfs file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_xfs_check_label (const gchar *label, GError **error); /** * bd_fs_xfs_set_uuid: * @device: the device containing the file system to set uuid for * @uuid: (nullable): UUID to set %NULL to generate a new one * UUID can also be one of "nil" and "generate" to clear or * generate a new UUID * @error: (out) (optional): place to store error (if any) * * Returns: whether the UUID of xfs file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_XFS-%BD_FS_TECH_MODE_SET_UUID */ gboolean bd_fs_xfs_set_uuid (const gchar *device, const gchar *uuid, GError **error); /** * bd_fs_xfs_get_info: * @device: the device containing the file system to get info for (device must be mounted, trying to get info for an unmounted device will result in an error) * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the file system on @device or * %NULL in case of error * * Tech category: %BD_FS_TECH_XFS-%BD_FS_TECH_MODE_QUERY */ BDFSXfsInfo* bd_fs_xfs_get_info (const gchar *device, GError **error); /** * bd_fs_xfs_resize: * @mpoint: the mount point of the file system to resize * @new_size: new requested size for the file system *in file system blocks* (see bd_fs_xfs_get_info()) * (if 0, the file system is adapted to the underlying block device) * @extra: (nullable) (array zero-terminated=1): extra options for the resize (right now * passed to the 'xfs_growfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the file system mounted on @mpoint was successfully resized or not * * Tech category: %BD_FS_TECH_XFS-%BD_FS_TECH_MODE_RESIZE */ gboolean bd_fs_xfs_resize (const gchar *mpoint, guint64 new_size, const BDExtraArg **extra, GError **error); /** * bd_fs_vfat_mkfs: * @device: the device to create a new vfat fs on * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkfs.vfat' utility) * @error: (out) (optional): place to store error (if any) * * Please remember that FAT labels should always be uppercase. * * Returns: whether a new vfat fs was successfully created on @device or not * * Tech category: %BD_FS_TECH_VFAT-%BD_FS_TECH_MODE_MKFS */ gboolean bd_fs_vfat_mkfs (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_vfat_check: * @device: the device containing the file system to check * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'fsck.vfat' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an vfat file system on the @device is clean or not * * Tech category: %BD_FS_TECH_VFAT-%BD_FS_TECH_MODE_CHECK */ gboolean bd_fs_vfat_check (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_vfat_repair: * @device: the device containing the file system to repair * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'fsck.vfat' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an vfat file system on the @device was successfully repaired * (if needed) or not (error is set in that case) * * Tech category: %BD_FS_TECH_VFAT-%BD_FS_TECH_MODE_REPAIR */ gboolean bd_fs_vfat_repair (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_vfat_set_label: * @device: the device containing the file system to set label for * @label: label to set * @error: (out) (optional): place to store error (if any) * * Returns: whether the label of vfat file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_VFAT-%BD_FS_TECH_MODE_SET_LABEL */ gboolean bd_fs_vfat_set_label (const gchar *device, const gchar *label, GError **error); /** * bd_fs_vfat_check_label: * @label: label to check * @error: (out) (optional): place to store error * * Returns: whether @label is a valid label for the vfat file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_vfat_check_label (const gchar *label, GError **error); /** * bd_fs_vfat_set_uuid: * @device: the device containing the file system to set uuid for * @uuid: (nullable): volume ID to set or %NULL to generate a new one * @error: (out) (optional): place to store error (if any) * * Returns: whether the volume ID of vfat file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_VFAT-%BD_FS_TECH_MODE_SET_UUID */ gboolean bd_fs_vfat_set_uuid (const gchar *device, const gchar *uuid, GError **error); /** * bd_fs_vfat_check_uuid: * @uuid: UUID to check * @error: (out) (optional): place to store error * * Returns: whether @uuid is a valid UUID for the vfat file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_vfat_check_uuid (const gchar *uuid, GError **error); /** * bd_fs_vfat_get_info: * @device: the device containing the file system to get info for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the file system on @device or * %NULL in case of error * * Tech category: %BD_FS_TECH_VFAT-%BD_FS_TECH_MODE_QUERY */ BDFSVfatInfo* bd_fs_vfat_get_info (const gchar *device, GError **error); /** * bd_fs_vfat_resize: * @device: the device the file system of which to resize * @new_size: new requested size for the file system (if 0, the file system is * adapted to the underlying block device) * @error: (out) (optional): place to store error (if any) * * Returns: whether the file system on @device was successfully resized or not * * Tech category: %BD_FS_TECH_VFAT-%BD_FS_TECH_MODE_RESIZE */ gboolean bd_fs_vfat_resize (const gchar *device, guint64 new_size, GError **error); /** * bd_fs_ntfs_mkfs: * @device: the device to create a new ntfs fs on * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkntfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether a new NTFS fs was successfully created on @device or not * * Tech category: %BD_FS_TECH_NTFS-%BD_FS_TECH_MODE_MKFS */ gboolean bd_fs_ntfs_mkfs (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_ntfs_check: * @device: the device containing the file system to check * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'ntfsfix' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an ntfs file system on the @device is clean or not * * Tech category: %BD_FS_TECH_NTFS-%BD_FS_TECH_MODE_CHECK */ gboolean bd_fs_ntfs_check (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_ntfs_repair: * @device: the device containing the file system to repair * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'ntfsfix' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an NTFS file system on the @device was successfully repaired * (if needed) or not (error is set in that case) * * Tech category: %BD_FS_TECH_NTFS-%BD_FS_TECH_MODE_REPAIR */ gboolean bd_fs_ntfs_repair (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_ntfs_set_label: * @device: the device containing the file system to set the label for * @label: label to set * @error: (out) (optional): place to store error (if any) * * Returns: whether the label of the NTFS file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_NTFS-%BD_FS_TECH_MODE_SET_LABEL */ gboolean bd_fs_ntfs_set_label (const gchar *device, const gchar *label, GError **error); /** * bd_fs_ntfs_check_label: * @label: label to check * @error: (out) (optional): place to store error * * Returns: whether @label is a valid label for the ntfs file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_ntfs_check_label (const gchar *label, GError **error); /** * bd_fs_ntfs_set_uuid: * @device: the device containing the file system to set the UUID (serial number) for * @uuid: (nullable): UUID to set or %NULL to generate a new one * @error: (out) (optional): place to store error (if any) * * Returns: whether the UUID of the NTFS file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_NTFS-%BD_FS_TECH_MODE_SET_UUID */ gboolean bd_fs_ntfs_set_uuid (const gchar *device, const gchar *uuid, GError **error); /** * bd_fs_ntfs_check_uuid: * @uuid: UUID to check * @error: (out) (optional): place to store error * * Returns: whether @uuid is a valid UUID for the ntfs file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_ntfs_check_uuid (const gchar *uuid, GError **error); /** * bd_fs_ntfs_resize: * @device: the device the file system of which to resize * @new_size: new requested size for the file system in bytes (if 0, the file system * is adapted to the underlying block device) * @error: (out) (optional): place to store error (if any) * * Returns: whether the file system on @device was successfully resized or not * * Tech category: %BD_FS_TECH_NTFS-%BD_FS_TECH_MODE_RESIZE */ gboolean bd_fs_ntfs_resize (const gchar *device, guint64 new_size, GError **error); /** * bd_fs_ntfs_get_info: * @device: the device containing the file system to get info for (device must not be mounted, trying to get info for a mounted device will result in an error) * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the file system on @device or * %NULL in case of error * * Tech category: %BD_FS_TECH_NTFS-%BD_FS_TECH_MODE_QUERY */ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error); /** * bd_fs_ntfs_get_min_size: * @device: the device containing the file system to get min size for * @error: (out) (optional): place to store error (if any) * * Returns: smallest shrunken filesystem size as reported by ntfsresize * in case of error 0 is returned and @error is set * * Tech category: %BD_FS_TECH_NTFS-%BD_FS_TECH_MODE_RESIZE */ guint64 bd_fs_ntfs_get_min_size (const gchar *device, GError **error); /** * bd_fs_f2fs_mkfs: * @device: the device to create a new f2fs fs on * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkfs.f2fs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether a new f2fs fs was successfully created on @device or not * * Tech category: %BD_FS_TECH_F2FS-%BD_FS_TECH_MODE_MKFS */ gboolean bd_fs_f2fs_mkfs (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_f2fs_check: * @device: the device containing the file system to check * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'fsck.f2fs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an f2fs file system on the @device is clean or not * * Tech category: %BD_FS_TECH_F2FS-%BD_FS_TECH_MODE_CHECK */ gboolean bd_fs_f2fs_check (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_f2fs_repair: * @device: the device containing the file system to repair * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'fsck.f2fs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether an f2fs file system on the @device was successfully repaired * (if needed) or not (error is set in that case) * * Tech category: %BD_FS_TECH_F2FS-%BD_FS_TECH_MODE_REPAIR */ gboolean bd_fs_f2fs_repair (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_f2fs_get_info: * @device: the device containing the file system to get info for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the file system on @device or * %NULL in case of error * * Tech category: %BD_FS_TECH_F2FS-%BD_FS_TECH_MODE_QUERY */ BDFSF2FSInfo* bd_fs_f2fs_get_info (const gchar *device, GError **error); /** * bd_fs_f2fs_resize: * @device: the device containing the file system to resize * @new_size: new requested size for the file system *in file system sectors* (see bd_fs_f2fs_get_info()) * (if 0, the file system is adapted to the underlying block device) * @safe: whether to perform safe resize or not (does not resize metadata) * @extra: (nullable) (array zero-terminated=1): extra options for the resize (right now * passed to the 'resize.f2fs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the file system on @device was successfully resized or not * * Tech category: %BD_FS_TECH_F2FS-%BD_FS_TECH_MODE_RESIZE */ gboolean bd_fs_f2fs_resize (const gchar *device, guint64 new_size, gboolean safe, const BDExtraArg **extra, GError **error); /** * bd_fs_f2fs_check_label: * @label: label to check * @error: (out) (optional): place to store error * * Returns: whether @label is a valid label for the f2fs file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_f2fs_check_label (const gchar *label, GError **error); /** * bd_fs_nilfs2_mkfs: * @device: the device to create a new nilfs fs on * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkfs.nilfs2' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether a new nilfs fs was successfully created on @device or not * * Tech category: %BD_FS_TECH_NILFS2-%BD_FS_TECH_MODE_MKFS */ gboolean bd_fs_nilfs2_mkfs (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_nilfs2_set_label: * @device: the device containing the file system to set label for * @label: label to set * @error: (out) (optional): place to store error (if any) * * Returns: whether the label of nilfs file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_NILFS2-%BD_FS_TECH_MODE_SET_LABEL */ gboolean bd_fs_nilfs2_set_label (const gchar *device, const gchar *label, GError **error); /** * bd_fs_nilfs2_check_label: * @label: label to check * @error: (out) (optional): place to store error * * Returns: whether @label is a valid label for the nilfs2 file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_nilfs2_check_label (const gchar *label, GError **error); /** * bd_fs_nilfs2_set_uuid: * @device: the device containing the file system to set UUID for * @uuid: (nullable): UUID to set or %NULL to generate a new one * @error: (out) (optional): place to store error (if any) * * Returns: whether the uuid of nilfs file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_NILFS2-%BD_FS_TECH_MODE_SET_UUID */ gboolean bd_fs_nilfs2_set_uuid (const gchar *device, const gchar *uuid, GError **error); /** * bd_fs_nilfs2_check_uuid: * @uuid: UUID to check * @error: (out) (optional): place to store error * * Returns: whether @uuid is a valid UUID for the nilfs file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_nilfs2_check_uuid (const gchar *uuid, GError **error); /** * bd_fs_nilfs2_get_info: * @device: the device containing the file system to get info for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the file system on @device or * %NULL in case of error * * Tech category: %BD_FS_TECH_NILFS2-%BD_FS_TECH_MODE_QUERY */ BDFSNILFS2Info* bd_fs_nilfs2_get_info (const gchar *device, GError **error); /** * bd_fs_nilfs2_resize: * @device: the device the file system of which to resize * @new_size: new requested size for the file system (if 0, the file system is * adapted to the underlying block device) * @error: (out) (optional): place to store error (if any) * * Returns: whether the file system on @device was successfully resized or not * * Tech category: %BD_FS_TECH_NILFS2-%BD_FS_TECH_MODE_RESIZE */ gboolean bd_fs_nilfs2_resize (const gchar *device, guint64 new_size, GError **error); /** * bd_fs_exfat_mkfs: * @device: the device to create a new exfat fs on * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkexfatfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether a new exfat fs was successfully created on @device or not * * Tech category: %BD_FS_TECH_EXFAT-%BD_FS_TECH_MODE_MKFS */ gboolean bd_fs_exfat_mkfs (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_exfat_check: * @device: the device containing the file system to check * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'exfatfsck' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the exfat file system on the @device is clean or not * * Tech category: %BD_FS_TECH_EXFAT-%BD_FS_TECH_MODE_CHECK */ gboolean bd_fs_exfat_check (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_exfat_repair: * @device: the device containing the file system to repair * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'exfatfsck' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the exfat file system on the @device was successfully repaired * (if needed) or not (error is set in that case) * * Tech category: %BD_FS_TECH_EXFAT-%BD_FS_TECH_MODE_REPAIR */ gboolean bd_fs_exfat_repair (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_exfat_set_label: * @device: the device containing the file system to set label for * @label: label to set * @error: (out) (optional): place to store error (if any) * * Returns: whether the label of exfat file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_EXFAT-%BD_FS_TECH_MODE_SET_LABEL */ gboolean bd_fs_exfat_set_label (const gchar *device, const gchar *label, GError **error); /** * bd_fs_exfat_check_label: * @label: label to check * @error: (out) (optional): place to store error * * Returns: whether @label is a valid label for the exfat file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_exfat_check_label (const gchar *label, GError **error); /** * bd_fs_exfat_set_uuid: * @device: the device containing the file system to set uuid for * @uuid: (nullable): volume ID to set or %NULL to generate a new one * @error: (out) (optional): place to store error (if any) * * Returns: whether the volume ID of exFAT file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_EXFAT-%BD_FS_TECH_MODE_SET_UUID */ gboolean bd_fs_exfat_set_uuid (const gchar *device, const gchar *uuid, GError **error); /** * bd_fs_exfat_check_uuid: * @uuid: UUID to check * @error: (out) (optional): place to store error * * Returns: whether @uuid is a valid UUID for the exFAT file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_exfat_check_uuid (const gchar *uuid, GError **error); /** * bd_fs_exfat_get_info: * @device: the device containing the file system to get info for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the file system on @device or * %NULL in case of error * Tech category: %BD_FS_TECH_EXFAT-%BD_FS_TECH_MODE_QUERY */ BDFSExfatInfo* bd_fs_exfat_get_info (const gchar *device, GError **error); /** * bd_fs_btrfs_mkfs: * @device: the device to create a new btrfs fs on * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkfs.btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether a new btrfs fs was successfully created on @device or not * * Tech category: %BD_FS_TECH_BTRFS-%BD_FS_TECH_MODE_MKFS * */ gboolean bd_fs_btrfs_mkfs (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_btrfs_check: * @device: the device containing the file system to check * @extra: (nullable) (array zero-terminated=1): extra options for the check (right now * passed to the 'btrfsck' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the filesystem was successfully checked or not * * Tech category: %BD_FS_TECH_BTRFS-%BD_FS_TECH_MODE_CHECK */ gboolean bd_fs_btrfs_check (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_btrfs_repair: * @device: the device containing the file system to repair * @extra: (nullable) (array zero-terminated=1): extra options for the repair (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the filesystem was successfully checked and repaired or not * * Tech category: %BD_FS_TECH_BTRFS-%BD_FS_TECH_MODE_REPAIR */ gboolean bd_fs_btrfs_repair (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_fs_btrfs_set_label: * @mpoint: the mount point of the file system to set label for * @label: label to set * @error: (out) (optional): place to store error (if any) * * Returns: whether the label of Btrfs file system on the @mpoint was * successfully set or not * * Note: This function is intended to be used for btrfs filesystem on a single device, * for more complicated setups use the btrfs plugin instead. * * Tech category: %BD_FS_TECH_BTRFS-%BD_FS_TECH_MODE_SET_LABEL */ gboolean bd_fs_btrfs_set_label (const gchar *mpoint, const gchar *label, GError **error); /** * bd_fs_btrfs_check_label: * @label: label to check * @error: (out) (optional): place to store error * * Returns: whether @label is a valid label for the Btrfs file system or not * (reason is provided in @error) * * Note: This function is intended to be used for btrfs filesystem on a single device, * for more complicated setups use the btrfs plugin instead. * * Tech category: always available */ gboolean bd_fs_btrfs_check_label (const gchar *label, GError **error); /** * bd_fs_btrfs_set_uuid: * @device: the device containing the file system to set the UUID (serial number) for * @uuid: (nullable): UUID to set or %NULL to generate a new one * @error: (out) (optional): place to store error (if any) * * Returns: whether the UUID of the Btrfs file system on the @device was * successfully set or not * * Note: This function is intended to be used for btrfs filesystem on a single device, * for more complicated setups use the btrfs plugin instead. * * Tech category: %BD_FS_TECH_BTRFS-%BD_FS_TECH_MODE_SET_UUID */ gboolean bd_fs_btrfs_set_uuid (const gchar *device, const gchar *uuid, GError **error); /** * bd_fs_btrfs_check_uuid: * @uuid: UUID to check * @error: (out) (optional): place to store error * * Returns: whether @uuid is a valid UUID for the Btrfs file system or not * (reason is provided in @error) * * Note: This function is intended to be used for btrfs filesystem on a single device, * for more complicated setups use the btrfs plugin instead. * * Tech category: always available */ gboolean bd_fs_btrfs_check_uuid (const gchar *uuid, GError **error); /** * bd_fs_btrfs_get_info: * @mpoint: a mountpoint of the btrfs filesystem to get information about * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the file system on @device or * %NULL in case of error * * Note: This function WON'T WORK for multi device btrfs filesystems, * for more complicated setups use the btrfs plugin instead. * * Tech category: %BD_FS_TECH_BTRFS-%BD_FS_TECH_MODE_QUERY */ BDFSBtrfsInfo* bd_fs_btrfs_get_info (const gchar *mpoint, GError **error); /** * bd_fs_btrfs_resize: * @mpoint: a mountpoint of the to be resized btrfs filesystem * @new_size: requested new size * @extra: (nullable) (array zero-terminated=1): extra options for the volume resize (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @mpoint filesystem was successfully resized to @new_size * or not * * Note: This function WON'T WORK for multi device btrfs filesystems, * for more complicated setups use the btrfs plugin instead. * * Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_MODIFY */ gboolean bd_fs_btrfs_resize (const gchar *mpoint, guint64 new_size, const BDExtraArg **extra, GError **error); /** * bd_fs_udf_mkfs: * @device: the device to create a new UDF fs on * @media_type: (nullable): specify the media type or %NULL for default ('hd') * @revision: (nullable): UDF revision to use or %NULL for default ('2.01') * @block_size: block size in bytes or 0 for auto detection (device logical block size) * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkudffs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether a new UDF fs was successfully created on @device or not * * Tech category: %BD_FS_TECH_UDF-%BD_FS_TECH_MODE_MKFS */ gboolean bd_fs_udf_mkfs (const gchar *device, const gchar *media_type, gchar *revision, guint64 block_size, const BDExtraArg **extra, GError **error); /** * bd_fs_udf_set_label: * @device: the device containing the file system to set label for * @label: label to set * @error: (out) (optional): place to store error (if any) * * Note: This sets both Volume Identifier and Logical Volume Identifier. Volume Identifier * is truncated to 30 or 15 characters to accommodate to the different length limits * of these labels. * * Returns: whether the label of UDF file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_UDF-%BD_FS_TECH_MODE_SET_LABEL */ gboolean bd_fs_udf_set_label (const gchar *device, const gchar *label, GError **error); /** * bd_fs_udf_check_label: * @label: label to check * @error: (out) (optional): place to store error * * Note: This checks only whether @label adheres the length limits for Logical Volume Identifier, * not the stricter limits for Volume Identifier. * * Returns: whether @label is a valid label for the UDF file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_udf_check_label (const gchar *label, GError **error); /** * bd_fs_udf_set_uuid: * @device: the device containing the file system to set the UUID (serial number) for * @uuid: (nullable): UUID to set or %NULL to generate a new one * @error: (out) (optional): place to store error (if any) * * Returns: whether the UUID of the UDF file system on the @device was * successfully set or not * * Tech category: %BD_FS_TECH_UDF-%BD_FS_TECH_MODE_SET_UUID */ gboolean bd_fs_udf_set_uuid (const gchar *device, const gchar *uuid, GError **error); /** * bd_fs_udf_check_uuid: * @uuid: UUID to check * @error: (out) (optional): place to store error * * Returns: whether @uuid is a valid UUID for the UDF file system or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_fs_udf_check_uuid (const gchar *uuid, GError **error); /** * bd_fs_udf_get_info: * @device: the device containing the file system to get info for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the file system on @device or * %NULL in case of error * * Tech category: %BD_FS_TECH_UDF-%BD_FS_TECH_MODE_QUERY */ BDFSUdfInfo* bd_fs_udf_get_info (const gchar *device, GError **error); typedef enum { BD_FS_SUPPORT_SET_LABEL = 1 << 1, BD_FS_SUPPORT_SET_UUID = 1 << 2 } BDFSConfigureFlags; typedef enum { BD_FS_FSCK_CHECK = 1 << 1, BD_FS_FSCK_REPAIR = 1 << 2 } BDFSFsckFlags; typedef enum { BD_FS_FEATURE_OWNERS = 1 << 1, BD_FS_FEATURE_PARTITION_TABLE = 1 << 2 } BDFSFeatureFlags; /** * BDFSFeatures: * @resize: supported resizes modes * @mkfs: supported options for mkfs * @fsck: support for fsck operations (check and repair) * @configure: support for changing properties of an existing filesystem * @features: other supported features * @partition_id: partition ID used for this filesystem on MSDOS partitions * @partition_type: partition type/GUID used for this filesystem GPT partitions */ typedef struct BDFSFeatures { BDFSResizeFlags resize; BDFSMkfsOptionsFlags mkfs; BDFSFsckFlags fsck; BDFSConfigureFlags configure; BDFSFeatureFlags features; const gchar *partition_id; const gchar *partition_type; } BDFSFeatures; /** * bd_fs_features_copy: (skip) * @data: (allow-none): %BDFSFeatures to copy * * Creates a new copy of @data. */ BDFSFeatures* bd_fs_features_copy (BDFSFeatures *data) { if (data == NULL) return NULL; BDFSFeatures *ret = g_new0 (BDFSFeatures, 1); ret->resize = data->resize; ret->mkfs = data->mkfs; ret->fsck = data->fsck; ret->configure = data->configure; ret->features = data->features; ret->partition_id = data->partition_id; ret->partition_type = data->partition_type; return ret; } /** * bd_fs_features_free: (skip) * @data: (allow-none): %BDFSFeatures to free * * Frees @data. */ void bd_fs_features_free (BDFSFeatures *data) { if (data == NULL) return; g_free (data); } GType bd_fs_features_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDFSFeatures", (GBoxedCopyFunc) bd_fs_features_copy, (GBoxedFreeFunc) bd_fs_features_free); } return type; } /** * bd_fs_features: * @fstype: name of the filesystem to get features for (e.g. "ext4") * @error: (allow-none): (out): place to store error (if any) * * Returns (transfer-none): features supported by @fstype, see %BDFSFeatures for more information. * * Tech category: always available * */ const BDFSFeatures* bd_fs_features (const gchar *fstype, GError **error); #endif /* BD_FS_API */ libblockdev-3.1.1-1/src/lib/plugin_apis/loop.api000066400000000000000000000142351460051510300214450ustar00rootroot00000000000000#include #include #ifndef BD_LOOP_API #define BD_LOOP_API GQuark bd_loop_error_quark (void) { return g_quark_from_static_string ("g-bd-loop-error-quark"); } #define BD_LOOP_ERROR bd_loop_error_quark () typedef enum { BD_LOOP_ERROR_TECH_UNAVAIL, BD_LOOP_ERROR_FAIL, BD_LOOP_ERROR_DEVICE, } BDLoopError; typedef enum { BD_LOOP_TECH_LOOP = 0, } BDLoopTech; typedef enum { BD_LOOP_TECH_MODE_CREATE = 1 << 0, BD_LOOP_TECH_MODE_DESTROY = 1 << 1, BD_LOOP_TECH_MODE_MODIFY = 1 << 2, BD_LOOP_TECH_MODE_QUERY = 1 << 3, } BDLoopTechMode; /** * bd_loop_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDLoopTechMode) for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_loop_is_tech_avail (BDLoopTech tech, guint64 mode, GError **error); #define BD_LOOP_TYPE_INFO (bd_loop_info_get_type ()) GType bd_loop_info_get_type(); /** * BDLoopInfo: * @backing_file: backing file for the give loop device; * @offset: offset of the start of the device (in @backing_file); * @autoclear: whether the autoclear flag is set or not; * @direct_io: whether direct IO is enabled or not; * @part_scan: whether the partition scan is enforced or not; * @read_only: whether the device is read-only or not; */ typedef struct BDLoopInfo { gchar *backing_file; guint64 offset; gboolean autoclear; gboolean direct_io; gboolean part_scan; gboolean read_only; } BDLoopInfo; /** * bd_loop_info_free: (skip) * @info: (nullable): %BDLoopInfo to free * * Frees @info. */ void bd_loop_info_free (BDLoopInfo *info) { if (info == NULL) return; g_free (info->backing_file); g_free (info); } /** * bd_loop_info_copy: (skip) * @info: (nullable): %BDLoopInfo to copy * * Creates a new copy of @info. */ BDLoopInfo* bd_loop_info_copy (BDLoopInfo *info) { if (info == NULL) return NULL; BDLoopInfo *new_info = g_new0 (BDLoopInfo, 1); new_info->backing_file = g_strdup (info->backing_file); new_info->offset = info->offset; new_info->autoclear = info->autoclear; new_info->direct_io = info->direct_io; new_info->part_scan = info->part_scan; new_info->read_only = info->read_only; return new_info; } GType bd_loop_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDLoopInfo", (GBoxedCopyFunc) bd_loop_info_copy, (GBoxedFreeFunc) bd_loop_info_free); } return type; } /** * bd_loop_info: * @loop: name of the loop device to get information about (e.g. "loop0") * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the @loop device or %NULL in case of error * * Tech category: %BD_LOOP_TECH_LOOP-%BD_LOOP_TECH_MODE_QUERY */ BDLoopInfo* bd_loop_info (const gchar *loop, GError **error); /** * bd_loop_get_loop_name: * @file: path of the backing file to get loop name for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): name of the loop device associated with the given @file * * Tech category: %BD_LOOP_TECH_LOOP-%BD_LOOP_TECH_MODE_QUERY */ gchar* bd_loop_get_loop_name (const gchar *file, GError **error); /** * bd_loop_setup: * @file: file to setup as a loop device * @offset: offset of the start of the device (in @file) * @size: maximum size of the device (or 0 to leave unspecified) * @read_only: whether to setup as read-only (%TRUE) or read-write (%FALSE) * @part_scan: whether to enforce partition scan on the newly created device or not * @sector_size: logical sector size for the loop device in bytes (or 0 for default) * @loop_name: (optional) (out): if not %NULL, it is used to store the name of the loop device * @error: (out) (optional): place to store error (if any) * * Returns: whether the @file was successfully setup as a loop device or not * * Tech category: %BD_LOOP_TECH_LOOP-%BD_LOOP_TECH_MODE_CREATE */ gboolean bd_loop_setup (const gchar *file, guint64 offset, guint64 size, gboolean read_only, gboolean part_scan, guint64 sector_size, const gchar **loop_name, GError **error); /** * bd_loop_setup_from_fd: * @fd: file descriptor for a file to setup as a new loop device * @offset: offset of the start of the device (in file given by @fd) * @size: maximum size of the device (or 0 to leave unspecified) * @read_only: whether to setup as read-only (%TRUE) or read-write (%FALSE) * @part_scan: whether to enforce partition scan on the newly created device or not * @sector_size: logical sector size for the loop device in bytes (or 0 for default) * @loop_name: (optional) (out): if not %NULL, it is used to store the name of the loop device * @error: (out) (optional): place to store error (if any) * * Returns: whether an new loop device was successfully setup for @fd or not * * Tech category: %BD_LOOP_TECH_LOOP-%BD_LOOP_TECH_MODE_CREATE */ gboolean bd_loop_setup_from_fd (gint fd, guint64 offset, guint64 size, gboolean read_only, gboolean part_scan, guint64 sector_size, const gchar **loop_name, GError **error); /** * bd_loop_teardown: * @loop: path or name of the loop device to tear down * @error: (out) (optional): place to store error (if any) * * Returns: whether the @loop device was successfully torn down or not * * Tech category: %BD_LOOP_TECH_LOOP-%BD_LOOP_TECH_MODE_DESTROY */ gboolean bd_loop_teardown (const gchar *loop, GError **error); /** * bd_loop_set_autoclear: * @loop: path or name of the loop device * @autoclear: whether to set or unset the autoclear flag * @error: (out) (optional): place to store error (if any) * * Returns: whether the autoclear flag was successfully set on the @loop device or not * * Tech category: %BD_LOOP_TECH_LOOP-%BD_LOOP_TECH_MODE_MODIFY */ gboolean bd_loop_set_autoclear (const gchar *loop, gboolean autoclear, GError **error); #endif /* BD_LOOP_API */ libblockdev-3.1.1-1/src/lib/plugin_apis/lvm.api000066400000000000000000002250261460051510300212740ustar00rootroot00000000000000#include #include #include #ifndef BD_LVM_API #define BD_LVM_API GQuark bd_lvm_error_quark (void) { return g_quark_from_static_string ("g-bd-lvm-error-quark"); } #define BD_LVM_ERROR bd_lvm_error_quark () typedef enum { BD_LVM_ERROR_TECH_UNAVAIL, BD_LVM_ERROR_FAIL, BD_LVM_ERROR_PARSE, BD_LVM_ERROR_NOEXIST, BD_LVM_ERROR_DM_ERROR, BD_LVM_ERROR_NOT_ROOT, BD_LVM_ERROR_CACHE_INVAL, BD_LVM_ERROR_CACHE_NOCACHE, BD_LVM_ERROR_NOT_SUPPORTED, BD_LVM_ERROR_VDO_POLICY_INVAL, BD_LVM_ERROR_DEVICES_DISABLED, } BDLVMError; typedef enum { BD_LVM_CACHE_POOL_STRIPED = 1 << 0, BD_LVM_CACHE_POOL_RAID1 = 1 << 1, BD_LVM_CACHE_POOL_RAID5 = 1 << 2, BD_LVM_CACHE_POOL_RAID6 = 1 << 3, BD_LVM_CACHE_POOL_RAID10 = 1 << 4, BD_LVM_CACHE_POOL_META_STRIPED = 1 << 10, BD_LVM_CACHE_POOL_META_RAID1 = 1 << 11, BD_LVM_CACHE_POOL_META_RAID5 = 1 << 12, BD_LVM_CACHE_POOL_META_RAID6 = 1 << 13, BD_LVM_CACHE_POOL_META_RAID10 = 1 << 14, } BDLVMCachePoolFlags; typedef enum { BD_LVM_CACHE_MODE_UNKNOWN, BD_LVM_CACHE_MODE_WRITETHROUGH, BD_LVM_CACHE_MODE_WRITEBACK, } BDLVMCacheMode; typedef enum { BD_LVM_VDO_MODE_UNKNOWN, BD_LVM_VDO_MODE_RECOVERING, BD_LVM_VDO_MODE_READ_ONLY, BD_LVM_VDO_MODE_NORMAL, } BDLVMVDOOperatingMode; typedef enum { BD_LVM_VDO_COMPRESSION_UNKNOWN, BD_LVM_VDO_COMPRESSION_ONLINE, BD_LVM_VDO_COMPRESSION_OFFLINE, } BDLVMVDOCompressionState; typedef enum { BD_LVM_VDO_INDEX_UNKNOWN, BD_LVM_VDO_INDEX_ERROR, BD_LVM_VDO_INDEX_CLOSED, BD_LVM_VDO_INDEX_OPENING, BD_LVM_VDO_INDEX_CLOSING, BD_LVM_VDO_INDEX_OFFLINE, BD_LVM_VDO_INDEX_ONLINE, } BDLVMVDOIndexState; typedef enum { BD_LVM_VDO_WRITE_POLICY_UNKNOWN, BD_LVM_VDO_WRITE_POLICY_AUTO, BD_LVM_VDO_WRITE_POLICY_SYNC, BD_LVM_VDO_WRITE_POLICY_ASYNC, } BDLVMVDOWritePolicy; #define BD_LVM_TYPE_PVDATA (bd_lvm_pvdata_get_type ()) GType bd_lvm_pvdata_get_type(); /** * BDLVMPVdata: * @pv_name: name of the PV * @pv_uuid: UUID of the PV * @pv_free: size of the free space in the PV * @pv_size: size of the PV * @pe_start: start of the physical extents area (i.e. offset of the first PE) * @vg_name: name of the VG the PV belongs to * @vg_uuid: UUID of the VG the PV belongs to * @vg_size: size of the VG the PV belongs to * @vg_free: size of the free space in the PV's VG * @vg_extent_size: extent size used by the PV's VG * @vg_extent_count: number of extents in the PV's VG * @vg_free_count: number of free extents in the PV's VG * @vg_pv_count: number of PVs that belong to this PV's VG * @pv_tags: (array zero-terminated=1): list of LVM tags for this PV * @missing: whether this PV is missing from the system or not */ typedef struct BDLVMPVdata { gchar *pv_name; gchar *pv_uuid; guint64 pv_free; guint64 pv_size; guint64 pe_start; gchar *vg_name; gchar *vg_uuid; guint64 vg_size; guint64 vg_free; guint64 vg_extent_size; guint64 vg_extent_count; guint64 vg_free_count; guint64 vg_pv_count; gchar **pv_tags; gboolean missing; } BDLVMPVdata; /** * bd_lvm_pvdata_copy: (skip) * @data: (nullable): %BDLVMPVdata to copy * * Creates a new copy of @data. */ BDLVMPVdata* bd_lvm_pvdata_copy (BDLVMPVdata *data) { if (data == NULL) return NULL; BDLVMPVdata *new_data = g_new0 (BDLVMPVdata, 1); new_data->pv_name = g_strdup (data->pv_name); new_data->pv_uuid = g_strdup (data->pv_uuid); new_data->pv_free = data->pv_free; new_data->pv_size = data->pv_size; new_data->pe_start = data->pe_start; new_data->vg_name = g_strdup (data->vg_name); new_data->vg_uuid = g_strdup (data->vg_uuid); new_data->vg_size = data->vg_size; new_data->vg_free = data->vg_free; new_data->vg_extent_size = data->vg_extent_size; new_data->vg_extent_count = data->vg_extent_count; new_data->vg_free_count = data->vg_free_count; new_data->vg_pv_count = data->vg_pv_count; new_data->pv_tags = g_strdupv (data->pv_tags); new_data->missing = data->missing; return new_data; } /** * bd_lvm_pvdata_free: (skip) * @data: (nullable): %BDLVMPVdata to free * * Frees @data. */ void bd_lvm_pvdata_free (BDLVMPVdata *data) { if (data == NULL) return; g_free (data->pv_name); g_free (data->pv_uuid); g_free (data->vg_name); g_free (data->vg_uuid); g_strfreev (data->pv_tags); g_free (data); } GType bd_lvm_pvdata_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDLVMPVdata", (GBoxedCopyFunc) bd_lvm_pvdata_copy, (GBoxedFreeFunc) bd_lvm_pvdata_free); } return type; } #define BD_LVM_TYPE_VGDATA (bd_lvm_vgdata_get_type ()) GType bd_lvm_vgdata_get_type(); /** * BDLVMVGdata: * @name: name of the VG * @uuid: UUID of the VG * @size: size of the VG * @free: size of the free space in the VG * @extent_size: extent size used by the VG * @extent_count: number of extents in the VG * @free_count: number of free extents in the VG * @pv_count: number of PVs that belong to the VG * @exported: whether the VG is exported or not * @vg_tags: (array zero-terminated=1): list of LVM tags for this VG */ typedef struct BDLVMVGdata { gchar *name; gchar *uuid; guint64 size; guint64 free; guint64 extent_size; guint64 extent_count; guint64 free_count; guint64 pv_count; gboolean exported; gchar **vg_tags; } BDLVMVGdata; /** * bd_lvm_vgdata_copy: (skip) * @data: (nullable): %BDLVMVGdata to copy * * Creates a new copy of @data. */ BDLVMVGdata* bd_lvm_vgdata_copy (BDLVMVGdata *data) { if (data == NULL) return NULL; BDLVMVGdata *new_data = g_new0 (BDLVMVGdata, 1); new_data->name = g_strdup (data->name); new_data->uuid = g_strdup (data->uuid); new_data->size = data->size; new_data->free = data->free; new_data->extent_size = data->extent_size; new_data->extent_count = data->extent_count; new_data->free_count = data->free_count; new_data->pv_count = data->pv_count; new_data->exported = data->exported; new_data->vg_tags = g_strdupv (data->vg_tags); return new_data; } /** * bd_lvm_vgdata_free: (skip) * @data: (nullable): %BDLVMVGdata to free * * Frees @data. */ void bd_lvm_vgdata_free (BDLVMVGdata *data) { if (data == NULL) return; g_free (data->name); g_free (data->uuid); g_strfreev (data->vg_tags); g_free (data); } GType bd_lvm_vgdata_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDLVMVGdata", (GBoxedCopyFunc) bd_lvm_vgdata_copy, (GBoxedFreeFunc) bd_lvm_vgdata_free); } return type; } #define BD_LVM_TYPE_SEGDATA (bd_lvm_segdata_get_type ()) GType bd_lvm_segdata_get_type(); /** * BDLVMSEGdata: * @size_pe: Size of this segment in extents * @pv_start_pe: Where it starts in the physical volume in extents * @pvdev: Device name of the physical volume or NULL */ typedef struct BDLVMSEGdata { guint64 size_pe; guint64 pv_start_pe; gchar *pvdev; } BDLVMSEGdata; /** * bd_lvm_segdata_copy: (skip) * @data: (nullable): %BDLVMSEGdata to copy * * Creates a new copy of @data. */ BDLVMSEGdata* bd_lvm_segdata_copy (BDLVMSEGdata *data) { if (data == NULL) return NULL; BDLVMSEGdata *new_data = g_new0 (BDLVMSEGdata, 1); new_data->size_pe = data->size_pe; new_data->pv_start_pe = data->pv_start_pe; new_data->pvdev = g_strdup (data->pvdev); return new_data; } /** * bd_lvm_segdata_free: (skip) * @data: (nullable): %BDLVMSEGdata to free * * Frees @data. */ void bd_lvm_segdata_free (BDLVMSEGdata *data) { if (data == NULL) return; g_free (data->pvdev); g_free (data); } GType bd_lvm_segdata_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDLVMSEGdata", (GBoxedCopyFunc) bd_lvm_segdata_copy, (GBoxedFreeFunc) bd_lvm_segdata_free) ; } return type; } static BDLVMSEGdata **copy_segs (BDLVMSEGdata **segs) { int i, len; BDLVMSEGdata **new_segs; if (segs == NULL) return NULL; for (len = 0; segs[len]; len++) ; new_segs = g_new0 (BDLVMSEGdata *, len+1); for (i = 0; i < len; i++) new_segs[i] = bd_lvm_segdata_copy (segs[i]); return new_segs; } static void free_segs (BDLVMSEGdata **segs) { int i; if (segs == NULL) return; for (i = 0; segs[i]; i++) bd_lvm_segdata_free (segs[i]); (g_free) (segs); } #define BD_LVM_TYPE_LVDATA (bd_lvm_lvdata_get_type ()) GType bd_lvm_lvdata_get_type(); /** * BDLVMLVdata: * @lv_name: name of the LV * @vg_name: name of the VG the LV belongs to * @uuid: UUID of the LV * @size: size of the LV * @attr: attributes of the LV * @segtype: segment type of the LV * @origin: origin of the LV (for snapshots, etc.) * @pool_lv: pool LV of the LV (for thin and cached LVs) * @data_lv: data LV of the LV (for thin and cache pools) * @metadata_lv: metadata LV of the LV (for thin and cache pools) * @roles: comma separated list of this LV's roles * @move_pv: source physical volume of a temporary logical volume created with the pvmove command * @data_percent: available data space in a thin pool * @metadata_percent: available metadata space in a thin pool * @copy_percent: synchronization percentage of a mirrored logical volume * @lv_tags: (array zero-terminated=1): list of LVM tags for this LV * @data_lvs: (nullable) (array zero-terminated=1): list of data sub-LVs this LV (for raids, etc). * @metadata_lvs: (nullable) (array zero-terminated=1): list of metadata sub-LVS for this LV (for raids, etc). * @segs: (nullable) (array zero-terminated=1): The segments of this LV. * * The @segs, @data_lvs, and @metadata_lvs fields are only filled by a * call to bd_lvm_lvinfo_tree or bd_lvm_lvs_tree. They are all NULL * normally. If they are filled, they follow these rules: * * A LV is either stored directly on physical volumes, or is made up * of sub-LVs. If it is stored on PVs, the @segs list is non-empty * and the @data_lvs and @metadata_lvs fields are both NULL. If it is * made up of sub-LVs, then @segs is NULL, @data_lvs is non-empty and * @metadata_lvs might or might not be empty but is non-NULL. The * sub-LVs contained in @data_lv and @metadata_lv are always included * in @data_lvs and @metadata_lvs, respectively. * * For a partial LV, the @segs list might not be complete; i.e., the * sum of the sizes of the listed segments might not be equal to the * size reported for the LV itself. * * Also, the order of entries in @segs must be assumed to be random; * it does not correspond to the order of segments in the logical * volume itself. */ typedef struct BDLVMLVdata { gchar *lv_name; gchar *vg_name; gchar *uuid; guint64 size; gchar *attr; gchar *segtype; gchar *origin; gchar *pool_lv; gchar *data_lv; gchar *metadata_lv; gchar *roles; gchar *move_pv; guint64 data_percent; guint64 metadata_percent; guint64 copy_percent; gchar **lv_tags; gchar **data_lvs; gchar **metadata_lvs; BDLVMSEGdata **segs; } BDLVMLVdata; /** * bd_lvm_lvdata_copy: (skip) * @data: (nullable): %BDLVMLVdata to copy * * Creates a new copy of @data. */ BDLVMLVdata* bd_lvm_lvdata_copy (BDLVMLVdata *data) { if (data == NULL) return NULL; BDLVMLVdata *new_data = g_new0 (BDLVMLVdata, 1); new_data->lv_name = g_strdup (data->lv_name); new_data->vg_name = g_strdup (data->vg_name); new_data->uuid = g_strdup (data->uuid); new_data->size = data->size; new_data->attr = g_strdup (data->attr); new_data->segtype = g_strdup (data->segtype); new_data->origin = g_strdup (data->origin); new_data->pool_lv = g_strdup (data->pool_lv); new_data->data_lv = g_strdup (data->data_lv); new_data->metadata_lv = g_strdup (data->metadata_lv); new_data->roles = g_strdup (data->roles); new_data->move_pv = g_strdup (data->move_pv); new_data->data_percent = data->data_percent; new_data->metadata_percent = data->metadata_percent; new_data->copy_percent = data->copy_percent; new_data->lv_tags = g_strdupv (data->lv_tags); new_data->data_lvs = g_strdupv (data->data_lvs); new_data->metadata_lvs = g_strdupv (data->metadata_lvs); new_data->segs = copy_segs (data->segs); return new_data; } /** * bd_lvm_lvdata_free: (skip) * @data: (nullable): %BDLVMLVdata to free * * Frees @data. */ void bd_lvm_lvdata_free (BDLVMLVdata *data) { if (data == NULL) return; g_free (data->lv_name); g_free (data->vg_name); g_free (data->uuid); g_free (data->attr); g_free (data->segtype); g_free (data->origin); g_free (data->pool_lv); g_free (data->data_lv); g_free (data->metadata_lv); g_free (data->roles); g_free (data->move_pv); g_strfreev (data->lv_tags); g_strfreev (data->data_lvs); g_strfreev (data->metadata_lvs); free_segs (data->segs); g_free (data); } GType bd_lvm_lvdata_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDLVMLVdata", (GBoxedCopyFunc) bd_lvm_lvdata_copy, (GBoxedFreeFunc) bd_lvm_lvdata_free); } return type; } #define BD_LVM_TYPE_VDOPOOLDATA (bd_lvm_vdopooldata_get_type ()) GType bd_lvm_vdopooldata_get_type(); /** * BDLVMVDOPooldata: * @operating_mode: operating mode of the VDO pool (e.g. %BD_LVM_VDO_MODE_NORMAL) * @compression_state: state of the compression * @index_state: state of the VDO index * @write_policy: write policy of the VDO LV * @used_size: currently used space * @saving_percent: percentage of physical blocks saved * @index_memory_size: index memory size of the VDO volume * @deduplication: whether deduplication is enabled * @compression: whether compression is enabled */ typedef struct BDLVMVDOPooldata { BDLVMVDOOperatingMode operating_mode; BDLVMVDOCompressionState compression_state; BDLVMVDOIndexState index_state; BDLVMVDOWritePolicy write_policy; guint64 used_size; gint32 saving_percent; guint64 index_memory_size; gboolean deduplication; gboolean compression; } BDLVMVDOPooldata; /** * bd_lvm_vdopooldata_copy: (skip) * @data: (nullable): %BDLVMVDOPooldata to copy * * Creates a new copy of @data. */ BDLVMVDOPooldata* bd_lvm_vdopooldata_copy (BDLVMVDOPooldata *data) { if (data == NULL) return NULL; BDLVMVDOPooldata *new_data = g_new0 (BDLVMVDOPooldata, 1); new_data->operating_mode = data->operating_mode; new_data->compression_state = data->compression_state; new_data->index_state = data->index_state; new_data->write_policy = data->write_policy; new_data->used_size = data->used_size; new_data->saving_percent = data->saving_percent; new_data->index_memory_size = data->index_memory_size; new_data->deduplication = data->deduplication; new_data->compression = data->compression; return new_data; } /** * bd_lvm_vdopooldata_free: (skip) * @data: (nullable): %BDLVMVDOPooldata to free * * Frees @data. */ void bd_lvm_vdopooldata_free (BDLVMVDOPooldata *data) { if (data == NULL) return; g_free (data); } GType bd_lvm_vdopooldata_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDLVMVDOPooldata", (GBoxedCopyFunc) bd_lvm_vdopooldata_copy, (GBoxedFreeFunc) bd_lvm_vdopooldata_free); } return type; } #define BD_LVM_TYPE_VDO_STATS (bd_lvm_vdo_stats_get_type ()) GType bd_lvm_vdo_stats_get_type(); /** * BDLVMVDOStats: * @block_size: The block size of a VDO volume, in bytes. * @logical_block_size: The logical block size, in bytes. * @physical_blocks: The total number of physical blocks allocated for a VDO volume. * @data_blocks_used: The number of physical blocks currently in use by a VDO volume * to store data. * @overhead_blocks_used: The number of physical blocks currently in use by a VDO volume * to store VDO metadata. * @logical_blocks_used: The number of logical blocks currently mapped. * @used_percent: The percentage of physical blocks used on a VDO volume * (= used blocks / allocated blocks * 100). * @saving_percent: The percentage of physical blocks saved on a VDO volume * (= [logical blocks used - physical blocks used] / logical blocks used). * @write_amplification_ratio: The average number of block writes to the underlying storage * per block written to the VDO device. */ typedef struct BDLVMVDOStats { gint64 block_size; gint64 logical_block_size; gint64 physical_blocks; gint64 data_blocks_used; gint64 overhead_blocks_used; gint64 logical_blocks_used; gint64 used_percent; gint64 saving_percent; gdouble write_amplification_ratio; } BDLVMVDOStats; /** * bd_lvm_vdo_stats_copy: (skip) * @stats: (nullable): %BDLVMVDOStats to copy * * Creates a new copy of @stats. */ BDLVMVDOStats* bd_lvm_vdo_stats_copy (BDLVMVDOStats *stats) { if (stats == NULL) return NULL; BDLVMVDOStats *new_stats = g_new0 (BDLVMVDOStats, 1); new_stats->block_size = stats->block_size; new_stats->logical_block_size = stats->logical_block_size; new_stats->physical_blocks = stats->physical_blocks; new_stats->data_blocks_used = stats->data_blocks_used; new_stats->overhead_blocks_used = stats->overhead_blocks_used; new_stats->logical_blocks_used = stats->logical_blocks_used; new_stats->used_percent = stats->used_percent; new_stats->saving_percent = stats->saving_percent; new_stats->write_amplification_ratio = stats->write_amplification_ratio; return new_stats; } /** * bd_lvm_vdo_stats_free: (skip) * @stats: (nullable): %BDLVMVDOStats to free * * Frees @stats. */ void bd_lvm_vdo_stats_free (BDLVMVDOStats *stats) { if (stats == NULL) return; g_free (stats); } GType bd_lvm_vdo_stats_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDLVMVDOStats", (GBoxedCopyFunc) bd_lvm_vdo_stats_copy, (GBoxedFreeFunc) bd_lvm_vdo_stats_free); } return type; } #define BD_LVM_TYPE_CACHE_STATS (bd_lvm_cache_stats_get_type ()) GType bd_lvm_cache_stats_get_type(); /** * BDLVMCacheStats: * @block_size: block size used by the cache * @cache_size: size of the cache * @cache_used: size of the used space in the cache * @md_block_size: block size used for cache metadata * @md_size: size of the metadata space of the cache * @md_used: size of the used metadata space in the cache * @read_hits: number of read hits * @read_misses: number of read misses * @write_hits: number of write hits * @write_misses: number of write misses * @mode: mode the cache is operating in */ typedef struct BDLVMCacheStats { guint64 block_size; guint64 cache_size; guint64 cache_used; guint64 md_block_size; guint64 md_size; guint64 md_used; guint64 read_hits; guint64 read_misses; guint64 write_hits; guint64 write_misses; BDLVMCacheMode mode; } BDLVMCacheStats; /** * bd_lvm_cache_stats_copy: (skip) * @data: (nullable): %BDLVMCacheStats to copy * * Creates a new copy of @data. */ BDLVMCacheStats* bd_lvm_cache_stats_copy (BDLVMCacheStats *data) { if (data == NULL) return NULL; BDLVMCacheStats *new = g_new0 (BDLVMCacheStats, 1); new->block_size = data->block_size; new->cache_size = data->cache_size; new->cache_used = data->cache_used; new->md_block_size = data->md_block_size; new->md_size = data->md_size; new->md_used = data->md_used; new->read_hits = data->read_hits; new->read_misses = data->read_misses; new->write_hits = data->write_hits; new->write_misses = data->write_misses; new->mode = data->mode; return new; } /** * bd_lvm_cache_stats_free: (skip) * @data: (nullable): %BDLVMCacheStats to free * * Frees @data. */ void bd_lvm_cache_stats_free (BDLVMLVdata *data) { g_free (data); } GType bd_lvm_cache_stats_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDLVMCacheStats", (GBoxedCopyFunc) bd_lvm_cache_stats_copy, (GBoxedFreeFunc) bd_lvm_cache_stats_free); } return type; } typedef enum { BD_LVM_TECH_BASIC = 0, BD_LVM_TECH_BASIC_SNAP, BD_LVM_TECH_THIN, BD_LVM_TECH_CACHE, BD_LVM_TECH_CALCS, BD_LVM_TECH_THIN_CALCS, BD_LVM_TECH_CACHE_CALCS, BD_LVM_TECH_GLOB_CONF, BD_LVM_TECH_VDO, BD_LVM_TECH_WRITECACHE, BD_LVM_TECH_DEVICES, BD_LVM_TECH_SHARED, } BDLVMTech; typedef enum { BD_LVM_TECH_MODE_CREATE = 1 << 0, BD_LVM_TECH_MODE_REMOVE = 1 << 2, BD_LVM_TECH_MODE_MODIFY = 1 << 3, BD_LVM_TECH_MODE_QUERY = 1 << 4, } BDLVMTechMode; /** * bd_lvm_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDLVMTechMode) for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_lvm_is_tech_avail (BDLVMTech tech, guint64 mode, GError **error); /** * bd_lvm_is_supported_pe_size: * @size: size (in bytes) to test * @error: (out) (optional): place to store error (if any) * * Returns: whether the given size is supported physical extent size or not * * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored) */ gboolean bd_lvm_is_supported_pe_size (guint64 size, GError **error); /** * bd_lvm_get_supported_pe_sizes: * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full) (array fixed-size=25): list of supported PE sizes * * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored) */ guint64 *bd_lvm_get_supported_pe_sizes (GError **error); /** * bd_lvm_get_max_lv_size: * @error: (out) (optional): place to store error (if any) * * Returns: maximum LV size in bytes * * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored) */ guint64 bd_lvm_get_max_lv_size (GError **error); /** * bd_lvm_round_size_to_pe: * @size: size to be rounded * @pe_size: physical extent (PE) size or 0 to use the default * @roundup: whether to round up or down (ceil or floor) * @error: (out) (optional): place to store error (if any) * * Returns: @size rounded to @pe_size according to the @roundup * * Rounds given @size up/down to a multiple of @pe_size according to the value * of the @roundup parameter. If the rounded value is too big to fit in the * return type, the result is rounded down (floored) regardless of the @roundup * parameter. * * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored) */ guint64 bd_lvm_round_size_to_pe (guint64 size, guint64 pe_size, gboolean roundup, GError **error); /** * bd_lvm_get_lv_physical_size: * @lv_size: LV size * @pe_size: PE size * @error: (out) (optional): place to store error (if any) * * Returns: space taken on disk(s) by the LV with given @size * * Gives number of bytes needed for an LV with the size @lv_size on an LVM stack * using given @pe_size. * * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored) */ guint64 bd_lvm_get_lv_physical_size (guint64 lv_size, guint64 pe_size, GError **error); /** * bd_lvm_get_thpool_padding: * @size: size of the thin pool * @pe_size: PE size or 0 if the default value should be used * @included: if padding is already included in the size * @error: (out) (optional): place to store error (if any) * * Returns: size of the padding needed for a thin pool with the given @size * according to the @pe_size and @included * * Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored) */ guint64 bd_lvm_get_thpool_padding (guint64 size, guint64 pe_size, gboolean included, GError **error); /** * bd_lvm_get_thpool_meta_size: * @size: size of the thin pool * @chunk_size: chunk size of the thin pool or 0 to use the default * @n_snapshots: ignored * @error: (out) (optional): place to store error (if any) * * Note: This function will be changed in 3.0: the @n_snapshots parameter * is currently not used and will be removed. * * Returns: recommended size of the metadata space for the specified pool * * Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored) */ guint64 bd_lvm_get_thpool_meta_size (guint64 size, guint64 chunk_size, guint64 n_snapshots, GError **error); /** * bd_lvm_is_valid_thpool_md_size: * @size: the size to be tested * @error: (out) (optional): place to store error (if any) * * Returns: whether the given size is a valid thin pool metadata size or not * * Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored) */ gboolean bd_lvm_is_valid_thpool_md_size (guint64 size, GError **error); /** * bd_lvm_is_valid_thpool_chunk_size: * @size: the size to be tested * @discard: whether discard/TRIM is required to be supported or not * @error: (out) (optional): place to store error (if any) * * Returns: whether the given size is a valid thin pool chunk size or not * * Tech category: %BD_LVM_TECH_THIN_CALCS no mode (it is ignored) */ gboolean bd_lvm_is_valid_thpool_chunk_size (guint64 size, gboolean discard, GError **error); /** * bd_lvm_pvcreate: * @device: the device to make PV from * @data_alignment: data (first PE) alignment or 0 to use the default * @metadata_size: size of the area reserved for metadata or 0 to use the default * @extra: (nullable) (array zero-terminated=1): extra options for the PV creation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the PV was successfully created or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_pvcreate (const gchar *device, guint64 data_alignment, guint64 metadata_size, const BDExtraArg **extra, GError **error); /** * bd_lvm_pvresize: * @device: the device to resize * @size: the new requested size of the PV or 0 if it should be adjusted to device's size * @extra: (nullable) (array zero-terminated=1): extra options for the PV resize * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the PV's size was successfully changed or not * * If given @size different from 0, sets the PV's size to the given value (see * pvresize(8)). If given @size 0, adjusts the PV's size to the underlying * block device's size. * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_pvresize (const gchar *device, guint64 size, const BDExtraArg **extra, GError **error); /** * bd_lvm_pvremove: * @device: the PV device to be removed/destroyed * @extra: (nullable) (array zero-terminated=1): extra options for the PV removal * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the PV was successfully removed/destroyed or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_REMOVE */ gboolean bd_lvm_pvremove (const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_lvm_pvmove: * @src: the PV device to move extents off of * @dest: (nullable): the PV device to move extents onto or %NULL * @extra: (nullable) (array zero-terminated=1): extra options for the PV move * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the extents from the @src PV where successfully moved or not * * If @dest is %NULL, VG allocation rules are used for the extents from the @src * PV (see pvmove(8)). * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_pvmove (const gchar *src, const gchar *dest, const BDExtraArg **extra, GError **error); /** * bd_lvm_pvscan: * @device: (nullable): the device to scan for PVs or %NULL * @update_cache: whether to update the lvmetad cache or not * @extra: (nullable) (array zero-terminated=1): extra options for the PV scan * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the system or @device was successfully scanned for PVs or not * * The @device argument is used only if @update_cache is %TRUE. Otherwise the * whole system is scanned for PVs. * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ gboolean bd_lvm_pvscan (const gchar *device, gboolean update_cache, const BDExtraArg **extra, GError **error); /** * bd_lvm_add_pv_tags: * @device: the device to set PV tags for * @tags: (array zero-terminated=1): list of tags to add * @error: (out) (optional): place to store error (if any) * * Returns: whether the tags were successfully added to @device or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ gboolean bd_lvm_add_pv_tags (const gchar *device, const gchar **tags, GError **error); /** * bd_lvm_delete_pv_tags: * @device: the device to set PV tags for * @tags: (array zero-terminated=1): list of tags to remove * @error: (out) (optional): place to store error (if any) * * Returns: whether the tags were successfully removed from @device or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ gboolean bd_lvm_delete_pv_tags (const gchar *device, const gchar **tags, GError **error); /** * bd_lvm_pvinfo: * @device: a PV to get information about or %NULL * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the PV on the given @device or * %NULL in case of error (the @error) gets populated in those cases) * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ BDLVMPVdata* bd_lvm_pvinfo (const gchar *device, GError **error); /** * bd_lvm_pvs: * @error: (out) (optional): place to store error (if any) * * Returns: (array zero-terminated=1): information about PVs found in the system * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ BDLVMPVdata** bd_lvm_pvs (GError **error); /** * bd_lvm_vgcreate: * @name: name of the newly created VG * @pv_list: (array zero-terminated=1): list of PVs the newly created VG should use * @pe_size: PE size or 0 if the default value should be used * @extra: (nullable) (array zero-terminated=1): extra options for the VG creation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the VG @name was successfully created or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_vgcreate (const gchar *name, const gchar **pv_list, guint64 pe_size, const BDExtraArg **extra, GError **error); /** * bd_lvm_vgremove: * @vg_name: name of the to be removed VG * @extra: (nullable) (array zero-terminated=1): extra options for the VG removal * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the VG was successfully removed or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_REMOVE */ gboolean bd_lvm_vgremove (const gchar *vg_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_vgrename: * @old_vg_name: old name of the VG to rename * @new_vg_name: new name for the @old_vg_name VG * @extra: (nullable) (array zero-terminated=1): extra options for the VG rename * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the VG was successfully renamed or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vgrename (const gchar *old_vg_name, const gchar *new_vg_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_vgactivate: * @vg_name: name of the to be activated VG * @extra: (nullable) (array zero-terminated=1): extra options for the VG activation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the VG was successfully activated or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vgactivate (const gchar *vg_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_vgdeactivate: * @vg_name: name of the to be deactivated VG * @extra: (nullable) (array zero-terminated=1): extra options for the VG deactivation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the VG was successfully deactivated or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vgdeactivate (const gchar *vg_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_vgextend: * @vg_name: name of the to be extended VG * @device: PV device to extend the @vg_name VG with * @extra: (nullable) (array zero-terminated=1): extra options for the VG extension * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the VG @vg_name was successfully extended with the given @device or not. * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vgextend (const gchar *vg_name, const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_lvm_vgreduce: * @vg_name: name of the to be reduced VG * @device: (nullable): PV device the @vg_name VG should be reduced of or %NULL * if the VG should be reduced of the missing PVs * @extra: (nullable) (array zero-terminated=1): extra options for the VG reduction * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the VG @vg_name was successfully reduced of the given @device or not * * Note: This function does not move extents off of the PV before removing * it from the VG. You must do that first by calling #bd_lvm_pvmove. * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vgreduce (const gchar *vg_name, const gchar *device, const BDExtraArg **extra, GError **error); /** * bd_lvm_add_vg_tags: * @vg_name: the VG to set tags on * @tags: (array zero-terminated=1): list of tags to add * @error: (out) (optional): place to store error (if any) * * Returns: whether the tags were successfully added to @vg_name or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ gboolean bd_lvm_add_vg_tags (const gchar *vg_name, const gchar **tags, GError **error); /** * bd_lvm_delete_vg_tags: * @vg_name: the VG to set tags on * @tags: (array zero-terminated=1): list of tags to remove * @error: (out) (optional): place to store error (if any) * * Returns: whether the tags were successfully removed from @vg_name or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ gboolean bd_lvm_delete_vg_tags (const gchar *vg_name, const gchar **tags, GError **error); /** * bd_lvm_vglock_start: * @vg_name: a shared VG to start the lockspace in lvmlockd * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the lock was successfully started for @vg_name or not * * Tech category: %BD_LVM_TECH_SHARED-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vglock_start (const gchar *vg_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_vglock_stop: * @vg_name: a shared VG to stop the lockspace in lvmlockd * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the lock was successfully stopped for @vg_name or not * * Tech category: %BD_LVM_TECH_SHARED-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vglock_stop (const gchar *vg_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_vginfo: * @vg_name: a VG to get information about * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the @vg_name VG or %NULL in case * of error (the @error) gets populated in those cases) * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ BDLVMVGdata* bd_lvm_vginfo (const gchar *vg_name, GError **error); /** * bd_lvm_vgs: * @error: (out) (optional): place to store error (if any) * * Returns: (array zero-terminated=1): information about VGs found in the system * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ BDLVMVGdata** bd_lvm_vgs (GError **error); /** * bd_lvm_lvorigin: * @vg_name: name of the VG containing the queried LV * @lv_name: name of the queried LV * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): the origin volume for the @vg_name/@lv_name LV or * %NULL if failed to determine (@error) is set in those cases) * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ gchar* bd_lvm_lvorigin (const gchar *vg_name, const gchar *lv_name, GError **error); /** * bd_lvm_lvcreate: * @vg_name: name of the VG to create a new LV in * @lv_name: name of the to-be-created LV * @size: requested size of the new LV * @type: (nullable): type of the new LV ("striped", "raid1",..., see lvcreate (8)) * @pv_list: (nullable) (array zero-terminated=1): list of PVs the newly created LV should use or %NULL * if not specified * @extra: (nullable) (array zero-terminated=1): extra options for the LV creation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the given @vg_name/@lv_name LV was successfully created or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_lvcreate (const gchar *vg_name, const gchar *lv_name, guint64 size, const gchar *type, const gchar **pv_list, const BDExtraArg **extra, GError **error); /** * bd_lvm_lvremove: * @vg_name: name of the VG containing the to-be-removed LV * @lv_name: name of the to-be-removed LV * @force: whether to force removal or not * @extra: (nullable) (array zero-terminated=1): extra options for the LV removal * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @vg_name/@lv_name LV was successfully removed or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_REMOVE */ gboolean bd_lvm_lvremove (const gchar *vg_name, const gchar *lv_name, gboolean force, const BDExtraArg **extra, GError **error); /** * bd_lvm_lvrename: * @vg_name: name of the VG containing the to-be-renamed LV * @lv_name: name of the to-be-renamed LV * @new_name: new name for the @vg_name/@lv_name LV * @extra: (nullable) (array zero-terminated=1): extra options for the LV rename * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @vg_name/@lv_name LV was successfully renamed to * @vg_name/@new_name or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_lvrename (const gchar *vg_name, const gchar *lv_name, const gchar *new_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_lvresize: * @vg_name: name of the VG containing the to-be-resized LV * @lv_name: name of the to-be-resized LV * @size: the requested new size of the LV * @extra: (nullable) (array zero-terminated=1): extra options for the LV resize * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @vg_name/@lv_name LV was successfully resized or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 size, const BDExtraArg **extra, GError **error); /** * bd_lvm_lvrepair: * @vg_name: name of the VG containing the to-be-repaired LV * @lv_name: name of the to-be-repaired LV * @pv_list: (array zero-terminated=1): list of PVs to be used for the repair * @extra: (nullable) (array zero-terminated=1): extra options for the LV repair * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @vg_name/@lv_name LV was successfully repaired or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_lvrepair (const gchar *vg_name, const gchar *lv_name, const gchar **pv_list, const BDExtraArg **extra, GError **error); /** * bd_lvm_lvactivate: * @vg_name: name of the VG containing the to-be-activated LV * @lv_name: name of the to-be-activated LV * @ignore_skip: whether to ignore the skip flag or not * @shared: whether to activate the LV in shared mode (used for shared LVM setups with lvmlockd, * use %FALSE if not sure) * @extra: (nullable) (array zero-terminated=1): extra options for the LV activation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @vg_name/@lv_name LV was successfully activated or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error); /** * bd_lvm_lvdeactivate: * @vg_name: name of the VG containing the to-be-deactivated LV * @lv_name: name of the to-be-deactivated LV * @extra: (nullable) (array zero-terminated=1): extra options for the LV deactivation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @vg_name/@lv_name LV was successfully deactivated or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_lvdeactivate (const gchar *vg_name, const gchar *lv_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_lvsnapshotcreate: * @vg_name: name of the VG containing the LV a new snapshot should be created of * @origin_name: name of the LV a new snapshot should be created of * @snapshot_name: name of the to-be-created snapshot * @size: requested size for the snapshot * @extra: (nullable) (array zero-terminated=1): extra options for the LV snapshot creation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @snapshot_name snapshot of the @vg_name/@origin_name LV * was successfully created or not. * * Tech category: %BD_LVM_TECH_BASIC_SNAP-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_lvsnapshotcreate (const gchar *vg_name, const gchar *origin_name, const gchar *snapshot_name, guint64 size, const BDExtraArg **extra, GError **error); /** * bd_lvm_lvsnapshotmerge: * @vg_name: name of the VG containing the to-be-merged LV snapshot * @snapshot_name: name of the to-be-merged LV snapshot * @extra: (nullable) (array zero-terminated=1): extra options for the LV snapshot merge * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @vg_name/@snapshot_name LV snapshot was successfully merged or not * * Tech category: %BD_LVM_TECH_BASIC_SNAP-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_lvsnapshotmerge (const gchar *vg_name, const gchar *snapshot_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_add_lv_tags: * @vg_name: name of the VG that contains the LV to set tags on * @lv_name: name of the LV to set tags on * @tags: (array zero-terminated=1): list of tags to add * @error: (out) (optional): place to store error (if any) * * Returns: whether the tags were successfully added to @device or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ gboolean bd_lvm_add_lv_tags (const gchar *vg_name, const gchar *lv_name, const gchar **tags, GError **error); /** * bd_lvm_delete_lv_tags: * @vg_name: name of the VG that contains the LV to set tags on * @lv_name: name of the LV to set tags on * @tags: (array zero-terminated=1): list of tags to remove * @error: (out) (optional): place to store error (if any) * * Returns: whether the tags were successfully removed from @device or not * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ gboolean bd_lvm_delete_lv_tags (const gchar *vg_name, const gchar *lv_name, const gchar **tags, GError **error); /** * bd_lvm_lvinfo: * @vg_name: name of the VG that contains the LV to get information about * @lv_name: name of the LV to get information about * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the @vg_name/@lv_name LV or %NULL in case * of error (the @error) gets populated in those cases) * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ BDLVMLVdata* bd_lvm_lvinfo (const gchar *vg_name, const gchar *lv_name, GError **error); /** * bd_lvm_lvinfo_tree: * @vg_name: name of the VG that contains the LV to get information about * @lv_name: name of the LV to get information about * @error: (out) (optional): place to store error (if any) * * This function will fill out the data_lvs, metadata_lvs, and segs fields as well. * * Returns: (transfer full): information about the @vg_name/@lv_name LV or %NULL in case * of error (the @error) gets populated in those cases) * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ BDLVMLVdata* bd_lvm_lvinfo_tree (const gchar *vg_name, const gchar *lv_name, GError **error); /** * bd_lvm_lvs: * @vg_name: (nullable): name of the VG to get information about LVs from * @error: (out) (optional): place to store error (if any) * * Returns: (array zero-terminated=1): information about LVs found in the given * @vg_name VG or in system if @vg_name is %NULL * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ BDLVMLVdata** bd_lvm_lvs (const gchar *vg_name, GError **error); /** * bd_lvm_lvs_tree: * @vg_name: (nullable): name of the VG to get information about LVs from * @error: (out) (optional): place to store error (if any) * * This function will fill out the data_lvs, metadata_lvs, and segs fields as well. * * Returns: (array zero-terminated=1): information about LVs found in the given * @vg_name VG or in system if @vg_name is %NULL. * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ BDLVMLVdata** bd_lvm_lvs_tree (const gchar *vg_name, GError **error); /** * bd_lvm_thpoolcreate: * @vg_name: name of the VG to create a thin pool in * @lv_name: name of the to-be-created pool LV * @size: requested size of the to-be-created pool * @md_size: requested metadata size or 0 to use the default * @chunk_size: requested chunk size or 0 to use the default * @profile: (nullable): profile to use (see lvm(8) for more information) or %NULL to use * the default * @extra: (nullable) (array zero-terminated=1): extra options for the thin pool creation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @vg_name/@lv_name thin pool was successfully created or not * * Tech category: %BD_LVM_TECH_THIN-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_thpoolcreate (const gchar *vg_name, const gchar *lv_name, guint64 size, guint64 md_size, guint64 chunk_size, const gchar *profile, const BDExtraArg **extra, GError **error); /** * bd_lvm_thlvcreate: * @vg_name: name of the VG containing the thin pool providing extents for the to-be-created thin LV * @pool_name: name of the pool LV providing extents for the to-be-created thin LV * @lv_name: name of the to-be-created thin LV * @size: requested virtual size of the to-be-created thin LV * @extra: (nullable) (array zero-terminated=1): extra options for the thin LV creation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @vg_name/@lv_name thin LV was successfully created or not * * Tech category: %BD_LVM_TECH_THIN-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_thlvcreate (const gchar *vg_name, const gchar *pool_name, const gchar *lv_name, guint64 size, const BDExtraArg **extra, GError **error); /** * bd_lvm_thlvpoolname: * @vg_name: name of the VG containing the queried thin LV * @lv_name: name of the queried thin LV * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): the name of the pool volume for the @vg_name/@lv_name * thin LV or %NULL if failed to determine (@error) is set in those cases) * * Tech category: %BD_LVM_TECH_THIN-%BD_LVM_TECH_MODE_QUERY */ gchar* bd_lvm_thlvpoolname (const gchar *vg_name, const gchar *lv_name, GError **error); /** * bd_lvm_thsnapshotcreate: * @vg_name: name of the VG containing the thin LV a new snapshot should be created of * @origin_name: name of the thin LV a new snapshot should be created of * @snapshot_name: name of the to-be-created snapshot * @pool_name: (nullable): name of the thin pool to create the snapshot in or %NULL if not specified * @extra: (nullable) (array zero-terminated=1): extra options for the thin LV snapshot creation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @snapshot_name snapshot of the @vg_name/@origin_name * thin LV was successfully created or not. * * Tech category: %BD_LVM_TECH_THIN-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_thsnapshotcreate (const gchar *vg_name, const gchar *origin_name, const gchar *snapshot_name, const gchar *pool_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_set_global_config: * @new_config: (nullable): string representation of the new global LVM * configuration to set or %NULL to reset to default * @error: (out) (optional): place to store error (if any) * * Returns: whether the new requested global config @new_config was successfully * set or not * * Tech category: %BD_LVM_TECH_GLOB_CONF no mode (it is ignored) */ gboolean bd_lvm_set_global_config (const gchar *new_config, GError **error); /** * bd_lvm_get_global_config: * @error: (out) (optional): place to store error (if any) * * Returns: a copy of a string representation of the currently set LVM global * configuration * * Tech category: %BD_LVM_TECH_GLOB_CONF no mode (it is ignored) */ gchar* bd_lvm_get_global_config (GError **error); /** * bd_lvm_set_devices_filter: * @devices: (nullable) (array zero-terminated=1): list of devices for lvm commands to work on * @error: (out) (optional): place to store error (if any) * * Returns: whether the devices filter was successfully set or not * * Tech category: %BD_LVM_TECH_DEVICES no mode (it is ignored) */ gboolean bd_lvm_set_devices_filter (const gchar **devices, GError **error); /** * bd_lvm_get_devices_filter: * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full) (array zero-terminated=1): a copy of a string representation of * the currently set LVM devices filter * * Tech category: %BD_LVM_TECH_DEVICES no mode (it is ignored) */ gchar** bd_lvm_get_devices_filter (GError **error); /** * bd_lvm_cache_get_default_md_size: * @cache_size: size of the cache to determine MD size for * @error: (out) (optional): place to store error (if any) * * Returns: recommended default size of the cache metadata LV or 0 in case of error * * Tech category: %BD_LVM_TECH_CACHE_CALCS no mode (it is ignored) */ guint64 bd_lvm_cache_get_default_md_size (guint64 cache_size, GError **error); /** * bd_lvm_cache_get_mode_str: * @mode: mode to get the string representation for * @error: (out) (optional): place to store error (if any) * * Returns: string representation of @mode or %NULL in case of error * * Tech category: always provided/supported */ const gchar* bd_lvm_cache_get_mode_str (BDLVMCacheMode mode, GError **error); /** * bd_lvm_cache_get_mode_from_str: * @mode_str: string representation of a cache mode * @error: (out) (optional): place to store error (if any) * * Returns: cache mode for the @mode_str or %BD_LVM_CACHE_MODE_UNKNOWN if * failed to determine * * Tech category: always provided/supported */ BDLVMCacheMode bd_lvm_cache_get_mode_from_str (const gchar *mode_str, GError **error); /** * bd_lvm_cache_create_pool: * @vg_name: name of the VG to create @pool_name in * @pool_name: name of the cache pool LV to create * @pool_size: desired size of the cache pool @pool_name * @md_size: desired size of the @pool_name cache pool's metadata LV or 0 to * use the default * @mode: cache mode of the @pool_name cache pool * @flags: a combination of (ORed) #BDLVMCachePoolFlags * @fast_pvs: (array zero-terminated=1): list of (fast) PVs to create the @pool_name * cache pool (and the metadata LV) * @error: (out) (optional): place to store error (if any) * * Returns: whether the cache pool @vg_name/@pool_name was successfully created or not * * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_cache_create_pool (const gchar *vg_name, const gchar *pool_name, guint64 pool_size, guint64 md_size, BDLVMCacheMode mode, BDLVMCachePoolFlags flags, const gchar **fast_pvs, GError **error); /** * bd_lvm_cache_attach: * @vg_name: name of the VG containing the @data_lv and the @cache_pool_lv LVs * @data_lv: data LV to attach the @cache_pool_lv to * @cache_pool_lv: cache pool LV to attach to the @data_lv * @extra: (nullable) (array zero-terminated=1): extra options for the cache attachment * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @cache_pool_lv was successfully attached to the @data_lv or not * * Note: Both @data_lv and @cache_lv will be deactivated before the operation. * * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_cache_attach (const gchar *vg_name, const gchar *data_lv, const gchar *cache_pool_lv, const BDExtraArg **extra, GError **error); /** * bd_lvm_cache_detach: * @vg_name: name of the VG containing the @cached_lv * @cached_lv: name of the cached LV to detach its cache from * @destroy: whether to destroy the cache after detach or not * @extra: (nullable) (array zero-terminated=1): extra options for the cache detachment * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the cache was successfully detached from the @cached_lv or not * * Note: synces the cache first * * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_cache_detach (const gchar *vg_name, const gchar *cached_lv, gboolean destroy, const BDExtraArg **extra, GError **error); /** * bd_lvm_cache_create_cached_lv: * @vg_name: name of the VG to create a cached LV in * @lv_name: name of the cached LV to create * @data_size: size of the data LV * @cache_size: size of the cache (or cached LV more precisely) * @md_size: size of the cache metadata LV or 0 to use the default * @mode: cache mode for the cached LV * @flags: a combination of (ORed) #BDLVMCachePoolFlags * @slow_pvs: (array zero-terminated=1): list of slow PVs (used for the data LV) * @fast_pvs: (array zero-terminated=1): list of fast PVs (used for the cache LV) * @error: (out) (optional): place to store error (if any) * * Returns: whether the cached LV @lv_name was successfully created or not * * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_cache_create_cached_lv (const gchar *vg_name, const gchar *lv_name, guint64 data_size, guint64 cache_size, guint64 md_size, BDLVMCacheMode mode, BDLVMCachePoolFlags flags, const gchar **slow_pvs, const gchar **fast_pvs, GError **error); /** * bd_lvm_cache_pool_name: * @vg_name: name of the VG containing the @cached_lv * @cached_lv: cached LV to get the name of the its pool LV for * @error: (out) (optional): place to store error (if any) * * Returns: name of the cache pool LV used by the @cached_lv or %NULL in case of error * * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_QUERY */ gchar* bd_lvm_cache_pool_name (const gchar *vg_name, const gchar *cached_lv, GError **error); /** * bd_lvm_cache_stats: * @vg_name: name of the VG containing the @cached_lv * @cached_lv: cached LV to get stats for * @error: (out) (optional): place to store error (if any) * * Returns: stats for the @cached_lv or %NULL in case of error * * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_QUERY */ BDLVMCacheStats* bd_lvm_cache_stats (const gchar *vg_name, const gchar *cached_lv, GError **error); /** * bd_lvm_writecache_attach: * @vg_name: name of the VG containing the @data_lv and the @cache_pool_lv LVs * @data_lv: data LV to attach the @cache_lv to * @cache_lv: cache (fast) LV to attach to the @data_lv * @extra: (nullable) (array zero-terminated=1): extra options for the cache attachment * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @cache_lv was successfully attached to the @data_lv or not * * Tech category: %BD_LVM_TECH_WRITECACHE-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_writecache_attach (const gchar *vg_name, const gchar *data_lv, const gchar *cache_lv, const BDExtraArg **extra, GError **error); /** * bd_lvm_writecache_detach: * @vg_name: name of the VG containing the @cached_lv * @cached_lv: name of the cached LV to detach its cache from * @destroy: whether to destroy the cache after detach or not * @extra: (nullable) (array zero-terminated=1): extra options for the cache detachment * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the cache was successfully detached from the @cached_lv or not * * Note: synces the cache first * * Tech category: %BD_LVM_TECH_WRITECACHE-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_writecache_detach (const gchar *vg_name, const gchar *cached_lv, gboolean destroy, const BDExtraArg **extra, GError **error); /** * bd_lvm_writecache_create_cached_lv: * @vg_name: name of the VG to create a cached LV in * @lv_name: name of the cached LV to create * @data_size: size of the data LV * @cache_size: size of the cache (or cached LV more precisely) * @slow_pvs: (array zero-terminated=1): list of slow PVs (used for the data LV) * @fast_pvs: (array zero-terminated=1): list of fast PVs (used for the cache LV) * @error: (out) (optional): place to store error (if any) * * Returns: whether the cached LV @lv_name was successfully created or not * * Tech category: %BD_LVM_TECH_WRITECACHE-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_writecache_create_cached_lv (const gchar *vg_name, const gchar *lv_name, guint64 data_size, guint64 cache_size, const gchar **slow_pvs, const gchar **fast_pvs, GError **error); /** * bd_lvm_thpool_convert: * @vg_name: name of the VG to create the new thin pool in * @data_lv: name of the LV that should become the data part of the new pool * @metadata_lv: name of the LV that should become the metadata part of the new pool * @name: (nullable): name for the thin pool (if %NULL, the name @data_lv is inherited) * @extra: (nullable) (array zero-terminated=1): extra options for the thin pool creation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Converts the @data_lv and @metadata_lv into a new thin pool in the @vg_name * VG. * * Returns: whether the new thin pool was successfully created from @data_lv and * @metadata_lv or not * * Tech category: %BD_LVM_TECH_THIN-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_thpool_convert (const gchar *vg_name, const gchar *data_lv, const gchar *metadata_lv, const gchar *name, const BDExtraArg **extra, GError **error); /** * bd_lvm_cache_pool_convert: * @vg_name: name of the VG to create the new thin pool in * @data_lv: name of the LV that should become the data part of the new pool * @metadata_lv: name of the LV that should become the metadata part of the new pool * @name: (nullable): name for the thin pool (if %NULL, the name @data_lv is inherited) * @extra: (nullable) (array zero-terminated=1): extra options for the thin pool creation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Converts the @data_lv and @metadata_lv into a new cache pool in the @vg_name * VG. * * Returns: whether the new cache pool was successfully created from @data_lv and * @metadata_lv or not * * Tech category: %BD_LVM_TECH_CACHE-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_cache_pool_convert (const gchar *vg_name, const gchar *data_lv, const gchar *metadata_lv, const gchar *name, const BDExtraArg **extra, GError **error); /** * bd_lvm_vdo_pool_create: * @vg_name: name of the VG to create a new LV in * @lv_name: name of the to-be-created VDO LV * @pool_name: (nullable): name of the to-be-created VDO pool LV or %NULL for default name * @data_size: requested size of the data VDO LV (physical size of the @pool_name VDO pool LV) * @virtual_size: requested virtual_size of the @lv_name VDO LV * @index_memory: amount of index memory (in bytes) or 0 for default * @compression: whether to enable compression or not * @deduplication: whether to enable deduplication or not * @write_policy: write policy for the volume * @extra: (nullable) (array zero-terminated=1): extra options for the VDO LV creation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the given @vg_name/@lv_name VDO LV was successfully created or not * * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_CREATE */ gboolean bd_lvm_vdo_pool_create (const gchar *vg_name, const gchar *lv_name, const gchar *pool_name, guint64 data_size, guint64 virtual_size, guint64 index_memory, gboolean compression, gboolean deduplication, BDLVMVDOWritePolicy write_policy, const BDExtraArg **extra, GError **error); /** * bd_lvm_vdo_enable_compression: * @vg_name: name of the VG containing the to-be-changed VDO pool LV * @pool_name: name of the VDO pool LV to enable compression on * @extra: (nullable) (array zero-terminated=1): extra options for the VDO change * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether compression was successfully enabled on @vg_name/@pool_name LV or not * * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vdo_enable_compression (const gchar *vg_name, const gchar *pool_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_vdo_disable_compression: * @vg_name: name of the VG containing the to-be-changed VDO pool LV * @pool_name: name of the VDO pool LV to disable compression on * @extra: (nullable) (array zero-terminated=1): extra options for the VDO change * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether compression was successfully disabled on @vg_name/@pool_name LV or not * * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vdo_disable_compression (const gchar *vg_name, const gchar *pool_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_vdo_enable_deduplication: * @vg_name: name of the VG containing the to-be-changed VDO pool LV * @pool_name: name of the VDO pool LV to enable deduplication on * @extra: (nullable) (array zero-terminated=1): extra options for the VDO change * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether deduplication was successfully enabled on @vg_name/@pool_name LV or not * * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vdo_enable_deduplication (const gchar *vg_name, const gchar *pool_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_vdo_disable_deduplication: * @vg_name: name of the VG containing the to-be-changed VDO pool LV * @pool_name: name of the VDO pool LV to disable deduplication on * @extra: (nullable) (array zero-terminated=1): extra options for the VDO change * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether deduplication was successfully disabled on @vg_name/@pool_name LV or not * * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vdo_disable_deduplication (const gchar *vg_name, const gchar *pool_name, const BDExtraArg **extra, GError **error); /** * bd_lvm_vdo_info: * @vg_name: name of the VG that contains the LV to get information about * @lv_name: name of the LV to get information about * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the @vg_name/@lv_name LV or %NULL in case * of error (the @error) gets populated in those cases) * * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_QUERY */ BDLVMVDOPooldata* bd_lvm_vdo_info (const gchar *vg_name, const gchar *lv_name, GError **error); /** * bd_lvm_vdo_resize: * @vg_name: name of the VG containing the to-be-resized VDO LV * @lv_name: name of the to-be-resized VDO LV * @size: the requested new size of the VDO LV * @extra: (nullable) (array zero-terminated=1): extra options for the VDO LV resize * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @vg_name/@lv_name VDO LV was successfully resized or not * * Note: Reduction needs to process TRIM for reduced disk area to unmap used data blocks * from the VDO pool LV and it may take a long time. * * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vdo_resize (const gchar *vg_name, const gchar *lv_name, guint64 size, const BDExtraArg **extra, GError **error); /** * bd_lvm_vdo_pool_resize: * @vg_name: name of the VG containing the to-be-resized VDO pool LV * @pool_name: name of the to-be-resized VDO pool LV * @size: the requested new size of the VDO pool LV * @extra: (nullable) (array zero-terminated=1): extra options for the VDO pool LV resize * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @vg_name/@pool_name VDO pool LV was successfully resized or not * * Note: Size of the VDO pool LV can be only extended, not reduced. * * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vdo_pool_resize (const gchar *vg_name, const gchar *pool_name, guint64 size, const BDExtraArg **extra, GError **error); /** * bd_lvm_vdo_pool_convert: * @vg_name: name of the VG that contains @pool_lv * @pool_lv: name of the LV that should become the new VDO pool LV * @name: (nullable): name for the VDO LV or %NULL for default name * @virtual_size: virtual size for the new VDO LV * @index_memory: amount of index memory (in bytes) or 0 for default * @compression: whether to enable compression or not * @deduplication: whether to enable deduplication or not * @write_policy: write policy for the volume * @extra: (nullable) (array zero-terminated=1): extra options for the VDO pool creation * (just passed to LVM as is) * @error: (out) (optional): place to store error (if any) * * Converts the @pool_lv into a new VDO pool LV in the @vg_name VG and creates a new * @name VDO LV with size @virtual_size. * * Note: All data on @pool_lv will be irreversibly destroyed. * * Returns: whether the new VDO pool LV was successfully created from @pool_lv and or not * * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_CREATE&%BD_LVM_TECH_MODE_MODIFY */ gboolean bd_lvm_vdo_pool_convert (const gchar *vg_name, const gchar *pool_lv, const gchar *name, guint64 virtual_size, guint64 index_memory, gboolean compression, gboolean deduplication, BDLVMVDOWritePolicy write_policy, const BDExtraArg **extra, GError **error); /** * bd_lvm_vdolvpoolname: * @vg_name: name of the VG containing the queried VDO LV * @lv_name: name of the queried VDO LV * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): the name of the pool volume for the @vg_name/@lv_name * VDO LV or %NULL if failed to determine (@error) is set in those cases) * * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_QUERY */ gchar* bd_lvm_vdolvpoolname (const gchar *vg_name, const gchar *lv_name, GError **error); /** * bd_lvm_get_vdo_operating_mode_str: * @mode: mode to get the string representation for * @error: (out) (optional): place to store error (if any) * * Returns: string representation of @mode or %NULL in case of error * * Tech category: always provided/supported */ const gchar* bd_lvm_get_vdo_operating_mode_str (BDLVMVDOOperatingMode mode, GError **error); /** * bd_lvm_get_vdo_compression_state_str: * @state: state to get the string representation for * @error: (out) (optional): place to store error (if any) * * Returns: string representation of @state or %NULL in case of error * * Tech category: always provided/supported */ const gchar* bd_lvm_get_vdo_compression_state_str (BDLVMVDOCompressionState state, GError **error); /** * bd_lvm_get_vdo_index_state_str: * @state: state to get the string representation for * @error: (out) (optional): place to store error (if any) * * Returns: string representation of @state or %NULL in case of error * * Tech category: always provided/supported */ const gchar* bd_lvm_get_vdo_index_state_str (BDLVMVDOIndexState state, GError **error); /** * bd_lvm_get_vdo_write_policy_str: * @policy: policy to get the string representation for * @error: (out) (optional): place to store error (if any) * * Returns: string representation of @policy or %NULL in case of error * * Tech category: always provided/supported */ const gchar* bd_lvm_get_vdo_write_policy_str (BDLVMVDOWritePolicy policy, GError **error); /** * bd_lvm_get_vdo_write_policy_from_str: * @policy_str: string representation of a policy * @error: (out) (optional): place to store error (if any) * * Returns: write policy for the @policy_str or %BD_LVM_VDO_WRITE_POLICY_UNKNOWN if * failed to determine * * Tech category: always provided/supported */ BDLVMVDOWritePolicy bd_lvm_get_vdo_write_policy_from_str (const gchar *policy_str, GError **error); /** * bd_lvm_vdo_get_stats_full: * @vg_name: name of the VG that contains @pool_name VDO pool * @pool_name: name of the VDO pool to get statistics for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full) (element-type utf8 utf8): hashtable of type string - string of available * statistics or %NULL in case of error * (@error gets populated in those cases) * * Statistics are collected from the values exposed by the kernel `kvdo` module * at the `/sys/kvdo//statistics/` path. * Some of the keys are computed to mimic the information produced by the vdo tools. * Please note the contents of the hashtable may vary depending on the actual kvdo module version. * * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_QUERY */ GHashTable* bd_lvm_vdo_get_stats_full (const gchar *vg_name, const gchar *pool_name, GError **error); /** * bd_lvm_vdo_get_stats: * @vg_name: name of the VG that contains @pool_name VDO pool * @pool_name: name of the VDO pool to get statistics for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): a structure containing selected statistics or %NULL in case of error * (@error gets populated in those cases) * * In contrast to @bd_lvm_vdo_get_stats_full this function will only return selected statistics * in a fixed structure. In case a value is not available, -1 would be returned. * * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_QUERY */ BDLVMVDOStats* bd_lvm_vdo_get_stats (const gchar *vg_name, const gchar *pool_name, GError **error); /** * bd_lvm_devices_add: * @device: device (PV) to add to the devices file * @devices_file: (nullable): LVM devices file or %NULL for default * @extra: (nullable) (array zero-terminated=1): extra options for the lvmdevices command * @error: (out) (optional): place to store error (if any) * * Returns: whether the @device was successfully added to @devices_file or not * * Tech category: %BD_LVM_TECH_DEVICES no mode (it is ignored) */ gboolean bd_lvm_devices_add (const gchar *device, const gchar *devices_file, const BDExtraArg **extra, GError **error); /** * bd_lvm_devices_delete: * @device: device (PV) to delete from the devices file * @devices_file: (nullable): LVM devices file or %NULL for default * @extra: (nullable) (array zero-terminated=1): extra options for the lvmdevices command * @error: (out) (optional): place to store error (if any) * * Returns: whether the @device was successfully removed from @devices_file or not * * Tech category: %BD_LVM_TECH_DEVICES no mode (it is ignored) */ gboolean bd_lvm_devices_delete (const gchar *device, const gchar *devices_file, const BDExtraArg **extra, GError **error); #endif /* BD_LVM_API */ libblockdev-3.1.1-1/src/lib/plugin_apis/mdraid.api000066400000000000000000000424541460051510300217400ustar00rootroot00000000000000#include #include #include #ifndef BD_MD_API #define BD_MD_API /* these defaults were determined empirically (taken from blivet) */ #define BD_MD_SUPERBLOCK_SIZE G_GUINT64_CONSTANT (2097152ULL) /* 2 MiB */ #define BD_MD_CHUNK_SIZE G_GUINT64_CONSTANT (524288ULL) /* 512 KiB */ GQuark bd_md_error_quark (void) { return g_quark_from_static_string ("g-bd-md-error-quark"); } #define BD_MD_ERROR bd_md_error_quark () typedef enum { BD_MD_ERROR_TECH_UNAVAIL, BD_MD_ERROR_FAIL, BD_MD_ERROR_PARSE, BD_MD_ERROR_BAD_FORMAT, BD_MD_ERROR_NO_MATCH, BD_MD_ERROR_INVAL, } BDMDError; #define BD_MD_TYPE_EXAMINEDATA (bd_md_examine_data_get_type ()) GType bd_md_examine_data_get_type(); /** * BDMDExamineData: * @device: path of the MD device * @level: RAID level of the device * @num_devices: number of devices used by the MD device * @name: name of the MD device * @size: size of the MD device * @uuid: array UUID * @update_time: update time of the MD device * @dev_uuid: UUID of the member device * @events: number of events on the MD device * @metadata: version of the metadata used by the MD device * @chunk_size: chunk size used by the MD device */ typedef struct BDMDExamineData { gchar *device; gchar *level; guint64 num_devices; gchar *name; guint64 size; gchar *uuid; guint64 update_time; gchar *dev_uuid; guint64 events; gchar *metadata; guint64 chunk_size; } BDMDExamineData; /** * bd_md_examine_data_copy: (skip) * @data: (nullable): %BDMDExamineData to copy * * Creates a new copy of @data. */ BDMDExamineData* bd_md_examine_data_copy (BDMDExamineData *data) { if (data == NULL) return NULL; BDMDExamineData *new_data = g_new0 (BDMDExamineData, 1); new_data->device = g_strdup (data->device); new_data->level = g_strdup (data->level); new_data->num_devices = data->num_devices; new_data->name = g_strdup (data->name); new_data->size = data->size; new_data->uuid = g_strdup (data->uuid); new_data->update_time = data->update_time; new_data->dev_uuid = g_strdup (data->dev_uuid); new_data->events = data->events; new_data->metadata = g_strdup (data->metadata); new_data->chunk_size = data->chunk_size; return new_data; } /** * bd_md_examine_data_free: (skip) * @data: (nullable): %BDMDExamineData to free * * Frees @data. */ void bd_md_examine_data_free (BDMDExamineData *data) { if (data == NULL) return; g_free (data->device); g_free (data->level); g_free (data->name); g_free (data->uuid); g_free (data->dev_uuid); g_free (data->metadata); g_free (data); } GType bd_md_examine_data_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDMDExamineData", (GBoxedCopyFunc) bd_md_examine_data_copy, (GBoxedFreeFunc) bd_md_examine_data_free); } return type; } #define BD_MD_TYPE_DETAILDATA (bd_md_detail_data_get_type ()) GType bd_md_detail_data_get_type(); /** * BDMDDetailData: * @device: path of the device * @metadata: version of the metadata used by the device * @creation_time: creation time * @level: level of the MD RAID * @name: name of the MD device * @array_size: size of the MD array * @use_dev_size: size of the used space * @raid_devices: number of devices in the MD array * @total_devices: total number of devices in the MD array * @active_devices: number of active devices in the MD array * @working_devices: number of working devices in the MD array * @failed_devices: number of failed devices in the MD array * @spare_devices: number of spare devices in the MD array * @clean: whether the MD array is clean or not * @uuid: uuid of the MD array * @container: path of the MD container this device belongs to */ typedef struct BDMDDetailData { gchar *device; gchar *metadata; gchar *creation_time; gchar *level; gchar *name; guint64 array_size; guint64 use_dev_size; guint64 raid_devices; guint64 total_devices; guint64 active_devices; guint64 working_devices; guint64 failed_devices; guint64 spare_devices; gboolean clean; gchar *uuid; gchar *container; } BDMDDetailData; /** * bd_md_detail_data_copy: (skip) * @data: (nullable): %BDMDDetailData to copy * * Creates a new copy of @data. */ BDMDDetailData* bd_md_detail_data_copy (BDMDDetailData *data) { if (data == NULL) return NULL; BDMDDetailData *new_data = g_new0 (BDMDDetailData, 1); new_data->device = g_strdup (data->device); new_data->name = g_strdup (data->name); new_data->metadata = g_strdup (data->metadata); new_data->creation_time = g_strdup (data->creation_time); new_data->level = g_strdup (data->level); new_data->array_size = data->array_size; new_data->use_dev_size = data->use_dev_size; new_data->raid_devices = data->raid_devices; new_data->active_devices = data->active_devices; new_data->working_devices = data->working_devices; new_data->failed_devices = data->failed_devices; new_data->spare_devices = data->spare_devices; new_data->clean = data->clean; new_data->uuid = g_strdup (data->uuid); new_data->container = g_strdup (data->container); return new_data; } /** * bd_md_detail_data_free: (skip) * @data: (nullable): %BDMDDetailData to free * * Frees @data. */ void bd_md_detail_data_free (BDMDDetailData *data) { if (data == NULL) return; g_free (data->device); g_free (data->name); g_free (data->metadata); g_free (data->creation_time); g_free (data->level); g_free (data->uuid); g_free (data->container); g_free (data); } GType bd_md_detail_data_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDMDDetailData", (GBoxedCopyFunc) bd_md_detail_data_copy, (GBoxedFreeFunc) bd_md_detail_data_free); } return type; } typedef enum { BD_MD_TECH_MDRAID = 0, } BDMDTech; typedef enum { BD_MD_TECH_MODE_CREATE = 1 << 0, BD_MD_TECH_MODE_DELETE = 1 << 1, BD_MD_TECH_MODE_MODIFY = 1 << 2, BD_MD_TECH_MODE_QUERY = 1 << 3, } BDMDTechMode; /** * bd_md_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_md_is_tech_avail (BDMDTech tech, guint64 mode, GError **error); /** * bd_md_get_superblock_size: * @member_size: size of an array member * @version: (nullable): metadata version or %NULL to use the current default version * @error: (out) (optional): place to store error (if any) * * Returns: Calculated superblock size for an array with a given @member_size * and metadata @version or default if unsupported @version is used. * * Tech category: always available */ guint64 bd_md_get_superblock_size (guint64 member_size, const gchar *version, GError **error); /** * bd_md_create: * @device_name: name of the device to create * @level: RAID level (as understood by mdadm, see mdadm(8)) * @disks: (array zero-terminated=1): disks to use for the new RAID (including spares) * @spares: number of spare devices * @version: (nullable): metadata version * @bitmap: (nullable): write-intent bitmap location ('none', 'internal') or %NULL to let mdadm decide (i.e. internal > 100GB) * @chunk_size: chunk size of the device to create * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mdadm' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the new MD RAID device @device_name was successfully created or not * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_CREATE */ gboolean bd_md_create (const gchar *device_name, const gchar *level, const gchar **disks, guint64 spares, const gchar *version, const gchar *bitmap, guint64 chunk_size, const BDExtraArg **extra, GError **error); /** * bd_md_destroy: * @device: device to destroy MD RAID metadata on * @error: (out) (optional): place to store error (if any) * * Returns: whether the MD RAID metadata was successfully destroyed on @device or not * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_DELETE */ gboolean bd_md_destroy (const gchar *device, GError **error); /** * bd_md_deactivate: * @raid_spec: specification of the RAID device (name, node or path) * @error: (out) (optional): place to store error (if any) * * Returns: whether the RAID device @raid_spec was successfully deactivated or not * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_MODIFY */ gboolean bd_md_deactivate (const gchar *raid_spec, GError **error); /** * bd_md_activate: * @raid_spec: (nullable): specification of the RAID device (name, node or path) to activate (if not given "--scan" is implied and @members is ignored) * @members: (nullable) (array zero-terminated=1): member devices to be considered for @device activation * @uuid: (nullable): UUID (in the MD RAID format!) of the MD RAID to activate * @start_degraded: whether to start the array even if it's degraded * @extra: (nullable) (array zero-terminated=1): extra options for the activation (right now * passed to the 'mdadm' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the MD RAID @device was successfully activated or not * * Note: either @members or @uuid (or both) have to be specified. * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_MODIFY */ gboolean bd_md_activate (const gchar *raid_spec, const gchar **members, const gchar *uuid, gboolean start_degraded, const BDExtraArg **extra, GError **error); /** * bd_md_run: * @raid_spec: specification of the (possibly degraded) RAID device (name, node or path) to be started * @error: (out) (optional): place to store error (if any) * * Returns: whether the @raid_spec was successfully started or not * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_MODIFY */ gboolean bd_md_run (const gchar *raid_spec, GError **error); /** * bd_md_nominate: * @device: device to nominate (add to its appropriate RAID) as a MD RAID device * @error: (out) (optional): place to store error (if any) * * Returns: whether the @device was successfully nominated (added to its * appropriate RAID) or not * * Note: may start the MD RAID if it becomes ready by adding @device. * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_MODIFY */ gboolean bd_md_nominate (const gchar *device, GError **error); /** * bd_md_denominate: * @device: device to denominate (remove from its appropriate RAID) as a MD RAID device * @error: (out) (optional): place to store error (if any) * * Returns: whether the @device was successfully denominated (added to its * appropriate RAID) or not * * Note: may start the MD RAID if it becomes ready by adding @device. * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_MODIFY */ gboolean bd_md_denominate (const gchar *device, GError **error); /** * bd_md_add: * @raid_spec: specification of the RAID device (name, node or path) to add @device into * @device: name of the device to add to the @raid_spec RAID device * @raid_devs: number of devices the @raid_spec RAID should actively use or 0 * to leave unspecified (see below) * @extra: (nullable) (array zero-terminated=1): extra options for the addition (right now * passed to the 'mdadm' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @device was successfully added to the @raid_spec RAID or * not * * The @raid_devs parameter is used when adding devices to a raid array that has * no actual redundancy. In this case it is necessary to explicitly grow the * array all at once rather than manage it in the sense of adding spares. * * Whether the new device will be added as a spare or an active member is * decided by mdadm. * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_MODIFY */ gboolean bd_md_add (const gchar *raid_spec, const gchar *device, guint64 raid_devs, const BDExtraArg **extra, GError **error); /** * bd_md_remove: * @raid_spec: specification of the RAID device (name, node or path) to remove @device from * @device: device to remove from the @raid_spec RAID * @fail: whether to mark the @device as failed before removing * @extra: (nullable) (array zero-terminated=1): extra options for the removal (right now * passed to the 'mdadm' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @device was successfully removed from the @raid_spec * RAID or not. * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_MODIFY */ gboolean bd_md_remove (const gchar *raid_spec, const gchar *device, gboolean fail, const BDExtraArg **extra, GError **error); /** * bd_md_examine: * @device: name of the device (a member of an MD RAID) to examine * @error: (out) (optional): place to store error (if any) * * Returns: information about the MD RAID extracted from the @device * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_QUERY */ BDMDExamineData* bd_md_examine (const gchar *device, GError **error); /** * bd_md_detail: * @raid_spec: specification of the RAID device (name, node or path) to examine * @error: (out) (optional): place to store error (if any) * * Returns: information about the MD RAID @raid_spec * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_QUERY */ BDMDDetailData* bd_md_detail (const gchar *raid_spec, GError **error); /** * bd_md_canonicalize_uuid: * @uuid: UUID to canonicalize * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): canonicalized form of @uuid * * This function expects a UUID in the form that mdadm returns. The change is as * follows: 3386ff85:f5012621:4a435f06:1eb47236 -> 3386ff85-f501-2621-4a43-5f061eb47236 * * Tech category: always available */ gchar* bd_md_canonicalize_uuid (const gchar *uuid, GError **error); /** * bd_md_get_md_uuid: * @uuid: UUID to transform into format used by MD RAID * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): transformed form of @uuid * * This function expects a UUID in the canonical (traditional format) and * returns a UUID in the format used by MD RAID and is thus reverse to * bd_md_canonicalize_uuid(). The change is as follows: * 3386ff85-f501-2621-4a43-5f061eb47236 -> 3386ff85:f5012621:4a435f06:1eb47236 * * Tech category: always available */ gchar* bd_md_get_md_uuid (const gchar *uuid, GError **error); /** * bd_md_node_from_name: * @name: name of the MD RAID * @error: (out) (optional): place to store error (if any) * * Returns: device node of the @name MD RAID or %NULL in case of error * * Tech category: always available */ gchar* bd_md_node_from_name (const gchar *name, GError **error); /** * bd_md_name_from_node: * @node: path of the MD RAID's device node * @error: (out) (optional): place to store error (if any) * * Returns: @name of the MD RAID the device node belongs to or %NULL in case of error * * Tech category: always available */ gchar* bd_md_name_from_node (const gchar *node, GError **error); /** * bd_md_get_status * @raid_spec: specification of the RAID device (name, node or path) to get status * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): status of the @raid_spec RAID. * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_QUERY */ gchar* bd_md_get_status (const gchar *raid_spec, GError **error); /** * bd_md_set_bitmap_location: * @raid_spec: specification of the RAID device (name, node or path) to set the bitmap location * @location: bitmap location (none, internal or path) * @error: (out) (optional): place to store error (if any) * * Returns: whether @location was successfully set for @raid_spec * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_MODIFY */ gboolean bd_md_set_bitmap_location (const gchar *raid_spec, const gchar *location, GError **error); /** * bd_md_get_bitmap_location: * @raid_spec: specification of the RAID device (name, node or path) to get the bitmap location * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): bitmap location for @raid_spec * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_QUERY */ gchar* bd_md_get_bitmap_location (const gchar *raid_spec, GError **error); /** * bd_md_request_sync_action: * @raid_spec: specification of the RAID device (name, node or path) to request sync action on * @action: requested sync action (resync, recovery, check, repair or idle) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @action was successfully requested for the @raid_spec * RAID or not. * * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_MODIFY */ gboolean bd_md_request_sync_action (const gchar *raid_spec, const gchar *action, GError **error); #endif /* BD_MD_API */ libblockdev-3.1.1-1/src/lib/plugin_apis/mpath.api000066400000000000000000000052401460051510300216010ustar00rootroot00000000000000#include #include #ifndef BD_MPATH_API #define BD_MPATH_API GQuark bd_mpath_error_quark (void) { return g_quark_from_static_string ("g-bd-mpath-error-quark"); } #define BD_MPATH_ERROR bd_mpath_error_quark () typedef enum { BD_MPATH_ERROR_TECH_UNAVAIL, BD_MPATH_ERROR_INVAL, BD_MPATH_ERROR_FLUSH, BD_MPATH_ERROR_NOT_ROOT, BD_MPATH_ERROR_DM_ERROR, } BDMpathError; typedef enum { BD_MPATH_TECH_BASE = 0, BD_MPATH_TECH_FRIENDLY_NAMES, } BDMpathTech; typedef enum { BD_MPATH_TECH_MODE_QUERY = 1 << 0, BD_MPATH_TECH_MODE_MODIFY = 1 << 1, } BDMpathTechMode; /** * bd_mpath_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_mpath_is_tech_avail (BDMpathTech tech, guint64 mode, GError **error); /** * bd_mpath_flush_mpaths: * @error: (out) (optional): place to store error (if any) * * Returns: whether multipath device maps were successfully flushed or not * * Flushes all unused multipath device maps. * * Tech category: %BD_MPATH_TECH_BASE-%BD_MPATH_TECH_MODE_MODIFY */ gboolean bd_mpath_flush_mpaths (GError **error); /** * bd_mpath_is_mpath_member: * @device: device to test * @error: (out) (optional): place to store error (if any) * * Returns: %TRUE if the device is a multipath member, %FALSE if not or an error * appeared when queried (@error is set in those cases) * * Tech category: %BD_MPATH_TECH_BASE-%BD_MPATH_TECH_MODE_QUERY */ gboolean bd_mpath_is_mpath_member (const gchar *device, GError **error); /** * bd_mpath_get_mpath_members: * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full) (array zero-terminated=1): list of names of all devices that are * members of the mpath mappings (or %NULL * in case of error) * * Tech category: %BD_MPATH_TECH_BASE-%BD_MPATH_TECH_MODE_QUERY */ gchar** bd_mpath_get_mpath_members (GError **error); /** * bd_mpath_set_friendly_names: * @enabled: whether friendly names should be enabled or not * @error: (out) (optional): place to store error (if any) * * Returns: if successfully set or not * * Tech category: %BD_MPATH_TECH_FRIENDLY_NAMES-%BD_MPATH_TECH_MODE_MODIFY */ gboolean bd_mpath_set_friendly_names (gboolean enabled, GError **error); #endif /* BD_MPATH_API */ libblockdev-3.1.1-1/src/lib/plugin_apis/nvdimm.api000066400000000000000000000226751460051510300217750ustar00rootroot00000000000000#include #include #include #ifndef BD_NVDIMM_API #define BD_NVDIMM_API GQuark bd_nvdimm_error_quark (void) { return g_quark_from_static_string ("g-bd-nvdimm-error-quark"); } #define BD_NVDIMM_ERROR bd_nvdimm_error_quark () typedef enum { BD_NVDIMM_ERROR_TECH_UNAVAIL, BD_NVDIMM_ERROR_NAMESPACE_FAIL, BD_NVDIMM_ERROR_NAMESPACE_PARSE, BD_NVDIMM_ERROR_NAMESPACE_NOEXIST, BD_NVDIMM_ERROR_NAMESPACE_MODE_INVAL, } BDNVDIMMError; typedef enum { BD_NVDIMM_NAMESPACE_MODE_RAW, BD_NVDIMM_NAMESPACE_MODE_SECTOR, BD_NVDIMM_NAMESPACE_MODE_MEMORY, BD_NVDIMM_NAMESPACE_MODE_DAX, BD_NVDIMM_NAMESPACE_MODE_FSDAX, BD_NVDIMM_NAMESPACE_MODE_DEVDAX, BD_NVDIMM_NAMESPACE_MODE_UNKNOWN, } BDNVDIMMNamespaceMode; #define BD_NVDIMM_TYPE_NAMESPACE_INFO (bd_nvdimm_namespace_info_get_type ()) GType bd_nvdimm_namespace_info_get_type(); /** * BDNVDIMMNamespaceInfo: * @dev: namespace device name ("namespaceX.Y") * @mode: mode of the namespace (BDNVDIMMNamespaceMode) * @size: size of the namespace * @uuid: UUID of the namespace * @sector_size: sector size of the namespace (0 for non-sector namespaces) * @blockdev: name of the block device for the namespace * @enabled: whether the namespace is enabled or not */ typedef struct BDNVDIMMNamespaceInfo { gchar *dev; guint64 mode; guint64 size; gchar *uuid; guint64 sector_size; gchar *blockdev; gboolean enabled; } BDNVDIMMNamespaceInfo; /** * bd_nvdimm_namespace_info_free: (skip) * @info: (nullable): %BDNVDIMMNamespaceInfo to free * * Frees @info. */ void bd_nvdimm_namespace_info_free (BDNVDIMMNamespaceInfo *info) { if (info == NULL) return; g_free (info->dev); g_free (info->uuid); g_free (info->blockdev); g_free (info); } /** * bd_nvdimm_namespace_info_copy: (skip) * @info: (nullable): %BDNVDIMMNamespaceInfo to copy * * Creates a new copy of @info. */ BDNVDIMMNamespaceInfo* bd_nvdimm_namespace_info_copy (BDNVDIMMNamespaceInfo *info) { if (info == NULL) return NULL; BDNVDIMMNamespaceInfo *new_info = g_new0 (BDNVDIMMNamespaceInfo, 1); new_info->dev = info->dev; new_info->mode = info->mode; new_info->size = info->size; new_info->uuid = g_strdup (info->uuid); new_info->sector_size = info->sector_size; new_info->blockdev = g_strdup (info->blockdev); new_info->enabled = info->enabled; return new_info; } GType bd_nvdimm_namespace_info_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDNVDIMMNamespaceInfo", (GBoxedCopyFunc) bd_nvdimm_namespace_info_copy, (GBoxedFreeFunc) bd_nvdimm_namespace_info_free); } return type; } typedef enum { BD_NVDIMM_TECH_NAMESPACE = 0, } BDNVDIMMTech; typedef enum { BD_NVDIMM_TECH_MODE_CREATE = 1 << 0, BD_NVDIMM_TECH_MODE_REMOVE = 1 << 1, BD_NVDIMM_TECH_MODE_ACTIVATE_DEACTIVATE = 1 << 2, BD_NVDIMM_TECH_MODE_QUERY = 1 << 3, BD_NVDIMM_TECH_MODE_RECONFIGURE = 1 << 4, } BDNVDIMMTechMode; /** * bd_nvdimm_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDNVDIMMTechMode) for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available * * Deprecated: 3.1: NVDIMM plugin will be removed in the next major release */ gboolean bd_nvdimm_is_tech_avail (BDNVDIMMTech tech, guint64 mode, GError **error); /** * bd_nvdimm_namespace_get_mode_from_str: * @mode_str: string representation of mode * @error: (out) (optional): place to store error (if any) * * Returns: mode matching the @mode_str given or %BD_NVDIMM_NAMESPACE_MODE_UNKNOWN in case of no match * * Tech category: always available * * Deprecated: 3.1: NVDIMM plugin will be removed in the next major release */ BDNVDIMMNamespaceMode bd_nvdimm_namespace_get_mode_from_str (const gchar *mode_str, GError **error); /** * bd_nvdimm_namespace_get_mode_str: * @mode: mode to get string representation of * @error: (out) (optional): place to store error (if any) * * Returns: (transfer none): string representation of @mode or %NULL in case of error * * Tech category: always available * * Deprecated: 3.1: NVDIMM plugin will be removed in the next major release */ const gchar* bd_nvdimm_namespace_get_mode_str (BDNVDIMMNamespaceMode mode, GError **error); /** * bd_nvdimm_namespace_get_devname: * @device: name or path of a block device (e.g. "/dev/pmem0") * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): namespace device name (e.g. "namespaceX.Y") for @device * or %NULL if @device is not a NVDIMM namespace * (@error may be set to indicate error) * * Tech category: %BD_NVDIMM_TECH_NAMESPACE-%BD_NVDIMM_TECH_MODE_QUERY * * Deprecated: 3.1: NVDIMM plugin will be removed in the next major release */ gchar* bd_nvdimm_namespace_get_devname (const gchar *device, GError **error); /** * bd_nvdimm_namespace_enable: * @namespace: name of the namespace to enable * @extra: (nullable) (array zero-terminated=1): extra options (currently unused) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @namespace was successfully enabled or not * * Tech category: %BD_NVDIMM_TECH_NAMESPACE-%BD_NVDIMM_TECH_MODE_ACTIVATE_DEACTIVATE * * Deprecated: 3.1: NVDIMM plugin will be removed in the next major release */ gboolean bd_nvdimm_namespace_enable (const gchar *namespace, const BDExtraArg **extra, GError **error); /** * bd_nvdimm_namespace_disable: * @namespace: name of the namespace to disable * @extra: (nullable) (array zero-terminated=1): extra options (currently unused) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @namespace was successfully disabled or not * * Tech category: %BD_NVDIMM_TECH_NAMESPACE-%BD_NVDIMM_TECH_MODE_ACTIVATE_DEACTIVATE * * Deprecated: 3.1: NVDIMM plugin will be removed in the next major release */ gboolean bd_nvdimm_namespace_disable (const gchar *namespace, const BDExtraArg **extra, GError **error); /** * bd_nvdimm_namespace_info: * @namespace: namespace to get information about * @extra: (nullable) (array zero-terminated=1): extra options (currently unused) * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about given namespace or %NULL if no such * namespace was found (@error may be set to indicate error) * * Tech category: %BD_NVDIMM_TECH_NAMESPACE-%BD_NVDIMM_TECH_MODE_QUERY * * Deprecated: 3.1: NVDIMM plugin will be removed in the next major release */ BDNVDIMMNamespaceInfo* bd_nvdimm_namespace_info (const gchar *namespace, const BDExtraArg **extra, GError **error); /** * bd_nvdimm_list_namespaces: * @bus: (nullable): return only namespaces on given bus (specified by name), * %NULL may be specified to return namespaces from all buses * @region: (nullable): return only namespaces on given region (specified by regionX name or region id), * %NULL may be specified to return namespaces from all regions * @idle: whether to list idle (not enabled) namespaces too * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'ndctl' utility) * @error: (out) (optional): place to store error (if any) * * Returns: (array zero-terminated=1): information about the namespaces on @bus and @region or * %NULL if no namespaces were found (@error may be set to indicate error) * * Tech category: %BD_NVDIMM_TECH_NAMESPACE-%BD_NVDIMM_TECH_MODE_QUERY * * Deprecated: 3.1: NVDIMM plugin will be removed in the next major release */ BDNVDIMMNamespaceInfo** bd_nvdimm_list_namespaces (const gchar *bus, const gchar *region, gboolean idle, const BDExtraArg **extra, GError **error); /** * bd_nvdimm_namespace_reconfigure: * @namespace: name of the namespace to reconfigure * @mode: mode type to set (memory/sector/raw/dax) * @force: whether to use force to reconfigure an active namespace * @error: (out) (optional): place to store error if any * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'ndctl' utility) * * Returns: whether @namespace was successfully reconfigured or not * * Deprecated: 3.1: NVDIMM plugin will be removed in the next major release */ gboolean bd_nvdimm_namespace_reconfigure (const gchar* namespace, BDNVDIMMNamespaceMode mode, gboolean force, const BDExtraArg **extra, GError** error); /** * bd_nvdimm_namespace_get_supported_sector_sizes: * @mode: namespace mode * @error: (out) (optional): place to store error if any * * Returns: (transfer none) (array zero-terminated=1): list of supported sector sizes for @mode * * Tech category: %BD_NVDIMM_TECH_NAMESPACE-%BD_NVDIMM_TECH_MODE_QUERY * * Deprecated: 3.1: NVDIMM plugin will be removed in the next major release */ const guint64 *bd_nvdimm_namespace_get_supported_sector_sizes (BDNVDIMMNamespaceMode mode, GError **error); #endif /* BD_NVDIMM_API */ libblockdev-3.1.1-1/src/lib/plugin_apis/nvme.api000066400000000000000000001745771460051510300214610ustar00rootroot00000000000000#include #include #include #include #ifndef BD_NVME_API #define BD_NVME_API GQuark bd_nvme_error_quark (void) { return g_quark_from_static_string ("g-bd-nvme-error-quark"); } #define BD_NVME_ERROR bd_nvme_error_quark () /* BpG-skip */ /** * BDNVMEError: * @BD_NVME_ERROR_TECH_UNAVAIL: NVMe support not available. * @BD_NVME_ERROR_FAILED: General error. * @BD_NVME_ERROR_BUSY: The device is temporarily unavailable or in an inconsistent state. * @BD_NVME_ERROR_INVALID_ARGUMENT: Invalid argument. * @BD_NVME_ERROR_WOULD_FORMAT_ALL_NS: The NVMe controller indicates that it would format all namespaces in the NVM subsystem. * @BD_NVME_ERROR_SC_GENERIC: Generic NVMe Command Status Code. * @BD_NVME_ERROR_SC_CMD_SPECIFIC: NVMe Command Specific error. * @BD_NVME_ERROR_SC_MEDIA: Media and Data Integrity Errors: media specific errors that occur in the NVM or data integrity type errors. * @BD_NVME_ERROR_SC_PATH: Path related error. * @BD_NVME_ERROR_SC_VENDOR_SPECIFIC: NVMe Vendor specific error. * @BD_NVME_ERROR_NO_MATCH: No matching resource found (e.g. a Fabrics Controller). * @BD_NVME_ERROR_CONNECT: General connection error. * @BD_NVME_ERROR_CONNECT_ALREADY: Already connected. * @BD_NVME_ERROR_CONNECT_INVALID: Invalid argument specified. * @BD_NVME_ERROR_CONNECT_ADDRINUSE: HostNQN already in use. * @BD_NVME_ERROR_CONNECT_NODEV: Invalid interface. * @BD_NVME_ERROR_CONNECT_OPNOTSUPP: Operation not supported. * @BD_NVME_ERROR_CONNECT_REFUSED: Connection refused. */ /* BpG-skip-end */ typedef enum { BD_NVME_ERROR_TECH_UNAVAIL, BD_NVME_ERROR_FAILED, BD_NVME_ERROR_BUSY, BD_NVME_ERROR_INVALID_ARGUMENT, BD_NVME_ERROR_WOULD_FORMAT_ALL_NS, BD_NVME_ERROR_SC_GENERIC, BD_NVME_ERROR_SC_CMD_SPECIFIC, BD_NVME_ERROR_SC_MEDIA, BD_NVME_ERROR_SC_PATH, BD_NVME_ERROR_SC_VENDOR_SPECIFIC, BD_NVME_ERROR_NO_MATCH, BD_NVME_ERROR_CONNECT, BD_NVME_ERROR_CONNECT_ALREADY, BD_NVME_ERROR_CONNECT_INVALID, BD_NVME_ERROR_CONNECT_ADDRINUSE, BD_NVME_ERROR_CONNECT_NODEV, BD_NVME_ERROR_CONNECT_OPNOTSUPP, BD_NVME_ERROR_CONNECT_REFUSED, } BDNVMEError; typedef enum { BD_NVME_TECH_NVME = 0, BD_NVME_TECH_FABRICS, } BDNVMETech; typedef enum { BD_NVME_TECH_MODE_INFO = 1 << 0, BD_NVME_TECH_MODE_MANAGE = 1 << 1, BD_NVME_TECH_MODE_INITIATOR = 1 << 2, } BDNVMETechMode; /** * bd_nvme_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDNVMETechMode) for @tech * @error: (out) (nullable): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_nvme_is_tech_avail (BDNVMETech tech, G_GNUC_UNUSED guint64 mode, GError **error); /* BpG-skip */ /** * BDNVMEControllerFeature: * @BD_NVME_CTRL_FEAT_MULTIPORT: if set, then the NVM subsystem may contain more than one NVM subsystem port, otherwise it's single-port only. * @BD_NVME_CTRL_FEAT_MULTICTRL: if set, then the NVM subsystem may contain two or more controllers, otherwise contains only single controller. * @BD_NVME_CTRL_FEAT_SRIOV: if set, then the controller is associated with an SR-IOV Virtual Function, otherwise it's associated with a PCI Function or a Fabrics connection. * @BD_NVME_CTRL_FEAT_ANA_REPORTING: indicates that the NVM subsystem supports Asymmetric Namespace Access (ANA) Reporting. * @BD_NVME_CTRL_FEAT_FORMAT: indicates that the controller supports the Format NVM command. * @BD_NVME_CTRL_FEAT_FORMAT_ALL_NS: if set, then a format (excluding secure erase) of any namespace results in a format of all namespaces * in an NVM subsystem with all namespaces in an NVM subsystem configured with the same attributes. * If not set, then the controller supports format on a per namespace basis. * @BD_NVME_CTRL_FEAT_NS_MGMT: indicates that the controller supports the Namespace Management and Attachment capability. * @BD_NVME_CTRL_FEAT_SELFTEST: indicates that the controller supports the Device Self-test command. * @BD_NVME_CTRL_FEAT_SELFTEST_SINGLE: indicates that the NVM subsystem supports only one device self-test operation in progress at a time. * @BD_NVME_CTRL_FEAT_SANITIZE_CRYPTO: indicates that the controller supports the Crypto Erase sanitize operation. * @BD_NVME_CTRL_FEAT_SANITIZE_BLOCK: indicates that the controller supports the Block Erase sanitize operation. * @BD_NVME_CTRL_FEAT_SANITIZE_OVERWRITE: indicates that the controller supports the Overwrite sanitize operation. * @BD_NVME_CTRL_FEAT_SECURE_ERASE_ALL_NS: if set, then any secure erase performed as part of a format operation * results in a secure erase of all namespaces in the NVM subsystem. If not set, * then any secure erase performed as part of a format results in a secure erase * of the particular namespace specified. * @BD_NVME_CTRL_FEAT_SECURE_ERASE_CRYPTO: indicates that the cryptographic erase is supported. * @BD_NVME_CTRL_FEAT_STORAGE_DEVICE: indicates that the NVM subsystem is part of an NVMe Storage Device. * @BD_NVME_CTRL_FEAT_ENCLOSURE: indicates that the NVM subsystem is part of an NVMe Enclosure. * @BD_NVME_CTRL_FEAT_MGMT_PCIE: indicates that the NVM subsystem contains a Management Endpoint on a PCIe port. * @BD_NVME_CTRL_FEAT_MGMT_SMBUS: indicates that the NVM subsystem contains a Management Endpoint on an SMBus/I2C port. */ /* BpG-skip-end */ typedef enum { BD_NVME_CTRL_FEAT_MULTIPORT = 1 << 0, BD_NVME_CTRL_FEAT_MULTICTRL = 1 << 1, BD_NVME_CTRL_FEAT_SRIOV = 1 << 2, BD_NVME_CTRL_FEAT_ANA_REPORTING = 1 << 3, BD_NVME_CTRL_FEAT_FORMAT = 1 << 4, BD_NVME_CTRL_FEAT_FORMAT_ALL_NS = 1 << 5, BD_NVME_CTRL_FEAT_NS_MGMT = 1 << 6, BD_NVME_CTRL_FEAT_SELFTEST = 1 << 7, BD_NVME_CTRL_FEAT_SELFTEST_SINGLE = 1 << 8, BD_NVME_CTRL_FEAT_SANITIZE_CRYPTO = 1 << 9, BD_NVME_CTRL_FEAT_SANITIZE_BLOCK = 1 << 10, BD_NVME_CTRL_FEAT_SANITIZE_OVERWRITE = 1 << 11, BD_NVME_CTRL_FEAT_SECURE_ERASE_ALL_NS = 1 << 12, BD_NVME_CTRL_FEAT_SECURE_ERASE_CRYPTO = 1 << 13, BD_NVME_CTRL_FEAT_STORAGE_DEVICE = 1 << 14, BD_NVME_CTRL_FEAT_ENCLOSURE = 1 << 15, BD_NVME_CTRL_FEAT_MGMT_PCIE = 1 << 16, BD_NVME_CTRL_FEAT_MGMT_SMBUS = 1 << 17, } BDNVMEControllerFeature; /* BpG-skip */ /** * BDNVMEControllerType: * @BD_NVME_CTRL_TYPE_UNKNOWN: Controller type not reported (as reported by older NVMe-compliant devices). * @BD_NVME_CTRL_TYPE_IO: I/O controller. * @BD_NVME_CTRL_TYPE_DISCOVERY: Discovery controller. * @BD_NVME_CTRL_TYPE_ADMIN: Administrative controller. */ /* BpG-skip-end */ typedef enum { BD_NVME_CTRL_TYPE_UNKNOWN = 0, BD_NVME_CTRL_TYPE_IO, BD_NVME_CTRL_TYPE_DISCOVERY, BD_NVME_CTRL_TYPE_ADMIN, } BDNVMEControllerType; #define BD_NVME_TYPE_CONTROLLER_INFO (bd_nvme_controller_info_get_type ()) GType bd_nvme_controller_info_get_type (); /** * BDNVMEControllerInfo: * @pci_vendor_id: The PCI Vendor ID. * @pci_subsys_vendor_id: The PCI Subsystem Vendor ID. * @ctrl_id: Controller ID, the NVM subsystem unique controller identifier associated with the controller. * @fguid: FRU GUID, a 128-bit value that is globally unique for a given Field Replaceable Unit. * @model_number: The model number. * @serial_number: The serial number. * @firmware_ver: The currently active firmware revision. * @nvme_ver: The NVM Express base specification that the controller implementation supports or %NULL when not reported by the device. * @features: features and capabilities present for this controller, see #BDNVMEControllerFeature. * @controller_type: The controller type. * @selftest_ext_time: Extended Device Self-test Time, if #BD_NVME_CTRL_FEAT_SELFTEST is supported then this field * indicates the nominal amount of time in one minute units that the controller takes * to complete an extended device self-test operation when in power state 0. * @hmb_pref_size: Host Memory Buffer Preferred Size indicates the preferred size that the host * is requested to allocate for the Host Memory Buffer feature in bytes. * @hmb_min_size: Host Memory Buffer Minimum Size indicates the minimum size that the host * is requested to allocate for the Host Memory Buffer feature in bytes. * @size_total: Total NVM Capacity in the NVM subsystem in bytes. * @size_unalloc: Unallocated NVM Capacity in the NVM subsystem in bytes. * @num_namespaces: Maximum Number of Allowed Namespaces supported by the NVM subsystem. * @subsysnqn: NVM Subsystem NVMe Qualified Name, UTF-8 null terminated string. */ typedef struct BDNVMEControllerInfo { guint16 pci_vendor_id; guint16 pci_subsys_vendor_id; guint16 ctrl_id; gchar *fguid; gchar *model_number; gchar *serial_number; gchar *firmware_ver; gchar *nvme_ver; guint64 features; BDNVMEControllerType controller_type; gint selftest_ext_time; guint64 hmb_pref_size; guint64 hmb_min_size; guint64 size_total; guint64 size_unalloc; guint num_namespaces; gchar *subsysnqn; } BDNVMEControllerInfo; /** * bd_nvme_controller_info_free: (skip) * @info: (nullable): %BDNVMEControllerInfo to free * * Frees @info. */ void bd_nvme_controller_info_free (BDNVMEControllerInfo *info) { if (info == NULL) return; g_free (info->fguid); g_free (info->subsysnqn); g_free (info->model_number); g_free (info->serial_number); g_free (info->firmware_ver); g_free (info->nvme_ver); g_free (info); } /** * bd_nvme_controller_info_copy: (skip) * @info: (nullable): %BDNVMEControllerInfo to copy * * Creates a new copy of @info. */ BDNVMEControllerInfo * bd_nvme_controller_info_copy (BDNVMEControllerInfo *info) { BDNVMEControllerInfo *new_info; if (info == NULL) return NULL; new_info = g_new0 (BDNVMEControllerInfo, 1); memcpy (new_info, info, sizeof (BDNVMEControllerInfo)); new_info->fguid = g_strdup (info->fguid); new_info->subsysnqn = g_strdup (info->subsysnqn); new_info->model_number = g_strdup (info->model_number); new_info->serial_number = g_strdup (info->serial_number); new_info->firmware_ver = g_strdup (info->firmware_ver); new_info->nvme_ver = g_strdup (info->nvme_ver); return new_info; } GType bd_nvme_controller_info_get_type () { static GType type = 0; if (G_UNLIKELY (type == 0)) { type = g_boxed_type_register_static ("BDNVMEControllerInfo", (GBoxedCopyFunc) bd_nvme_controller_info_copy, (GBoxedFreeFunc) bd_nvme_controller_info_free); } return type; } /* BpG-skip */ /** * BDNVMELBAFormatRelativePerformance: * Performance index of the LBA format relative to other LBA formats supported by the controller. * @BD_NVME_LBA_FORMAT_RELATIVE_PERFORMANCE_UNKNOWN: Unknown relative performance index. * @BD_NVME_LBA_FORMAT_RELATIVE_PERFORMANCE_BEST: Best performance. * @BD_NVME_LBA_FORMAT_RELATIVE_PERFORMANCE_BETTER: Better performance. * @BD_NVME_LBA_FORMAT_RELATIVE_PERFORMANCE_GOOD: Good performance. * @BD_NVME_LBA_FORMAT_RELATIVE_PERFORMANCE_DEGRADED: Degraded performance. */ /* BpG-skip-end */ typedef enum { BD_NVME_LBA_FORMAT_RELATIVE_PERFORMANCE_UNKNOWN = 0, BD_NVME_LBA_FORMAT_RELATIVE_PERFORMANCE_BEST = 1, BD_NVME_LBA_FORMAT_RELATIVE_PERFORMANCE_BETTER = 2, BD_NVME_LBA_FORMAT_RELATIVE_PERFORMANCE_GOOD = 3, BD_NVME_LBA_FORMAT_RELATIVE_PERFORMANCE_DEGRADED = 4 } BDNVMELBAFormatRelativePerformance; #define BD_NVME_TYPE_LBA_FORMAT (bd_nvme_lba_format_get_type ()) GType bd_nvme_lba_format_get_type (); /** * BDNVMELBAFormat: * Namespace LBA Format Data Structure. * @data_size: LBA data size (i.e. a sector size) in bytes. * @metadata_size: metadata size in bytes or `0` in case of no metadata support. * @relative_performance: Relative Performance index, see #BDNVMELBAFormatRelativePerformance. */ typedef struct BDNVMELBAFormat { guint16 data_size; guint16 metadata_size; BDNVMELBAFormatRelativePerformance relative_performance; } BDNVMELBAFormat; /** * bd_nvme_lba_format_free: (skip) * @fmt: (nullable): %BDNVMELBAFormat to free * * Frees @fmt. */ void bd_nvme_lba_format_free (BDNVMELBAFormat *fmt) { g_free (fmt); } /** * bd_nvme_lba_format_copy: (skip) * @fmt: (nullable): %BDNVMELBAFormat to copy * * Creates a new copy of @fmt. */ BDNVMELBAFormat * bd_nvme_lba_format_copy (BDNVMELBAFormat *fmt) { BDNVMELBAFormat *new_fmt; if (fmt == NULL) return NULL; new_fmt = g_new0 (BDNVMELBAFormat, 1); new_fmt->data_size = fmt->data_size; new_fmt->metadata_size = fmt->metadata_size; new_fmt->relative_performance = fmt->relative_performance; return new_fmt; } GType bd_nvme_lba_format_get_type () { static GType type = 0; if (G_UNLIKELY (type == 0)) { type = g_boxed_type_register_static ("BDNVMELBAFormat", (GBoxedCopyFunc) bd_nvme_lba_format_copy, (GBoxedFreeFunc) bd_nvme_lba_format_free); } return type; } /* BpG-skip */ /** * BDNVMENamespaceFeature: * @BD_NVME_NS_FEAT_THIN: indicates that the namespace supports thin provisioning. Specifically, the Namespace Capacity * reported may be less than the Namespace Size. * @BD_NVME_NS_FEAT_MULTIPATH_SHARED: indicates the capability to attach the namespace to two or more controllers * in the NVM subsystem concurrently. * @BD_NVME_NS_FEAT_FORMAT_PROGRESS: indicates the capability to report the percentage of the namespace * that remains to be formatted. * @BD_NVME_NS_FEAT_ROTATIONAL: indicates a rotational medium. */ /* BpG-skip-end */ typedef enum { BD_NVME_NS_FEAT_THIN = 1 << 0, BD_NVME_NS_FEAT_MULTIPATH_SHARED = 1 << 1, BD_NVME_NS_FEAT_FORMAT_PROGRESS = 1 << 2, BD_NVME_NS_FEAT_ROTATIONAL = 1 << 3, } BDNVMENamespaceFeature; #define BD_NVME_TYPE_NAMESPACE_INFO (bd_nvme_namespace_info_get_type ()) GType bd_nvme_namespace_info_get_type (); /** * BDNVMENamespaceInfo: * @nsid: The Namespace Identifier (NSID). * @eui64: IEEE Extended Unique Identifier: a 64-bit IEEE Extended Unique Identifier (EUI-64) * that is globally unique and assigned to the namespace when the namespace is created. * Remains fixed throughout the life of the namespace and is preserved across namespace * and controller operations. * @nguid: Namespace Globally Unique Identifier: a 128-bit value that is globally unique and * assigned to the namespace when the namespace is created. Remains fixed throughout * the life of the namespace and is preserved across namespace and controller operations. * @uuid: Namespace 128-bit Universally Unique Identifier (UUID) as specified in RFC 4122. * @nsize: Namespace Size: total size of the namespace in logical blocks. The number of logical blocks * is based on the formatted LBA size (see @current_lba_format). * @ncap: Namespace Capacity: maximum number of logical blocks that may be allocated in the namespace * at any point in time. The number of logical blocks is based on the formatted LBA size (see @current_lba_format). * @nuse: Namespace Utilization: current number of logical blocks allocated in the namespace. * This field is smaller than or equal to the Namespace Capacity. The number of logical * blocks is based on the formatted LBA size (see @current_lba_format). * @features: features and capabilities present for this namespace, see #BDNVMENamespaceFeature. * @format_progress_remaining: The percentage value remaining of a format operation in progress. * @write_protected: %TRUE if the namespace is currently write protected and all write access to the namespace shall fail. * @lba_formats: (array zero-terminated=1) (element-type BDNVMELBAFormat): A list of supported LBA Formats. * @current_lba_format: A LBA Format currently used for the namespace. Contains zeroes in case of * an invalid or no supported LBA Format reported. */ typedef struct BDNVMENamespaceInfo { guint32 nsid; gchar *eui64; gchar *uuid; gchar *nguid; guint64 nsize; guint64 ncap; guint64 nuse; guint64 features; guint8 format_progress_remaining; gboolean write_protected; BDNVMELBAFormat **lba_formats; BDNVMELBAFormat current_lba_format; } BDNVMENamespaceInfo; /** * bd_nvme_namespace_info_free: (skip) * @info: (nullable): %BDNVMENamespaceInfo to free * * Frees @info. */ void bd_nvme_namespace_info_free (BDNVMENamespaceInfo *info) { BDNVMELBAFormat **lba_formats; if (info == NULL) return; g_free (info->eui64); g_free (info->uuid); g_free (info->nguid); for (lba_formats = info->lba_formats; lba_formats && *lba_formats; lba_formats++) bd_nvme_lba_format_free (*lba_formats); g_free (info->lba_formats); g_free (info); } /** * bd_nvme_namespace_info_copy: (skip) * @info: (nullable): %BDNVMENamespaceInfo to copy * * Creates a new copy of @info. */ BDNVMENamespaceInfo * bd_nvme_namespace_info_copy (BDNVMENamespaceInfo *info) { BDNVMENamespaceInfo *new_info; BDNVMELBAFormat **lba_formats; GPtrArray *ptr_array; if (info == NULL) return NULL; new_info = g_new0 (BDNVMENamespaceInfo, 1); memcpy (new_info, info, sizeof (BDNVMENamespaceInfo)); new_info->eui64 = g_strdup (info->eui64); new_info->uuid = g_strdup (info->uuid); new_info->nguid = g_strdup (info->nguid); ptr_array = g_ptr_array_new (); for (lba_formats = info->lba_formats; lba_formats && *lba_formats; lba_formats++) g_ptr_array_add (ptr_array, bd_nvme_lba_format_copy (*lba_formats)); g_ptr_array_add (ptr_array, NULL); new_info->lba_formats = (BDNVMELBAFormat **) g_ptr_array_free (ptr_array, FALSE); return new_info; } GType bd_nvme_namespace_info_get_type () { static GType type = 0; if (G_UNLIKELY (type == 0)) { type = g_boxed_type_register_static ("BDNVMENamespaceInfo", (GBoxedCopyFunc) bd_nvme_namespace_info_copy, (GBoxedFreeFunc) bd_nvme_namespace_info_free); } return type; } /* BpG-skip */ /** * BDNVMESmartCriticalWarning: * @BD_NVME_SMART_CRITICAL_WARNING_SPARE: the available spare capacity has fallen below the threshold. * @BD_NVME_SMART_CRITICAL_WARNING_TEMPERATURE: a temperature is either greater than or equal to an over temperature threshold; * or less than or equal to an under temperature threshold. * @BD_NVME_SMART_CRITICAL_WARNING_DEGRADED: the NVM subsystem reliability has been degraded due to significant media * related errors or any internal error that degrades NVM subsystem reliability. * @BD_NVME_SMART_CRITICAL_WARNING_READONLY: all of the media has been placed in read only mode. Unrelated to the write * protection state of a namespace. * @BD_NVME_SMART_CRITICAL_WARNING_VOLATILE_MEM: the volatile memory backup device has failed. Valid only if the controller * has a volatile memory backup solution. * @BD_NVME_SMART_CRITICAL_WARNING_PMR_READONLY: Persistent Memory Region has become read-only or unreliable. */ /* BpG-skip-end */ typedef enum { BD_NVME_SMART_CRITICAL_WARNING_SPARE = 1 << 0, BD_NVME_SMART_CRITICAL_WARNING_TEMPERATURE = 1 << 1, BD_NVME_SMART_CRITICAL_WARNING_DEGRADED = 1 << 2, BD_NVME_SMART_CRITICAL_WARNING_READONLY = 1 << 3, BD_NVME_SMART_CRITICAL_WARNING_VOLATILE_MEM = 1 << 4, BD_NVME_SMART_CRITICAL_WARNING_PMR_READONLY = 1 << 5, } BDNVMESmartCriticalWarning; #define BD_NVME_TYPE_SMART_LOG (bd_nvme_smart_log_get_type ()) GType bd_nvme_smart_log_get_type (); /** * BDNVMESmartLog: * @critical_warning: critical warnings for the state of the controller, see #BDNVMESmartCriticalWarning. * @avail_spare: Available Spare: a normalized percentage (0% to 100%) of the remaining spare capacity available. * @spare_thresh: Available Spare Threshold: a normalized percentage (0% to 100%) of the available spare threshold. * @percent_used: Percentage Used: a vendor specific estimate of the percentage drive life used based on the * actual usage and the manufacturer's prediction. A value of 100 indicates that the estimated * endurance has been consumed, but may not indicate an NVM subsystem failure. * The value is allowed to exceed 100. * @total_data_read: An estimated calculation of total data read in bytes based on calculation of data * units read from the host. A value of 0 indicates that the number of Data Units Read * is not reported. * @total_data_written: An estimated calculation of total data written in bytes based on calculation * of data units written by the host. A value of 0 indicates that the number * of Data Units Written is not reported. * @ctrl_busy_time: Amount of time the controller is busy with I/O commands, reported in minutes. * @power_cycles: The number of power cycles. * @power_on_hours: The number of power-on hours, excluding a non-operational power state. * @unsafe_shutdowns: The number of unsafe shutdowns as a result of a Shutdown Notification not received prior to loss of power. * @media_errors: Media and Data Integrity Errors: the number of occurrences where the controller detected * an unrecovered data integrity error (e.g. uncorrectable ECC, CRC checksum failure, or LBA tag mismatch). * @num_err_log_entries: Number of Error Information Log Entries: the number of Error Information log * entries over the life of the controller. * @temperature: Composite Temperature: temperature in Kelvins that represents the current composite * temperature of the controller and associated namespaces or 0 when not applicable. * @temp_sensors: Temperature Sensor 1-8: array of the current temperature reported by temperature sensors * 1-8 in Kelvins or 0 when the particular sensor is not available. * @wctemp: Warning Composite Temperature Threshold (WCTEMP): indicates the minimum Composite Temperature (@temperature) * value that indicates an overheating condition during which controller operation continues. * A value of 0 indicates that no warning temperature threshold value is reported by the controller. * @cctemp: Critical Composite Temperature Threshold (CCTEMP): indicates the minimum Composite Temperature (@temperature) * value that indicates a critical overheating condition (e.g., may prevent continued normal operation, * possibility of data loss, automatic device shutdown, extreme performance throttling, or permanent damage). * A value of 0 indicates that no critical temperature threshold value is reported by the controller. * @warning_temp_time: Warning Composite Temperature Time: the amount of time in minutes that the Composite Temperature (@temperature) * is greater than or equal to the Warning Composite Temperature Threshold (@wctemp) and less than the * Critical Composite Temperature Threshold (@cctemp). * @critical_temp_time: Critical Composite Temperature Time: the amount of time in minutes that the Composite Temperature (@temperature) * is greater than or equal to the Critical Composite Temperature Threshold (@cctemp). */ typedef struct BDNVMESmartLog { guint critical_warning; guint8 avail_spare; guint8 spare_thresh; guint8 percent_used; guint64 total_data_read; guint64 total_data_written; guint64 ctrl_busy_time; guint64 power_cycles; guint64 power_on_hours; guint64 unsafe_shutdowns; guint64 media_errors; guint64 num_err_log_entries; guint16 temperature; guint16 temp_sensors[8]; guint16 wctemp; guint16 cctemp; guint warning_temp_time; guint critical_temp_time; } BDNVMESmartLog; /** * bd_nvme_smart_log_free: (skip) * @log: (nullable): %BDNVMESmartLog to free * * Frees @log. */ void bd_nvme_smart_log_free (BDNVMESmartLog *log) { g_free (log); } /** * bd_nvme_smart_log_copy: (skip) * @log: (nullable): %BDNVMESmartLog to copy * * Creates a new copy of @log. */ BDNVMESmartLog * bd_nvme_smart_log_copy (BDNVMESmartLog *log) { BDNVMESmartLog *new_log; if (log == NULL) return NULL; new_log = g_new0 (BDNVMESmartLog, 1); memcpy (new_log, log, sizeof (BDNVMESmartLog)); return new_log; } GType bd_nvme_smart_log_get_type () { static GType type = 0; if (G_UNLIKELY (type == 0)) { type = g_boxed_type_register_static ("BDNVMESmartLog", (GBoxedCopyFunc) bd_nvme_smart_log_copy, (GBoxedFreeFunc) bd_nvme_smart_log_free); } return type; } /* BpG-skip */ /** * BDNVMETransportType: * Transport Type. * @BD_NVME_TRANSPORT_TYPE_UNSPECIFIED: Not indicated * @BD_NVME_TRANSPORT_TYPE_RDMA: RDMA Transport * @BD_NVME_TRANSPORT_TYPE_FC: Fibre Channel Transport * @BD_NVME_TRANSPORT_TYPE_TCP: TCP Transport * @BD_NVME_TRANSPORT_TYPE_LOOP: Intra-host Transport (loopback) */ /* BpG-skip-end */ typedef enum { BD_NVME_TRANSPORT_TYPE_UNSPECIFIED = 0, BD_NVME_TRANSPORT_TYPE_RDMA = 1, BD_NVME_TRANSPORT_TYPE_FC = 2, BD_NVME_TRANSPORT_TYPE_TCP = 3, BD_NVME_TRANSPORT_TYPE_LOOP = 254 } BDNVMETransportType; #define BD_NVME_TYPE_ERROR_LOG_ENTRY (bd_nvme_error_log_entry_get_type ()) GType bd_nvme_error_log_entry_get_type (); /** * BDNVMEErrorLogEntry: * @error_count: internal error counter, a unique identifier for the error. * @command_id: the Command Identifier of the command that the error is associated with or `0xffff` if the error is not specific to a particular command. * @command_specific: Command Specific Information specific to @command_id. * @command_status: the Status code for the command that completed. * @command_error: translated command error in the BD_NVME_ERROR domain or %NULL in case @command_status indicates success. * @lba: the first LBA that experienced the error condition. * @nsid: the NSID of the namespace that the error is associated with. * @transport_type: type of the transport associated with the error. */ typedef struct BDNVMEErrorLogEntry { guint64 error_count; guint16 command_id; guint64 command_specific; guint16 command_status; GError *command_error; guint64 lba; guint32 nsid; BDNVMETransportType transport_type; } BDNVMEErrorLogEntry; /** * bd_nvme_error_log_entry_free: (skip) * @entry: (nullable): %BDNVMEErrorLogEntry to free * * Frees @entry. */ void bd_nvme_error_log_entry_free (BDNVMEErrorLogEntry *entry) { if (entry == NULL) return; if (entry->command_error) g_error_free (entry->command_error); g_free (entry); } /** * bd_nvme_error_log_entry_copy: (skip) * @entry: (nullable): %BDNVMEErrorLogEntry to copy * * Creates a new copy of @entry. */ BDNVMEErrorLogEntry * bd_nvme_error_log_entry_copy (BDNVMEErrorLogEntry *entry) { BDNVMEErrorLogEntry *new_entry; if (entry == NULL) return NULL; new_entry = g_new0 (BDNVMEErrorLogEntry, 1); memcpy (new_entry, entry, sizeof (BDNVMEErrorLogEntry)); if (entry->command_error) new_entry->command_error = g_error_copy (entry->command_error); return new_entry; } GType bd_nvme_error_log_entry_get_type () { static GType type = 0; if (G_UNLIKELY (type == 0)) { type = g_boxed_type_register_static ("BDNVMEErrorLogEntry", (GBoxedCopyFunc) bd_nvme_error_log_entry_copy, (GBoxedFreeFunc) bd_nvme_error_log_entry_free); } return type; } /* BpG-skip */ /** * BDNVMESelfTestAction: * Action taken by the Device Self-test command. * @BD_NVME_SELF_TEST_ACTION_NOT_RUNNING: No device self-test operation in progress. Not a valid argument for bd_nvme_device_self_test(). * @BD_NVME_SELF_TEST_ACTION_SHORT: Start a short device self-test operation. * @BD_NVME_SELF_TEST_ACTION_EXTENDED: Start an extended device self-test operation. * @BD_NVME_SELF_TEST_ACTION_VENDOR_SPECIFIC: Start a vendor specific device self-test operation. * @BD_NVME_SELF_TEST_ACTION_ABORT: Abort the device self-test operation. Only valid for bd_nvme_device_self_test(). */ /* BpG-skip-end */ typedef enum { BD_NVME_SELF_TEST_ACTION_NOT_RUNNING = 0, BD_NVME_SELF_TEST_ACTION_SHORT = 1, BD_NVME_SELF_TEST_ACTION_EXTENDED = 2, BD_NVME_SELF_TEST_ACTION_VENDOR_SPECIFIC = 3, BD_NVME_SELF_TEST_ACTION_ABORT = 4, } BDNVMESelfTestAction; /* BpG-skip */ /** * BDNVMESelfTestResult: * Self-test log entry result value. * @BD_NVME_SELF_TEST_RESULT_NO_ERROR: Operation completed without error. * @BD_NVME_SELF_TEST_RESULT_ABORTED: Operation was aborted by a Device Self-test command. * @BD_NVME_SELF_TEST_RESULT_CTRL_RESET: Operation was aborted by a Controller Level Reset. * @BD_NVME_SELF_TEST_RESULT_NS_REMOVED: Operation was aborted due to a removal of a namespace from the namespace inventory. * @BD_NVME_SELF_TEST_RESULT_ABORTED_FORMAT: Operation was aborted due to the processing of a Format NVM command. * @BD_NVME_SELF_TEST_RESULT_FATAL_ERROR: A fatal error or unknown test error occurred while the controller was executing the device self-test operation and the operation did not complete. * @BD_NVME_SELF_TEST_RESULT_UNKNOWN_SEG_FAIL: Operation completed with a segment that failed and the segment that failed is not known. * @BD_NVME_SELF_TEST_RESULT_KNOWN_SEG_FAIL: Operation completed with one or more failed segments and the first segment that failed is indicated in the Segment Number field. * @BD_NVME_SELF_TEST_RESULT_ABORTED_UNKNOWN: Operation was aborted for unknown reason. * @BD_NVME_SELF_TEST_RESULT_ABORTED_SANITIZE: Operation was aborted due to a sanitize operation. */ /* BpG-skip-end */ typedef enum { BD_NVME_SELF_TEST_RESULT_NO_ERROR = 0, BD_NVME_SELF_TEST_RESULT_ABORTED = 1, BD_NVME_SELF_TEST_RESULT_CTRL_RESET = 2, BD_NVME_SELF_TEST_RESULT_NS_REMOVED = 3, BD_NVME_SELF_TEST_RESULT_ABORTED_FORMAT = 4, BD_NVME_SELF_TEST_RESULT_FATAL_ERROR = 5, BD_NVME_SELF_TEST_RESULT_UNKNOWN_SEG_FAIL = 6, BD_NVME_SELF_TEST_RESULT_KNOWN_SEG_FAIL = 7, BD_NVME_SELF_TEST_RESULT_ABORTED_UNKNOWN = 8, BD_NVME_SELF_TEST_RESULT_ABORTED_SANITIZE = 9, } BDNVMESelfTestResult; /** * bd_nvme_self_test_result_to_string: * @result: A %BDNVMESelfTestResult. * @error: (out) (optional): place to store error (if any) * * Returns: (transfer none): A string representation of @result for use as an identifier string * or %NULL when the code is unknown. */ const gchar * bd_nvme_self_test_result_to_string (BDNVMESelfTestResult result, GError **error); #define BD_NVME_TYPE_SELF_TEST_LOG_ENTRY (bd_nvme_self_test_log_entry_get_type ()) GType bd_nvme_self_test_log_entry_get_type (); /** * BDNVMESelfTestLogEntry: * @result: Result of the device self-test operation. * @action: The Self-test Code value (action) that was specified in the Device Self-test command that started this device self-test operation. * @segment: Segment number where the first self-test failure occurred. Valid only when @result is set to #BD_NVME_SELF_TEST_RESULT_KNOWN_SEG_FAIL. * @power_on_hours: Number of power-on hours at the time the device self-test operation was completed or aborted. Does not include time that the controller was powered and in a low power state condition. * @nsid: Namespace ID that the Failing LBA occurred on. * @failing_lba: LBA of the logical block that caused the test to fail. If the device encountered more than one failed logical block during the test, then this field only indicates one of those failed logical blocks. * @status_code_error: Translated NVMe Command Status Code representing additional information related to errors or conditions. */ typedef struct BDNVMESelfTestLogEntry { BDNVMESelfTestResult result; BDNVMESelfTestAction action; guint8 segment; guint64 power_on_hours; guint32 nsid; guint64 failing_lba; GError *status_code_error; } BDNVMESelfTestLogEntry; /** * bd_nvme_self_test_log_entry_free: (skip) * @entry: (nullable): %BDNVMESelfTestLogEntry to free * * Frees @entry. */ void bd_nvme_self_test_log_entry_free (BDNVMESelfTestLogEntry *entry) { if (entry == NULL) return; if (entry->status_code_error) g_error_free (entry->status_code_error); g_free (entry); } /** * bd_nvme_self_test_log_entry_copy: (skip) * @entry: (nullable): %BDNVMESelfTestLogEntry to copy * * Creates a new copy of @entry. */ BDNVMESelfTestLogEntry * bd_nvme_self_test_log_entry_copy (BDNVMESelfTestLogEntry *entry) { BDNVMESelfTestLogEntry *new_entry; if (entry == NULL) return NULL; new_entry = g_new0 (BDNVMESelfTestLogEntry, 1); memcpy (new_entry, entry, sizeof (BDNVMESelfTestLogEntry)); if (entry->status_code_error) new_entry->status_code_error = g_error_copy (entry->status_code_error); return new_entry; } GType bd_nvme_self_test_log_entry_get_type () { static GType type = 0; if (G_UNLIKELY (type == 0)) { type = g_boxed_type_register_static ("BDNVMESelfTestLogEntry", (GBoxedCopyFunc) bd_nvme_self_test_log_entry_copy, (GBoxedFreeFunc) bd_nvme_self_test_log_entry_free); } return type; } #define BD_NVME_TYPE_SELF_TEST_LOG (bd_nvme_self_test_log_get_type ()) GType bd_nvme_self_test_log_get_type (); /** * BDNVMESelfTestLog: * @current_operation: Current running device self-test operation. There's no corresponding record in @entries for a device self-test operation that is in progress. * @current_operation_completion: Percentage of the currently running device self-test operation. Only valid when @current_operation is other than #BD_NVME_SELF_TEST_ACTION_NOT_RUNNING. * @entries: (array zero-terminated=1) (element-type BDNVMESelfTestLogEntry): Self-test log entries for the last 20 operations, sorted from newest (first element) to oldest. */ typedef struct BDNVMESelfTestLog { BDNVMESelfTestAction current_operation; guint8 current_operation_completion; BDNVMESelfTestLogEntry **entries; } BDNVMESelfTestLog; /** * bd_nvme_self_test_log_free: (skip) * @log: (nullable): %BDNVMESelfTestLog to free * * Frees @log. */ void bd_nvme_self_test_log_free (BDNVMESelfTestLog *log) { BDNVMESelfTestLogEntry **entries; if (log == NULL) return; for (entries = log->entries; entries && *entries; entries++) bd_nvme_self_test_log_entry_free (*entries); g_free (log->entries); g_free (log); } /** * bd_nvme_self_test_log_copy: (skip) * @log: (nullable): %BDNVMESelfTestLog to copy * * Creates a new copy of @log. */ BDNVMESelfTestLog * bd_nvme_self_test_log_copy (BDNVMESelfTestLog *log) { BDNVMESelfTestLog *new_log; BDNVMESelfTestLogEntry **entries; GPtrArray *ptr_array; if (log == NULL) return NULL; new_log = g_new0 (BDNVMESelfTestLog, 1); memcpy (new_log, log, sizeof (BDNVMESelfTestLog)); ptr_array = g_ptr_array_new (); for (entries = log->entries; entries && *entries; entries++) g_ptr_array_add (ptr_array, bd_nvme_self_test_log_entry_copy (*entries)); g_ptr_array_add (ptr_array, NULL); new_log->entries = (BDNVMESelfTestLogEntry **) g_ptr_array_free (ptr_array, FALSE); return new_log; } GType bd_nvme_self_test_log_get_type () { static GType type = 0; if (G_UNLIKELY (type == 0)) { type = g_boxed_type_register_static ("BDNVMESelfTestLog", (GBoxedCopyFunc) bd_nvme_self_test_log_copy, (GBoxedFreeFunc) bd_nvme_self_test_log_free); } return type; } /* BpG-skip */ /** * BDNVMEFormatSecureErase: * Optional Format NVM secure erase action. * @BD_NVME_FORMAT_SECURE_ERASE_NONE: No secure erase operation requested. * @BD_NVME_FORMAT_SECURE_ERASE_USER_DATA: User Data Erase: All user data shall be erased, contents of the user data after the erase is indeterminate * (e.g., the user data may be zero filled, one filled, etc.). If a User Data Erase is requested and all affected * user data is encrypted, then the controller is allowed to use a cryptographic erase to perform the requested User Data Erase. * @BD_NVME_FORMAT_SECURE_ERASE_CRYPTO: Cryptographic Erase: All user data shall be erased cryptographically. This is accomplished by deleting the encryption key. */ /* BpG-skip-end */ typedef enum { BD_NVME_FORMAT_SECURE_ERASE_NONE = 0, BD_NVME_FORMAT_SECURE_ERASE_USER_DATA = 1, BD_NVME_FORMAT_SECURE_ERASE_CRYPTO = 2, } BDNVMEFormatSecureErase; /* BpG-skip */ /** * BDNVMESanitizeStatus: * @BD_NVME_SANITIZE_STATUS_NEVER_SANITIZED: The NVM subsystem has never been sanitized. * @BD_NVME_SANITIZE_STATUS_IN_PROGESS: A sanitize operation is currently in progress. * @BD_NVME_SANITIZE_STATUS_SUCCESS: The most recent sanitize operation completed successfully including any additional media modification. * @BD_NVME_SANITIZE_STATUS_SUCCESS_NO_DEALLOC: The most recent sanitize operation for which No-Deallocate After Sanitize was requested has completed successfully with deallocation of all user data. * @BD_NVME_SANITIZE_STATUS_FAILED: The most recent sanitize operation failed. */ /* BpG-skip-end */ typedef enum { BD_NVME_SANITIZE_STATUS_NEVER_SANITIZED = 0, BD_NVME_SANITIZE_STATUS_IN_PROGESS = 1, BD_NVME_SANITIZE_STATUS_SUCCESS = 2, BD_NVME_SANITIZE_STATUS_SUCCESS_NO_DEALLOC = 3, BD_NVME_SANITIZE_STATUS_FAILED = 4, } BDNVMESanitizeStatus; #define BD_NVME_TYPE_SANITIZE_LOG (bd_nvme_sanitize_log_get_type ()) GType bd_nvme_sanitize_log_get_type (); /** * BDNVMESanitizeLog: * @sanitize_progress: The percentage complete of the sanitize operation. * @sanitize_status: The status of the most recent sanitize operation. * @global_data_erased: Indicates that no user data has been written either since the drive was manufactured and * has never been sanitized or since the most recent successful sanitize operation. * @overwrite_passes: Number of completed passes if the most recent sanitize operation was an Overwrite. * @time_for_overwrite: Estimated time in seconds needed to complete an Overwrite sanitize operation with 16 passes in the background. * A value of -1 means that no time estimate is reported. A value of 0 means that the operation is expected * to be completed in the background when the Sanitize command is completed. * @time_for_block_erase: Estimated time in seconds needed to complete a Block Erase sanitize operation in the background. * A value of -1 means that no time estimate is reported. A value of 0 means that the operation is expected * to be completed in the background when the Sanitize command is completed. * @time_for_crypto_erase: Estimated time in seconds needed to complete a Crypto Erase sanitize operation in the background. * A value of -1 means that no time estimate is reported. A value of 0 means that the operation is expected * to be completed in the background when the Sanitize command is completed. * @time_for_overwrite_nd: Estimated time in seconds needed to complete an Overwrite sanitize operation and the associated * additional media modification in the background when the No-Deallocate After Sanitize or * the No-Deallocate Modifies Media After Sanitize features have been requested. * @time_for_block_erase_nd: Estimated time in seconds needed to complete a Block Erase sanitize operation and the associated * additional media modification in the background when the No-Deallocate After Sanitize or * the No-Deallocate Modifies Media After Sanitize features have been requested. * @time_for_crypto_erase_nd: Estimated time in seconds needed to complete a Crypto Erase sanitize operation and the associated * additional media modification in the background when the No-Deallocate After Sanitize or * the No-Deallocate Modifies Media After Sanitize features have been requested. */ typedef struct BDNVMESanitizeLog { gdouble sanitize_progress; BDNVMESanitizeStatus sanitize_status; gboolean global_data_erased; guint8 overwrite_passes; gint64 time_for_overwrite; gint64 time_for_block_erase; gint64 time_for_crypto_erase; gint64 time_for_overwrite_nd; gint64 time_for_block_erase_nd; gint64 time_for_crypto_erase_nd; } BDNVMESanitizeLog; /** * bd_nvme_sanitize_log_free: (skip) * @log: (nullable): %BDNVMESanitizeLog to free * * Frees @log. */ void bd_nvme_sanitize_log_free (BDNVMESanitizeLog *log) { if (log == NULL) return; g_free (log); } /** * bd_nvme_sanitize_log_copy: (skip) * @log: (nullable): %BDNVMESanitizeLog to copy * * Creates a new copy of @log. */ BDNVMESanitizeLog * bd_nvme_sanitize_log_copy (BDNVMESanitizeLog *log) { BDNVMESanitizeLog *new_log; if (log == NULL) return NULL; new_log = g_new0 (BDNVMESanitizeLog, 1); memcpy (new_log, log, sizeof (BDNVMESanitizeLog)); return new_log; } GType bd_nvme_sanitize_log_get_type () { static GType type = 0; if (G_UNLIKELY (type == 0)) { type = g_boxed_type_register_static ("BDNVMESanitizeLog", (GBoxedCopyFunc) bd_nvme_sanitize_log_copy, (GBoxedFreeFunc) bd_nvme_sanitize_log_free); } return type; } /* BpG-skip */ /** * BDNVMESanitizeAction: * @BD_NVME_SANITIZE_ACTION_EXIT_FAILURE: Exit Failure Mode. * @BD_NVME_SANITIZE_ACTION_BLOCK_ERASE: Start a Block Erase sanitize operation - a low-level block erase method that is specific to the media. * @BD_NVME_SANITIZE_ACTION_OVERWRITE: Start an Overwrite sanitize operation - writing a fixed data pattern or related patterns in multiple passes. * @BD_NVME_SANITIZE_ACTION_CRYPTO_ERASE: Start a Crypto Erase sanitize operation - changing the media encryption keys for all locations on the media. */ /* BpG-skip-end */ typedef enum { BD_NVME_SANITIZE_ACTION_EXIT_FAILURE = 0, BD_NVME_SANITIZE_ACTION_BLOCK_ERASE = 1, BD_NVME_SANITIZE_ACTION_OVERWRITE = 2, BD_NVME_SANITIZE_ACTION_CRYPTO_ERASE = 3, } BDNVMESanitizeAction; /** * bd_nvme_get_controller_info: * @device: a NVMe controller device (e.g. `/dev/nvme0`) * @error: (out) (nullable): place to store error (if any) * * Retrieves information about the NVMe controller (the Identify Controller command) * as specified by the @device block device path. * * Returns: (transfer full): information about given controller or %NULL in case of an error (with @error set). * * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_INFO */ BDNVMEControllerInfo * bd_nvme_get_controller_info (const gchar *device, GError **error); /** * bd_nvme_get_namespace_info: * @device: a NVMe namespace device (e.g. `/dev/nvme0n1`) * @error: (out) (nullable): place to store error (if any) * * Retrieves information about the NVMe namespace (the Identify Namespace command) * as specified by the @device block device path. * * Returns: (transfer full): information about given namespace or %NULL in case of an error (with @error set). * * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_INFO */ BDNVMENamespaceInfo * bd_nvme_get_namespace_info (const gchar *device, GError **error); /** * bd_nvme_get_smart_log: * @device: a NVMe controller device (e.g. `/dev/nvme0`) * @error: (out) (nullable): place to store error (if any) * * Retrieves drive SMART and general health information (Log Identifier `02h`). * The information provided is over the life of the controller and is retained across power cycles. * * Returns: (transfer full): health log data or %NULL in case of an error (with @error set). * * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_INFO */ BDNVMESmartLog * bd_nvme_get_smart_log (const gchar *device, GError **error); /** * bd_nvme_get_error_log_entries: * @device: a NVMe controller device (e.g. `/dev/nvme0`) * @error: (out) (nullable): place to store error (if any) * * Retrieves Error Information Log (Log Identifier `01h`) entries, used to describe * extended error information for a command that completed with error or to report * an error that is not specific to a particular command. This log is global to the * controller. The ordering of the entries is based on the time when the error * occurred, with the most recent error being returned as the first log entry. * As the number of entries is typically limited by the drive implementation, only * most recent entries are provided. * * Returns: (transfer full) (array zero-terminated=1): null-terminated list * of error entries or %NULL in case of an error (with @error set). * * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_INFO */ BDNVMEErrorLogEntry ** bd_nvme_get_error_log_entries (const gchar *device, GError **error); /** * bd_nvme_get_self_test_log: * @device: a NVMe controller device (e.g. `/dev/nvme0`) * @error: (out) (nullable): place to store error (if any) * * Retrieves drive self-test log (Log Identifier `06h`). Provides the status of a self-test operation * in progress and the percentage complete of that operation, along with the results of the last * 20 device self-test operations. * * Returns: (transfer full): self-test log data or %NULL in case of an error (with @error set). * * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_INFO */ BDNVMESelfTestLog * bd_nvme_get_self_test_log (const gchar *device, GError **error); /** * bd_nvme_get_sanitize_log: * @device: a NVMe controller device (e.g. `/dev/nvme0`) * @error: (out) (nullable): place to store error (if any) * * Retrieves the drive sanitize status log (Log Identifier `81h`) that includes information * about the most recent sanitize operation and the sanitize operation time estimates. * * As advised in the NVMe specification whitepaper the host should limit polling * to retrieve progress of a running sanitize operations (e.g. to at most once every * several minutes) to avoid interfering with the progress of the sanitize operation itself. * * Returns: (transfer full): sanitize log data or %NULL in case of an error (with @error set). * * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_INFO */ BDNVMESanitizeLog * bd_nvme_get_sanitize_log (const gchar *device, GError **error); /** * bd_nvme_device_self_test: * @device: a NVMe controller or namespace device (e.g. `/dev/nvme0`) * @action: self-test action to take. * @error: (out) (nullable): place to store error (if any) * * Initiates or aborts the Device Self-test operation on the controller or a namespace, * distinguished by the @device path specified. In case a controller device * is specified then the self-test operation would include all active namespaces. * * To abort a running operation, pass #BD_NVME_SELF_TEST_ACTION_ABORT as @action. * To retrieve progress of a current running operation, check the self-test log using * bd_nvme_get_self_test_log(). * * Returns: %TRUE if the device self-test command was issued successfully, * %FALSE otherwise with @error set. * * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_MANAGE */ gboolean bd_nvme_device_self_test (const gchar *device, BDNVMESelfTestAction action, GError **error); /** * bd_nvme_format: * @device: NVMe namespace or controller device to format (e.g. `/dev/nvme0n1`) * @lba_data_size: desired LBA data size (i.e. a sector size) in bytes or `0` to keep current. See #BDNVMELBAFormat and bd_nvme_get_namespace_info(). * @metadata_size: desired metadata size in bytes or `0` for default. See #BDNVMELBAFormat and bd_nvme_get_namespace_info(). * @secure_erase: optional secure erase action to take. * @error: (out) (nullable): place to store error (if any) * * Performs low level format of the NVM media, destroying all data and metadata for either * a specific namespace or all attached namespaces to the controller. Use this command * to change LBA sector size. Optional secure erase method can be specified as well. * * Supported LBA data sizes for a given namespace can be listed using the bd_nvme_get_namespace_info() * call. In case of a special value `0` the current LBA format for a given namespace will be * retained. When called on a controller device the first namespace is used as a reference. * * Note that the NVMe controller may define a Format NVM attribute indicating that the format * operation would apply to all namespaces and a format (excluding secure erase) of any * namespace results in a format of all namespaces in the NVM subsystem. In such case and * when @device is a namespace block device the #BD_NVME_ERROR_WOULD_FORMAT_ALL_NS error * is returned to prevent further damage. This is then supposed to be handled by the caller * and bd_nvme_format() is supposed to be called on a controller device instead. * * This call blocks until the format operation has finished. To retrieve progress * of a current running operation, check the namespace info using bd_nvme_get_namespace_info(). * * Returns: %TRUE if the format command finished successfully, %FALSE otherwise with @error set. * * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_MANAGE */ gboolean bd_nvme_format (const gchar *device, guint16 lba_data_size, guint16 metadata_size, BDNVMEFormatSecureErase secure_erase, GError **error); /** * bd_nvme_sanitize: * @device: NVMe namespace or controller device to format (e.g. `/dev/nvme0n1`) * @action: the sanitize action to perform. * @no_dealloc: instruct the controller to not deallocate the affected media area. * @overwrite_pass_count: number of overwrite passes [1-15] or 0 for the default (16 passes). * @overwrite_pattern: a 32-bit pattern used for the Overwrite sanitize operation. * @overwrite_invert_pattern: invert the overwrite pattern between passes. * @error: (out) (nullable): place to store error (if any) * * Starts a sanitize operation or recovers from a previously failed sanitize operation. * By definition, a sanitize operation alters all user data in the NVM subsystem such * that recovery of any previous user data from any cache, the non-volatile media, * or any Controller Memory Buffer is not possible. The scope of a sanitize operation * is all locations in the NVM subsystem that are able to contain user data, including * caches, Persistent Memory Regions, and unallocated or deallocated areas of the media. * * Once started, a sanitize operation is not able to be aborted and continues after * a Controller Level Reset including across power cycles. Once the sanitize operation * has run the media affected may not be immediately ready for use unless additional * media modification mechanism is run. This is often vendor specific and also depends * on the sanitize method (@action) used. Callers to this sanitize operation should * set @no_dealloc to %TRUE for the added convenience. * * The controller also ignores Critical Warning(s) in the SMART / Health Information * log page (e.g., read only mode) and attempts to complete the sanitize operation requested. * * This call returns immediately and the actual sanitize operation is performed * in the background. Use bd_nvme_get_sanitize_log() to retrieve status and progress * of a running sanitize operation. In case a sanitize operation fails the controller * may restrict its operation until a subsequent sanitize operation is started * (i.e. retried) or an #BD_NVME_SANITIZE_ACTION_EXIT_FAILURE action is used * to acknowledge the failure explicitly. * * The @overwrite_pass_count, @overwrite_pattern and @overwrite_invert_pattern * arguments are only valid when @action is #BD_NVME_SANITIZE_ACTION_OVERWRITE. * * The sanitize operation is set to run under the Allow Unrestricted Sanitize Exit * mode. * * Returns: %TRUE if the format command finished successfully, %FALSE otherwise with @error set. * * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_MANAGE */ gboolean bd_nvme_sanitize (const gchar *device, BDNVMESanitizeAction action, gboolean no_dealloc, gint overwrite_pass_count, guint32 overwrite_pattern, gboolean overwrite_invert_pattern, GError **error); /** * bd_nvme_get_host_nqn: * @error: (out) (nullable): Place to store error (if any). * * Reads the Host NQN (NVM Qualified Name) value from the global `/etc/nvme/hostnqn` * file. An empty string is an indication that no Host NQN has been set. * * Returns: (transfer full): the Host NQN string or an empty string if none set. * * Tech category: %BD_NVME_TECH_FABRICS-%BD_NVME_TECH_MODE_INITIATOR */ gchar * bd_nvme_get_host_nqn (GError **error); /** * bd_nvme_generate_host_nqn: * @error: (out) (nullable): Place to store error (if any). * * Compute new Host NQN (NVM Qualified Name) value for the current system. This * takes in account various system identifiers (DMI, device tree) with the goal * of a stable unique identifier whenever feasible. * * Returns: (transfer full): the Host NQN string or %NULL with @error set. * * Tech category: %BD_NVME_TECH_FABRICS-%BD_NVME_TECH_MODE_INITIATOR */ gchar * bd_nvme_generate_host_nqn (GError **error); /** * bd_nvme_get_host_id: * @error: (out) (nullable): Place to store error (if any). * * Reads the Host ID value from the global `/etc/nvme/hostid` file. An empty * string is an indication that no Host ID has been set. * * Returns: (transfer full): the Host ID string or an empty string if none set. * * Tech category: %BD_NVME_TECH_FABRICS-%BD_NVME_TECH_MODE_INITIATOR */ gchar * bd_nvme_get_host_id (GError **error); /** * bd_nvme_set_host_nqn: * @host_nqn: The Host NVM Qualified Name. * @error: (out) (nullable): Place to store error (if any). * * Writes the Host NQN (NVM Qualified Name) value to the system `/etc/nvme/hostnqn` file. * No validation of the string is performed. * * Returns: %TRUE if the value was set successfully or %FALSE otherwise with @error set. * * Tech category: %BD_NVME_TECH_FABRICS-%BD_NVME_TECH_MODE_INITIATOR */ gboolean bd_nvme_set_host_nqn (const gchar *host_nqn, GError **error); /** * bd_nvme_set_host_id: * @host_id: The Host ID. * @error: (out) (nullable): Place to store error (if any). * * Writes the Host ID value to the system `/etc/nvme/hostid` file. * No validation of the string is performed. * * Returns: %TRUE if the value was set successfully or %FALSE otherwise with @error set. * * Tech category: %BD_NVME_TECH_FABRICS-%BD_NVME_TECH_MODE_INITIATOR */ gboolean bd_nvme_set_host_id (const gchar *host_id, GError **error); /** * bd_nvme_connect: * @subsysnqn: The name for the NVMe subsystem to connect to. * @transport: The network fabric used for a NVMe-over-Fabrics network. * @transport_addr: (nullable): The network address of the Controller. For transports using IP addressing (e.g. `rdma`) this should be an IP-based address. * @transport_svcid: (nullable): The transport service id. For transports using IP addressing (e.g. `rdma`) this field is the port number. By default, the IP port number for the `RDMA` transport is `4420`. * @host_traddr: (nullable): The network address used on the host to connect to the Controller. For TCP, this sets the source address on the socket. * @host_iface: (nullable): The network interface used on the host to connect to the Controller (e.g. IP `eth1`, `enp2s0`). This forces the connection to be made on a specific interface instead of letting the system decide. * @host_nqn: (nullable): Overrides the default Host NQN that identifies the NVMe Host. If this option is %NULL, the default is read from `/etc/nvme/hostnqn` first. * If that does not exist, the autogenerated NQN value from the NVMe Host kernel module is used next. The Host NQN uniquely identifies the NVMe Host. * @host_id: (nullable): User-defined host UUID or %NULL to use default (as defined in `/etc/nvme/hostid`) * @extra: (nullable) (array zero-terminated=1): Additional arguments. * @error: (out) (nullable): Place to store error (if any). * * Creates a transport connection to a remote system (specified by @transport_addr and @transport_svcid) * and creates a NVMe over Fabrics controller for the NVMe subsystem specified by the @subsysnqn option. * * Valid values for @transport include: * - `"rdma"`: An rdma network (RoCE, iWARP, Infiniband, basic rdma, etc.) * - `"fc"`: A Fibre Channel network. * - `"tcp"`: A TCP/IP network. * - `"loop"`: A NVMe over Fabrics target on the local host. * * In addition to the primary options it's possible to supply @extra arguments: * - `"config"`: Use the specified JSON configuration file instead of the default file (see below) or * specify `"none"` to avoid reading any configuration file. * - `"dhchap_key"`: NVMe In-band authentication secret in ASCII format as described * in the NVMe 2.0 specification. When not specified, the secret is by default read * from `/etc/nvme/hostkey`. In case that file does not exist no in-band authentication * is attempted. * - `"dhchap_ctrl_key"`: NVMe In-band authentication controller secret for bi-directional authentication. * When not specified, no bi-directional authentication is attempted. * - `"nr_io_queues"`: The number of I/O queues. * - `"nr_write_queues"`: Number of additional queues that will be used for write I/O. * - `"nr_poll_queues"`: Number of additional queues that will be used for polling latency sensitive I/O. * - `"queue_size"`: Number of elements in the I/O queues. * - `"keep_alive_tmo"`: The keep alive timeout (in seconds). * - `"reconnect_delay"`: The delay (in seconds) before reconnect is attempted after a connect loss. * - `"ctrl_loss_tmo"`: The controller loss timeout period (in seconds). A special value of `-1` will cause reconnecting forever. * - `"fast_io_fail_tmo"`: Fast I/O Fail timeout (in seconds). * - `"tos"`: Type of service. * - `"duplicate_connect"`: Allow duplicated connections between same transport host and subsystem port. Boolean value. * - `"disable_sqflow"`: Disables SQ flow control to omit head doorbell update for submission queues when sending nvme completions. Boolean value. * - `"hdr_digest"`: Generates/verifies header digest (TCP). Boolean value. * - `"data_digest"`: Generates/verifies data digest (TCP). Boolean value. * - `"tls"`: Enable TLS encryption (TCP). Boolean value. * - `"hostsymname"`: TP8010: NVMe host symbolic name. * - `"keyring"`: Keyring to store and lookup keys. String value. * - `"tls_key"`: TLS PSK for the connection. String value. * * Boolean values can be expressed by "0"/"1", "on"/"off" or "True"/"False" case-insensitive * strings. Failed numerical or boolean string conversions will result in the option being ignored. * * By default additional options are read from the default configuration file `/etc/nvme/config.json`. * This follows the default behaviour of `nvme-cli`. Use the @extra `"config"` argument * to either specify a different config file or disable use of it. The JSON configuration * file format is documented in [https://raw.githubusercontent.com/linux-nvme/libnvme/master/doc/config-schema.json](https://raw.githubusercontent.com/linux-nvme/libnvme/master/doc/config-schema.json). * As a rule @extra key names are kept consistent with the JSON config file schema. * Any @extra option generally overrides particular option specified in a configuration file. * * Returns: %TRUE if the subsystem was connected successfully, %FALSE otherwise with @error set. * * Tech category: %BD_NVME_TECH_FABRICS-%BD_NVME_TECH_MODE_INITIATOR */ gboolean bd_nvme_connect (const gchar *subsysnqn, const gchar *transport, const gchar *transport_addr, const gchar *transport_svcid, const gchar *host_traddr, const gchar *host_iface, const gchar *host_nqn, const gchar *host_id, const BDExtraArg **extra, GError **error); /** * bd_nvme_disconnect: * @subsysnqn: The name of the NVMe subsystem to disconnect. * @error: (out) (nullable): Place to store error (if any). * * Disconnects and removes one or more existing NVMe over Fabrics controllers. * This may disconnect multiple controllers with matching @subsysnqn and %TRUE * is only returned when all controllers were disconnected successfully. * * Returns: %TRUE if all matching controllers were disconnected successfully, %FALSE with @error * set in case of a disconnect error or when no matching controllers were found. * * Tech category: %BD_NVME_TECH_FABRICS-%BD_NVME_TECH_MODE_INITIATOR */ gboolean bd_nvme_disconnect (const gchar *subsysnqn, GError **error); /** * bd_nvme_disconnect_by_path: * @path: NVMe controller device to disconnect (e.g. `/dev/nvme0`). * @error: (out) (nullable): Place to store error (if any). * * Disconnects and removes a NVMe over Fabrics controller represented * by a block device path. * * Returns: %TRUE if the controller was disconnected successfully, * %FALSE otherwise with @error set. * * Tech category: %BD_NVME_TECH_FABRICS-%BD_NVME_TECH_MODE_INITIATOR */ gboolean bd_nvme_disconnect_by_path (const gchar *path, GError **error); /** * bd_nvme_find_ctrls_for_ns: * @ns_sysfs_path: NVMe namespace device file. * @subsysnqn: (nullable): Limit matching to the specified subsystem NQN. * @host_nqn: (nullable): Limit matching to the specified host NQN. * @host_id: (nullable): Limit matching to the specified host ID. * @error: (out) (nullable): Place to store error (if any). * * A convenient utility function to look up all controllers associated * with a NVMe subsystem the specified namespace is part of. * * Returns: (transfer full) (array zero-terminated=1): list of controller sysfs paths * or %NULL in case of an error (with @error set). * * Tech category: %BD_NVME_TECH_FABRICS-%BD_NVME_TECH_MODE_INITIATOR */ gchar ** bd_nvme_find_ctrls_for_ns (const gchar *ns_sysfs_path, const gchar *subsysnqn, const gchar *host_nqn, const gchar *host_id, GError **error); #endif /* BD_NVME_API */ libblockdev-3.1.1-1/src/lib/plugin_apis/part.api000066400000000000000000000347611460051510300214500ustar00rootroot00000000000000#include #include #include #ifndef BD_PART_API #define BD_PART_API GQuark bd_part_error_quark (void) { return g_quark_from_static_string ("g-bd-part-error-quark"); } #define BD_PART_ERROR bd_part_error_quark () typedef enum { BD_PART_ERROR_TECH_UNAVAIL, BD_PART_ERROR_FAIL, BD_PART_ERROR_INVAL, BD_PART_ERROR_EXISTS, } BDPartError; typedef enum { BD_PART_TABLE_MSDOS, BD_PART_TABLE_GPT, BD_PART_TABLE_UNDEF, } BDPartTableType; typedef enum { BD_PART_TYPE_NORMAL = 0x00, BD_PART_TYPE_LOGICAL = 0x01, BD_PART_TYPE_EXTENDED = 0x02, BD_PART_TYPE_FREESPACE = 0x04, BD_PART_TYPE_METADATA = 0x08, BD_PART_TYPE_PROTECTED = 0x10 } BDPartType; typedef enum { BD_PART_TYPE_REQ_NORMAL = 0x00, BD_PART_TYPE_REQ_LOGICAL = 0x01, BD_PART_TYPE_REQ_EXTENDED = 0x02, BD_PART_TYPE_REQ_NEXT = 0x04 } BDPartTypeReq; typedef enum { BD_PART_ALIGN_NONE, BD_PART_ALIGN_MINIMAL, BD_PART_ALIGN_OPTIMAL, } BDPartAlign; #define BD_PART_TYPE_SPEC (bd_part_spec_get_type ()) GType bd_part_spec_get_type(); /** * BDPartSpec: * @path: path of the partition (block device) * @name: name of the partition (for GPT partitions) * @uuid: UUID of the partition (for GPT partitions) * @id: id of the partition (for MSDOS partitions) * @type_guid: GUID of the partition's type (GPT) * @type: bit combination of partition's types (#BDPartType) * @start: start of the partition * @size: size of the partition * @bootable: whether the bootable flag is set or not (for MSDOS partitions) * @attrs: partition GPT attributes */ typedef struct BDPartSpec { gchar *path; gchar *name; gchar *uuid; gchar *id; gchar *type_guid; guint64 type; guint64 start; guint64 size; gboolean bootable; guint64 attrs; } BDPartSpec; BDPartSpec* bd_part_spec_copy (BDPartSpec *data) { if (data == NULL) return NULL; BDPartSpec *ret = g_new0 (BDPartSpec, 1); ret->path = g_strdup (data->path); ret->name = g_strdup (data->name); ret->name = g_strdup (data->uuid); ret->id = g_strdup (data->id); ret->type_guid = g_strdup (data->type_guid); ret->type = data->type; ret->start = data->start; ret->size = data->size; ret->bootable = data->bootable; ret->attrs = data->attrs; return ret; } void bd_part_spec_free (BDPartSpec *data) { if (data == NULL) return; g_free (data->path); g_free (data->name); g_free (data->uuid); g_free (data->id); g_free (data->type_guid); g_free (data); } GType bd_part_spec_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDPartSpec", (GBoxedCopyFunc) bd_part_spec_copy, (GBoxedFreeFunc) bd_part_spec_free); } return type; } #define BD_PART_TYPE_DISK_SPEC (bd_part_disk_spec_get_type ()) GType bd_part_disk_spec_get_type(); /** * BDPartDiskSpec: * @path: path of the disk (block device) * @table_type: type of the disk's partition table * @size: size of the disk * @sector_size: disk's sector size */ typedef struct BDPartDiskSpec { gchar *path; BDPartTableType table_type; guint64 size; guint64 sector_size; } BDPartDiskSpec; BDPartDiskSpec* bd_part_disk_spec_copy (BDPartDiskSpec *data) { if (data == NULL) return NULL; BDPartDiskSpec *ret = g_new0 (BDPartDiskSpec, 1); ret->path = g_strdup (data->path); ret->table_type = data->table_type; ret->size = data->size; ret->sector_size = data->sector_size; return ret; } void bd_part_disk_spec_free (BDPartDiskSpec *data) { if (data == NULL) return; g_free (data->path); g_free (data); } GType bd_part_disk_spec_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDPartDiskSpec", (GBoxedCopyFunc) bd_part_disk_spec_copy, (GBoxedFreeFunc) bd_part_disk_spec_free); } return type; } typedef enum { BD_PART_TECH_MBR = 0, BD_PART_TECH_GPT, } BDPartTech; typedef enum { BD_PART_TECH_MODE_CREATE_TABLE = 1 << 0, BD_PART_TECH_MODE_MODIFY_TABLE = 1 << 1, BD_PART_TECH_MODE_QUERY_TABLE = 1 << 2, BD_PART_TECH_MODE_MODIFY_PART = 1 << 3, BD_PART_TECH_MODE_QUERY_PART = 1 << 4, } BDPartTechMode; /** * bd_part_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDPartTechMode) for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_part_is_tech_avail (BDPartTech tech, guint64 mode, GError **error); /** * bd_part_create_table: * @disk: path of the disk block device to create partition table on * @type: type of the partition table to create * @ignore_existing: whether to ignore/overwrite the existing table or not * (reports an error if %FALSE and there's some table on @disk) * @error: (out) (optional): place to store error (if any) * * Returns: whether the partition table was successfully created or not * * Tech category: %BD_PART_TECH_MODE_CREATE_TABLE + the tech according to @type */ gboolean bd_part_create_table (const gchar *disk, BDPartTableType type, gboolean ignore_existing, GError **error); /** * bd_part_get_part_spec: * @disk: disk to remove the partition from * @part: partition to get spec for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): spec of the @part partition from @disk or %NULL in case of error * * Tech category: %BD_PART_TECH_MODE_QUERY_PART + the tech according to the partition table type */ BDPartSpec* bd_part_get_part_spec (const gchar *disk, const gchar *part, GError **error); /** * bd_part_get_part_by_pos: * @disk: disk to remove the partition from * @position: position (in bytes) determining the partition * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): spec of the partition from @disk spanning over the @position or %NULL if no such * partition exists or in case of error (@error is set) * * Tech category: %BD_PART_TECH_MODE_QUERY_PART + the tech according to the partition table type */ BDPartSpec* bd_part_get_part_by_pos (const gchar *disk, guint64 position, GError **error); /** * bd_part_get_disk_spec: * @disk: disk to get information about * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): information about the given @disk or %NULL (in case of error) * * Tech category: %BD_PART_TECH_MODE_QUERY_TABLE + the tech according to the partition table type */ BDPartDiskSpec* bd_part_get_disk_spec (const gchar *disk, GError **error); /** * bd_part_get_disk_parts: * @disk: disk to get information about partitions for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full) (array zero-terminated=1): specs of the partitions from @disk or %NULL in case of error * * Tech category: %BD_PART_TECH_MODE_QUERY_TABLE + the tech according to the partition table type */ BDPartSpec** bd_part_get_disk_parts (const gchar *disk, GError **error); /** * bd_part_get_disk_free_regions: * @disk: disk to get free regions for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full) (array zero-terminated=1): specs of the free regions from @disk or %NULL in case of error * * Tech category: %BD_PART_TECH_MODE_QUERY_TABLE + the tech according to the partition table type */ BDPartSpec** bd_part_get_disk_free_regions (const gchar *disk, GError **error); /** * bd_part_get_best_free_region: * @disk: disk to get the best free region for * @type: type of the partition that is planned to be added * @size: size of the partition to be added * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): spec of the best free region on @disk for a new partition of type @type * with the size of @size or %NULL if there is none such region or if * there was an error (@error gets populated) * * Note: For the @type %BD_PART_TYPE_NORMAL, the smallest possible space that *is not* in an extended partition * is found. For the @type %BD_PART_TYPE_LOGICAL, the smallest possible space that *is* in an extended * partition is found. For %BD_PART_TYPE_EXTENDED, the biggest possible space is found as long as there * is no other extended partition (there can only be one). * * Tech category: %BD_PART_TECH_MODE_QUERY_TABLE + the tech according to the partition table type */ BDPartSpec* bd_part_get_best_free_region (const gchar *disk, BDPartType type, guint64 size, GError **error); /** * bd_part_create_part: * @disk: disk to create partition on * @type: type of the partition to create (if %BD_PART_TYPE_REQ_NEXT, the * partition type will be determined automatically based on the existing * partitions) * @start: where the partition should start (i.e. offset from the disk start) * @size: desired size of the partition (if 0, a max-sized partition is created) * @align: alignment to use for the partition * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): specification of the created partition or %NULL in case of error * * NOTE: The resulting partition may start at a different position than given by * @start and can have different size than @size due to alignment. * * Tech category: %BD_PART_TECH_MODE_MODIFY_TABLE + the tech according to the partition table type */ BDPartSpec* bd_part_create_part (const gchar *disk, BDPartTypeReq type, guint64 start, guint64 size, BDPartAlign align, GError **error); /** * bd_part_delete_part: * @disk: disk to remove the partition from * @part: partition to remove * @error: (out) (optional): place to store error (if any) * * Returns: whether the @part partition was successfully deleted from @disk * * Tech category: %BD_PART_TECH_MODE_MODIFY_TABLE + the tech according to the partition table type */ gboolean bd_part_delete_part (const gchar *disk, const gchar *part, GError **error); /** * bd_part_resize_part: * @disk: disk containing the partition * @part: partition to resize * @size: new partition size, 0 for maximal size * @align: alignment to use for the partition end * @error: (out) (optional): place to store error (if any) * * Returns: whether the @part partition was successfully resized on @disk to @size * * NOTE: The resulting partition may be slightly bigger than requested due to alignment. * * Tech category: %BD_PART_TECH_MODE_MODIFY_TABLE + the tech according to the partition table type */ gboolean bd_part_resize_part (const gchar *disk, const gchar *part, guint64 size, BDPartAlign align, GError **error); /** * bd_part_set_part_name: * @disk: device the partition belongs to * @part: partition the name should be set for * @name: name to set * @error: (out) (optional): place to store error (if any) * * Returns: whether the name was successfully set or not * * Tech category: %BD_PART_TECH_GPT-%BD_PART_TECH_MODE_MODIFY_PART */ gboolean bd_part_set_part_name (const gchar *disk, const gchar *part, const gchar *name, GError **error); /** * bd_part_set_part_type: * @disk: device the partition belongs to * @part: partition the type should be set for * @type_guid: GUID of the type * @error: (out) (optional): place to store error (if any) * * Returns: whether the @type_guid type was successfully set for @part or not * * Tech category: %BD_PART_TECH_GPT-%BD_PART_TECH_MODE_MODIFY_PART */ gboolean bd_part_set_part_type (const gchar *disk, const gchar *part, const gchar *type_guid, GError **error); /** * bd_part_set_part_id: * @disk: device the partition belongs to * @part: partition the ID should be set for * @part_id: partition Id * @error: (out) (optional): place to store error (if any) * * Returns: whether the @part_id type was successfully set for @part or not * * Tech category: %BD_PART_TECH_MBR-%BD_PART_TECH_MODE_MODIFY_PART */ gboolean bd_part_set_part_id (const gchar *disk, const gchar *part, const gchar *part_id, GError **error); /** * bd_part_set_part_uuid: * @disk: device the partition belongs to * @part: partition the UUID should be set for * @uuid: partition UUID to set * @error: (out) (optional): place to store error (if any) * * Returns: whether the @uuid type was successfully set for @part or not * * Tech category: %BD_PART_TECH_MODE_MODIFY_PART + the tech according to the partition table type */ gboolean bd_part_set_part_uuid (const gchar *disk, const gchar *part, const gchar *uuid, GError **error); /** * bd_part_set_part_bootable: * @disk: device the partition belongs to * @part: partition the bootable flag should be set for * @bootable: whether to set or unset the bootable flag * @error: (out) (optional): place to store error (if any) * * Returns: whether the @bootable flag was successfully set for @part or not * * Tech category: %BD_PART_TECH_MBR-%BD_PART_TECH_MODE_MODIFY_PART */ gboolean bd_part_set_part_bootable (const gchar *disk, const gchar *part, gboolean bootable, GError **error); /** * bd_part_set_part_attributes: * @disk: device the partition belongs to * @part: partition the attributes should be set for * @attrs: GPT attributes to set on @part * @error: (out) (optional): place to store error (if any) * * Returns: whether the @attrs GPT attributes were successfully set for @part or not * * Tech category: %BD_PART_TECH_GPT-%BD_PART_TECH_MODE_MODIFY_PART */ gboolean bd_part_set_part_attributes (const gchar *disk, const gchar *part, guint64 attrs, GError **error); /** * bd_part_get_part_table_type_str: * @type: table type to get string representation for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer none): string representation of @table_type * * Tech category: the tech according to @type */ const gchar* bd_part_get_part_table_type_str (BDPartTableType type, GError **error); /** * bd_part_get_type_str: * @type: type to get string representation for * @error: (out) (optional): place to store error (if any) * * Returns: (transfer none): string representation of @type * * Tech category: always available */ const gchar* bd_part_get_type_str (BDPartType type, GError **error); #endif /* BD_PART_API */ libblockdev-3.1.1-1/src/lib/plugin_apis/s390.api000066400000000000000000000131251460051510300211670ustar00rootroot00000000000000#include #include #ifndef BD_S390_API #define BD_S390_API GQuark bd_s390_error_quark (void) { return g_quark_from_static_string ("g-bd-s390-error-quark"); } #define BD_S390_ERROR bd_s390_error_quark () typedef enum { BD_S390_ERROR_TECH_UNAVAIL, BD_S390_ERROR_DEVICE, BD_S390_ERROR_FORMAT_FAILED, BD_S390_ERROR_DASDFMT, BD_S390_ERROR_IO, } BDS390Error; typedef enum { BD_S390_TECH_DASD = 0, BD_S390_TECH_ZFCP, } BDS390Tech; typedef enum { BD_S390_TECH_MODE_MODIFY = 1 << 0, BD_S390_TECH_MODE_QUERY = 1 << 1, } BDS390TechMode; /** * bd_s390_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDS390TechMode) for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_s390_is_tech_avail (BDS390Tech tech, guint64 mode, GError **error); /** * bd_s390_dasd_format: * @dasd: dasd to format * @extra: (nullable) (array zero-terminated=1): extra options for the formatting (right now * passed to the 'dasdfmt' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether dasdfmt was successful or not * * Tech category: %BD_S390_TECH_DASD-%BD_S390_TECH_MODE_MODIFY */ gboolean bd_s390_dasd_format (const gchar *dasd, const BDExtraArg **extra, GError **error); /** * bd_s390_dasd_needs_format: * @dasd: dasd to check, whether it needs dasdfmt run on it * @error: (out) (optional): place to store error (if any) * * Returns: whether a dasd needs dasdfmt run against it * * Tech category: %BD_S390_TECH_DASD-%BD_S390_TECH_MODE_QUERY */ gboolean bd_s390_dasd_needs_format (const gchar *dasd, GError **error); /** * bd_s390_dasd_online: * @dasd: dasd to switch online * @error: (out) (optional): place to store error (if any) * * Returns: whether a dasd was successfully switched online * * Tech category: %BD_S390_TECH_DASD-%BD_S390_TECH_MODE_MODIFY */ gboolean bd_s390_dasd_online (const gchar *dasd, GError **error); /** * bd_s390_dasd_is_Ldl: * @dasd: dasd to check, whether it is LDL formatted * @error: (out) (optional): place to store error (if any) * * Returns: whether a dasd is LDL formatted * * Tech category: %BD_S390_TECH_DASD-%BD_S390_TECH_MODE_QUERY */ gboolean bd_s390_dasd_is_ldl (const gchar *dasd, GError **error); /** * bd_s390_dasd_is_fba: * @dasd: dasd to check, whether it is FBA * @error: (out) (optional): place to store error (if any) * * Returns: whether a dasd is FBA * * Tech category: %BD_S390_TECH_DASD-%BD_S390_TECH_MODE_QUERY */ gboolean bd_s390_dasd_is_fba (const gchar *dasd, GError **error); /** * bd_s390_sanitize_dev_input: * @dev: a DASD or zFCP device number * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): a synthesized dasd or zfcp device number * * Tech category: always available */ gchar* bd_s390_sanitize_dev_input (const gchar *dev, GError **error); /** * bd_s390_zfcp_sanitize_wwpn_input: * @wwpn: a zFCP WWPN identifier * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): a synthesized zFCP WWPN * * Tech category: always available */ gchar* bd_s390_zfcp_sanitize_wwpn_input (const gchar *wwpn, GError **error); /** * bd_s390_zfcp_sanitize_lun_input: * @lun: a zFCP LUN identifier * @error: (out) (optional): place to store error (if any) * * Returns: (transfer full): a synthesized zFCP LUN * * Tech category: always available */ gchar* bd_s390_zfcp_sanitize_lun_input (const gchar *lun, GError **error); /** * bd_s390_zfcp_online: * @devno: a zFCP device number * @wwpn: a zFCP WWPN identifier * @lun: a zFCP LUN identifier * @error: (out) (optional): place to store error (if any) * * Returns: whether a zFCP device was successfully switched online * * Tech category: %BD_S390_TECH_ZFCP-%BD_S390_TECH_MODE_MODIFY */ gboolean bd_s390_zfcp_online (const gchar *devno, const gchar *wwpn, const gchar *lun, GError **error); /** * bd_s390_zfcp_scsi_offline: * @devno: a zFCP device number * @wwpn: a zFCP WWPN identifier * @lun: a zFCP LUN identifier * @error: (out) (optional): place to store error (if any) * * Returns: whether a LUN was successfully removed from associated WWPN * * This function looks through /proc/scsi/scsi and manually removes LUNs from * associated WWPNs. zFCP devices are SCSI devices accessible over FCP protocol. * In z/OS the IODF (I/O definition file) contains basic information about the * I/O config, but WWPN and LUN configuration is done at the OS level, hence * this function becomes necessary when switching the device offline. This * particular sequence of actions is for some reason unnecessary when switching * the device online. Chalk it up to s390x being s390x. * * Tech category: %BD_S390_TECH_ZFCP-%BD_S390_TECH_MODE_MODIFY */ gboolean bd_s390_zfcp_scsi_offline(const gchar *devno, const gchar *wwpn, const gchar *lun, GError **error); /** * bd_s390_zfcp_offline: * @devno: zfcp device number * @wwpn: zfcp WWPN (World Wide Port Number) * @lun: zfcp LUN (Logical Unit Number) * @error: (out) (optional): place to store error (if any) * * Returns: whether a zfcp device was successfully switched offline * * Tech category: %BD_S390_TECH_ZFCP-%BD_S390_TECH_MODE_MODIFY */ gboolean bd_s390_zfcp_offline (const gchar *devno, const gchar *wwpn, const gchar *lun, GError **error); #endif /* BD_S390_API */ libblockdev-3.1.1-1/src/lib/plugin_apis/swap.api000066400000000000000000000111211460051510300214350ustar00rootroot00000000000000#include #include #ifndef BD_SWAP_API #define BD_SWAP_API GQuark bd_swap_error_quark (void) { return g_quark_from_static_string ("g-bd-swap-error-quark"); } #define BD_SWAP_ERROR bd_swap_error_quark () typedef enum { BD_SWAP_ERROR_TECH_UNAVAIL, BD_SWAP_ERROR_UNKNOWN_STATE, BD_SWAP_ERROR_ACTIVATE, BD_SWAP_ERROR_ACTIVATE_OLD, BD_SWAP_ERROR_ACTIVATE_SUSPEND, BD_SWAP_ERROR_ACTIVATE_UNKNOWN, BD_SWAP_ERROR_ACTIVATE_PAGESIZE, BD_SWAP_ERROR_LABEL_INVALID, BD_SWAP_ERROR_UUID_INVALID, } BDSwapError; typedef enum { BD_SWAP_TECH_SWAP = 0, } BDSwapTech; typedef enum { BD_SWAP_TECH_MODE_CREATE = 1 << 0, BD_SWAP_TECH_MODE_ACTIVATE_DEACTIVATE = 1 << 1, BD_SWAP_TECH_MODE_QUERY = 1 << 2, BD_SWAP_TECH_MODE_SET_LABEL = 1 << 3, BD_SWAP_TECH_MODE_SET_UUID = 1 << 3, } BDSwapTechMode; /** * bd_swap_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDSwapTechMode) for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_swap_is_tech_avail (BDSwapTech tech, guint64 mode, GError **error); /** * bd_swap_mkswap: * @device: a device to create swap space on * @label: (nullable): a label for the swap space device * @uuid: (nullable): UUID for the swap space device * @extra: (nullable) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkswap' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the swap space was successfully created or not * * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_CREATE */ gboolean bd_swap_mkswap (const gchar *device, const gchar *label, const gchar *uuid, const BDExtraArg **extra, GError **error); /** * bd_swap_swapon: * @device: swap device to activate * @priority: priority of the activated device or -1 to use the default * @error: (out) (optional): place to store error (if any) * * Returns: whether the swap device was successfully activated or not * * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_ACTIVATE_DEACTIVATE */ gboolean bd_swap_swapon (const gchar *device, gint priority, GError **error); /** * bd_swap_swapoff: * @device: swap device to deactivate * @error: (out) (optional): place to store error (if any) * * Returns: whether the swap device was successfully deactivated or not * * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_ACTIVATE_DEACTIVATE */ gboolean bd_swap_swapoff (const gchar *device, GError **error); /** * bd_swap_swapstatus: * @device: swap device to get status of * @error: (out) (optional): place to store error (if any) * * Returns: %TRUE if the swap device is active, %FALSE if not active or failed * to determine (@error) is set not a non-NULL value in such case) * * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_QUERY */ gboolean bd_swap_swapstatus (const gchar *device, GError **error); /** * bd_swap_check_label: * @label: label to check * @error: (out) (optional): place to store error * * Returns: whether @label is a valid label for swap or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_swap_check_label (const gchar *label, GError **error); /** * bd_swap_set_label: * @device: a device to set label on * @label: label that will be set * @error: (out) (optional): place to store error (if any) * * Returns: whether the label was successfully set or not * * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_SET_LABEL */ gboolean bd_swap_set_label (const gchar *device, const gchar *label, GError **error); /** * bd_swap_check_uuid: * @uuid: UUID to check * @error: (out) (optional): place to store error * * Returns: whether @uuid is a valid UUID for swap or not * (reason is provided in @error) * * Tech category: always available */ gboolean bd_swap_check_uuid (const gchar *uuid, GError **error); /** * bd_swap_set_uuid: * @device: a device to set UUID on * @uuid: UUID that will be set * @error: (out) (optional): place to store error (if any) * * Returns: whether the UUID was successfully set or not * * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_SET_UUID */ gboolean bd_swap_set_uuid (const gchar *device, const gchar *uuid, GError **error); #endif /* BD_SWAP_API */ libblockdev-3.1.1-1/src/lib/plugins.c000066400000000000000000000033111460051510300173050ustar00rootroot00000000000000#include #include #include "plugins.h" /** * SECTION: plugins * @short_description: functions related to querying plugins * @title: Plugins * @include: blockdev.h */ /** * bd_plugin_spec_copy: (skip) * @spec: (nullable): %BDPluginSpec to copy * * Creates a new copy of @spec. */ BDPluginSpec* bd_plugin_spec_copy (BDPluginSpec *spec) { if (!spec) return NULL; BDPluginSpec *new_spec = g_new0 (BDPluginSpec, 1); new_spec->name = spec->name; new_spec->so_name = g_strdup (spec->so_name); return new_spec; } /** * bd_plugin_spec_free: (skip) * @spec: (nullable): %BDPluginSpec to free * * Frees @spec. */ void bd_plugin_spec_free (BDPluginSpec *spec) { if (!spec) return; g_free ((gchar *) spec->so_name); g_free (spec); } /** * bd_plugin_spec_new: (constructor) * @name: %BDPlugin name, e.g. %BD_PLUGIN_LVM * @so_name: (nullable): SO name of the plugin to load or %NULL for default * * Returns: (transfer full): a new plugin spec */ BDPluginSpec* bd_plugin_spec_new (BDPlugin name, const gchar *so_name) { BDPluginSpec* ret = g_new0 (BDPluginSpec, 1); ret->name = name; /* FIXME: this should be const, but we are already allocating a new string in _copy * and freeing it in _free */ ret->so_name = so_name ? g_strdup (so_name) : NULL; return ret; } GType bd_plugin_spec_get_type (void) { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDPluginSpec", (GBoxedCopyFunc) bd_plugin_spec_copy, (GBoxedFreeFunc) bd_plugin_spec_free); } return type; } libblockdev-3.1.1-1/src/lib/plugins.h000066400000000000000000000021461460051510300173170ustar00rootroot00000000000000#include #include #ifndef BD_PLUGINS #define BD_PLUGINS typedef enum { BD_PLUGIN_LVM = 0, BD_PLUGIN_BTRFS, BD_PLUGIN_SWAP, BD_PLUGIN_LOOP, BD_PLUGIN_CRYPTO, BD_PLUGIN_MPATH, BD_PLUGIN_DM, BD_PLUGIN_MDRAID, BD_PLUGIN_S390, BD_PLUGIN_PART, BD_PLUGIN_FS, BD_PLUGIN_NVDIMM, BD_PLUGIN_NVME, BD_PLUGIN_UNDEF } BDPlugin; #define BD_TYPE_PLUGIN_SPEC (bd_plugin_spec_get_type ()) GType bd_plugin_spec_get_type(void); /** * BDPluginSpec: * @name: %BDPlugin name, e.g. %BD_PLUGIN_LVM * @so_name: (nullable): SO name of the plugin to load or %NULL for default * */ typedef struct BDPluginSpec { BDPlugin name; const gchar *so_name; } BDPluginSpec; BDPluginSpec* bd_plugin_spec_copy (BDPluginSpec *spec); void bd_plugin_spec_free (BDPluginSpec *spec); BDPluginSpec* bd_plugin_spec_new (BDPlugin name, const gchar *so_name); gboolean bd_is_plugin_available (BDPlugin plugin); gchar** bd_get_available_plugin_names (void); gchar* bd_get_plugin_soname (BDPlugin plugin); gchar* bd_get_plugin_name (BDPlugin plugin); #endif /* BD_PLUGINS */ libblockdev-3.1.1-1/src/plugins/000077500000000000000000000000001460051510300163755ustar00rootroot00000000000000libblockdev-3.1.1-1/src/plugins/Makefile.am000066400000000000000000000162261460051510300204400ustar00rootroot00000000000000SUBDIRS = . if WITH_FS SUBDIRS += fs endif if WITH_NVME SUBDIRS += nvme endif lib_LTLIBRARIES = if WITH_BTRFS lib_LTLIBRARIES += libbd_btrfs.la endif if WITH_CRYPTO lib_LTLIBRARIES += libbd_crypto.la endif if WITH_DM lib_LTLIBRARIES += libbd_dm.la endif if WITH_LOOP lib_LTLIBRARIES += libbd_loop.la endif if WITH_LVM lib_LTLIBRARIES += libbd_lvm.la endif if WITH_LVM_DBUS lib_LTLIBRARIES += libbd_lvm-dbus.la endif if WITH_MDRAID lib_LTLIBRARIES += libbd_mdraid.la endif if WITH_MPATH lib_LTLIBRARIES += libbd_mpath.la endif if WITH_NVDIMM lib_LTLIBRARIES += libbd_nvdimm.la endif if WITH_SWAP lib_LTLIBRARIES += libbd_swap.la endif if WITH_PART lib_LTLIBRARIES += libbd_part.la endif if WITH_S390 lib_LTLIBRARIES += libbd_s390.la endif if WITH_BTRFS libbd_btrfs_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(BYTESIZE_CFLAGS) -Wall -Wextra -Werror libbd_btrfs_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) $(BYTESIZE_LIBS) libbd_btrfs_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libbd_btrfs_la_CPPFLAGS = -I${builddir}/../../include/ libbd_btrfs_la_SOURCES = btrfs.c btrfs.h check_deps.c check_deps.h endif if WITH_CRYPTO if WITH_ESCROW libbd_crypto_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(CRYPTSETUP_CFLAGS) $(BLKID_CFLAGS) $(NSS_CFLAGS) -Wall -Wextra -Werror libbd_crypto_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) $(CRYPTSETUP_LIBS) $(NSS_LIBS) $(BLKID_LIBS) -lkeyutils -lvolume_key else libbd_crypto_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(CRYPTSETUP_CFLAGS) $(BLKID_CFLAGS) -Wall -Wextra -Werror libbd_crypto_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) $(CRYPTSETUP_LIBS) $(BLKID_LIBS) -lkeyutils endif libbd_crypto_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libbd_crypto_la_CPPFLAGS = -I${builddir}/../../include/ libbd_crypto_la_SOURCES = crypto.c crypto.h endif if WITH_DM libbd_dm_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(DEVMAPPER_CFLAGS) -Wall -Wextra -Werror libbd_dm_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) $(DEVMAPPER_LIBS) libbd_dm_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libbd_dm_la_CPPFLAGS = -I${builddir}/../../include/ libbd_dm_la_SOURCES = dm.c dm.h check_deps.c check_deps.h dm_logging.c dm_logging.h endif if WITH_LOOP libbd_loop_la_CFLAGS = $(GLIB_CFLAGS) -Wall -Wextra -Werror libbd_loop_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) libbd_loop_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libbd_loop_la_CPPFLAGS = -I${builddir}/../../include/ libbd_loop_la_SOURCES = loop.c loop.h endif if WITH_LVM libbd_lvm_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(DEVMAPPER_CFLAGS) -Wall -Wextra -Werror libbd_lvm_la_LIBADD = ${builddir}/../utils/libbd_utils.la -lm $(GLIB_LIBS) $(GIO_LIBS) $(DEVMAPPER_LIBS) libbd_lvm_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libbd_lvm_la_CPPFLAGS = -I${builddir}/../../include/ libbd_lvm_la_SOURCES = lvm.c lvm.h check_deps.c check_deps.h dm_logging.c dm_logging.h vdo_stats.c vdo_stats.h endif if WITH_LVM_DBUS libbd_lvm_dbus_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(DEVMAPPER_CFLAGS) -Wall -Wextra -Werror libbd_lvm_dbus_la_LIBADD = ${builddir}/../utils/libbd_utils.la -lm $(GLIB_LIBS) $(GIO_LIBS) $(DEVMAPPER_LIBS) libbd_lvm_dbus_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libbd_lvm_dbus_la_CPPFLAGS = -I${builddir}/../../include/ libbd_lvm_dbus_la_SOURCES = lvm-dbus.c lvm.h check_deps.c check_deps.h dm_logging.c dm_logging.h vdo_stats.c vdo_stats.h endif if WITH_MDRAID libbd_mdraid_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(BYTESIZE_CFLAGS) -Wall -Wextra -Werror libbd_mdraid_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) $(BYTESIZE_LIBS) libbd_mdraid_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libbd_mdraid_la_CPPFLAGS = -I${builddir}/../../include/ libbd_mdraid_la_SOURCES = mdraid.c mdraid.h check_deps.c check_deps.h endif if WITH_MPATH libbd_mpath_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(DEVMAPPER_CFLAGS) -Wall -Wextra -Werror libbd_mpath_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) $(DEVMAPPER_LIBS) libbd_mpath_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libbd_mpath_la_CPPFLAGS = -I${builddir}/../../include/ libbd_mpath_la_SOURCES = mpath.c mpath.h check_deps.c check_deps.h endif if WITH_NVDIMM libbd_nvdimm_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(UUID_CFLAGS) $(NDCTL_CFLAGS) -Wall -Wextra -Werror libbd_nvdimm_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) $(UUID_LIBS) $(NDCTL_LIBS) libbd_nvdimm_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libbd_nvdimm_la_CPPFLAGS = -I${builddir}/../../include/ libbd_nvdimm_la_SOURCES = nvdimm.c nvdimm.h check_deps.c check_deps.h endif if WITH_SWAP libbd_swap_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(BLKID_CFLAGS) $(UUID_CFLAGS) -Wall -Wextra -Werror libbd_swap_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) $(BLKID_LIBS) $(UUID_LIBS) libbd_swap_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libbd_swap_la_CPPFLAGS = -I${builddir}/../../include/ libbd_swap_la_SOURCES = swap.c swap.h check_deps.c check_deps.h endif if WITH_S390 libbd_s390_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) -Wall -Wextra -Werror libbd_s390_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) libbd_s390_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libbd_s390_la_CPPFLAGS = -I${srcdir}/../utils/ libbd_s390_la_CPPFLAGS = -I${builddir}/../../include/ libbd_s390_la_SOURCES = s390.c s390.h check_deps.c check_deps.h endif if WITH_PART libbd_part_la_CFLAGS = $(GLIB_CFLAGS) $(GIO_CFLAGS) $(FDISK_CFLAGS) -Wall -Wextra -Werror libbd_part_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) $(GIO_LIBS) $(FDISK_LIBS) libbd_part_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 3:0:0 -Wl,--no-undefined -export-symbols-regex '^bd_.*' libbd_part_la_CPPFLAGS = -I${builddir}/../../include/ libbd_part_la_SOURCES = part.c part.h check_deps.c check_deps.h endif libincludedir = $(includedir)/blockdev libinclude_HEADERS = if WITH_BTRFS libinclude_HEADERS += btrfs.h endif if WITH_CRYPTO libinclude_HEADERS += crypto.h endif if WITH_DM libinclude_HEADERS += dm.h endif if WITH_LOOP libinclude_HEADERS += loop.h endif if WITH_LVM libinclude_HEADERS += lvm.h endif if WITH_MDRAID libinclude_HEADERS += mdraid.h endif if WITH_MPATH libinclude_HEADERS += mpath.h endif if WITH_NVDIMM libinclude_HEADERS += nvdimm.h endif if WITH_SWAP libinclude_HEADERS += swap.h endif if WITH_PART libinclude_HEADERS += part.h endif if WITH_FS libinclude_HEADERS += fs.h endif if WITH_S390 libinclude_HEADERS += s390.h endif MAINTAINERCLEANFILES = Makefile.in libblockdev-3.1.1-1/src/plugins/btrfs.c000066400000000000000000001021251460051510300176620ustar00rootroot00000000000000/* * Copyright (C) 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . * * Author: Vratislav Podzimek */ #include #include #include #include #include #include "btrfs.h" #include "check_deps.h" #define BTRFS_MIN_VERSION "3.18.2" /** * SECTION: btrfs * @short_description: plugin for operations with BTRFS devices * @title: BTRFS * @include: btrfs.h * * A plugin for operations with btrfs devices. */ /** * bd_btrfs_error_quark: (skip) */ GQuark bd_btrfs_error_quark (void) { return g_quark_from_static_string ("g-bd-btrfs-error-quark"); } BDBtrfsDeviceInfo* bd_btrfs_device_info_copy (BDBtrfsDeviceInfo *info) { if (info == NULL) return NULL; BDBtrfsDeviceInfo *new_info = g_new0 (BDBtrfsDeviceInfo, 1); new_info->id = info->id; new_info->path = g_strdup (info->path); new_info->size = info->size; new_info->used = info->used; return new_info; } void bd_btrfs_device_info_free (BDBtrfsDeviceInfo *info) { if (info == NULL) return; g_free (info->path); g_free (info); } BDBtrfsSubvolumeInfo* bd_btrfs_subvolume_info_copy (BDBtrfsSubvolumeInfo *info) { if (info == NULL) return NULL; BDBtrfsSubvolumeInfo *new_info = g_new0 (BDBtrfsSubvolumeInfo, 1); new_info->id = info->id; new_info->parent_id = info->parent_id; new_info->path = g_strdup (info->path); return new_info; } void bd_btrfs_subvolume_info_free (BDBtrfsSubvolumeInfo *info) { if (info == NULL) return; g_free (info->path); g_free (info); } BDBtrfsFilesystemInfo* bd_btrfs_filesystem_info_copy (BDBtrfsFilesystemInfo *info) { if (info == NULL) return NULL; BDBtrfsFilesystemInfo *new_info = g_new0 (BDBtrfsFilesystemInfo, 1); new_info->label = g_strdup (info->label); new_info->uuid = g_strdup (info->uuid); new_info->num_devices = info->num_devices; new_info->used = info->used; return new_info; } void bd_btrfs_filesystem_info_free (BDBtrfsFilesystemInfo *info) { if (info == NULL) return; g_free (info->label); g_free (info->uuid); g_free (info); } static volatile guint avail_deps = 0; static volatile guint avail_module_deps = 0; static GMutex deps_check_lock; #define DEPS_BTRFS 0 #define DEPS_BTRFS_MASK (1 << DEPS_BTRFS) #define DEPS_LAST 1 static const UtilDep deps[DEPS_LAST] = { {"btrfs", BTRFS_MIN_VERSION, NULL, "[Bb]trfs.* v([\\d\\.]+)"}, }; #define MODULE_DEPS_BTRFS 0 #define MODULE_DEPS_BTRFS_MASK (1 << MODULE_DEPS_BTRFS) #define MODULE_DEPS_LAST 1 static const gchar*const module_deps[MODULE_DEPS_LAST] = { "btrfs" }; /** * bd_btrfs_init: * * Initializes the plugin. **This function is called automatically by the * library's initialization functions.** * */ gboolean bd_btrfs_init (void) { /* nothing to do here */ return TRUE; }; /** * bd_btrfs_close: * * Cleans up after the plugin. **This function is called automatically by the * library's functions that unload it.** * */ void bd_btrfs_close (void) { /* nothing to do here */ } /** * bd_btrfs_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation for @tech * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is available -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_btrfs_is_tech_avail (BDBtrfsTech tech G_GNUC_UNUSED, guint64 mode G_GNUC_UNUSED, GError **error) { /* all tech-mode combinations are supported by this implementation of the plugin */ return check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) && check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error); } static BDBtrfsDeviceInfo* get_device_info_from_match (GMatchInfo *match_info) { BDBtrfsDeviceInfo *ret = g_new(BDBtrfsDeviceInfo, 1); gchar *item = NULL; BSSize size = NULL; BSError *error = NULL; item = g_match_info_fetch_named (match_info, "id"); ret->id = g_ascii_strtoull (item, NULL, 0); g_free (item); ret->path = g_match_info_fetch_named (match_info, "path"); item = g_match_info_fetch_named (match_info, "size"); if (item) { size = bs_size_new_from_str (item, &error); if (size) { ret->size = bs_size_get_bytes (size, NULL, &error); bs_size_free (size); } if (error) bd_utils_log_format (BD_UTILS_LOG_WARNING, "%s", error->msg); bs_clear_error (&error); g_free (item); } item = g_match_info_fetch_named (match_info, "used"); if (item) { size = bs_size_new_from_str (item, &error); if (size) { ret->used = bs_size_get_bytes (size, NULL, &error); bs_size_free (size); } if (error) bd_utils_log_format (BD_UTILS_LOG_WARNING, "%s", error->msg); bs_clear_error (&error); g_free (item); } return ret; } static BDBtrfsSubvolumeInfo* get_subvolume_info_from_match (GMatchInfo *match_info) { BDBtrfsSubvolumeInfo *ret = g_new(BDBtrfsSubvolumeInfo, 1); gchar *item = NULL; item = g_match_info_fetch_named (match_info, "id"); ret->id = g_ascii_strtoull (item, NULL, 0); g_free (item); item = g_match_info_fetch_named (match_info, "parent_id"); ret->parent_id = g_ascii_strtoull (item, NULL, 0); g_free (item); ret->path = g_match_info_fetch_named (match_info, "path"); return ret; } static BDBtrfsFilesystemInfo* get_filesystem_info_from_match (GMatchInfo *match_info) { BDBtrfsFilesystemInfo *ret = g_new(BDBtrfsFilesystemInfo, 1); gchar *item = NULL; BSSize size = NULL; BSError *error = NULL; ret->label = g_match_info_fetch_named (match_info, "label"); ret->uuid = g_match_info_fetch_named (match_info, "uuid"); item = g_match_info_fetch_named (match_info, "num_devices"); ret->num_devices = g_ascii_strtoull (item, NULL, 0); g_free (item); item = g_match_info_fetch_named (match_info, "used"); if (item) { size = bs_size_new_from_str (item, &error); if (size) { ret->used = bs_size_get_bytes (size, NULL, &error); bs_size_free (size); } if (error) bd_utils_log_format (BD_UTILS_LOG_WARNING, "%s", error->msg); bs_clear_error (&error); g_free (item); } return ret; } /** * bd_btrfs_create_volume: * @devices: (array zero-terminated=1): list of devices to create btrfs volume from * @label: (nullable): label for the volume * @data_level: (nullable): RAID level for the data or %NULL to use the default * @md_level: (nullable): RAID level for the metadata or %NULL to use the default * @extra: (nullable) (array zero-terminated=1): extra options for the volume creation (right now * passed to the 'mkfs.btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the new btrfs volume was created from @devices or not * * See mkfs.btrfs(8) for details about @data_level, @md_level and btrfs in general. * * Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_CREATE */ gboolean bd_btrfs_create_volume (const gchar **devices, const gchar *label, const gchar *data_level, const gchar *md_level, const BDExtraArg **extra, GError **error) { const gchar **device_p = NULL; guint8 num_args = 0; const gchar **argv = NULL; guint8 next_arg = 1; gboolean success = FALSE; if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) || !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error)) return FALSE; if (!devices || (g_strv_length ((gchar **) devices) < 1)) { g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_DEVICE, "No devices given"); return FALSE; } for (device_p = devices; *device_p != NULL; device_p++) { if (access (*device_p, F_OK) != 0) { g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_DEVICE, "Device %s does not exist", *device_p); return FALSE; } num_args++; } if (label) num_args += 2; if (data_level) num_args += 2; if (md_level) num_args += 2; argv = g_new0 (const gchar*, num_args + 2); argv[0] = "mkfs.btrfs"; if (label) { argv[next_arg] = "--label"; next_arg++; argv[next_arg] = label; next_arg++; } if (data_level) { argv[next_arg] = "--data"; next_arg++; argv[next_arg] = data_level; next_arg++; } if (md_level) { argv[next_arg] = "--metadata"; next_arg++; argv[next_arg] = md_level; next_arg++; } for (device_p = devices; next_arg <= num_args; device_p++, next_arg++) argv[next_arg] = *device_p; argv[next_arg] = NULL; success = bd_utils_exec_and_report_error (argv, extra, error); g_free (argv); return success; } /** * bd_btrfs_add_device: * @mountpoint: mountpoint of the btrfs volume to add new device to * @device: a device to add to the btrfs volume * @extra: (nullable) (array zero-terminated=1): extra options for the addition (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @device was successfully added to the @mountpoint btrfs volume or not * * Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_MODIFY */ gboolean bd_btrfs_add_device (const gchar *mountpoint, const gchar *device, const BDExtraArg **extra, GError **error) { const gchar *argv[6] = {"btrfs", "device", "add", device, mountpoint, NULL}; if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) || !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error)) return FALSE; return bd_utils_exec_and_report_error (argv, extra, error); } /** * bd_btrfs_remove_device: * @mountpoint: mountpoint of the btrfs volume to remove device from * @device: a device to remove from the btrfs volume * @extra: (nullable) (array zero-terminated=1): extra options for the removal (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @device was successfully removed from the @mountpoint btrfs volume or not * * Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_MODIFY */ gboolean bd_btrfs_remove_device (const gchar *mountpoint, const gchar *device, const BDExtraArg **extra, GError **error) { const gchar *argv[6] = {"btrfs", "device", "delete", device, mountpoint, NULL}; if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) || !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error)) return FALSE; return bd_utils_exec_and_report_error (argv, extra, error); } /** * bd_btrfs_create_subvolume: * @mountpoint: mountpoint of the btrfs volume to create subvolume under * @name: name of the subvolume * @extra: (nullable) (array zero-terminated=1): extra options for the subvolume creation (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @mountpoint/@name subvolume was successfully created or not * * Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_CREATE */ gboolean bd_btrfs_create_subvolume (const gchar *mountpoint, const gchar *name, const BDExtraArg **extra, GError **error) { gchar *path = NULL; gboolean success = FALSE; const gchar *argv[5] = {"btrfs", "subvol", "create", NULL, NULL}; if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) || !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error)) return FALSE; if (g_str_has_suffix (mountpoint, "/")) path = g_strdup_printf ("%s%s", mountpoint, name); else path = g_strdup_printf ("%s/%s", mountpoint, name); argv[3] = path; success = bd_utils_exec_and_report_error (argv, extra, error); g_free (path); return success; } /** * bd_btrfs_delete_subvolume: * @mountpoint: mountpoint of the btrfs volume to delete subvolume from * @name: name of the subvolume * @extra: (nullable) (array zero-terminated=1): extra options for the subvolume deletion (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @mountpoint/@name subvolume was successfully deleted or not * * Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_DELETE */ gboolean bd_btrfs_delete_subvolume (const gchar *mountpoint, const gchar *name, const BDExtraArg **extra, GError **error) { gchar *path = NULL; gboolean success = FALSE; const gchar *argv[5] = {"btrfs", "subvol", "delete", NULL, NULL}; if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) || !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error)) return FALSE; if (g_str_has_suffix (mountpoint, "/")) path = g_strdup_printf ("%s%s", mountpoint, name); else path = g_strdup_printf ("%s/%s", mountpoint, name); argv[3] = path; success = bd_utils_exec_and_report_error (argv, extra, error); g_free (path); return success; } /** * bd_btrfs_get_default_subvolume_id: * @mountpoint: mountpoint of the volume to get the default subvolume ID of * @error: (out) (optional): place to store error (if any) * * Returns: ID of the @mountpoint volume's default subvolume. If 0, * @error) may be set to indicate error * * Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_QUERY */ guint64 bd_btrfs_get_default_subvolume_id (const gchar *mountpoint, GError **error) { GRegex *regex = NULL; GMatchInfo *match_info = NULL; gboolean success = FALSE; gchar *output = NULL; gchar *match = NULL; guint64 ret = 0; const gchar *argv[5] = {"btrfs", "subvol", "get-default", mountpoint, NULL}; if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) || !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error)) return 0; regex = g_regex_new ("ID (\\d+) .*", 0, 0, error); if (!regex) { bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to create new GRegex"); /* error is already populated */ return 0; } success = bd_utils_exec_and_capture_output (argv, NULL, &output, error); if (!success) { g_regex_unref (regex); return 0; } success = g_regex_match (regex, output, 0, &match_info); if (!success) { g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse subvolume's ID"); g_regex_unref (regex); g_match_info_free (match_info); g_free (output); return 0; } match = g_match_info_fetch (match_info, 1); ret = g_ascii_strtoull (match, NULL, 0); g_free (match); g_match_info_free (match_info); g_regex_unref (regex); g_free (output); return ret; } /** * bd_btrfs_set_default_subvolume: * @mountpoint: mountpoint of the volume to set the default subvolume ID of * @subvol_id: ID of the subvolume to be set as the default subvolume * @extra: (nullable) (array zero-terminated=1): extra options for the setting (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @mountpoint volume's default subvolume was correctly set * to @subvol_id or not * * Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_MODIFY */ gboolean bd_btrfs_set_default_subvolume (const gchar *mountpoint, guint64 subvol_id, const BDExtraArg **extra, GError **error) { const gchar *argv[6] = {"btrfs", "subvol", "set-default", NULL, mountpoint, NULL}; gboolean ret = FALSE; if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) || !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error)) return FALSE; argv[3] = g_strdup_printf ("%"G_GUINT64_FORMAT, subvol_id); ret = bd_utils_exec_and_report_error (argv, extra, error); g_free ((gchar *) argv[3]); return ret; } /** * bd_btrfs_create_snapshot: * @source: path to source subvolume * @dest: path to new snapshot volume * @ro: whether the snapshot should be read-only * @extra: (nullable) (array zero-terminated=1): extra options for the snapshot creation (right now * passed to the 'btrfs' utility) * @error: (out) (optional): place to store error (if any) * * Returns: whether the @dest snapshot of @source was successfully created or not * * Tech category: %BD_BTRFS_TECH_SNAPSHOT-%BD_BTRFS_TECH_MODE_CREATE */ gboolean bd_btrfs_create_snapshot (const gchar *source, const gchar *dest, gboolean ro, const BDExtraArg **extra, GError **error) { const gchar *argv[7] = {"btrfs", "subvol", "snapshot", NULL, NULL, NULL, NULL}; guint next_arg = 3; if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) || !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error)) return FALSE; if (ro) { argv[next_arg] = "-r"; next_arg++; } argv[next_arg] = source; next_arg++; argv[next_arg] = dest; return bd_utils_exec_and_report_error (argv, extra, error); } /** * bd_btrfs_list_devices: * @device: a device that is part of the queried btrfs volume * @error: (out) (optional): place to store error (if any) * * Returns: (array zero-terminated=1): information about the devices that are part of the btrfs volume * containing @device or %NULL in case of error * * Tech category: %BD_BTRFS_TECH_MULTI_DEV-%BD_BTRFS_TECH_MODE_QUERY */ BDBtrfsDeviceInfo** bd_btrfs_list_devices (const gchar *device, GError **error) { const gchar *argv[5] = {"btrfs", "filesystem", "show", device, NULL}; gchar *output = NULL; gboolean success = FALSE; gchar **lines = NULL; gchar **line_p = NULL; gchar const * const pattern = "devid[ \\t]+(?P\\d+)[ \\t]+" \ "size[ \\t]+(?P\\S+)[ \\t]+" \ "used[ \\t]+(?P\\S+)[ \\t]+" \ "path[ \\t]+(?P\\S+)\n"; GRegex *regex = NULL; GMatchInfo *match_info = NULL; GPtrArray *dev_infos; if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) || !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error)) return NULL; regex = g_regex_new (pattern, G_REGEX_EXTENDED, 0, error); if (!regex) { bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to create new GRegex"); /* error is already populated */ return NULL; } success = bd_utils_exec_and_capture_output (argv, NULL, &output, error); if (!success) { g_regex_unref (regex); /* error is already populated from the previous call */ return NULL; } lines = g_strsplit (output, "\n", 0); g_free (output); dev_infos = g_ptr_array_new (); for (line_p = lines; *line_p; line_p++) { success = g_regex_match (regex, *line_p, 0, &match_info); if (!success) { g_match_info_free (match_info); continue; } g_ptr_array_add (dev_infos, get_device_info_from_match (match_info)); g_match_info_free (match_info); } g_strfreev (lines); g_regex_unref (regex); if (dev_infos->len == 0) { g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse information about devices"); g_ptr_array_free (dev_infos, TRUE); return NULL; } g_ptr_array_add (dev_infos, NULL); return (BDBtrfsDeviceInfo **) g_ptr_array_free (dev_infos, FALSE); } /** * bd_btrfs_list_subvolumes: * @mountpoint: a mountpoint of the queried btrfs volume * @snapshots_only: whether to list only snapshot subvolumes or not * @error: (out) (optional): place to store error (if any) * * Returns: (array zero-terminated=1): information about the subvolumes that are part of the btrfs volume * mounted at @mountpoint or %NULL in case of error * * The subvolumes are sorted in a way that no child subvolume appears in the * list before its parent (sub)volume. * * Tech category: %BD_BTRFS_TECH_SUBVOL-%BD_BTRFS_TECH_MODE_QUERY */ BDBtrfsSubvolumeInfo** bd_btrfs_list_subvolumes (const gchar *mountpoint, gboolean snapshots_only, GError **error) { const gchar *argv[7] = {"btrfs", "subvol", "list", "-p", NULL, NULL, NULL}; gchar *output = NULL; gboolean success = FALSE; gchar **lines = NULL; gchar **line_p = NULL; gchar const * const pattern = "ID\\s+(?P\\d+)\\s+gen\\s+\\d+\\s+(cgen\\s+\\d+\\s+)?" \ "parent\\s+(?P\\d+)\\s+top\\s+level\\s+\\d+\\s+" \ "(otime\\s+(\\d{4}-\\d{2}-\\d{2}\\s+\\d\\d:\\d\\d:\\d\\d|-)\\s+)?"\ "path\\s+(?P\\S+)"; GRegex *regex = NULL; GMatchInfo *match_info = NULL; guint64 i = 0; guint64 y = 0; guint64 next_sorted_idx = 0; GPtrArray *subvol_infos; BDBtrfsSubvolumeInfo* item = NULL; BDBtrfsSubvolumeInfo* swap_item = NULL; BDBtrfsSubvolumeInfo** ret = NULL; GError *l_error = NULL; if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) || !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error)) return NULL; if (snapshots_only) { argv[4] = "-s"; argv[5] = mountpoint; } else argv[4] = mountpoint; regex = g_regex_new (pattern, G_REGEX_EXTENDED, 0, error); if (!regex) { bd_utils_log_format (BD_UTILS_LOG_WARNING, "Failed to create new GRegex"); /* error is already populated */ return NULL; } success = bd_utils_exec_and_capture_output (argv, NULL, &output, &l_error); if (!success) { g_regex_unref (regex); if (g_error_matches (l_error, BD_UTILS_EXEC_ERROR, BD_UTILS_EXEC_ERROR_NOOUT)) { /* no output -> no subvolumes */ g_clear_error (&l_error); return g_new0 (BDBtrfsSubvolumeInfo*, 1); } else { g_propagate_error (error, l_error); return NULL; } } lines = g_strsplit (output, "\n", 0); g_free (output); subvol_infos = g_ptr_array_new (); for (line_p = lines; *line_p; line_p++) { success = g_regex_match (regex, *line_p, 0, &match_info); if (!success) { g_match_info_free (match_info); continue; } g_ptr_array_add (subvol_infos, get_subvolume_info_from_match (match_info)); g_match_info_free (match_info); } g_strfreev (lines); g_regex_unref (regex); if (subvol_infos->len == 0) { g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse information about subvolumes"); g_ptr_array_free (subvol_infos, TRUE); return NULL; } /* now we know how much space to allocate for the result (subvols + NULL) */ ret = g_new0 (BDBtrfsSubvolumeInfo*, subvol_infos->len + 1); /* we need to sort the subvolumes in a way that no child subvolume appears in the list before its parent (sub)volume */ /* let's start by moving all top-level (sub)volumes to the beginning */ for (i=0; i < subvol_infos->len; i++) { item = (BDBtrfsSubvolumeInfo*) g_ptr_array_index (subvol_infos, i); if (item->parent_id == BD_BTRFS_MAIN_VOLUME_ID) /* top-level (sub)volume */ ret[next_sorted_idx++] = item; } /* top-level (sub)volumes are now processed */ for (i=0; i < next_sorted_idx; i++) g_ptr_array_remove_fast (subvol_infos, ret[i]); /* now sort the rest in a way that we search for an already sorted parent or sibling */ for (i=0; i < subvol_infos->len; i++) { item = (BDBtrfsSubvolumeInfo*) g_ptr_array_index (subvol_infos, i); ret[next_sorted_idx] = item; /* move the item towards beginning of the array checking if some parent or sibling has been already processed/sorted before or we reached the top-level (sub)volumes */ for (y=next_sorted_idx; (y > 0 && (ret[y-1]->id != item->parent_id) && (ret[y-1]->parent_id != item->parent_id) && (ret[y-1]->parent_id != BD_BTRFS_MAIN_VOLUME_ID)); y--) { swap_item = ret[y-1]; ret[y-1] = ret[y]; ret[y] = swap_item; } next_sorted_idx++; } ret[next_sorted_idx] = NULL; /* now just free the pointer array */ g_ptr_array_free (subvol_infos, TRUE); return ret; } /** * bd_btrfs_filesystem_info: * @device: a device that is part of the queried btrfs volume * @error: (out) (optional): place to store error (if any) * * Returns: information about the @device's volume's filesystem or %NULL in case of error * * Tech category: %BD_BTRFS_TECH_FS-%BD_BTRFS_TECH_MODE_QUERY */ BDBtrfsFilesystemInfo* bd_btrfs_filesystem_info (const gchar *device, GError **error) { const gchar *argv[5] = {"btrfs", "filesystem", "show", device, NULL}; gchar *output = NULL; gboolean success = FALSE; gchar const * const pattern = "Label:\\s+(none|'(?P