pax_global_header00006660000000000000000000000064132370300610014505gustar00rootroot0000000000000052 comment=e2e0899efe8dd3f111ff955fb6c1dc10b0bd2075 libblockdev-2.16-1/000077500000000000000000000000001323703006100140535ustar00rootroot00000000000000libblockdev-2.16-1/.gitignore000066400000000000000000000015071323703006100160460ustar00rootroot00000000000000*.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 **/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 libblockdev-2.16-1/HACKING.md000066400000000000000000000017611323703006100154460ustar00rootroot00000000000000CODING STYLE ============ - Please follow the coding style already used. - Spaces, not tabs, are used (except for Makefiles). 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. - [ ] Update the documentation by rsyncing the contents of the *docs/html* folder elsewhere, switching to the *gh-pages* branch, rsyncing the contents back and commiting it as an update of the docs for the new release. libblockdev-2.16-1/LICENSE000066400000000000000000000635201323703006100150660ustar00rootroot00000000000000 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-2.16-1/Makefile.am000066400000000000000000000116471323703006100161200ustar00rootroot00000000000000SHELL = /bin/bash .SHELLFLAGS = -o pipefail -c ACLOCAL_AMFLAGS = -I m4 DISTCHECK_CONFIGURE_FLAGS = --enable-introspection SUBDIRS = include src dist scripts data if WITH_GTK_DOC SUBDIRS += docs endif dist_noinst_DATA = features.rst roadmap.rst specs.rst 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/lib/.libs GIDIR = src/lib if WITH_PYTHON3 PYTHON = python3 PYLINT = python3-pylint else PYTHON = python PYLINT = pylint endif TEST_PYTHON ?= $(PYTHON) COVERAGE ?= coverage TEST_SUITE_LOG ?= test-suite-$(TEST_PYTHON).log PYLINT_LOG ?= pylint.log PLUGINS = btrfs \ crypto \ dm \ fs \ kbd \ loop \ lvm \ mdraid \ mpath \ 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: which $(PYLINT) && $(PYLINT) -E src/python/gi/overrides/BlockDev.py || echo "pylint not available, skipping" if TESTS_ENABLED test: all pylint sudo $(TEST_PYTHON) tests/run_tests.py 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/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/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]+\.[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-2.16-1/NEWS.rst000066400000000000000000000260261323703006100153670ustar00rootroot00000000000000Libblockdev 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-2.16-1/README.DEVEL.rst000066400000000000000000000110151323703006100163760ustar00rootroot00000000000000libblockdev 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. 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). 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) 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 defitions 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. The directory structure is as follows:: libblockdev ├── data -- data files │ └── conf.d -- configuration files ├── dist -- packaging files ├── docs -- files used to generate documentation ├── 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 libblockdev-2.16-1/README.md000066400000000000000000000016261323703006100153370ustar00rootroot00000000000000### 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). For more information about the library's architecture see the specs.rst file. For more infomation about the expected functionality and features see the features.rst file. For more information about the schedule see the roadmap.rst file. For information about development and contributing guidelines see the README.DEVEL.rst file. For more information about the API see the generated documentation at http://storaged.org/libblockdev/. libblockdev-2.16-1/acinclude.m4000066400000000000000000000100531323703006100162430ustar00rootroot00000000000000dnl 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" false ])])dnl libblockdev-2.16-1/autogen.sh000077500000000000000000000006311323703006100160540ustar00rootroot00000000000000#!/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-2.16-1/configure.ac000066400000000000000000000163571323703006100163550ustar00rootroot00000000000000# configure.ac for libblockdev AC_INIT([libblockdev], [2.16], [vpodzime@redhat.com]) # 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 AM_PROG_AR AC_PROG_CC LT_INIT AC_CONFIG_FILES([Makefile src/Makefile \ src/plugins/Makefile \ src/plugins/fs/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 \ 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 skip_patterns="" 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([bcache], AS_HELP_STRING([--with-bcache], [support bcache @<:@default=yes@:>@]), [], [with_bcache=yes]) AC_SUBST([WITH_BCACHE], [0]) AM_CONDITIONAL(WITH_BCACHE, test "x$with_bcache" != "xno") AS_IF([test "x$with_bcache" != "xno"], [AC_DEFINE([WITH_BD_BCACHE], [], [Define if bcache is supported]) AC_SUBST([WITH_BCACHE], [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([KBD], [kbd]) LIBBLOCKDEV_PLUGIN([PART], [part]) LIBBLOCKDEV_PLUGIN([FS], [fs]) AM_CONDITIONAL(WITH_PART_O_WITH_FS, test "x$with_part" != "xno" -o "x$with_fs" != "xno") dnl these two 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 >= 1.6.7]) 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]) ], []) 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_dm" != "xno"], [LIBBLOCKDEV_CHECK_HEADER([dmraid/dmraid.h], [], [dmraid.h not available])], []) AS_IF([test "x$with_part" != "xno" -o "x$with_fs" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([PARTED], [libparted >= 3.1])] []) AS_IF([test "x$with_fs" != "xno"], [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([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])]) # 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_btrfs" != "xno" -o "x$with_mdraid" != "xno" -o "x$with_kbd" != "xno"], [LIBBLOCKDEV_PKG_CHECK_MODULES([BYTESIZE], [bytesize >= 0.1])], []) AC_SUBST([skip_patterns], [$skip_patterns]) AC_SUBST([MAJOR_VER], [\"2\"]) CFLAGS="$CFLAGS -std=gnu99" AC_OUTPUT LIBBLOCKDEV_FAILURES libblockdev-2.16-1/data/000077500000000000000000000000001323703006100147645ustar00rootroot00000000000000libblockdev-2.16-1/data/Makefile.am000066400000000000000000000000651323703006100170210ustar00rootroot00000000000000SUBDIRS = conf.d MAINTAINERCLEANFILES = Makefile.in libblockdev-2.16-1/data/conf.d/000077500000000000000000000000001323703006100161335ustar00rootroot00000000000000libblockdev-2.16-1/data/conf.d/00-default.cfg000066400000000000000000000015651323703006100204640ustar00rootroot00000000000000# 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.2 [crypto] sonames=libbd_crypto.so.2 [dm] sonames=libbd_dm.so.2 [kbd] sonames=libbd_kbd.so.2 [loop] sonames=libbd_loop.so.2 [lvm] sonames=libbd_lvm.so.2 [mdraid] sonames=libbd_mdraid.so.2 [mpath] sonames=libbd_mpath.so.2 [swap] sonames=libbd_swap.so.2 [s390] sonames=libbd_s390.so.2 libblockdev-2.16-1/data/conf.d/10-lvm-dbus.cfg000066400000000000000000000000421323703006100205570ustar00rootroot00000000000000[lvm] sonames=libbd_lvm-dbus.so.2 libblockdev-2.16-1/data/conf.d/Makefile.am000066400000000000000000000003141323703006100201650ustar00rootroot00000000000000libbdconfdir = $(sysconfdir)/libblockdev/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-2.16-1/dist/000077500000000000000000000000001323703006100150165ustar00rootroot00000000000000libblockdev-2.16-1/dist/Makefile.am000066400000000000000000000001311323703006100170450ustar00rootroot00000000000000dist_noinst_DATA = libblockdev.spec MAINTAINERCLEANFILES = Makefile.in libblockdev.spec libblockdev-2.16-1/dist/libblockdev.spec.in000066400000000000000000002077711323703006100205750ustar00rootroot00000000000000%define with_python3 @WITH_PYTHON3@ %define with_gtk_doc @WITH_GTK_DOC@ %define with_bcache @WITH_BCACHE@ %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_kbd @WITH_KBD@ %define with_part @WITH_PART@ %define with_fs @WITH_FS@ %define with_gi @WITH_GI@ # python3 is not available on older RHEL %if ! 0%{?fedora} && 0%{?rhel} <= 7 %define with_python3 0 %define with_bcache 0 %define with_lvm_dbus 0 %define distro_copts --without-python3 --without-bcache --without-lvm-dbus %endif %if %{with_btrfs} != 1 %define btrfs_copts --without-btrfs %endif %if %{with_crypto} != 1 %define crypto_copts --without-crypto %endif %if %{with_dm} != 1 %define dm_copts --without-dm %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_kbd} != 1 %define kbd_copts --without-kbd %endif %if %{with_part} != 1 %define part_copts --without-part %endif %if %{with_fs} != 1 %define fs_copts --without-fs %endif %if %{with_gi} != 1 %define gi_copts --disable-introspection %endif %define configure_opts %{?distro_copts} %{?btrfs_copts} %{?crypto_copts} %{?dm_copts} %{?loop_copts} %{?lvm_copts} %{?lvm_dbus_copts} %{?mdraid_copts} %{?mpath_copts} %{?swap_copts} %{?kbd_copts} %{?part_copts} %{?fs_copts} %{?gi_copts} Name: libblockdev Version: 2.16 Release: 1%{?dist} Summary: A library for low-level manipulation with block devices License: LGPLv2+ URL: https://github.com/storaged-project/libblockdev Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-%{release}/%{name}-%{version}.tar.gz BuildRequires: glib2-devel %if %{with_gi} BuildRequires: gobject-introspection-devel %endif BuildRequires: python-devel %if %{with_python3} BuildRequires: python3-devel %endif %if %{with_gtk_doc} BuildRequires: gtk-doc %endif BuildRequires: glib2-doc # Needed for the escrow tests in tests/crypto_test.py, but not used to build # BuildRequires: volume_key # BuildRequires: nss-tools # Needed for python 2 vs. 3 compatibility in the tests, but not used to build # BuildRequires: python-six # BuildRequires: python3-six %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: glib2-devel %description devel This package contains header files and pkg-config files needed for development with the libblockdev library. %package -n python2-blockdev Summary: Python2 gobject-introspection bindings for libblockdev Requires: %{name}%{?_isa} = %{version}-%{release} Requires: pygobject3-base %{?python_provide:%python_provide python2-blockdev} %description -n python2-blockdev This package contains enhancements to the gobject-introspection bindings for libblockdev in Python2. %if %{with_python3} %package -n python3-blockdev Summary: Python3 gobject-introspection bindings for libblockdev Requires: %{name}%{?_isa} = %{version}-%{release} Requires: python3-gobject-base %{?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} >= 0.11 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} %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 BuildRequires: cryptsetup-devel BuildRequires: volume_key-devel >= 0.3.9-7 BuildRequires: nss-devel 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: 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: dmraid-devel BuildRequires: systemd-devel Summary: The Device Mapper plugin for the libblockdev library Requires: %{name}-utils%{?_isa} >= 0.11 Requires: device-mapper Requires: dmraid %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: dmraid-devel Requires: %{name}-utils-devel%{?_isa} %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: parted-devel BuildRequires: libblkid-devel BuildRequires: libmount-devel Summary: The FS plugin for the libblockdev library Requires: %{name}-utils%{?_isa} >= 0.11 Requires: device-mapper-multipath %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} Requires: glib2-devel Requires: xfsprogs Requires: dosfstools %description fs-devel This package contains header files and pkg-config files needed for development with the libblockdev-fs plugin/library. %endif %if %{with_kbd} %package kbd BuildRequires: libbytesize-devel Summary: The KBD plugin for the libblockdev library Requires: %{name}-utils%{?_isa} >= 0.11 %if %{with_bcache} Requires: bcache-tools >= 1.0.8 %endif %description kbd The libblockdev library plugin (and in the same time a standalone library) providing the functionality related to kernel block devices (namely zRAM and Bcache). %package kbd-devel Summary: Development files for the libblockdev-kbd plugin/library Requires: %{name}-kbd%{?_isa} = %{version}-%{release} Requires: %{name}-utils-devel%{?_isa} Requires: glib2-devel %description kbd-devel This package contains header files and pkg-config files needed for development with the libblockdev-kbd plugin/library. %endif %if %{with_loop} %package loop Summary: The loop plugin for the libblockdev library Requires: %{name}-utils%{?_isa} >= 0.11 %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} 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} >= 0.11 Requires: lvm2 # for thin_metadata_size Requires: device-mapper-persistent-data %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} 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} >= 1.4 Requires: lvm2-dbusd >= 2.02.156 # for thin_metadata_size Requires: device-mapper-persistent-data %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} >= 1.4 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} >= 0.11 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} 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} >= 0.11 Requires: 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} 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_part} %package part BuildRequires: parted-devel Summary: The partitioning plugin for the libblockdev library Requires: %{name}-utils%{?_isa} >= 0.11 Requires: device-mapper-multipath Requires: gdisk 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} 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 Summary: The swap plugin for the libblockdev library Requires: %{name}-utils%{?_isa} >= 0.11 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} 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 %ifarch s390 s390x %package s390 Summary: The s390 plugin for the libblockdev library 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} 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_kbd} Requires: %{name}-kbd%{?_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_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 %setup -q -n %{name}-%{version} %build %configure %{?configure_opts} %{__make} %{?_smp_mflags} %install %{make_install} find %{buildroot} -type f -name "*.la" | xargs %{__rm} %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %post utils -p /sbin/ldconfig %postun utils -p /sbin/ldconfig %if %{with_btrfs} %post btrfs -p /sbin/ldconfig %postun btrfs -p /sbin/ldconfig %endif %if %{with_crypto} %post crypto -p /sbin/ldconfig %postun crypto -p /sbin/ldconfig %endif %if %{with_dm} %post dm -p /sbin/ldconfig %postun dm -p /sbin/ldconfig %endif %if %{with_fs} %post fs -p /sbin/ldconfig %postun fs -p /sbin/ldconfig %endif %if %{with_loop} %post loop -p /sbin/ldconfig %postun loop -p /sbin/ldconfig %endif %if %{with_lvm} %post lvm -p /sbin/ldconfig %postun lvm -p /sbin/ldconfig %endif %if %{with_lvm_dbus} %post lvm-dbus -p /sbin/ldconfig %postun lvm-dbus -p /sbin/ldconfig %endif %if %{with_mdraid} %post mdraid -p /sbin/ldconfig %postun mdraid -p /sbin/ldconfig %endif %if %{with_mpath} %post mpath -p /sbin/ldconfig %postun mpath -p /sbin/ldconfig %endif %if %{with_part} %post part -p /sbin/ldconfig %postun part -p /sbin/ldconfig %endif %if %{with_swap} %post swap -p /sbin/ldconfig %postun swap -p /sbin/ldconfig %endif %ifarch s390 s390x %post s390 -p /sbin/ldconfig %postun s390 -p /sbin/ldconfig %endif %if %{with_kbd} %post kbd -p /sbin/ldconfig %postun kbd -p /sbin/ldconfig %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/conf.d %config %{_sysconfdir}/libblockdev/conf.d/00-default.cfg %files devel %doc features.rst specs.rst %{_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 %files -n python2-blockdev %{python2_sitearch}/gi/overrides/* %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.* %{_libdir}/libbd_part_err.so.* %files utils-devel %{_libdir}/libbd_utils.so %{_libdir}/libbd_part_err.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 %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_kbd} %files kbd %{_libdir}/libbd_kbd.so.* %files kbd-devel %{_libdir}/libbd_kbd.so %dir %{_includedir}/blockdev %{_includedir}/blockdev/kbd.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/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_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 %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 * Thu Feb 08 2018 Vojtech Trefny - 2.16-1 - Add tests for progress report (jtulak) - Add e2fsck progress (jtulak) - Add progress reporting infrastructure for Ext fsck (jtulak) - Add a function to test if prog. reporting was initialized (jtulak) - Add support for LUKS 2 opening and key management (vtrefny) - Fix few more links for project and documentation website (vtrefny) - Sync the spec file with downstream (vpodzime) - Check if 'journalctl' is available before trying to use it in tests (vtrefny) - Update 'Testing libblockdev' section in documentation (vtrefny) - Fix link to online documentation (vtrefny) - Fix how the new kernel module functions are added to docs (vpodzime) * Fri Dec 01 2017 Vratislav Podzimek - 2.15-1 - Do not use the 'btrfs' plugin in overrides tests (vpodzime) - Do not use the btrfs plugin in library tests (vpodzime) - Check for btrfs module availability in btrfs module (vtrefny) - Move kernel modules (un)loading and checking into utils (vtrefny) - Free locale struct in kbd plugin (vtrefny) - Add test for setting partition flags on GPT (vtrefny) - Use only sgdisk to set flags on GPT (vtrefny) - Move the fs.h file to its original place (vpodzime) - Add a HACKING.rst file (vpodzime) - Mark bcache tests as unstable (vpodzime) - Fix memory leaks in bd_fs_vfat_get_info() (vpodzime) - Revert the behaviour of bd_fs_check_deps() (vpodzime) - Split the bd_fs_is_tech_avail() implementation (vpodzime) - Split the FS plugin source into multiple files (vpodzime) - Fix bd_s390_dasd_format (vponcova) - Mark unstable tests as such (vpodzime) - bd_s390_dasd_is_ldl should be true only for LDL DADSs (vponcova) - Do not lie about tag creation (vpodzime) * Wed Nov 08 2017 Zbigniew Jędrzejewski-Szmek - 2.14-2 - Rebuild for cryptsetup-2.0.0 * Tue Oct 31 2017 Vratislav Podzimek - 2.14-1 - Support the legacy boot GPT flag (intrigeri) - Respect the version in the blockdev.pc file (vpodzime) - Add pkgconfig definitions for the utils library (vpodzime) - fs.c: Fix potential NULL pointer dereference (vtrefny) - dm.c: Fix uninitialized values in various dm plugin functions (vtrefny) - dm.c: Check return values of dm_task_set_name/run/get_info functions (vtrefny) - fs.c: Fix multiple "forward NULL" warnings in 'bd_fs_ntfs_get_info' (vtrefny) - lvm-dbus.c: Fix multiple "use after free" coverity warnings (vtrefny) - Fix duplicate 'const' in generated functions (vtrefny) - Add some test cases for NTFS (kailueke) - Add function wrappers for NTFS tools (kailueke) - exec.c: Fix error message in 'bd_utils_exec_and_report_progress' (vtrefny) - crypto.c: Fix waiting for enough entropy (vtrefny) - Ignore some coverity false positive errors (vtrefny) - exec.c: Ignore errors from 'g_io_channel_shutdown' (vtrefny) - part.c: Check if we've found a place to put new logical partitions (vtrefny) - kbd.c: Fix potential string overflow in 'bd_kbd_bcache_create' (vtrefny) - exec.c: Fix resource leaks in 'bd_utils_exec_and_report_progress' (vtrefny) - fs.c: Fix "forward null" in 'do_mount' and 'bd_fs_xfs_get_info' (vtrefny) - part.c: Fix possible NULL pointer dereference (vtrefny) - crypto.c: Use right key buffer in 'bd_crypto_luks_add_key' (vtrefny) - exec.c: Fix "use after free" in 'bd_utils_check_util_version' (vtrefny) - kbd.c: Fix double free in 'bd_kbd_zram_get_stats' (vtrefny) - part.c: Check if file discriptor is >= 0 before closing it (vtrefny) - mdraid.c: Fix resource leaks (vtrefny) - lvm.c: Fix "use after free" in 'bd_lvm_get_thpool_meta_size' (vtrefny) - fs.c: Fix for loop condition in 'bd_fs_get_fstype' (vtrefny) - fs.c: Check sscanf return value in 'bd_fs_vfat_get_info' (vtrefny) - fs.c: Fix resource leaks in 'bd_fs_get_fstype' (vtrefny) - blockdev.c.in: Fix unused variables (vtrefny) - Use libbytesize to parse bcache block size (vtrefny) - Use system values in KbdTestBcacheStatusTest (vtrefny) - Fix BSSize memory leaks in btrfs and mdraid plugins (vtrefny) - Skip btrfs subvolume tests with btrfs-progs 4.13.2 (vtrefny) - Added function to get DM device subsystem (japokorn) - Sync spec with downstream (vpodzime) * Fri Sep 29 2017 Vratislav Podzimek - 2.13-1 - Fix the rpmlog and shortlog targets (vpodzime) - Add a function for enabling/disabling plugins' init checks (vpodzime) - Assign functions to tech-mode categories (vpodzime) - Add missing items to particular sections in the documentation (vpodzime) - Add a basic test for the runtime dependency checking (vpodzime) - Simplify what WITH_BD_BCACHE changes in the KBD plugin (vpodzime) - Add functions for querying available technologies (vpodzime) - Dynamically check for the required utilities (vpodzime) - Use shorter prefix for tempfiles (vtrefny) - Try harder when waiting for lio device to show up (vtrefny) - Better handle old and new zram sysfs api in tests (vtrefny) - Skip btrfs tests on CentOS 7 aarch64 (vtrefny) - Add new function for setting swap label (vtrefny) - Use only one git tag for new releases (vtrefny) - Fix source URL in spec file (vtrefny) - Add NEWS.rst file (vtrefny) - Do not include s390utils/vtoc.h in s390 plugin (vtrefny) - Use "AC_CANONICAL_BUILD" to check architecture instead of "uname" (vtrefny) - Bypass error proxy in s390 test (vtrefny) - Fix zFCP LUN max length (vtrefny) - Do not run g_clear_error after setting it (vtrefny) - Allow compiling libblockdev without s390 plugin (vtrefny) - Add a function for getting plugin name (vpodzime) * Thu Sep 28 2017 Troy Dawson - 2.12-3 - Cleanup spec file conditionals correctly * Wed Sep 27 2017 Troy Dawson - 2.12-2 - Cleanup spec file conditionals * Wed Aug 30 2017 Vratislav Podzimek - 2.12-1 - Own directories /etc/libblockdev and /etc/libblockdev/conf.d (vtrefny) - Wait for resized partition (kailueke) - Make sure the device is opened for libparted (vpodzime) - Fix label check in swap_test (vtrefny) - Use "run_tests" script for running tests from Makefile (vtrefny) - Add a script for running tests (vtrefny) - Tests: Move library initialization to setUpClass method (vtrefny) - Stop skipping FAT resize tests on rawhide (vtrefny) - Close filesystem before closing the partition during FAT resize (vtrefny) - Use mountpoint for "xfs_info" calls (vtrefny) - Use libmount cache when parsing /proc/mounts (vtrefny) - Add some space for the CI status (vpodzime) - Confirm the force when creating PVs in FS tests (vpodzime) - Skip vgremove tests on 32bit Debian (vtrefny) - Fix names of backing files in tests (vtrefny) - Fix checking for available locales (vtrefny) - Skip dependency checking in mpath tests on Debian (vtrefny) - Skip zRAM tests on Debian (vtrefny) - Skip the test for device escrow on Debian too (vtrefny) - Skip free region tests on Debian too (vtrefny) - Fix redirecting command output to /dev/null in tests (vtrefny) - Try harder to unmount devices in test cleanup (vtrefny) - Require only plugins that are needed for given test (vtrefny) - Try to get distribution info from "PrettyName" if "CPEName" isn't available (vtrefny) - Use -ff when creating PVs in FS tests (vpodzime) - Sync spec with downstream (vpodzime) * Mon Jul 31 2017 Vratislav Podzimek - 2.11-1 - Make the KbdZRAMDevicesTestCase inherit from KbdZRAMTestCase (vpodzime) - Allow non-source directory builds (kailueke) - Add a way to disable runtime dependency checks (vpodzime) - Link to GObject even if no plugin is activated (kailueke) - Skip zram tests on Rawhide (vpodzime) - Keep most utilities available for tests (vpodzime) - Use new libmount function to get (un)mount error message (vtrefny) - Update the documentation URL (vpodzime) * Wed Jul 26 2017 Fedora Release Engineering - 2.10-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild * Wed Jul 05 2017 Vratislav Podzimek - 2.10-1 - Only enable partition size tolerance with alignment (vpodzime) - Limit the requested partition size to maximum possible (vpodzime) - Do not verify vfat FS' size after generic resize (vpodzime) - Specify tolerance for partition size (kailueke) - Only use the exact constraint if not using any other (vpodzime) - Check resulting FS size in tests for generic FS resize (vpodzime) - Query setting FS label support and generic relabeling (kailueke) - Do not strictly require all FS utilities (vpodzime) - Compile everything with the C99 standard (vpodzime) - Add partition resize function (kailueke) - Generic Check and Repair Functions (kailueke) - Query functions for FS resize and repair support (kailueke) - Update the project/source URL in the spec file (vpodzime) - Add functions for opening/closing TrueCrypt/VeraCrypt volumes (vpodzime) - Adapt to a change in behaviour in new libmount (vpodzime) - Try RO mount also if we get EACCES (vpodzime) - Size in bytes for xfs_resize_device (kailueke) - src/plugins/Makefile.am: Remove hard coded include path in /usr prefix (tristan.vanberkom) - Fixed include for libvolume_key.h (tristan.vanberkom) - Ignore parted warnings if possible (squimrel) - bcache tests: Remove FEELINGLUCKY checks (tasleson) - kbd.c: Code review corrections (tasleson) - kbd.c: Make bd_kbd_bcache_create work without abort (tasleson) * Tue Jun 13 2017 Vratislav Podzimek - 2.9-1 - Fix hardcoded reference to gcc (timo.gurr) - Catch and ignore partial failures in LVM tests' cleanups (vpodzime) - Fix hardcoded reference to pkg-config (timo.gurr) - Make GObject introspection optional (vpodzime) - Do not link libraries required by plugins to the GI files (vpodzime) - Make sure the whole build status image is shown (vpodzime) - Show CI status in README (at the GH repo's front page) (vpodzime) - Always require the libudev pkg (tgurr) - Make sure we give kernel time to fully setup zram device(s) (vpodzime) - fs_test.py: Close FDs when calling utilities (tasleson) - crypto.c: Correct segmentation fault (tasleson) * Tue Jun 06 2017 Vratislav Podzimek - 2.8-1 - Temporarily skip vfat generic resize test on rawhide (vtrefny) - Use "safeprobe" in "bd_fs_wipe" (vtrefny) - Add a generic filesystem resize function (vtrefny) - Add a function to get mountpoint for a device (vtrefny) - Add a function to get filesystem type for a device (vtrefny) - Only include the LVM DBus config when shipping LVM DBus (vpodzime) - Skip the LVM DBus vgreduce tests on Rawhide (vpodzime) - Do not build the lvm-dbus plugin on RHEL/CentOS (vpodzime) - Give zRAM more time to settle before trying to remove a device (vpodzime) - Put zram tests adding/removing devices into a separate class (vpodzime) - Skip LVM cache and RAID tests on Rawhide (vpodzime) - Fix the skip_on decorator factory for tests (vpodzime) - Use 'blkid -p' instead of lsblk to get device's FS type (vpodzime) - Improve the lvm_set_global_config test (vpodzime) - Pass '-y' to pvresize (vpodzime) - Create a copy of os.environ for a child process (vpodzime) - Revert "Use the "C.UTF-8" locale instead of just "C"" (vpodzime) - Fix how we create vfat FS in tests (vpodzime) - Skip the test if requiring unavailable locales (vpodzime) - Use the "C.UTF-8" locale instead of just "C" (vpodzime) - Add functions for working with ext2 and ext3 filesystems (vtrefny) - Link to gobject when lvm or btrfs is enabled (andreas) - Link to libm where needed (andreas) - Add a function for cleaning a device (vtrefny) - Add few code exaples to documentation (vtrefny) - Use a special exception for no fs signature when doing wipe (vpodzime) - One more incompatible os.symlink() call (vpodzime) - Do not use pass-by-name in the os.symlink() call (vpodzime) - Ignore previous errors when falling back to using ioctl() (vpodzime) - Use ioctl() call to teardown loop devices (vpodzime) - Resolve the device to remove for mdadm (vpodzime) - Add a function for getting device symlinks (vpodzime) - Use the new resolve_device() function where appropriate (vpodzime) - Add the resolve_device() function to the utils library (vpodzime) - First try to read the 'autoclear' flag from /sys/ (vpodzime) * Wed Apr 26 2017 Vratislav Podzimek - 2.7-1 - Skip btrfs min size tests on Fedora 25 (vtrefny) - Make sure the loop device doesn't disappear during tests (vpodzime) - Close the loop device when autoclear is (un)set (vpodzime) - Do not enforce Python 3 for running tests in CI (vpodzime) - Revert "Use different BTRFS_MIN_MEMBER_SIZE on aarch64" (vtrefny) - Use both 'old' and 'new' sysfs files to read zRAM stats (vtrefny) - Check if libparted-fs-resize pkgconfig is available (vpodzime) - Do not try to get name for inactive partitions (vtrefny) - Skip tests for getting free regions on CentOS/RHEL (vpodzime) - Free the container holding the specs of free regions (vpodzime) - Open loop devices as O_RDONLY when getting flags (vpodzime) - Resolve maximum partition size when we know its start (vpodzime) - Use --id instead of --part-type when setting partition id (vpodzime) - Fix mdadm command for removing failed device from an array (vtrefny) - Skip bcache tests on CentOS/RHEL 7 (vpodzime) - Use six.assertRaisesRegex in the FS tests (vpodzime) - Use mkdtemp() instead of TemporaryDirectory() (vpodzime) - Fix installation without specifying --exec-prefix (vpodzime) - Add options to force mkfs.ext4/vfat to create a FS on the whole device (vpodzime) - Skip the test for device escrow on CentOS/RHEL (vpodzime) - Define DEVNULL on our own if not in subprocess (vpodzime) - Remove the patches from the spec file (vpodzime) - Sync the spec file with downstream (vpodzime) - Stop skipping zRAM stats tests (vtrefny) - Add more tests for zRAM stats (vtrefny) - Fix reading zRAM properties from sysfs (vtrefny) * Wed Apr 12 2017 Vratislav Podzimek - 2.6-3 - Do not try to parse 'raid_spec' for 'bd_md_activate' (vtrefny) Resolves: rhbz#1439111 * Tue Apr 11 2017 Vratislav Podzimek - 2.6-2 - Make sure the returned thpool MD size is valid (vpodzime) * Wed Mar 15 2017 Vratislav Podzimek - 2.6-1 - Move the part_err library before part and fs (vtrefny) - Fix BuildRequires for crypto and dm packages (vtrefny) - Fix mounting read-only devices (vtrefny) - Fix the bd_s390_dasd_is_ldl function. (vponcova) - Add the bd_s390_dasd_is_fba function to check if DASD is FBA (vponcova) - Disable MD RAID tests on 32bit systems (vpodzime) - Fix error message when mounting with a wrong fs type (vtrefny) - Only create RPMs for requested/configured plugins (vpodzime) - Only check dependencies of plugins to be built (vpodzime) - Only build and distribute plugins if configured so (vpodzime) - Fix format-security and unused-result compiler warnings (vtrefny) - Add an AC macro for modular builds (vpodzime) - Add functions for mounting and unmounting filesystems (vtrefny) * Mon Mar 06 2017 Vratislav Podzimek - 2.5-1 - Do not try to get GVariant after not adding anything to its builder (vpodzime) - Replace NULL with "" when building ExtraArg (vpodzime) - Replace NULL with "" when adding it as a 's' GVariant (vpodzime) - Make sure we don't try to add NULL as GVariant to DBus params (vpodzime) - Add function for getting recommended thpool metadata size (vpodzime) - Make udev settle after we create a LIO device (vpodzime) - Always use '--yes' for lvremove (vpodzime) * Tue Feb 21 2017 Vratislav Podzimek - 2.4-1 - Update specs.rst to use present-tense and current API (agrover) - Add functions using BLOBs as LUKS passphrases (vpodzime) - Make sure the _error_quark() functions are in the library (vtrefny) - Return a special error when trying to wipe empty device (vtrefny) - Adapt tests to use LIO devices instead of loop devices (vpodzime) - Add functions for creating and deleting LIO devices (vpodzime) - MDRAID: Allow path as input for functions that work with sysfs (vtrefny) * Wed Feb 15 2017 Vratislav Podzimek - 2.3-3 - Rebuild with changelog fixed up * Tue Feb 14 2017 Vratislav Podzimek - 2.3-1 - Allow specifying raid 'name' in multiple way when calling md functions (vtrefny) - Allow using both path and raid name in bd_md_set_bitmap_location (vtrefny) - Fix potential memory issues in s390 sanitizate functions (vpodzime) - Try multiple times when probing device for wiping (vpodzime) - Check for libvolume_key.h and dmraid.h in configure.ac (vpodzime) - Define our own macro for testing required header files (vpodzime) - Include blockdev/utils.h in mdraid.h (vtrefny) - Fix misspelling (agrover) - Skip the bcache tests even on x86_64 (vpodzime) - Take a break between bcache creation tests (vpodzime) - Make sure ./configure fails if there are some soft failures (vpodzime) - Improve the error message on missing GI support (vpodzime) - Only require bcache-tools if supporting bcache (vpodzime) - Skip bcache tests on non-x86_64 architectures (vpodzime) - Try harder to register a new bcache device (vpodzime) - Reimplement swapon/swapoff functions by using syscalls (vpodzime) - Make sure bcache functions are correctly provided or not (vpodzime) - Changelog fixup (vpodzime) * Fri Feb 10 2017 Fedora Release Engineering - 2.2-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild * Wed Jan 11 2017 Vratislav Podzimek - 2.2-2 - Rebuild with changelog fixed up * Wed Jan 11 2017 Vratislav Podzimek - 2.2-1 - Use the .in file as source when bumping version (vpodzime) - Run pylint based on the python version and make it optional (vpodzime) - Disable python3 and bcache on RHEL (vpodzime) - Make bcache support optional (vpodzime) - Teach boileplate_generator.py to skip things based on patterns (vpodzime) - Require lower versions of some utilities (vpodzime) - Do not require python3 for the boilerplate generation script (vpodzime) - Use a proper initialization value for 'GPollFD fds[2]' (vpodzime) - Deal with older parted and libblkid (vpodzime) - Make python3 and gtk-doc optional (vpodzime) - Bump the version of the utils library (vpodzime) - Fix docstring for 'bd_md_node_from_name' (vtrefny) - Add tests for added mdraid methods (vtrefny) - Skip 'MDTestNominateDenominateActive' unless feeling lucky (vtrefny) - MDRaid tests: change 'wait_for_resync' to wait for given action (vtrefny) - Add functionality need by storaged to mdraid plugin (vtrefny) - Move 'echo_str_to_file' method to utils (vtrefny) - Add a function to setup a loop device from a file descriptor (vpodzime) - Add functions to get/set the autoclear flag on a loop device (vpodzime) - Fix checking /proc/mdstat for resync action (vtrefny) - Adapt the test config files to version 2.x (vpodzime) * Mon Dec 12 2016 Charalampos Stratakis - 2.1-3 - Rebuild for Python 3.6 * Tue Nov 15 2016 Vratislav Podzimek - 2.1-2 - Rebuild for a chain-build with storaged (vpodzime) * Thu Nov 10 2016 Vratislav Podzimek - 2.1-1 - Do not require an exclusive lock on the device to commit part stuff (vpodzime) - Prevent failure if there are no btrfs subvolumes (vpodzime) - Fix the test for getting version of a failing utility (vpodzime) - Also run the utils tests (vpodzime) - Bump the version of the pkgconfig module (vpodzime) - Include utils.h in plugins that need it (vpodzime) - Fix dependency check in fs plugin (vtrefny) - Add support for setting part id (part type) on msdos part tables (vtrefny) - Trim the extra info for MD RAID's name (vpodzime) - Add xfsprogs and dosfstools as dependencies of the fs plugin (vpodzime) - Fix md_name_from_node to work with the "/dev/" prefix (vpodzime) - New major upstream release * Wed Nov 9 2016 Vratislav Podzimek - 1.9-8 - Revert "Prevent issues between libparted and udev" (vpodzime) - Revert "Open the device file as RDWR when committing parts" (vpodzime) * Thu Oct 27 2016 Vratislav Podzimek - 1.9-7 - Open the device file as RDWR when committing parts (vpodzime) - Handle mdadm --examine output during migration (adamw) Resolves: rhbz#1381996 * Mon Oct 24 2016 Vratislav Podzimek - 1.9-6 - Prevent issues between libparted and udev (vpodzime) * Mon Oct 10 2016 Vratislav Podzimek - 1.9-5 - Make sure all object paths are passed and extracted as such (vpodzime) Resolves: rhbz#1374973 * Tue Oct 4 2016 Vratislav Podzimek - 1.9-4 - Do not report volume name for FW RAID container device (vpodzime) Related: rhbz#1379865 - Search for just "UUID" in mdadm --examine output (vpodzime) Related: rhbz#1379865 - Use 'mdadm --examine --export' to get MD RAID level (vpodzime) Related: rhbz#1379865 * Mon Oct 3 2016 Vratislav Podzimek - 1.9-3 - Try to search for "RAID Level" in mdadm's output (vpodzime) Resolves: rhbz#1379865 - Fix the number passed to LVM DBus as a job-creation timeout (vpodzime) Resolves: rhbz#1378970 * Mon Aug 29 2016 Vratislav Podzimek - 1.9-2 - Explicitly cast number constants for GVariants (vpodzime) * Wed Jul 27 2016 Vratislav Podzimek - 1.9-1 - Add functions for creating thin/cache pools from existing LVs (vpodzime) - Add the new mpath_get_members() function to the docs (vpodzime) * Tue Jul 19 2016 Fedora Release Engineering - 1.8-2 - https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages * Wed Jun 29 2016 Vratislav Podzimek - 1.8-1 - Add a function to get all mpath member devices (vpodzime) - Fix backport issues in the zfcp-related functionality (#1348442) (vpodzime) - Revert "Fix a few const params in the s390 plugin." (vpodzime) - Fix creation of the version-only tags (vpodzime) * Wed Jun 15 2016 Vratislav Podzimek - 1.7-1 - Include the LV roles in the LVdata (vpodzime) - Add a few missing items to the documentation (vpodzime) - Document fields of the structures (vpodzime) - Report (meta)data LV name properly for cache pools in lvm-dbus (vpodzime) - Add information about related LVs to LVMLVdata (vpodzime) - Remove unused code for getting supported functions (vpodzime) - Add zFCP functionality to s390 plugin (sbueno+anaconda) - Fix a few const params in the s390 plugin. (sbueno+anaconda) * Wed Jun 01 2016 Vratislav Podzimek - 1.6-1 - Ignore merge commits when creating changelog (vpodzime) - Only take the number of the first %changelog line found (vpodzime) - Add some more detailed description to the part plugin (vpodzime) - Fix a few extra issues with the const types (vpodzime) - Add function for getting best free region (vpodzime) - Add function for getting free regions (vpodzime) - Fix the error message when setting part flag fails (vpodzime) - Add function for setting disk flags (vpodzime) - Add function for getting information about disk(s) (vpodzime) - Do not set nonsense partition paths (vpodzime) - Add function for getting partition by position (vpodzime) - Indicate if there was error from parted or not in set_parted_error() (vpodzime) - Minor fixes for the bd_part_get_part_spec() function (vpodzime) - Add support for extra GPT flags (vpodzime) - Add functionality for partition types (GUIDs) (vpodzime) - Add functionality for partition names (vpodzime) - Do not destroy disk objects we didn't get (vpodzime) - Add a function for setting multiple partition flags at once (vpodzime) - Remove the unused definition USE_PYTHON3 from configure.ac (vpodzime) - Use different BTRFS_MIN_MEMBER_SIZE on aarch64 (vpodzime) - Better release memory from parted objects on failures (vpodzime) - Rework how we do optimal alignment (vpodzime) - Do not try to destroy object we didn't get (vpodzime) - Don't pass sizes in bytes to LVM (#1317373) (vpodzime) - Add the libbytesize-devel build requires (vpodzime) - Search for the LVM DBus service in both active and activatable names (vpodzime) - Adapt to another stupid change in btrfs-progs (vpodzime) - Add the XFS-related functions to the documentation (vpodzime) - Add tests for the XFS-related functions (vpodzime) - Add support for the XFS file system to the FS plugin (vpodzime) - Add chunk_size to BDMDExamineData (vtrefny) - Add the subpackage for the FS plugin (vpodzime) - Add the FS plugin to the docs (vpodzime) - Add tests for the ext4 functionality in the fs plugin (vpodzime) - Add the FS plugin and the ext4 support (vpodzime) - Add a function for running utility reporting error and exit code (vpodzime) - Add the subpackage for the part plugin (vpodzime) - Add a missing BuildRequires for parted-devel (vpodzime) - Tag as both libblockdev-$version and just $version (vpodzime) - Add the 'part' plugin to documentation (vpodzime) - Add tests for the newly added part plugin (vpodzime) - Add the part plugin with storaged-required functionality (vpodzime) * Mon Mar 21 2016 Vratislav Podzimek - 1.5-1 - Merge pull request #72 from vpodzime/master-faster_tests (vpodzime) - Ignore all .bak files (vpodzime) - Use python3-pylint and skip Python 2 tests (vpodzime) - Try a bit harder when deactivating MD arrays in tests (vpodzime) - Recompile only the LVM plugin in tests (vpodzime) - Merge pull request #65 from vpodzime/master-loc_indep_error (vpodzime) - Merge pull request #70 from vojtechtrefny/master-chunk_size (vpodzime) - Add bd_md_create_with_chunk_size() function (vtrefny) - Merge pull request #68 from vpodzime/master-no_intro_data (vpodzime) - Merge pull request #71 from vpodzime/master-ipython3 (vpodzime) - Run coverage with the right config directories (vpodzime) - Merge pull request #67 from phatina/master (vpodzime) - Merge pull request #69 from vpodzime/master-lvm_dbus_autostart (vpodzime) - Use ipython3 for debugging and testing sessions (vpodzime) - Don't expect to always get introspection data from DBus (vpodzime) - Make invocation of tests configurable (phatina) - Make error messages locale agnostic (vpodzime) * Tue Mar 15 2016 Vratislav Podzimek - 1.4-5 - Search for the LVM DBus service in activatable names (vpodzime) - Better check for the LVM DBus API (vpodzime) * Wed Mar 9 2016 Vratislav Podzimek - 1.4-4 - Do not try to get object path of NULL in vgreduce (vpodzime) * Tue Mar 1 2016 Peter Robinson 1.4-3 - Depend on python3-gobject-base not python3-gobject so as to not pull in X components * Thu Feb 25 2016 Vratislav Podzimek - 1.4-2 - Add/fix the requirement for the LVM DBus daemon * Thu Feb 25 2016 Vratislav Podzimek - 1.4-1 - Merge pull request #62 from vpodzime/master-clean_up (vpodzime) - Use addCleanup() instead of tearDown() in tests (vpodzime) - Merge pull request #58 from vpodzime/master-lvm_dbus_pr (vpodzime) - Add the VG renaming functionality (vpodzime) - Packaging of the lvm-dbus plugin (vpodzime) - The LVM DBus plugin (vpodzime) - Add more generic functions for logging (vpodzime) - Use MAX(a, b) instead of CLAMP(b, a, b) (vpodzime) - Merge pull request #59 from vpodzime/master-vgrename (vpodzime) - Add a function for renaming VGs (vpodzime) - Merge pull request #57 from clumens/master (vpodzime) - Fix error reporting when running "make test". (clumens) - Merge pull request #54 from vojtechtrefny/master-pvsize (vpodzime) - Do not try to create a PV with 4KiB metadata space (vpodzime) - Add pv_info to BDLVMPVdata (vtrefny) - btrfs now requires at least 128MiB device(s) (vpodzime) - Merge pull request #52 from vpodzime/master (vpodzime) - Round size in thpoolcreate() to KiB (vpodzime) - Sync the %changelog in spec with downstream (vpodzime) * Wed Nov 25 2015 Vratislav Podzimek - 1.3-4 - Create the cache pool before the to-be-cached LV (vpodzime) * Thu Nov 05 2015 Robert Kuska - 1.3-3 - Rebuilt for Python3.5 rebuild * Wed Nov 04 2015 Vratislav Podzimek - 1.3-2 - Fix the annotation of bd_try_init in blockdev.c (vpodzime) * Mon Oct 26 2015 Vratislav Podzimek - 1.3-1 - Add missing python GI requires (vpodzime) - Merge pull request #49 from dashea/libblockdev-python (vpodzime) - Merge pull request #50 from vpodzime/master-fix_striped_lv (vpodzime) - Merge pull request #46 from vpodzime/master-bcache_destroy (vpodzime) - Merge pull request #39 from vpodzime/master-lvm_physical_space (vpodzime) - Add a missing ldconfig that rpmlint found. (dshea) - Move python files to separate packages (#1256758) (dshea) - Fix lvcreate calls for striped LVs (vpodzime) - Merge pull request #48 from vojtechtrefny/master_pvfree (vpodzime) - Add pv_free to BDLVMPVdata (vtrefny) - Merge pull request #47 from atodorov/add_coverage_report (vpodzime) - Produce coverage report in CI (atodorov) - Check bcache device's state before trying to detach the cache in destroy() (vpodzime) - Fix URLs in the spec (vpodzime) - Fix the int-float less-than comparison (vpodzime) - Fix the calculation of physical space taken by an LV (vpodzime) * Wed Sep 23 2015 Vratislav Podzimek - 1.2-1 - Merge pull request #40 from vpodzime/master-config_support (vpodzime) - Add tests for configuration support (vpodzime) - Add a function for getting the loaded soname for a plugin (vpodzime) - Add the default configuration (vpodzime) - Load and respect configuration files when loading plugins (vpodzime) - Add functions for finding and processing configuration files (vpodzime) - Merge pull request #38 from vpodzime/master-md_superblock_size (vpodzime) - Better document how MD RAID superblock size should be calculated (vpodzime) - Merge pull request #36 from phatina/master (vpodzime) - BTRFS: allow an arbitrary label to be set for a btrfs volume (phatina) - Merge pull request #32 from phatina/master (vpodzime) - BTRFS: fix parsing empty partition label (phatina) - Merge pull request #35 from vpodzime/master (vpodzime) - Define env variables for sudo via the env utility (vpodzime) - Merge pull request #34 from dashea/python3-tests (vpodzime) - Use unittest.addCleanup to simplify crypto_test. (dshea) - Run tests with both python2 and python3 in the ci target. (dshea) - Fix python3 issues in the unittests. (dshea) - Do not run all tests in the 'ci' target (vpodzime) - Merge pull request #33 from clumens/master (vpodzime) - Add a new makefile target that does everything needed for jenkins. (clumens) - Synchronize the .spec file with downstream (vpodzime) * Fri Jul 24 2015 Vratislav Podzimek - 1.1-2 - Explicitly specify the type of the cert_data parameter (#1246096) (vpodzime) * Fri Jun 19 2015 Vratislav Podzimek - 1.1-1 - Clean generated boilerplate code on 'make clean' (vpodzime) - Merge pull request #31 from atodorov/use_lang_c (vpodzime) - tests: use LANG=C in test_backup_passphrase() (atodorov) - Merge pull request #30 from atodorov/makefile_updates (vpodzime) - Makefile.am: - add separate check target - add coverage targets - make it possible to test with Python3 (atodorov) - Merge pull request #29 from atodorov/fix_issue_28 (vpodzime) - Merge pull request #27 from atodorov/fix_docs_url (vpodzime) - Merge pull request #26 from atodorov/test_docs (vpodzime) - Change the modified sources back in tearDown() method as well. Closes #28. (atodorov) - update URL to on-line documentation (atodorov) - add test documentation (atodorov) - Merge pull request #22 from dashea/escrow-tests (vpodzime) - Merge pull request #25 from dashea/python-dep (vpodzime) - Filter the python files from automatic rpm requires (dshea) - Added tests for escrow packets and backup passphrases (dshea) - Free leaked contexts from crypto_init (dshea) - Cooperate with volume_key's memory management (dshea) - Fix inheritance in the LVM tests to prevent multiple runs of some tests (vpodzime) - Make the regexp for testing crypto_generate_backup_passphrase() stricter (vpodzime) - Leave room in the backup passphrase for a trailing 0 (dshea) - Add functions to get names of data/metadata internal LVs (vpodzime) - Allow getting info for an internal LV (vpodzime) - Gather information about all LVs (vpodzime) - Round requested size to KBs in lvresize() (#1221247) (vpodzime) - Add overrides for the ensure_init() function (vpodzime) - Change the default value of the 'reload' parameter of try_reinit() (vpodzime) - Merge pull request #21 from vpodzime/master-thpool_size_discard (vpodzime) - Add overrides for the lvm_is_valid_thpool_chunk_size() function (vpodzime) * Wed Jun 17 2015 Fedora Release Engineering - 1.0-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild * Thu May 21 2015 Vratislav Podzimek - 1.0-1 - Adapt the release helper targets to autotools (vpodzime) - Fixes of paths in Makefile.am's inspired by build failures on s390 (vpodzime) - Add an s390-specific BuildRequires (vpodzime) - Distribute also the boilerplate_generator.py script (vpodzime) - Fix path to the generated blockdev.pc file (vpodzime) - Adapt tests that compile stuff to autotools (vpodzime) - Merge pull request #18 from vpodzime/master-autotools (vpodzime) - Merge pull request #20 from dashea/gtkdoc-sections (vpodzime) - Use the autotools building system instead of scons (vpodzime) - Add the two new functions to the 'blockdev' docs section (vpodzime) - Fix the line defining the docs file for the s390 section (vpodzime) - Add a missing #include to the kbd.api file (vpodzime) - Prevent s390-specific stuff from being used on other architectures (vpodzime) - Update the documentation of the is_initialized() function (vpodzime) - Merge pull request #19 from vpodzime/master-ensure_init (vpodzime) - Remove private macros from the gtkdoc sections file. (dshea) - Terminate ifdef statements for arch check. (sbueno+anaconda) - Return early from the init functions if setting up logging fails (vpodzime) - Add tests for the new and modified init functions (vpodzime) - Add new try_init() and try_reinit() functions (vpodzime) - Fix for adding number of loaded plugins (vpodzime) - Fix for ensure_init() (vpodzime) - Rename the try_init() function to ensure_init() and improve it (vpodzime) - Check number of loaded plugins and library initialization state (vpodzime) - Make 'reload' default to True instead of False in overrides (vpodzime) - Add the s390 plugin test file. (sbueno+anaconda) - Add the s390 plugin functions. (sbueno+anaconda) - Add the s390 plugin. (sbueno+anaconda) - Fix a typo in the spec file. (sbueno+anaconda) - Require the kmod-devel package for the build process (vpodzime) - Merge pull request #16 from dashea/escrow-encoding (vpodzime) - Merge pull request #13 from vpodzime/master-lvm_cache (vpodzime) - Merge pull request #12 from vpodzime/master-kbd_plugin (vpodzime) - Merge pull request #14 from vpodzime/master-better_is_multipath (vpodzime) - Use g_strdup() instead of g_strdup_printf() to just dup a string (vpodzime) - Fix the spelling of "escrow" (dshea) - Make the crypto plugin string parameters const (dshea) - Set encoding to NULL before writing the escrow packet. (dshea) - Get cache stats directly from the device mapper (vpodzime) - Reimplement the is_mpath_member() function using device mapper (vpodzime) - Add the LVM cache related symbols to the LVM section in the documentation (vpodzime) - Update the list of LVM cache related functions in features.rst (vpodzime) - Add tests for functions related to the LVM cache technology (vpodzime) - Implement the lvm_cache_stats() function (vpodzime) - Implement the lvm_cache_pool_name function (vpodzime) - Implement the lvm_cache_create_cached_lv() function (vpodzime) - Implement lvm_cache_attach/detach() functions (vpodzime) - Implement the lvm_cache_create_pool() function plus two support functions (vpodzime) - Implement the lvm_cache_get_default_md_size() function (vpodzime) - Add the 'type' parameter to the lvm_lvcreate function (vpodzime) - Teach boilerplate_generator to work with enum return types (vpodzime) - Teach boilerplate_generator to work with 'const' return types (vpodzime) - Add subpackages for the KBD plugin and its devel files (vpodzime) - Add provided symbols to the documentation section of the KBD plugin (vpodzime) - Implement the bcache_get_backing/cache_device functions (vpodzime) - Exclude bcache tests from the normal 'test' target (vpodzime) - Add some more and prolong some of the waits in KBD tests (vpodzime) - Zero all newly allocated structures (vpodzime) - Implement the bcache_status function and all it wants (vpodzime) - Fix for the zram stats (vpodzime) - Add bcache_get_mode and bcache_set_mode functions (vpodzime) - Teach boilerplate_generator to work with enum return types (vpodzime) - Teach boilerplate_generator to work with 'const' return types (vpodzime) - Add the zram_get_stats function (vpodzime) - Add the check() function for the KBD plugin (vpodzime) - Add ErrorProxy instance for the KBD plugin (vpodzime) - Add tests for bcache_create/attach/detach/destroy functions (vpodzime) - Add the 'rebuild' Makefile target (vpodzime) - Add bcache_create, bcache_attach, bcache_detach and bcache_destroy functions (vpodzime) - Implement a helper function to echo string into a file (vpodzime) - Add tests for zram_create_devices and zram_destroy_devices functions (vpodzime) - Add the zram_destroy_devices function to the KBD plugin (vpodzime) - Add first function to the KBD plugin: zram_create_devices (vpodzime) - Add the KernelBlockDevices plugin (vpodzime) * Wed May 13 2015 Vratislav Podzimek - 0.13-1 - Prevent a leaky test from running in Jenkins (vpodzime) - Try harder when cleaning up after MD RAID tests (vpodzime) - Improve the MD RAID activate/deactivate test (vpodzime) - One more @contextmanager that needs try-finally (vpodzime) - Do not require metadata version to be reported by 'mdadm --examine' (#1217900) (vpodzime) - Make sure we always set things back in context managers (vpodzime) - Make the release date for version 1.0 more realistic (vpodzime) - Merge pull request #11 from vpodzime/master (vpodzime) - Run utilities with LC_ALL=C (vpodzime) (#1219033) - Free GMatchInfo instance even in case of no match (vpodzime) - Resolve /dev/md/ symlinks when checking swap status. (dlehman) * Fri Apr 24 2015 Vratislav Podzimek - 0.12-1 - Require minimum version of libblockdev-utils in some plugins (vpodzime) - Report both stdout and stderr if exit code != 0 (vpodzime) * Fri Apr 17 2015 Vratislav Podzimek - 0.11-1 - Fix issues with using overriden functions over ErrorProxy (vpodzime) - Update the roadmap.rst and features.rst with new stuff (vpodzime) - Fix two minor issues with docs generation (vpodzime) * Thu Apr 16 2015 Vratislav Podzimek - 0.10-1 - Fix return type of the unload_plugins() function (vpodzime) - Close the DL handle when check() or init() fail (vpodzime) - Add one more check to the reload test (vpodzime) - Drop reference to check() and init() functions (vpodzime) - Add more cats to tests (vpodzime) - Make regexp for getting btrfs version more generic (vpodzime) - Merge pull request #8 from vpodzime/master-check_functions (vpodzime) - Fix parameters passed to unoverridden swapon function (vpodzime) - Implement and test swap plugin's check function (vpodzime) - Implement and test MD RAID plugin's check function (vpodzime) - Implement and test mpath plugin's check function (vpodzime) - Try harder to get util's version (vpodzime) - Implement and test loop plugin's check function (vpodzime) - Implement and test DM plugin's check function (vpodzime) - Implement and test BTRFS plugin's check function (vpodzime) - Implement and test LVM plugin's check function (vpodzime) - Init logging before loading plugins (vpodzime) - Add function for utility availability checking (vpodzime) - Fix default value for the fake_utils' path argument (vpodzime) - Add ErrorProxy instance for the utils functions (vpodzime) - Add function for version comparison (vpodzime) - Merge pull request #9 from clumens/master (vpodzime) - Disable pylint checking on the new exception proxy. (clumens) - Fix XRules application and add a test for it (vpodzime) - Raise NotImplementedError when an unavailable function is called (vpodzime) - Merge pull request #4 from vpodzime/master-error_proxy (vpodzime) - Merge branch 'master' into master-error_proxy (vpodzime) - Merge pull request #5 from vpodzime/master-not_implemented_error (vpodzime) - Add a simple test for unloaded/unavailable functions (vpodzime) - Unload the plugins properly when reinit() is called (vpodzime) - Raise error/exception when an unimplemented function is called (#1201475) (vpodzime) - Do an ugly but necessary hack to make local GI overrides work (vpodzime) - Add the __dir__ method to ErrorProxy (vpodzime) - Add a rationale for the ErrorProxy to the overrides' docstring (vpodzime) - Add some basic info about GI overrides to the documentation (vpodzime) - Use pylint to check for errors in python overrides (vpodzime) - Add the first small test for the ErrorProxy (vpodzime) - Put the GI overrides in a special dir so that they are preferred (vpodzime) - Add a cache for attributes already resolved by ErrorProxy (vpodzime) - Implement the ErrorProxy python class and use it (vpodzime) * Tue Apr 07 2015 Vratislav Podzimek - 0.9-1 - Merge pull request #7 from vpodzime/master-fw_raid_fixes (vpodzime) - Try a bit harder when trying to determine MD RAID name (#1207317) (vpodzime) - Don't be naïve about mdadm --detail telling us what we want (#1207317) (vpodzime) - Ignore libblockdev tarballs (vpodzime) - Implement a test of btrfs_list_subvolumes on data from bug report (vpodzime) - Implement a context manager for running tests with fake utils (vpodzime) - Do not try to cannonicalize MD UUIDs if we didn't get them (#1207317) (vpodzime) - Fix the table in roadmap.rst (vpodzime) - Enrich the roadmap.rst file and add info about new plans (vpodzime) - Sync spec file with downstream (vpodzime) * Fri Mar 27 2015 Vratislav Podzimek - 0.8-1 - Merge pull request #6 from vpodzime/master-sort_btrfs_subvolumes (vpodzime) - Don't be naïve about mdadm providing us data we would like (#1206394) (vpodzime) - Sort BTRFS subvolumes in a way that child never appears before parent (#1201120) (vpodzime) - Let libcryptsetup handle LUKSname->/dev/mapper/LUKSname for us (vpodzime) - Fix the crypto_luks_resize and create a test for it (vpodzime) - Add targets to create the SRPM and RPM files easily (vpodzime) - Don't round up to multiple of PE size bigger than max value of the rtype (vpodzime) - Mark majority of MD RAID tests as slow (vpodzime) - Merge pull request #1 from dashea/file-paths (vpodzime) - Don't report error for no loop device associated with given file (vpodzime) - Skip the detail_data.clean check when running tests in Jenkins (vpodzime) - Make package file paths more specific (dshea) - Implement and use MD RAID-specific wait for tests (vpodzime) - Try to give MD RAID time to sync things before querying them (vpodzime) - Fix the default value of the BDMDDetailData.clean field (vpodzime) - Do cleanup after every single MD RAID tests (vpodzime) - Do cleanup after every single LVM test (vpodzime) - Do cleanup after every single BTRFS test (vpodzime) - Make sure the LUKS device is closed and removed after tests (vpodzime) - Make sure DM maps from tests are removed after tests (vpodzime) - Make sure that loop devices are deactivated after tests (vpodzime) - Make the tearDown method of the mpath test case better visible (vpodzime) - Make sure that the swap is deactivated after tests (vpodzime) - Fix docstrings in tests' utils helper functions (vpodzime) - Improve the logging tests in utils_test.py (vpodzime) - Update the features.rst file (vpodzime) - Update the roadmap (vpodzime) - Don't check if we get a mountpoint for BTRFS operations (vpodzime) * Sun Mar 22 2015 Peter Robinson 0.7-2 - Ship license as per packaging guidelines - plugins-all should depend on base library too - Add dev docs * Fri Feb 27 2015 Vratislav Podzimek - 0.7-1 - Be ready for mdadm --examine to not provide some of the values we want (vpodzime) - Add exit code information to exec logging (vpodzime) - Improve and add tests (vpodzime) - Mark the test_force_plugin and test_reload as slow (vpodzime) - Make sure we get some devices when creating btrfs volume (vpodzime) - Add override for the lvremove function (vpodzime) - Do not create LUKS format with no passphrase and no key file (vpodzime) - Make sure we use the /dev/mapper/... path for luks_status (vpodzime) * Thu Feb 19 2015 Vratislav Podzimek - 0.6-1 - Don't report error when non-existing swap's status is queried (vpodzime) - Make libblockdev-plugins-all pull the same version of plugins (vpodzime) - Don't report error when asked for a backing file of an uknown loop (vpodzime) - Fix accidental change in the spec's changelog (vpodzime) * Mon Feb 16 2015 Vratislav Podzimek - 0.5-1 - Add tests for what we can easily test from the mpath plugin (vpodzime) - Add link to sources to the documentation (vpodzime) - Add missing symbols into the libblockdev-sections.txt file (vpodzime) - Do not build docs for testing (vpodzime) - Add the bd_try_init function (vpodzime) - Log stdout and stderr output when running processes (vpodzime) - Allow a subset of plugins to be load instead of all (vpodzime) - Make sure devmapper doesn't spam stdout with tons of messages (vpodzime) - Let debug messages go to stderr when running ipython (vpodzime) - Give plugins a way to initialize themselves (vpodzime) - Give plugins a way how to check if they could run properly (vpodzime) - Allow a subset of plugins to be load instead of all [TEST NEEDED] (vpodzime) - Make sure we use the whole /dev/mapper path for cryptsetup (vpodzime) - Fix vg_pv_count parsing when getting info about PV (vpodzime) - Set default values to data structures if real values are not available (vpodzime) - Fix the parameter name specifying pool metadata size (vpodzime) - Activate LUKS as ReadWrite in luks_open (vpodzime) - Make sure we pass key_size to cryptsetup in bytes (vpodzime) - Add the min_entropy parameter to luks_format Python overrides (vpodzime) - Pass size in KiB instead of B to lvcreate (vpodzime) - Add underscore into dataalignment and metadatasize parameter names (vpodzime) - Don't report error if non-mpath device is tested for being mpath member (vpodzime) - Fix name of the invoked utility in mpath_set_friendly_names (vpodzime) * Sat Jan 31 2015 Vratislav Podzimek - 0.4-1 - Improve the test for lvm_set_global_config (vpodzime) - Fix some minor issues in the spec file (vpodzime) - Fix issues with the LVM global config str (vpodzime) - Add couple more Python overrides (vpodzime) - Fix the name of the lvm_thlvpoolname() function in the header file (vpodzime) - Use assertEqual instead of assertTrue(a == b) (vpodzime) - Add the min_entropy parameter to luks_format (vpodzime) - Move internal dmraid-related macros into the source file (vpodzime) - Add an override for the md_add function (vpodzime) - Fix parameters in luks_open python overrides (vpodzime) - Prevent init() from being done multiple times and provide a test function (vpodzime) - Add the roadmap.rst document (vpodzime) - Remove an extra parenthesis in one of the docstrings (vpodzime) - Move the mddetail function next to the mdexamine function (vpodzime) - Add some more constants required by blivet (vpodzime) * Wed Jan 21 2015 Vratislav Podzimek - 0.3-1 - Require volume_key-devel in a version that fixes build issues (vpodzime) - Fix Python 2 devel package name in BuildRequires (vpodzime) - Generate docs for the library and all plugins (vpodzime) - Make doc comments better for documentation generation (vpodzime) - Fix parameter names in function prototypes (vpodzime) - Add the metadatasize parameter to pvcreate (vpodzime) - Add the dataalignment parameter to lvm_pvcreate (vpodzime) - Export non-internal constants via introspection (vpodzime) - Expand size constants in the GI-scanned files (vpodzime) - Fix usage printing in the boilerplate_generator (vpodzime) - Add the build directory to .gitignore (vpodzime) - Add the md_run function (vpodzime) - Fix some issues in Python overrides (vpodzime) - Add the escrow_device function to the crypto plugin (vpodzime) - Fix version of GI files in the Makefile (vpodzime) - Make the order of release target's dependencies more explicit (vpodzime) * Mon Jan 12 2015 Vratislav Podzimek - 0.2-1 - Fix dependencies of the release target (vpodzime) - Python overrides for the GI-generated bindings (vpodzime) - Pass version info to the code and use it to load plugins (vpodzime) * Wed Dec 10 2014 Vratislav Podzimek - 0.1-1 - Initial release libblockdev-2.16-1/docs/000077500000000000000000000000001323703006100150035ustar00rootroot00000000000000libblockdev-2.16-1/docs/Makefile.am000066400000000000000000000035131323703006100170410ustar00rootroot00000000000000all-local: html-doc.stamp html-doc.stamp: ${srcdir}/libblockdev-docs.xml ${srcdir}/libblockdev-sections.txt $(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/ 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 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 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-2.16-1/docs/libblockdev-docs.xml.in000066400000000000000000000137241323703006100213470ustar00rootroot00000000000000 ]> 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 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-2.16-1/docs/libblockdev-sections.txt000066400000000000000000000242531323703006100216570ustar00rootroot00000000000000
blockdev BD_INIT_ERROR BDInitError bd_init bd_ensure_init bd_try_init bd_reinit bd_try_reinit bd_is_initialized bd_switch_init_checks bd_init_error_quark
btrfs bd_btrfs_check_deps 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_check_deps bd_crypto_close bd_crypto_init BD_CRYPTO_LUKS_METADATA_SIZE bd_crypto_error_quark BD_CRYPTO_ERROR BDCryptoError BD_CRYPTO_BACKUP_PASSPHRASE_CHARSET BD_CRYPTO_BACKUP_PASSPHRASE_LENGTH DEFAULT_LUKS_KEYSIZE_BITS DEFAULT_LUKS_CIPHER bd_crypto_generate_backup_passphrase bd_crypto_device_is_luks bd_crypto_luks_uuid bd_crypto_luks_status bd_crypto_luks_format bd_crypto_luks_format_blob bd_crypto_luks_open bd_crypto_luks_open_blob bd_crypto_luks_close bd_crypto_luks_add_key bd_crypto_luks_add_key_blob bd_crypto_luks_remove_key bd_crypto_luks_remove_key_blob bd_crypto_luks_change_key bd_crypto_luks_change_key_blob bd_crypto_luks_resize bd_crypto_tc_open bd_crypto_tc_close bd_crypto_escrow_device BDCryptoTech BDCryptoTechMode bd_crypto_is_tech_avail
dm bd_dm_check_deps 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 bd_dm_get_member_raid_sets bd_dm_activate_raid_set bd_dm_deactivate_raid_set bd_dm_get_raid_set_type BDDMTech BDDMTechMode bd_dm_is_tech_avail
utils BDUtilsProgExtract BDUtilsProgFunc BDUtilsProgStatus BDUtilsLogFunc bd_utils_exec_error_quark BD_UTILS_EXEC_ERROR BDUtilsExecError BDUtilsDevUtilsError BD_UTILS_DEV_UTILS_ERROR 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_init_logging bd_utils_init_prog_reporting bd_utils_report_finished bd_utils_report_progress bd_utils_report_started bd_utils_echo_str_to_file BD_UTILS_SIZE_ERROR BDUtilsSizeError bd_utils_size_human_readable bd_utils_size_from_spec 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_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 EXBIBYTE EiB GIBIBYTE GiB KIBIBYTE KiB MEBIBYTE MiB PEBIBYTE PiB TEBIBYTE TiB
loop bd_loop_check_deps bd_loop_init bd_loop_close bd_loop_error_quark BD_LOOP_ERROR BDLoopError bd_loop_get_backing_file bd_loop_get_loop_name bd_loop_setup bd_loop_setup_from_fd bd_loop_teardown bd_loop_get_autoclear bd_loop_set_autoclear BDLoopTech BDLoopTechMode bd_loop_is_tech_avail
lvm bd_lvm_check_deps bd_lvm_close bd_lvm_init BD_LVM_MAX_LV_SIZE BD_LVM_DEFAULT_PE_SIZE BD_LVM_DEFAULT_PE_START BD_LVM_MIN_PE_SIZE BD_LVM_MAX_PE_SIZE USE_DEFAULT_PE_SIZE RESOLVE_PE_SIZE BD_LVM_MIN_THPOOL_MD_SIZE BD_LVM_MAX_THPOOL_MD_SIZE BD_LVM_MIN_THPOOL_CHUNK_SIZE BD_LVM_MAX_THPOOL_CHUNK_SIZE THPOOL_MD_FACTOR_NEW THPOOL_MD_FACTOR_EXISTS BD_LVM_MIN_CACHE_MD_SIZE BD_LVM_DEFAULT_CHUNK_SIZE 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 BDLVMLVdata bd_lvm_lvdata_free bd_lvm_lvdata_copy BDLVMCacheMode BDLVMCachePoolFlags BDLVMCacheStats bd_lvm_cache_stats_copy bd_lvm_cache_stats_free 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_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_vginfo bd_lvm_vgs bd_lvm_lvorigin bd_lvm_lvcreate bd_lvm_lvremove bd_lvm_lvrename bd_lvm_lvresize bd_lvm_lvactivate bd_lvm_lvdeactivate bd_lvm_lvsnapshotcreate bd_lvm_lvsnapshotmerge bd_lvm_lvinfo bd_lvm_lvs 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_data_lv_name bd_lvm_metadata_lv_name BDLVMTech BDLVMTechMode bd_lvm_is_tech_avail
mdraid bd_md_check_deps 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_check_deps 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_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_check_deps 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_set_label BDSwapTech BDSwapTechMode bd_swap_is_tech_avail
kbd bd_kbd_check_deps bd_kbd_init bd_kbd_close BDKBDBcacheMode BDKBDBcacheStats BDKBDError BDKBDZramStats BD_KBD_ERROR bd_kbd_bcache_attach bd_kbd_bcache_create bd_kbd_bcache_destroy bd_kbd_bcache_detach bd_kbd_bcache_get_backing_device bd_kbd_bcache_get_cache_device bd_kbd_bcache_get_mode bd_kbd_bcache_get_mode_from_str bd_kbd_bcache_get_mode_str bd_kbd_bcache_set_mode bd_kbd_bcache_stats_copy bd_kbd_bcache_stats_free bd_kbd_bcache_status bd_kbd_error_quark bd_kbd_zram_create_devices bd_kbd_zram_destroy_devices bd_kbd_zram_add_device bd_kbd_zram_remove_device bd_kbd_zram_get_stats bd_kbd_zram_stats_copy bd_kbd_zram_stats_free BDKBDTech BDKBDTechMode bd_kbd_is_tech_avail
part bd_part_check_deps bd_part_init bd_part_close BD_PART_ERROR BD_PART_TYPE_SPEC BDPartAlign BDPartFlag BDPartSpec BDPartType BDPartTypeReq BDPartError BDPartTableType BDPartDiskFlag 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_set_part_flag bd_part_spec_copy bd_part_spec_free bd_part_spec_get_type bd_part_get_flag_str 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_disk_flag bd_part_set_part_flags bd_part_set_part_name bd_part_set_part_type bd_part_set_part_id bd_part_get_part_id bd_part_error_quark BDPartTech BDPartTechMode bd_part_is_tech_avail bd_part_disk_spec_copy bd_part_disk_spec_free
fs bd_fs_check_deps 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_mount bd_fs_unmount bd_fs_get_mountpoint bd_fs_resize bd_fs_repair bd_fs_check bd_fs_set_label bd_fs_can_resize bd_fs_can_check bd_fs_can_repair bd_fs_can_set_label 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_wipe 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_wipe 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_wipe 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_wipe 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_wipe 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_wipe
s390 bd_s390_check_deps 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
libblockdev-2.16-1/features.rst000066400000000000000000000114471323703006100164320ustar00rootroot00000000000000Features ========= *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). Every plugin is also usable as a standalone shared library. partitions ----------- :supported technologies: MBR, GPT, partition manipulation on partitionable devices :functions: * mklabel * create_part * resize_part * remove_part filesystems ------------ :supported technologies: * DONE: ext2, ext3, ext4, xfs, vfat :functions: * make_FSTYPE * resize_FSTYPE * check_FSTYPE * repair_FSTYPE * change_label_FSTYPE * wipefs * mount * unmount * generic_resize [TODO] LVM ---- :supported technologies: "plain LVM", LVM Thin Provisioning :TODO: * read-only locking and default config :functions: * get_global_config * set_global_config * get_possible_pe_sizes * is_supported_pe_size * get_max_lv_size * round_size_to_pe * get_lv_physical_size * get_thpool_padding * is_valid_thpool_metadata_size * is_valid_thpool_chunk_size * pvcreate * pvresize * pvremove * pvmove * pvscan * pvinfo * pvs * vgcreate * vgextend * vgremove * vgactivate * vgdeactivate * vgreduce * vginfo * vgs * lvorigin * lvcreate * lvremove * lvresize * lvactivate * lvdeactivate * lvsnapshotcreate * lvsnapshotmerge * lvinfo * lvs * thpoolcreate * thlvcreate * thlvpoolname * thsnapshotcreate * cache_get_default_md_size * cache_get_mode_str * cache_get_mode_from_str * cache_create_pool * cache_attach * cache_detach * cache_create_cached_lv * cache_pool_name * cache_stats * data_lv_name * metadata_lv_name * thpool_convert * cache_pool_convert BTRFS ------ :supported technologies: btrfs as both filesystem and multi-device volume, subvolumes, snapshots :functions: * create_volume * add_device * remove_device * list_devices * create_subvolume * delete_subvolume * list_subvolumes * get_default_subvolume * set_default_subvolume * create_snapshot * filesystem_info * mkfs * resize * check * repair * change_label SWAP ----- :supported technologies: swap partitions/LVs, swap files :functions: * mkswap * swapon * swapoff * swapstatus MDRAID ------- :supported technologies: all RAID levels supported by the MD RAID :functions: * get_superblock_size * create * destroy * activate * deactivate * run * nominate * denominate * add * remove * examine * canonicalize_uuid * get_md_uuid * detail * node_from_name * name_from_node CRYPTO/LUKS ------------ :supported technologies: only LUKS encrypted devices :functions: * generate_backup_passphrase * device_is_luks * luks_uuid * luks_status * luks_format * luks_open * luks_close * luks_add_key * luks_remove_key * luks_change_key * luks_resize * escrow_device MULTIPATH ---------- :supported technologies: just very basic functionality :functions: * flush_mpaths * device_is_mpath_member * get_mpath_members * set_friendly_names LOOP ----- :supported technologies: basic operations with loop devices :functions: * get_backing_file * get_loop_name * loop_setup * loop_teardown DEVICE MAPPER -------------- :supported technologies: basic operations with raw device mapper and DM RAID sets :functions: * create_linear * remove * node_from_name * name_from_node * map_exists * get_member_raid_sets * activate_raid_set * deactivate_raid_set * get_raid_set_type s390 ----- :supported technologies: DASD, zFCP :functions: * s390_dasd_format * s390_dasd_needs_format * s390_dasd_online * s390_dasd_is_ldl * s390_dasd_is_fba * s390_sanitize_dev_input * s390_zfcp_sanitize_wwpn_input * s390_zfcp_sanitize_lun_input * s390_zfcp_online * s390_zfcp_scsi_offline * s390_zfcp_offline KBD (Kernel Block Devices) --------------------------- :supported technologies: bcache, zram :functions: * bcache_create * bcache_destroy * bcache_attach * bcache_detach * bcache_status * bcache_set_mode * bcache_get_mode * bcache_get_backing_device * bcache_get_cache_device * zram_create_devices * zram_destroy_devices * zram_get_stats utils ------ Library (not a plugin) providing utility functions usable for multiple plugins and any third-party code. :functions: * exec_and_report_error * exec_and_capture_output * size_human_readable * size_from_spec * init_logging * version_cmp * check_util_version libblockdev-2.16-1/include/000077500000000000000000000000001323703006100154765ustar00rootroot00000000000000libblockdev-2.16-1/include/Makefile.am000066400000000000000000000000671323703006100175350ustar00rootroot00000000000000SUBDIRS = blockdev MAINTAINERCLEANFILES = Makefile.in libblockdev-2.16-1/include/blockdev/000077500000000000000000000000001323703006100172675ustar00rootroot00000000000000libblockdev-2.16-1/include/blockdev/Makefile.am000066400000000000000000000006401323703006100213230ustar00rootroot00000000000000all-local: for header in ${srcdir}/../../src/plugins/*.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-2.16-1/roadmap.rst000066400000000000000000000023131323703006100162270ustar00rootroot00000000000000libblockdev's roadmap ====================== :authors: Vratislav Podzimek Releases --------- +-----------+-------------+---------------------------------------------------------------------------------+ | **Date** | **Version** | **Expected Features** | +===========+=============+=================================================================================+ | May 14 | 1.0 | autotools, *kbd* and *s390* plugins, LVM cache support, first stable API | +-----------+-------------+---------------------------------------------------------------------------------+ | Aug 1 | 2.0 | *part* and *fs* plugins, progress reporting, new API (so-name bump) | +-----------+-------------+---------------------------------------------------------------------------------+ Tasks ------ * migrate from scons to autotools (vpodzime) * develop the *kbd* (*Kernel Block Devices*) plugin (vpodzime) * develop the *s390* plugin (sbueno) * implement the LVM cache support (vpodzime) * develop the *part* plugin (vpodzime) * develop the *fs* plugin (vpodzime) * design and implement progress reporting (vpodzime) libblockdev-2.16-1/scripts/000077500000000000000000000000001323703006100155425ustar00rootroot00000000000000libblockdev-2.16-1/scripts/Makefile.am000066400000000000000000000001231323703006100175720ustar00rootroot00000000000000dist_noinst_SCRIPTS = boilerplate_generator.py MAINTAINERCLEANFILES = Makefile.in libblockdev-2.16-1/scripts/boilerplate_generator.py000077500000000000000000000277601323703006100225030ustar00rootroot00000000000000#!/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: in_body = False # 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)) 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 = ("{0.rtype} {0.name}_stub ({0.args}) {{\n" + " g_critical (\"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) # then add a variable holding a reference to the dynamically loaded function # (if any) initialized to the stub ret += "{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_funcs_info(fn_infos, module_name): ret = "static const gchar* const {0}_functions[] = {{\n".format(module_name) for info in fn_infos: ret += ' "{0.name}",\n'.format(info) ret += " NULL};\n\n" ret += ("const gchar* const* get_{0}_functions (void) {{\n".format(module_name) + " return {0}_functions;\n".format(module_name) + "}\n\n") ret += "static const guint8 {0}_num_functions = {1};\n\n".format(module_name, len(fn_infos)) ret += ("guint8 get_{0}_num_functions (void) {{\n".format(module_name) + " return {0}_num_functions;\n".format(module_name) + "}\n\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 = '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 (*check_fn) (void) = NULL;\n' ret += ' gboolean (*init_fn) (void) = NULL;\n\n' ret += ' handle = dlopen(so_name, RTLD_LAZY);\n' ret += ' if (!handle) {\n' ret += ' g_warning("failed to load module {0}: %s", dlerror());\n'.format(module_name) ret += ' return NULL;\n' ret += ' }\n\n' ret += ' dlerror();\n' ret += ' * (void**) (&check_fn) = dlsym(handle, "bd_{0}_check_deps");\n'.format(MOD_FNAME_OVERRIDES.get(module_name, module_name)) ret += ' if ((error = dlerror()) != NULL)\n' ret += ' g_debug("failed to load the check() function for {0}: %s", error);\n'.format(module_name) ret += ' if (!g_getenv ("LIBBLOCKDEV_SKIP_DEP_CHECKS") && check_fn && !check_fn()) {\n' ret += ' dlclose(handle);\n' ret += ' return NULL;\n' ret += ' }' ret += ' check_fn = NULL;\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 += ' g_debug("failed to load the init() function for {0}: %s", error);\n'.format(module_name) ret += ' if (init_fn && !init_fn()) {\n' ret += ' dlclose(handle);\n' ret += ' return NULL;\n' ret += ' }' 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 += ' g_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 = '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 += ' g_debug("failed to load the close_plugin() function for {0}: %s", error);\n'.format(module_name) 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)) src_f.write(get_funcs_info(api_fn_infos, mod_name)) 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, exitting.") 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-2.16-1/specs.rst000066400000000000000000000057641323703006100157360ustar00rootroot00000000000000Rationale and specifications of the libblockdev library ======================================================== :Authors: Vratislav Podzimek Scope ------ libblockdev library is a library for doing operations with block devices replacing and extending the code from the blivet.devicelibs (python-blivet) modules as well as udisks2. It supports the following storage technologies: * partitions * filesystem operations * LVM * BTRFS * SWAP * cryptsetup/LUKS * DM (device mapper) * loop devices * MD RAID * multipath * DASD Of course some additional technologies may be supported in the future. 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. Although the architecture described in the previous paragraph may look overly complicated, it brings quite nice advantages: 1. a different implementation of the operations for technologies can be easily used/tested (e.g. LVM plugin using binaries vs. LVM plugin using liblvm), as part of the library initialization, the application may explicitly state it wants to use a particular plugin 2. if some functionality is missing in a plugin, no crash will appear 3. plugins may be used per se without the library (if some application needs to do e.g. LVM-only operations) 4. plugins may be implemented in various languages as long as they provide functions with the right names in a way that those functions can be dynamically loaded 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. The implementation gathers knowledge from the blivet, system-storage-manager (SSM), udisks2 projects. Purpose of the library ----------------------- The library replaces the blivet.devicelibs code as well as udisks2's low-level code and is available for other new projects. libblockdev-2.16-1/src/000077500000000000000000000000001323703006100146425ustar00rootroot00000000000000libblockdev-2.16-1/src/Makefile.am000066400000000000000000000001071323703006100166740ustar00rootroot00000000000000SUBDIRS = utils plugins lib python MAINTAINERCLEANFILES = Makefile.in libblockdev-2.16-1/src/lib/000077500000000000000000000000001323703006100154105ustar00rootroot00000000000000libblockdev-2.16-1/src/lib/Makefile.am000066400000000000000000000040771323703006100174540ustar00rootroot00000000000000-include $(INTROSPECTION_MAKEFILE) SUBDIRS = plugin_apis lib_LTLIBRARIES = libblockdev.la libblockdev_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) libblockdev_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) ${builddir}/../utils/libbd_utils.la -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 2:0:0 -Wl,--no-undefined libblockdev_la_CPPFLAGS = -I${builddir}/../../include/ libblockdev_la_SOURCES = blockdev.c blockdev.h plugins.c plugins.h if HAVE_INTROSPECTION GIHEADERS = ${builddir}/plugin_apis/kbd.h \ ${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 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-2.0.gir: libblockdev.la BlockDev_2_0_gir_FILES = $(GIHEADERS) BlockDev_2_0_gir_LIBS = libblockdev.la BlockDev_2_0_gir_INCLUDES = GObject-2.0 BlockDev_2_0_gir_CFLAGS = -I${builddir}/../../include/ BlockDev_2_0_gir_LDFLAGS = -L${builddir}/../utils/ -lbd_utils BlockDev_2_0_gir_SCANNERFLAGS = --warn-error --warn-all --identifier-prefix=BD --symbol-prefix=bd BlockDev_2_0_gir_EXPORT_PACKAGES = blockdev INTROSPECTION_GIRS = BlockDev-2.0.gir typelibdir = $(libdir)/girepository-1.0 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) CLEANFILES = BlockDev-2.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-2.16-1/src/lib/blockdev.c.in000066400000000000000000000702661323703006100177650ustar00rootroot00000000000000#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/kbd.h" #include "plugin_apis/kbd.c" #include "plugin_apis/part.h" #include "plugin_apis/part.c" #include "plugin_apis/fs.h" #include "plugin_apis/fs.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/conf.d/" static GMutex init_lock; static gboolean initialized = FALSE; static GMutex env_lock; 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_kbd.so."@MAJOR_VER@,"libbd_s390.so."@MAJOR_VER@, "libbd_part.so."@MAJOR_VER@, "libbd_fs.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_KBD, NULL}, NULL}, {{BD_PLUGIN_S390, NULL}, NULL}, {{BD_PLUGIN_PART, NULL}, NULL}, {{BD_PLUGIN_FS, NULL}, NULL}, }; static gchar* plugin_names[BD_PLUGIN_UNDEF] = { "lvm", "btrfs", "swap", "loop", "crypto", "mpath", "dm", "mdraid", "kbd", "s390", "part", "fs" }; 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 __attribute__((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)) { g_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 () { if (plugins[BD_PLUGIN_LVM].handle && !unload_lvm (plugins[BD_PLUGIN_LVM].handle)) g_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)) g_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)) g_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)) g_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)) g_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)) g_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)) g_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)) g_warning ("Failed to close the mdraid plugin"); plugins[BD_PLUGIN_MDRAID].handle = NULL; if (plugins[BD_PLUGIN_KBD].handle && !unload_kbd (plugins[BD_PLUGIN_KBD].handle)) g_warning ("Failed to close the kbd plugin"); plugins[BD_PLUGIN_KBD].handle = NULL; #if defined(__s390__) || defined(__s390x__) if (plugins[BD_PLUGIN_S390].handle && !unload_s390 (plugins[BD_PLUGIN_S390].handle)) g_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)) g_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)) g_warning ("Failed to close the fs plugin"); plugins[BD_PLUGIN_FS].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 (!plugins[BD_PLUGIN_KBD].handle && plugins_sonames[BD_PLUGIN_KBD]) load_plugin_from_sonames (BD_PLUGIN_KBD, load_kbd_from_plugin, &(plugins[BD_PLUGIN_KBD].handle), plugins_sonames[BD_PLUGIN_KBD]); #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]); } 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}; 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)) g_warning ("Failed to load config files: %s. Using the built-in config", error->message); g_sequence_free (config_files); } else g_warning ("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 () { return g_quark_from_static_string ("g-bd-init-error-quark"); } /** * bd_init: * @require_plugins: (allow-none) (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: (allow-none) (scope notified): logging function to use * @error: (out): 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.2"}; * * 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) { g_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: (allow-none) (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: (allow-none) (scope notified): logging function to use * @error: (out): 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: (allow-none) (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: (allow-none) (scope notified): logging function to use * @loaded_plugin_names: (allow-none) (out) (transfer container) (array zero-terminated=1): names * of the successfully loaded plugins * @error: (out): 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) { g_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: (allow-none) (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: (allow-none) (scope notified): logging function to use or %NULL * to keep the old one * @error: (out): 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: (allow-none) (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: (allow-none) (scope notified): logging function to use or %NULL * to keep the old one * @loaded_plugin_names: (allow-none) (out) (transfer container) (array zero-terminated=1): names of the successfully * loaded plugins * @error: (out): 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 () { 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 () { 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]; } /** * bd_switch_init_checks: * @enable: whether to enable init checks (%TRUE) or not (%FALSE) * @error: (out): place to store error (if any) * * Enables or disables plugins' init checks based on @enable. * * Note: The current implementation (un)sets the LIBBLOCKDEV_SKIP_DEP_CHECKS * environment variable. */ gboolean bd_switch_init_checks (gboolean enable, GError **error) { /* getenv/setenv/unsetenv are not thread-safe, better use a lock here */ g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&env_lock); if (!enable && !g_getenv ("LIBBLOCKDEV_SKIP_DEP_CHECKS")) { if (!g_setenv ("LIBBLOCKDEV_SKIP_DEP_CHECKS", "", FALSE)) { g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_FAILED, "Failed to set the LIBBLOCKDEV_SKIP_DEP_CHECKS environment variable"); return FALSE; } return TRUE; } else if (enable && g_getenv ("LIBBLOCKDEV_SKIP_DEP_CHECKS")) { g_unsetenv ("LIBBLOCKDEV_SKIP_DEP_CHECKS"); return TRUE; } else return TRUE; } libblockdev-2.16-1/src/lib/blockdev.h000066400000000000000000000020651323703006100173550ustar00rootroot00000000000000#include #include #ifndef BD_LIB #define BD_LIB #include "plugins.h" /** * bd_init_error_quark: (skip) */ GQuark bd_init_error_quark (); #define BD_INIT_ERROR bd_init_error_quark () typedef enum { BD_INIT_ERROR_PLUGINS_FAILED, BD_INIT_ERROR_NOT_IMPLEMENTED, BD_INIT_ERROR_FAILED, } 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 (); gboolean bd_switch_init_checks (gboolean enable, GError **error); #endif /* BD_LIB */ libblockdev-2.16-1/src/lib/blockdev.pc.in000066400000000000000000000004251323703006100201330ustar00rootroot00000000000000prefix=@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: -lblockdev libblockdev-2.16-1/src/lib/plugin_apis/000077500000000000000000000000001323703006100177225ustar00rootroot00000000000000libblockdev-2.16-1/src/lib/plugin_apis/Makefile.am000066400000000000000000000010571323703006100217610ustar00rootroot00000000000000API_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 ${srcdir}/../../../scripts/boilerplate_generator.py $*.api ./ ${skip_patterns} 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-2.16-1/src/lib/plugin_apis/btrfs.api000066400000000000000000000364471323703006100215530ustar00rootroot00000000000000#include #include #include #define BD_BTRFS_MAIN_VOLUME_ID 5 #define BD_BTRFS_MIN_MEMBER_SIZE (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_DEVICE, BD_BTRFS_ERROR_PARSE, BD_BTRFS_ERROR_TECH_UNAVAIL, } 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) * * Creates a new copy of @info. */ BDBtrfsDeviceInfo* bd_btrfs_device_info_copy (BDBtrfsDeviceInfo *info) { 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) * * Frees @info. */ void bd_btrfs_device_info_free (BDBtrfsDeviceInfo *info) { 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) * * Creates a new copy of @info. */ BDBtrfsSubvolumeInfo* bd_btrfs_subvolume_info_copy (BDBtrfsSubvolumeInfo *info) { 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) * * Frees @info. */ void bd_btrfs_subvolume_info_free (BDBtrfsSubvolumeInfo *info) { 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) * * Creates a new copy of @info. */ BDBtrfsFilesystemInfo* bd_btrfs_filesystem_info_copy (BDBtrfsFilesystemInfo *info) { 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) * * Frees @info. */ void bd_btrfs_filesystem_info_free (BDBtrfsFilesystemInfo *info) { 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): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is avaible -- 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: (allow-none): label for the volume * @data_level: (allow-none): RAID level for the data or %NULL to use the default * @md_level: (allow-none): RAID level for the metadata or %NULL to use the default * @extra: (allow-none) (array zero-terminated=1): extra options for the volume creation (right now * passed to the 'mkfs.btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the addition (right now * passed to the 'btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the removal (right now * passed to the 'btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the subvolume creation (right now * passed to the 'btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the subvolume deletion (right now * passed to the 'btrfs' utility) * @error: (out): 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): 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: (allow-none) (array zero-terminated=1): extra options for the setting (right now * passed to the 'btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the snapshot creation (right now * passed to the 'btrfs' utility) * @error: (out): 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): 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): 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): 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: (allow-none): label for the volume * @data_level: (allow-none): RAID level for the data or %NULL to use the default * @md_level: (allow-none): RAID level for the metadata or %NULL to use the default * @extra: (allow-none) (array zero-terminated=1): extra options for the volume creation (right now * passed to the 'btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the volume resize (right now * passed to the 'btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the check (right now * passed to the 'btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the repair (right now * passed to the 'btrfs' utility) * @error: (out): 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 * @extra: (allow-none) (array zero-terminated=1): extra options for the volume creation (right now * passed to the 'btrfs' utility) * @error: (out): 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, const BDExtraArg **extra, GError **error); libblockdev-2.16-1/src/lib/plugin_apis/crypto.api000066400000000000000000000324331323703006100217420ustar00rootroot00000000000000#include #include #define BD_CRYPTO_LUKS_METADATA_SIZE (2 MiB) 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_DEVICE, BD_CRYPTO_ERROR_STATE, BD_CRYPTO_ERROR_INVALID_SPEC, BD_CRYPTO_ERROR_FORMAT_FAILED, BD_CRYPTO_ERROR_RESIZE_FAILED, 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_TECH_UNAVAIL, } BDCryptoError; typedef enum { BD_CRYPTO_TECH_LUKS = 0, BD_CRYPTO_TECH_TRUECRYPT, BD_CRYPTO_TECH_ESCROW, } 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, } BDCryptoTechMode; /** * bd_crypto_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDCryptoTechMode) for @tech * @error: (out): 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): 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): 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_uuid: * @device: the queried device * @error: (out): place to store error (if any) * * Returns: UUID of the @device 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 */ gchar* bd_crypto_luks_uuid (const gchar *device, GError **error); /** * bd_crypto_luks_status: * @luks_device: the queried LUKS device * @error: (out): 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 */ gchar* bd_crypto_luks_status (const gchar *luks_device, GError **error); /** * bd_crypto_luks_format: * @device: a device to format as LUKS * @cipher: (allow-none): 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 * @passphrase: (allow-none): a passphrase for the new LUKS device or %NULL if not requested * @key_file: (allow-none): a key file for the new LUKS device or %NULL if not requested * @min_entropy: minimum random data entropy (in bits) required to format @device as LUKS * @error: (out): 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). * * 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, const gchar *passphrase, const gchar *key_file, guint64 min_entropy, GError **error); /** * bd_crypto_luks_format_blob: * @device: a device to format as LUKS * @cipher: (allow-none): 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 * @pass_data: (array length=data_len): a passphrase for the new LUKS device (may contain arbitrary binary data) * @data_len: length of the @pass_data buffer * @min_entropy: minimum random data entropy (in bits) required to format @device as LUKS * @error: (out): 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). * * 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_blob (const gchar *device, const gchar *cipher, guint64 key_size, const guint8 *pass_data, gsize data_len, guint64 min_entropy, GError **error); /** * bd_crypto_luks_open: * @device: the device to open * @name: name for the LUKS device * @passphrase: (allow-none): passphrase to open the @device or %NULL * @key_file: (allow-none): key file path to use for opening the @device or %NULL * @read_only: whether to open as read-only or not (meaning read-write) * @error: (out): place to store error (if any) * * Returns: whether the @device was successfully opened or not * * One of @passphrase, @key_file has to be != %NULL. * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE */ gboolean bd_crypto_luks_open (const gchar *device, const gchar *name, const gchar *passphrase, const gchar *key_file, gboolean read_only, GError **error); /** * bd_crypto_luks_open_blob: * @device: the device to open * @name: name for the LUKS device * @pass_data: (array length=data_len): a passphrase for the new LUKS device (may contain arbitrary binary data) * @data_len: length of the @pass_data buffer * @read_only: whether to open as read-only or not (meaning read-write) * @error: (out): place to store error (if any) * * Returns: whether the @device was successfully opened or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE */ gboolean bd_crypto_luks_open_blob (const gchar *device, const gchar *name, const guint8* pass_data, gsize data_len, gboolean read_only, GError **error); /** * bd_crypto_luks_close: * @luks_device: LUKS device to close * @error: (out): 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 * @pass: (allow-none): passphrase for the @device or %NULL * @key_file: (allow-none): key file for the @device or %NULL * @npass: (allow-none): passphrase to add to @device or %NULL * @nkey_file: (allow-none): key file to add to @device or %NULL * @error: (out): place to store error (if any) * * Returns: whether the @npass or @nkey_file was successfully added to @device * or not * * One of @pass, @key_file has to be != %NULL and the same applies to @npass, * @nkey_file. * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_ADD_KEY */ gboolean bd_crypto_luks_add_key (const gchar *device, const gchar *pass, const gchar *key_file, const gchar *npass, const gchar *nkey_file, GError **error); /** * bd_crypto_luks_add_key_blob: * @device: device to add new key to * @pass_data: (array length=data_len): a passphrase for the new LUKS device (may contain arbitrary binary data) * @data_len: length of the @pass_data buffer * @npass_data: (array length=ndata_len): a new passphrase for the new LUKS device (may contain arbitrary binary data) * @ndata_len: length of the @npass_data buffer * @error: (out): place to store error (if any) * * Returns: whether the @npass_data 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_blob (const gchar *device, const guint8 *pass_data, gsize data_len, const guint8 *npass_data, gsize ndata_len, GError **error); /** * bd_crypto_luks_remove_key: * @device: device to add new key to * @pass: (allow-none): passphrase for the @device or %NULL * @key_file: (allow-none): key file for the @device or %NULL * @error: (out): place to store error (if any) * * Returns: whether the key was successfully removed or not * * Either @pass or @key_file has to be != %NULL. * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_REMOVE_KEY */ gboolean bd_crypto_luks_remove_key (const gchar *device, const gchar *pass, const gchar *key_file, GError **error); /** * bd_crypto_luks_remove_key_blob: * @device: device to add new key to * @pass_data: (array length=data_len): a passphrase for the new LUKS device (may contain arbitrary binary data) to remove * @data_len: length of the @pass_data buffer * @error: (out): place to store error (if any) * * Returns: whether the key was successfully removed or not * * Either @pass or @key_file has to be != %NULL. * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_REMOVE_KEY */ gboolean bd_crypto_luks_remove_key_blob (const gchar *device, const guint8 *pass_data, gsize data_len, GError **error); /** * bd_crypto_luks_change_key: * @device: device to change key of * @pass: old passphrase * @npass: new passphrase * @error: (out): place to store error (if any) * * Returns: whether the key was successfully changed or not * * No support for changing key files (yet). * * 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, const gchar *pass, const gchar *npass, GError **error); /** * bd_crypto_luks_change_key_blob: * @device: device to change key of * @pass_data: (array length=data_len): a passphrase for the new LUKS device (may contain arbitrary binary data) * @data_len: length of the @pass_data buffer * @npass_data: (array length=ndata_len): a new passphrase for the new LUKS device (may contain arbitrary binary data) * @ndata_len: length of the @npass_data buffer * @error: (out): place to store error (if any) * * 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_blob (const gchar *device, const guint8 *pass_data, gsize data_len, const guint8 *npass_data, gsize ndata_len, 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 * @error: (out): place to store error (if any) * * Returns: whether the @luks_device was successfully resized or not * * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_RESIZE */ gboolean bd_crypto_luks_resize (const gchar *luks_device, guint64 size, GError **error); /** * bd_crypto_tc_open: * @device: the device to open * @name: name for the TrueCrypt/VeraCrypt device * @pass_data: (array length=data_len): a passphrase for the TrueCrypt/VeraCrypt volume (may contain arbitrary binary data) * @data_len: length of the @pass_data buffer * @read_only: whether to open as read-only or not (meaning read-write) * @error: (out): place to store error (if any) * * 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, const guint8* pass_data, gsize data_len, gboolean read_only, GError **error); /** * bd_crypto_tc_close: * @tc_device: TrueCrypt/VeraCrypt device to close * @error: (out): 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: (allow-none): backup passphrase for the device or %NULL * @error: (out): place to store error (if any) * * Returns: whether the ecrow 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); libblockdev-2.16-1/src/lib/plugin_apis/dm.api000066400000000000000000000122541323703006100210210ustar00rootroot00000000000000#include #include 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_SYS, BD_DM_ERROR_NOT_ROOT, BD_DM_ERROR_TASK, BD_DM_ERROR_RAID_FAIL, BD_DM_ERROR_RAID_NO_DEVS, BD_DM_ERROR_TECH_UNAVAIL, } BDDMError; typedef enum { BD_DM_TECH_MAP = 0, BD_DM_TECH_RAID, } 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): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is avaible -- 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: (allow-none): UUID for the new dev mapper device or %NULL if not specified * @error: (out): 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): 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): 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): 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): place to store error (if any) * * Returns: subsystem of the given device * * Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_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): 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); /** * bd_dm_get_member_raid_sets: * @name: (allow-none): name of the member * @uuid: (allow-none): uuid of the member * @major: major number of the device or -1 if not specified * @minor: minor number of the device or -1 if not specified * @error: (out): variable to store error (if any) * * Returns: (transfer full) (array zero-terminated=1): list of names of the RAID sets related to * the member or %NULL in case of error * * One of @name, @uuid or @major:@minor has to be given. * * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_MODE_QUERY */ gchar** bd_dm_get_member_raid_sets (const gchar *name, const gchar *uuid, gint major, gint minor, GError **error); /** * bd_dm_activate_raid_set: * @name: name of the DM RAID set to activate * @error: (out): variable to store error (if any) * * Returns: whether the RAID set @name was successfully activate or not * * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_CREATE_ACTIVATE */ gboolean bd_dm_activate_raid_set (const gchar *name, GError **error); /** * bd_dm_deactivate_raid_set: * @name: name of the DM RAID set to deactivate * @error: (out): variable to store error (if any) * * Returns: whether the RAID set @name was successfully deactivate or not * * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_REMOVE_DEACTIVATE */ gboolean bd_dm_deactivate_raid_set (const gchar *name, GError **error); /** * bd_dm_get_raid_set_type: * @name: name of the DM RAID set to get the type of * @error: (out): variable to store error (if any) * * Returns: string representation of the @name RAID set's type * * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_QUERY */ gchar* bd_dm_get_raid_set_type (const gchar *name, GError **error); libblockdev-2.16-1/src/lib/plugin_apis/fs.api000066400000000000000000001144531323703006100210350ustar00rootroot00000000000000#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_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_TECH_UNAVAIL, } BDFsError; #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) * * Creates a new copy of @data. */ BDFSExt2Info* bd_fs_ext2_info_copy (BDFSExt2Info *data) { 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) * * 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) * * 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) * * Frees @data. */ void bd_fs_ext2_info_free (BDFSExt2Info *data) { g_free (data->label); g_free (data->uuid); g_free (data->state); g_free (data); } /** * bd_fs_ext3_info_free: (skip) * * Frees @data. */ void bd_fs_ext3_info_free (BDFSExt3Info *data) { bd_fs_ext2_info_free ((BDFSExt2Info*) data); } /** * bd_fs_ext4_info_free: (skip) * * 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) * * Creates a new copy of @data. */ BDFSXfsInfo* bd_fs_xfs_info_copy (BDFSXfsInfo *data) { 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) * * Frees @data. */ void bd_fs_xfs_info_free (BDFSXfsInfo *data) { 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) * * Creates a new copy of @data. */ BDFSVfatInfo* bd_fs_vfat_info_copy (BDFSVfatInfo *data) { 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) * * Frees @data. */ void bd_fs_vfat_info_free (BDFSVfatInfo *data) { 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: * @size: size of the filesystem in bytes * @free_space: number of free space in the filesystem in bytes */ typedef struct BDFSNtfsInfo { guint64 size; guint64 free_space; } BDFSNtfsInfo; /** * bd_fs_ntfs_info_copy: (skip) * * Creates a new copy of @data. */ BDFSNtfsInfo* bd_fs_ntfs_info_copy (BDFSNtfsInfo *data) { BDFSNtfsInfo *ret = g_new0 (BDFSNtfsInfo, 1); ret->size = data->size; ret->free_space = data->free_space; return ret; } /** * bd_fs_ntfs_info_free: (skip) * * Frees @data. */ void bd_fs_ntfs_info_free (BDFSNtfsInfo *data) { 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; } 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 } 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, } BDFSTechMode; /** * bd_fs_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDFSTechMode) for @tech * @error: (out): 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_wipe: * @device: the device to wipe signatures from * @all: whether to wipe all (%TRUE) signatures or just the first (%FALSE) one * @error: (out): 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, GError **error); /** * bd_fs_clean: * @device: the device to clean * @error: (out): 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, GError **error); /** * bd_fs_get_fstype: * @device: the device to probe * @error: (out): 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_unmount: * @spec: mount point or device to unmount * @lazy: enable/disable lazy unmount * @force: enable/disable force unmount * @extra: (allow-none) (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) * @error: (out): 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: (allow-none): device to mount, if not specified @mountpoint entry * from fstab will be used * @mountpoint: (allow-none): mountpoint for @device, if not specified @device * entry from fstab will be used * @fstype: (allow-none): filesystem type * @options: (allow-none): comma delimited options for mount * @extra: (allow-none) (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) * @error: (out): 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): 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_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): place to store error (if any) * * 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, GError **error); /** * bd_fs_repair: * @device: the device the file system of which to repair * @error: (out): 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. * * 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, GError **error); /** * bd_fs_check: * @device: the device the file system of which to check * @error: (out): place to store error (if any) * * Check filesystem on @device. 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. * * 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, GError **error); /** * bd_fs_set_label: * @device: the device with file system to set the label for * @error: (out): 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. * * Returns: whether the file system on @device was successfully relabled 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, 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): 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): 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): 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): 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_ext2_mkfs: * @device: the device to create a new ext2 fs on * @extra: (allow-none) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mke2fs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mke2fs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkfs.ext4' utility) * @error: (out): 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_wipe: * @device: the device to wipe an ext2 signature from * @error: (out): place to store error (if any) * * Returns: whether an ext2 signature was successfully wiped from the @device or * not * * Tech category: %BD_FS_TECH_EXT2-%BD_FS_TECH_MODE_WIPE */ gboolean bd_fs_ext2_wipe (const gchar *device, GError **error); /** * bd_fs_ext3_wipe: * @device: the device to wipe an ext3 signature from * @error: (out): place to store error (if any) * * Returns: whether an ext3 signature was successfully wiped from the @device or * not * * Tech category: %BD_FS_TECH_EXT3-%BD_FS_TECH_MODE_WIPE */ gboolean bd_fs_ext3_wipe (const gchar *device, GError **error); /** * bd_fs_ext4_wipe: * @device: the device to wipe an ext4 signature from * @error: (out): place to store error (if any) * * Returns: whether an ext4 signature was successfully wiped from the @device or * not * * Tech category: %BD_FS_TECH_EXT4-%BD_FS_TECH_MODE_WIPE */ gboolean bd_fs_ext4_wipe (const gchar *device, GError **error); /** * bd_fs_ext2_check: * @device: the device the file system on which to check * @extra: (allow-none) (array zero-terminated=1): extra options for the check (right now * passed to the 'e2fsck' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the check (right now * passed to the 'e2fsck' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the check (right now * passed to the 'e2fsck' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the repair (right now * passed to the 'e2fsck' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the repair (right now * passed to the 'e2fsck' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the repair (right now * passed to the 'e2fsck' utility) * @error: (out): 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): 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): 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): 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_get_info: * @device: the device the file system of which to get info for * @error: (out): 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): 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): 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: (allow-none) (array zero-terminated=1): extra options for the resize (right now * passed to the 'resize2fs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the resize (right now * passed to the 'resize2fs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the resize (right now * passed to the 'resize2fs' utility) * @error: (out): 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_xfs_mkfs: * @device: the device to create a new xfs fs on * @extra: (allow-none) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkfs.xfs' utility) * @error: (out): 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_wipe: * @device: the device to wipe an xfs signature from * @error: (out): place to store error (if any) * * Returns: whether an xfs signature was successfully wiped from the @device or * not * * Tech category: %BD_FS_TECH_XFS-%BD_FS_TECH_MODE_WIPE */ gboolean bd_fs_xfs_wipe (const gchar *device, GError **error); /** * bd_fs_xfs_check: * @device: the device containing the file system to check * @error: (out): 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 it may be reported as unclean even if * everything is okay and there are just some pending/in-progress writes * * Tech category: %BD_FS_TECH_XFS-%BD_FS_TECH_MODE_CHECK */ gboolean bd_fs_xfs_check (const gchar *device, GError **error); /** * bd_fs_xfs_repair: * @device: the device containing the file system to repair * @extra: (allow-none) (array zero-terminated=1): extra options for the repair (right now * passed to the 'xfs_repair' utility) * @error: (out): 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): 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_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): 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: (allow-none) (array zero-terminated=1): extra options for the resize (right now * passed to the 'xfs_growfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkfs.vfat' utility) * @error: (out): place to store error (if any) * * 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_wipe: * @device: the device to wipe an vfat signature from * @error: (out): place to store error (if any) * * Returns: whether an vfat signature was successfully wiped from the @device or * not * * Tech category: %BD_FS_TECH_VFAT-%BD_FS_TECH_MODE_WIPE */ gboolean bd_fs_vfat_wipe (const gchar *device, GError **error); /** * bd_fs_vfat_check: * @device: the device containing the file system to check * @extra: (allow-none) (array zero-terminated=1): extra options for the repair (right now * passed to the 'fsck.vfat' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the repair (right now * passed to the 'fsck.vfat' utility) * @error: (out): 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): 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_get_info: * @device: the device containing the file system to get info for * @error: (out): 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): 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: (allow-none) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkntfs' utility) * @error: (out): 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_wipe: * @device: the device to wipe an ntfs signature from * @error: (out): place to store error (if any) * * Returns: whether an ntfs signature was successfully wiped from the @device or not * * Tech category: %BD_FS_TECH_NTFS-%BD_FS_TECH_MODE_WIPE */ gboolean bd_fs_ntfs_wipe (const gchar *device, GError **error); /** * bd_fs_ntfs_check: * @device: the device containing the file system to check * @error: (out): 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, GError **error); /** * bd_fs_ntfs_repair: * @device: the device containing the file system to repair * @error: (out): 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, 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): 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_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): 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): 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); #endif /* BD_FS_API */ libblockdev-2.16-1/src/lib/plugin_apis/kbd.api000066400000000000000000000304711323703006100211620ustar00rootroot00000000000000#include #include #include #ifndef BD_KBD_API #define BD_KBD_API GQuark bd_kbd_error_quark (void) { return g_quark_from_static_string ("g-bd-kbd-error-quark"); } #define BD_KBD_ERROR bd_kbd_error_quark () typedef enum { BD_KBD_ERROR_INVAL, BD_KBD_ERROR_KMOD_INIT_FAIL, BD_KBD_ERROR_MODULE_FAIL, BD_KBD_ERROR_MODULE_NOEXIST, BD_KBD_ERROR_ZRAM_NOEXIST, BD_KBD_ERROR_ZRAM_INVAL, BD_KBD_ERROR_BCACHE_PARSE, BD_KBD_ERROR_BCACHE_SETUP_FAIL, BD_KBD_ERROR_BCACHE_DETACH_FAIL, BD_KBD_ERROR_BCACHE_NOT_ATTACHED, BD_KBD_ERROR_BCACHE_UUID, BD_KBD_ERROR_BCACHE_MODE_FAIL, BD_KBD_ERROR_BCACHE_MODE_INVAL, BD_KBD_ERROR_BCACHE_NOEXIST, BD_KBD_ERROR_BCACHE_INVAL, BD_KBD_ERROR_TECH_UNAVAIL, } BDKBDError; typedef enum { BD_KBD_MODE_WRITETHROUGH, BD_KBD_MODE_WRITEBACK, BD_KBD_MODE_WRITEAROUND, BD_KBD_MODE_NONE, BD_KBD_MODE_UNKNOWN, } BDKBDBcacheMode; #define BD_KBD_TYPE_ZRAM_STATS (bd_kbd_zram_stats_get_type ()) GType bd_kbd_zram_stats_get_type(); /** * BDKBDZramStats: * * see zRAM kernel documentation for details * (https://www.kernel.org/doc/Documentation/blockdev/zram.txt) */ typedef struct BDKBDZramStats { guint64 disksize; guint64 num_reads; guint64 num_writes; guint64 invalid_io; guint64 zero_pages; guint64 max_comp_streams; gchar* comp_algorithm; guint64 orig_data_size; guint64 compr_data_size; guint64 mem_used_total; } BDKBDZramStats; /** * bd_kbd_zram_stats_copy: (skip) * * Creates a new copy of @data. */ BDKBDZramStats* bd_kbd_zram_stats_copy (BDKBDZramStats *data) { BDKBDZramStats *new = g_new0 (BDKBDZramStats, 1); new->disksize = data->disksize; new->num_reads = data->num_reads; new->num_writes = data->num_writes; new->invalid_io = data->invalid_io; new->zero_pages = data->zero_pages; new->max_comp_streams = data->max_comp_streams; new->comp_algorithm = g_strdup (data->comp_algorithm); new->orig_data_size = data->orig_data_size; new->compr_data_size = data->compr_data_size; new->mem_used_total = data->mem_used_total; return new; } /** * bd_kbd_zram_stats_free: (skip) * * Frees @data. */ void bd_kbd_zram_stats_free (BDKBDZramStats *data) { g_free (data->comp_algorithm); g_free (data); } GType bd_kbd_zram_stats_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDKBDZramStats", (GBoxedCopyFunc) bd_kbd_zram_stats_copy, (GBoxedFreeFunc) bd_kbd_zram_stats_free); } return type; } #define BD_KBD_TYPE_BCACHE_STATS (bd_kbd_bcache_stats_get_type ()) GType bd_kbd_bcache_stats_get_type(); /** * BDKBDBcacheStats: * @state: state of the cache * @block_size: block size used by the cache * @cache_size: size of the cache * @cache_used: size of the used space in the cache * @hits: number of hits * @misses: number of misses * @bypass_hits: number of bypass hits * @bypass_misses: number of bypass misses */ typedef struct BDKBDBcacheStats { gchar *state; guint64 block_size; guint64 cache_size; guint64 cache_used; guint64 hits; guint64 misses; guint64 bypass_hits; guint64 bypass_misses; } BDKBDBcacheStats; /** * bd_kbd_bcache_stats_copy: (skip) * * Creates a new copy of @data. */ BDKBDBcacheStats* bd_kbd_bcache_stats_copy (BDKBDBcacheStats *data) { BDKBDBcacheStats *new = g_new0 (BDKBDBcacheStats, 1); new->state = g_strdup (data->state); new->block_size = data->block_size; new->cache_size = data->cache_size; new->cache_used = data->cache_used; new->hits = data->hits; new->misses = data->misses; new->bypass_hits = data->bypass_hits; new->bypass_misses = data->bypass_misses; return new; } /** * bd_kbd_bcache_stats_free: (skip) * * Frees @data. */ void bd_kbd_bcache_stats_free (BDKBDBcacheStats *data) { g_free (data->state); g_free (data); } GType bd_kbd_bcache_stats_get_type () { static GType type = 0; if (G_UNLIKELY(type == 0)) { type = g_boxed_type_register_static("BDKBDBcacheStats", (GBoxedCopyFunc) bd_kbd_bcache_stats_copy, (GBoxedFreeFunc) bd_kbd_bcache_stats_free); } return type; } typedef enum { BD_KBD_TECH_ZRAM = 0, BD_KBD_TECH_BCACHE, } BDKBDTech; typedef enum { BD_KBD_TECH_MODE_CREATE = 1 << 0, BD_KBD_TECH_MODE_DESTROY = 1 << 1, BD_KBD_TECH_MODE_MODIFY = 1 << 2, BD_KBD_TECH_MODE_QUERY = 1 << 3, } BDKBDTechMode; /** * bd_kbd_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDKBDTechMode) for @tech * @error: (out): 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_kbd_is_tech_avail (BDKBDTech tech, guint64 mode, GError **error); /** * bd_kbd_zram_create_devices: * @num_devices: number of devices to create * @sizes: (array zero-terminated=1): requested sizes (in bytes) for created zRAM * devices * @nstreams: (allow-none) (array zero-terminated=1): numbers of streams for created * zRAM devices * @error: (out): place to store error (if any) * * Returns: whether @num_devices zRAM devices were successfully created or not * * **Lengths of @size and @nstreams (if given) have to be >= @num_devices!** * * Tech category: %BD_KBD_TECH_ZRAM-%BD_KBD_TECH_MODE_CREATE */ gboolean bd_kbd_zram_create_devices (guint64 num_devices, const guint64 *sizes, const guint64 *nstreams, GError **error); /** * bd_kbd_zram_destroy_devices: * @error: (out): place to store error (if any) * * Returns: whether zRAM devices were successfully destroyed or not * * The only way how to destroy zRAM device right now is to unload the 'zram' * module and thus destroy all of them. That's why this function doesn't allow * specification of which devices should be destroyed. * * Tech category: %BD_KBD_TECH_ZRAM-%BD_KBD_TECH_MODE_DESTROY */ gboolean bd_kbd_zram_destroy_devices (GError **error); /** * bd_kbd_zram_add_device: * @size: size of the zRAM device to add * @nstreams: number of streams to use for the new device (or 0 to use the defaults) * @device: (allow-none) (out): place to store the name of the newly added device * @error: (out): place to store error (if any) * * Returns: whether a new zRAM device was added or not * * Tech category: %BD_KBD_TECH_ZRAM-%BD_KBD_TECH_MODE_MODIFY */ gboolean bd_kbd_zram_add_device (guint64 size, guint64 nstreams, gchar **device, GError **error); /** * bd_kbd_zram_remove_device: * @device: zRAM device to remove * @error: (out): place to store error (if any) * * Returns: whether the @device was successfully removed or not * * Tech category: %BD_KBD_TECH_ZRAM-%BD_KBD_TECH_MODE_MODIFY */ gboolean bd_kbd_zram_remove_device (const gchar *device, GError **error); /** * bd_kbd_zram_get_stats: * @device: zRAM device to get stats for * @error: (out): place to store error (if any) * * Returns: (transfer full): statistics for the zRAM device * * Tech category: %BD_KBD_TECH_ZRAM-%BD_KBD_TECH_MODE_QUERY */ BDKBDZramStats* bd_kbd_zram_get_stats (const gchar *device, GError **error); /** * bd_kbd_bcache_create: * @backing_device: backing (slow) device of the cache * @cache_device: cache (fast) device of the cache * @extra: (allow-none) (array zero-terminated=1): extra options for the creation (right now * passed to the 'make-bcache' utility) * @bcache_device: (out) (allow-none) (transfer full): place to store the name of the new bcache device (if any) * @error: (out): place to store error (if any) * * Returns: whether the bcache device was successfully created or not * * Tech category: %BD_KBD_TECH_BCACHE-%BD_KBD_TECH_MODE_CREATE */ gboolean bd_kbd_bcache_create (const gchar *backing_device, const gchar *cache_device, const BDExtraArg **extra, const gchar **bcache_device, GError **error); /** * bd_kbd_bcache_attach: * @c_set_uuid: cache set UUID of the cache to attach * @bcache_device: bcache device to attach @c_set_uuid cache to * @error: (out): place to store error (if any) * * Returns: whether the @c_set_uuid cache was successfully attached to @bcache_device or not * * Tech category: %BD_KBD_TECH_BCACHE-%BD_KBD_TECH_MODE_MODIFY */ gboolean bd_kbd_bcache_attach (const gchar *c_set_uuid, const gchar *bcache_device, GError **error); /** * bd_kbd_bcache_detach: * @bcache_device: bcache device to detach the cache from * @c_set_uuid: (out) (allow-none) (transfer full): cache set UUID of the detached cache * @error: (out): place to store error (if any) * Returns: whether the bcache device @bcache_device was successfully destroyed or not * * Note: Flushes the cache first. * * Tech category: %BD_KBD_TECH_BCACHE-%BD_KBD_TECH_MODE_MODIFY */ gboolean bd_kbd_bcache_detach (const gchar *bcache_device, gchar **c_set_uuid, GError **error); /** * bd_kbd_bcache_destroy: * @bcache_device: bcache device to destroy * @error: (out): place to store error (if any) * * Returns: whether the bcache device @bcache_device was successfully destroyed or not * * Tech category: %BD_KBD_TECH_BCACHE-%BD_KBD_TECH_MODE_DESTROY */ gboolean bd_kbd_bcache_destroy (const gchar *bcache_device, GError **error); /** * bd_kbd_bcache_get_mode: * @bcache_device: device to get mode of * @error: (out): place to store error (if any) * * Returns: current mode of the @bcache_device * * Tech category: %BD_KBD_TECH_BCACHE-%BD_KBD_TECH_MODE_QUERY */ BDKBDBcacheMode bd_kbd_bcache_get_mode (const gchar *bcache_device, GError **error); /** * bd_kbd_bcache_get_mode_str: * @mode: mode to get string representation of * @error: (out): place to store error (if any) * * Returns: (transfer none): string representation of @mode or %NULL in case of error * * Tech category: always available */ const gchar* bd_kbd_bcache_get_mode_str (BDKBDBcacheMode mode, GError **error); /** * bd_kbd_bcache_get_mode_from_str: * @mode_str: string representation of mode * @error: (out): place to store error (if any) * * Returns: mode matching the @mode_str given or %BD_KBD_MODE_UNKNOWN in case of no match */ BDKBDBcacheMode bd_kbd_bcache_get_mode_from_str (const gchar *mode_str, GError **error); /** * bd_kbd_bcache_set_mode: * @bcache_device: bcache device to set mode of * @mode: mode to set * @error: (out): place to store error (if any) * * Returns: whether the mode was successfully set or not * * Tech category: %BD_KBD_TECH_BCACHE-%BD_KBD_TECH_MODE_MODIFY */ gboolean bd_kbd_bcache_set_mode (const gchar *bcache_device, BDKBDBcacheMode mode, GError **error); /** * bd_kbd_bcache_status: * @bcache_device: bcache device to get status for * @error: (out): place to store error (if any) * * Returns: (transfer full): status of the @bcache_device or %NULL in case of * error (@error is set) * * Tech category: %BD_KBD_TECH_BCACHE-%BD_KBD_TECH_MODE_QUERY */ BDKBDBcacheStats* bd_kbd_bcache_status (const gchar *bcache_device, GError **error); /** * bd_kbd_bcache_get_backing_device: * @bcache_device: Bcache device to get the backing device for * @error: (out): place to store error (if any) * * Returns: (transfer full): name of the backing device of the @bcache_device * or %NULL if failed to determine (@error is populated) * * Tech category: %BD_KBD_TECH_BCACHE-%BD_KBD_TECH_MODE_QUERY */ gchar* bd_kbd_bcache_get_backing_device (const gchar *bcache_device, GError **error); /** * bd_kbd_bcache_get_cache_device: * @bcache_device: Bcache device to get the cache device for * @error: (out): place to store error (if any) * * Returns: (transfer full): name of the cache device of the @bcache_device * or %NULL if failed to determine (@error is populated) * * Note: returns the name of the first cache device of @bcache_device (in case * there are more) * * Tech category: %BD_KBD_TECH_BCACHE-%BD_KBD_TECH_MODE_QUERY */ gchar* bd_kbd_bcache_get_cache_device (const gchar *bcache_device, GError **error); #endif /* BD_KBD_API */ libblockdev-2.16-1/src/lib/plugin_apis/loop.api000066400000000000000000000107631323703006100213750ustar00rootroot00000000000000#include #include 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_DEVICE, BD_LOOP_ERROR_FAIL, BD_LOOP_ERROR_TECH_UNAVAIL, } 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): 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); /** * bd_loop_get_backing_file: * @dev_name: name of the loop device to get backing file for (e.g. "loop0") * @error: (out): place to store error (if any) * * Returns: (transfer full): path of the device's backing file or %NULL if none * is found * * Tech category: %BD_LOOP_TECH_LOOP-%BD_LOOP_TECH_MODE_QUERY */ gchar* bd_loop_get_backing_file (const gchar *dev_name, GError **error); /** * bd_loop_get_loop_name: * @file: path of the backing file to get loop name for * @error: (out): 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 * @loop_name: (allow-none) (out): if not %NULL, it is used to store the name of the loop device * @error: (out): 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, 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 * @loop_name: (allow-none) (out): if not %NULL, it is used to store the name of the loop device * @error: (out): 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, const gchar **loop_name, GError **error); /** * bd_loop_teardown: * @loop: path or name of the loop device to tear down * @error: (out): 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_get_autoclear: * @loop: path or name of the loop device * @error: (out): place to store error (if any) * * Returns: whether the autoclear flag is set on the @loop device or not (if %FALSE, @error may be set) * * Tech category: %BD_LOOP_TECH_LOOP-%BD_LOOP_TECH_MODE_QUERY */ gboolean bd_loop_get_autoclear (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): 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); libblockdev-2.16-1/src/lib/plugin_apis/lvm.api000066400000000000000000001255001323703006100212160ustar00rootroot00000000000000#include #include #include #ifndef BD_LVM_API #define BD_LVM_API #ifdef __LP64__ // 64bit system #define BD_LVM_MAX_LV_SIZE (8 EiB) #else // 32bit system #define BD_LVM_MAX_LV_SIZE (16 TiB) #endif #define BD_LVM_DEFAULT_PE_START (1 MiB) #define BD_LVM_DEFAULT_PE_SIZE (4 MiB) #define BD_LVM_MIN_PE_SIZE (1 KiB) #define BD_LVM_MAX_PE_SIZE (16 GiB) #define BD_LVM_MIN_THPOOL_MD_SIZE (2 MiB) #define BD_LVM_MAX_THPOOL_MD_SIZE (16 GiB) #define BD_LVM_MIN_THPOOL_CHUNK_SIZE (64 KiB) #define BD_LVM_MAX_THPOOL_CHUNK_SIZE (1 GiB) #define BD_LVM_DEFAULT_CHUNK_SIZE (64 KiB) /* according to lvmcache (7) */ #define BD_LVM_MIN_CACHE_MD_SIZE (8 MiB) 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_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_TECH_UNAVAIL, } 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_WRITETHROUGH, BD_LVM_CACHE_MODE_WRITEBACK, BD_LVM_CACHE_MODE_UNKNOWN, } BDLVMCacheMode; #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 */ 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; } BDLVMPVdata; /** * bd_lvm_pvdata_copy: (skip) * * Creates a new copy of @data. */ BDLVMPVdata* bd_lvm_pvdata_copy (BDLVMPVdata *data) { 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_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; return new_data; } /** * bd_lvm_pvdata_free: (skip) * * Frees @data. */ void bd_lvm_pvdata_free (BDLVMPVdata *data) { g_free (data->pv_name); g_free (data->pv_uuid); g_free (data->vg_name); 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 */ typedef struct BDLVMVGdata { gchar *name; gchar *uuid; guint64 size; guint64 free; guint64 extent_size; guint64 extent_count; guint64 free_count; guint64 pv_count; } BDLVMVGdata; /** * bd_lvm_vgdata_copy: (skip) * * Creates a new copy of @data. */ BDLVMVGdata* bd_lvm_vgdata_copy (BDLVMVGdata *data) { 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; return new_data; } /** * bd_lvm_vgdata_free: (skip) * * Frees @data. */ void bd_lvm_vgdata_free (BDLVMVGdata *data) { g_free (data->name); g_free (data->uuid); 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_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) */ 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; } BDLVMLVdata; /** * bd_lvm_lvdata_copy: (skip) * * Creates a new copy of @data. */ BDLVMLVdata* bd_lvm_lvdata_copy (BDLVMLVdata *data) { 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; return new_data; } /** * bd_lvm_lvdata_free: (skip) * * Frees @data. */ void bd_lvm_lvdata_free (BDLVMLVdata *data) { 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_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_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) * * Creates a new copy of @data. */ BDLVMCacheStats* bd_lvm_cache_stats_copy (BDLVMCacheStats *data) { 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) * * 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, } 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): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is avaible -- 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): 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): place to store error (if any) * * Returns: (transfer full) (array zero-terminated=1): 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): 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): 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): 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): 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 (%BD_LVM_DEFAULT_CHUNK_SIZE) * @n_snapshots: number of snapshots that will be created in the pool * @error: (out): place to store error (if any) * * Returns: recommended size of the metadata space for the specified pool or 0 * in case of error * * 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): 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): 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: (allow-none) (array zero-terminated=1): extra options for the PV creation * (just passed to LVM as is) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the PV resize * (just passed to LVM as is) * @error: (out): 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 underlaying * 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: (allow-none) (array zero-terminated=1): extra options for the PV removal * (just passed to LVM as is) * @error: (out): 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: (allow-none): the PV device to move extents onto or %NULL * @extra: (allow-none) (array zero-terminated=1): extra options for the PV move * (just passed to LVM as is) * @error: (out): 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: (allow-none): the device to scan for PVs or %NULL * @update_cache: whether to update the lvmetad cache or not * @extra: (allow-none) (array zero-terminated=1): extra options for the PV scan * (just passed to LVM as is) * @error: (out): 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_pvinfo: * @device: a PV to get information about or %NULL * @error: (out): 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): 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: (allow-none) (array zero-terminated=1): extra options for the VG creation * (just passed to LVM as is) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the VG removal * (just passed to LVM as is) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the VG rename * (just passed to LVM as is) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the VG activation * (just passed to LVM as is) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the VG deactivation * (just passed to LVM as is) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the VG extension * (just passed to LVM as is) * @error: (out): 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: (allow-none): PV device the @vg_name VG should be reduced of or %NULL * if the VG should be reduced of the missing PVs * @extra: (allow-none) (array zero-terminated=1): extra options for the VG reduction * (just passed to LVM as is) * @error: (out): 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_vginfo: * @vg_name: a VG to get information about * @error: (out): 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): 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): 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: (allow-none): type of the new LV ("striped", "raid1",..., see lvcreate (8)) * @pv_list: (allow-none) (array zero-terminated=1): list of PVs the newly created LV should use or %NULL * if not specified * @extra: (allow-none) (array zero-terminated=1): extra options for the LV creation * (just passed to LVM as is) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the LV removal * (just passed to LVM as is) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the LV rename * (just passed to LVM as is) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the LV resize * (just passed to LVM as is) * @error: (out): 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_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 * @extra: (allow-none) (array zero-terminated=1): extra options for the LV activation * (just passed to LVM as is) * @error: (out): 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, 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: (allow-none) (array zero-terminated=1): extra options for the LV deactivation * (just passed to LVM as is) * @error: (out): 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 fo the to-be-created snapshot * @size: requested size for the snapshot * @extra: (allow-none) (array zero-terminated=1): extra options for the LV snapshot creation * (just passed to LVM as is) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the LV snapshot merge * (just passed to LVM as is) * @error: (out): 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_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): 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_lvs: * @vg_name: (allow-none): name of the VG to get information about LVs from * @error: (out): 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_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: (allow-none): profile to use (see lvm(8) for more information) or %NULL to use * the default * @extra: (allow-none) (array zero-terminated=1): extra options for the thin pool creation * (just passed to LVM as is) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the thin LV creation * (just passed to LVM as is) * @error: (out): 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): 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 fo the to-be-created snapshot * @pool_name: (allow-none): name of the thin pool to create the snapshot in or %NULL if not specified * @extra: (allow-none) (array zero-terminated=1): extra options for the thin LV snapshot creation * (just passed to LVM as is) * @error: (out): 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: (allow-none): string representation of the new global LVM * configuration to set or %NULL to reset to default * @error: (out): 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): 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_cache_get_default_md_size: * @cache_size: size of the cache to determine MD size for * @error: (out): 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): 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): 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): 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 attache the @cache_pool_lv to * @cache_pool_lv: cache pool LV to attach to the @data_lv * @extra: (allow-none) (array zero-terminated=1): extra options for the cache attachment * (just passed to LVM as is) * @error: (out): place to store error (if any) * * Returns: whether the @cache_pool_lv was successfully attached to the @data_lv or not * * 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: (allow-none) (array zero-terminated=1): extra options for the cache detachment * (just passed to LVM as is) * @error: (out): 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): 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): 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): 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_data_lv_name: * @vg_name: name of the VG containing the queried LV * @lv_name: name of the queried LV * @error: (out): place to store error (if any) * * Returns: (transfer full): the name of the (internal) data LV of the * @vg_name/@lv_name LV * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ gchar* bd_lvm_data_lv_name (const gchar *vg_name, const gchar *lv_name, GError **error); /** * bd_lvm_metadata_lv_name: * @vg_name: name of the VG containing the queried LV * @lv_name: name of the queried LV * @error: (out): place to store error (if any) * * Returns: (transfer full): the name of the (internal) metadata LV of the * @vg_name/@lv_name LV * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_QUERY */ gchar* bd_lvm_metadata_lv_name (const gchar *vg_name, const gchar *lv_name, 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: (allow-none): name for the thin pool (if %NULL, the name @data_lv is inherited) * @extra: (allow-none) (array zero-terminated=1): extra options for the thin pool creation * (just passed to LVM as is) * @error: (out): 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: (allow-none): name for the thin pool (if %NULL, the name @data_lv is inherited) * @extra: (allow-none) (array zero-terminated=1): extra options for the thin pool creation * (just passed to LVM as is) * @error: (out): 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); #endif /* BD_LVM_API */ libblockdev-2.16-1/src/lib/plugin_apis/mdraid.api000066400000000000000000000407141323703006100216630ustar00rootroot00000000000000#include #include #include #ifndef BD_MD_API #define BD_MD_API /* taken from blivet */ // these defaults were determined empirically #define BD_MD_SUPERBLOCK_SIZE (2 MiB) #define BD_MD_CHUNK_SIZE (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_PARSE, BD_MD_ERROR_BAD_FORMAT, BD_MD_ERROR_NO_MATCH, BD_MD_ERROR_INVAL, BD_MD_ERROR_FAIL, BD_MD_ERROR_TECH_UNAVAIL, } 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) * * Creates a new copy of @data. */ BDMDExamineData* bd_md_examine_data_copy (BDMDExamineData *data) { 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) * * Frees @data. */ void bd_md_examine_data_free (BDMDExamineData *data) { 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 */ 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; } BDMDDetailData; /** * bd_md_detail_data_copy: (skip) * * Creates a new copy of @data. */ BDMDDetailData* bd_md_detail_data_copy (BDMDDetailData *data) { 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); return new_data; } /** * bd_md_detail_data_free: (skip) * * Frees @data. */ void bd_md_detail_data_free (BDMDDetailData *data) { 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); } 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): 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: (allow-none): metadata version or %NULL to use the current default version * @error: (out): 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: (allow-none): metadata version * @bitmap: whether to create an internal bitmap on the device or not * @chunk_size: chunk size of the device to create * @extra: (allow-none) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mdadm' utility) * @error: (out): 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, gboolean bitmap, guint64 chunk_size, const BDExtraArg **extra, GError **error); /** * bd_md_destroy: * @device: device to destroy MD RAID metadata on * @error: (out): 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): 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: (allow-none): specification of the RAID device (name, node or path) to activate (if not given "--scan" is implied and @members is ignored) * @members: (allow-none) (array zero-terminated=1): member devices to be considered for @device activation * @uuid: (allow-none): 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: (allow-none) (array zero-terminated=1): extra options for the activation (right now * passed to the 'mdadm' utility) * @error: (out): 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): 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): 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): 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: (allow-none) (array zero-terminated=1): extra options for the addition (right now * passed to the 'mdadm' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the removal (right now * passed to the 'mdadm' utility) * @error: (out): 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): 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): 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): place to store error (if any) * * Returns: (transfer full): cannonicalized 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): 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): 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): 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): 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): 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): 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): 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-2.16-1/src/lib/plugin_apis/mpath.api000066400000000000000000000050401323703006100215250ustar00rootroot00000000000000#include #include 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_FLUSH, BD_MPATH_ERROR_NOT_ROOT, BD_MPATH_ERROR_DM_ERROR, BD_MPATH_ERROR_INVAL, BD_MPATH_ERROR_TECH_UNAVAIL, } 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): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is avaible -- 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): 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): 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): 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): 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); libblockdev-2.16-1/src/lib/plugin_apis/part.api000066400000000000000000000403001323703006100213600ustar00rootroot00000000000000#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_EXISTS, BD_PART_ERROR_INVAL, BD_PART_ERROR_FAIL, BD_PART_ERROR_TECH_UNAVAIL, } BDPartError; typedef enum { BD_PART_TABLE_MSDOS = 0, BD_PART_TABLE_GPT, BD_PART_TABLE_UNDEF } BDPartTableType; typedef enum { BD_PART_DISK_FLAG_GPT_PMBR_BOOT = 1 } BDPartDiskFlag; /* BpG-skip */ /** * BDPartFlag: * * Partition flags supported by libblockdev. First part of the flags (up to * @BD_PART_FLAG_BASIC_LAST) corresponds to the flags supported by libparted * (see https://www.gnu.org/software/parted/manual/parted.html#set). Second * part corresponds to the flags supported by sgdisk (GPT, see `sgdisk -A=list`). * * The only exception from the above is @BD_PART_FLAG_LEGACY_BOOT which is * supported by libparted too but is GPT specific. * */ /* BpG-skip-end */ typedef enum { BD_PART_FLAG_BOOT = 1 << 1, BD_PART_FLAG_ROOT = 1 << 2, BD_PART_FLAG_SWAP = 1 << 3, BD_PART_FLAG_HIDDEN = 1 << 4, BD_PART_FLAG_RAID = 1 << 5, BD_PART_FLAG_LVM = 1 << 6, BD_PART_FLAG_LBA = 1 << 7, BD_PART_FLAG_HPSERVICE = 1 << 8, BD_PART_FLAG_CPALO = 1 << 9, BD_PART_FLAG_PREP = 1 << 10, BD_PART_FLAG_MSFT_RESERVED = 1 << 11, BD_PART_FLAG_BIOS_GRUB = 1 << 12, BD_PART_FLAG_APPLE_TV_RECOVERY = 1 << 13, BD_PART_FLAG_DIAG = 1 << 14, BD_PART_FLAG_LEGACY_BOOT = 1 << 15, BD_PART_FLAG_MSFT_DATA = 1 << 16, BD_PART_FLAG_IRST = 1 << 17, BD_PART_FLAG_ESP = 1 << 18, BD_PART_FLAG_GPT_SYSTEM_PART = 1 << 25, BD_PART_FLAG_GPT_READ_ONLY = 1 << 26, BD_PART_FLAG_GPT_HIDDEN = 1 << 27, BD_PART_FLAG_GPT_NO_AUTOMOUNT = 1 << 28 } BDPartFlag; 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_MINIMAL, BD_PART_ALIGN_OPTIMAL, BD_PART_ALIGN_NONE } 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) * @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 * @flags: bit combination of partition's flags (#BDPartFlag) */ typedef struct BDPartSpec { gchar *path; gchar *name; gchar *type_guid; guint64 type; guint64 start; guint64 size; guint64 flags; } BDPartSpec; BDPartSpec* bd_part_spec_copy (BDPartSpec *data) { BDPartSpec *ret = g_new0 (BDPartSpec, 1); ret->path = g_strdup (data->path); ret->name = g_strdup (data->name); ret->type_guid = g_strdup (data->type_guid); ret->type = data->type; ret->start = data->start; ret->size = data->size; return ret; } void bd_part_spec_free (BDPartSpec *data) { g_free (data->path); g_free (data->name); 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 * @flags: bit combination of the disk's flags (#BDPartDiskFlag) */ typedef struct BDPartDiskSpec { gchar *path; BDPartTableType table_type; guint64 size; guint64 sector_size; guint64 flags; } BDPartDiskSpec; BDPartDiskSpec* bd_part_disk_spec_copy (BDPartDiskSpec *data) { 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; ret->flags = data->flags; return ret; } void bd_part_disk_spec_free (BDPartDiskSpec *data) { 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): 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): 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): 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): 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): 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): 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): 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): 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): 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): 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 paritition * @part: partition to resize * @size: new partition size, 0 for maximal size * @align: alignment to use for the partition end * @error: (out): 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_flag: * @disk: disk the partition belongs to * @part: partition to set the flag on * @flag: flag to set * @state: state to set for the @flag (%TRUE = enabled) * @error: (out): place to store error (if any) * * Returns: whether the flag @flag was successfully set on the @part partition * or not. * * Tech category: %BD_PART_TECH_MODE_MODIFY_PART + the tech according to the partition table type */ gboolean bd_part_set_part_flag (const gchar *disk, const gchar *part, BDPartFlag flag, gboolean state, GError **error); /** * bd_part_set_disk_flag: * @disk: disk the partition belongs to * @flag: flag to set * @state: state to set for the @flag (%TRUE = enabled) * @error: (out): place to store error (if any) * * Returns: whether the flag @flag was successfully set on the @disk or not * * Tech category: %BD_PART_TECH_MODE_MODIFY_TABLE + the tech according to the partition table type */ gboolean bd_part_set_disk_flag (const gchar *disk, BDPartDiskFlag flag, gboolean state, GError **error); /** * bd_part_set_part_flags: * @disk: disk the partition belongs to * @part: partition to set the flag on * @flags: flags to set (mask combined from #BDPartFlag numbers) * @error: (out): place to store error (if any) * * Returns: whether the @flags were successfully set on the @part partition or * not * * Note: Unsets all the other flags on the partition. * Only GPT-specific flags and the legacy boot flag are supported on GPT * partition tables. * * Tech category: %BD_PART_TECH_MODE_MODIFY_PART + the tech according to the partition table type */ gboolean bd_part_set_part_flags (const gchar *disk, const gchar *part, guint64 flags, GError **error); /** * bd_part_set_part_name: * @disk: device the partition belongs to * @part: partition the should be set for * @name: name to set * @error: (out): 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 should be set for * @type_guid: GUID of the type * @error: (out): 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 should be set for * @part_id: partition Id * @error: (out): place to store error (if any) * * Returns: whether the @part_id 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_id (const gchar *disk, const gchar *part, const gchar *part_id, GError **error); /** * bd_part_get_part_id: * @disk: device the partition belongs to * @part: partition the should be set for * @error: (out): place to store error (if any) * * Returns (transfer full): partition id type or %NULL in case of error * * Tech category: %BD_PART_TECH_MODE_QUERY_PART + the tech according to the partition table type */ gchar* bd_part_get_part_id (const gchar *disk, const gchar *part, GError **error); /** * bd_part_get_part_table_type_str: * @type: table type to get string representation for * @error: (out): 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_flag_str: * @flag: flag to get string representation for * @error: (out): place to store error (if any) * * Returns: (transfer none): string representation of @flag * * Tech category: always available */ const gchar* bd_part_get_flag_str (BDPartFlag flag, GError **error); /** * bd_part_get_type_str: * @type: type to get string representation for * @error: (out): 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_KBD_API */ libblockdev-2.16-1/src/lib/plugin_apis/s390.api000066400000000000000000000125601323703006100211170ustar00rootroot00000000000000#include #include 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_DEVICE, BD_S390_ERROR_FORMAT_FAILED, BD_S390_ERROR_DASDFMT, BD_S390_ERROR_TECH_UNAVAIL, } 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): 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: (allow-none) (array zero-terminated=1): extra options for the formatting (right now * passed to the 'dasdfmt' utility) * @error: (out): 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): 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): 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): 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): 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): 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): 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): 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): 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): 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): 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); libblockdev-2.16-1/src/lib/plugin_apis/swap.api000066400000000000000000000062331323703006100213730ustar00rootroot00000000000000#include #include 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_UNKNOWN_STATE, BD_SWAP_ERROR_ACTIVATE, BD_SWAP_ERROR_TECH_UNAVAIL, } 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, } BDSwapTechMode; /** * bd_swap_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation (#BDSwapTechMode) for @tech * @error: (out): 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: (allow-none): a label for the swap space device * @extra: (allow-none) (array zero-terminated=1): extra options for the creation (right now * passed to the 'mkswap' utility) * @error: (out): 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 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): 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): 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): 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_set_label: * @device: a device to set label on * @label: label that will be set * @error: (out): 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); libblockdev-2.16-1/src/lib/plugins.c000066400000000000000000000017561323703006100172460ustar00rootroot00000000000000#include #include #include "plugins.h" /** * SECTION: plugins * @short_description: functions related to querying plugins * @title: Plugins * @include: blockdev.h */ /** * bd_plugin_spec_copy: (skip) * * Creates a new copy of @spec. */ BDPluginSpec* bd_plugin_spec_copy (BDPluginSpec *spec) { 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) * * Frees @spec. */ void bd_plugin_spec_free (BDPluginSpec *spec) { g_free ((gchar *) spec->so_name); g_free (spec); } GType bd_plugin_spec_get_type () { 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-2.16-1/src/lib/plugins.h000066400000000000000000000015511323703006100172440ustar00rootroot00000000000000#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_KBD, BD_PLUGIN_S390, BD_PLUGIN_PART, BD_PLUGIN_FS, BD_PLUGIN_UNDEF } BDPlugin; #define BD_TYPE_PLUGIN_SPEC (bd_plugin_spec_get_type ()) GType bd_plugin_spec_get_type(); typedef struct BDPluginSpec { BDPlugin name; const gchar *so_name; } BDPluginSpec; BDPluginSpec* bd_plugin_spec_copy (BDPluginSpec *spec); void bd_plugin_spec_free (BDPluginSpec *spec); gboolean bd_is_plugin_available (BDPlugin plugin); gchar** bd_get_available_plugin_names (); gchar* bd_get_plugin_soname (BDPlugin plugin); gchar* bd_get_plugin_name (BDPlugin plugin); #endif /* BD_PLUGINS */ libblockdev-2.16-1/src/plugins/000077500000000000000000000000001323703006100163235ustar00rootroot00000000000000libblockdev-2.16-1/src/plugins/Makefile.am000066400000000000000000000151701323703006100203630ustar00rootroot00000000000000if WITH_FS SUBDIRS = . fs 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_SWAP lib_LTLIBRARIES += libbd_swap.la endif if WITH_KBD lib_LTLIBRARIES += libbd_kbd.la endif if WITH_PART_O_WITH_FS lib_LTLIBRARIES += libbd_part_err.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) $(BYTESIZE_CFLAGS) -Wall -Wextra -Werror libbd_btrfs_la_LIBADD = $(GLIB_LIBS) $(BYTESIZE_LIBS) ${builddir}/../utils/libbd_utils.la libbd_btrfs_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined 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 libbd_crypto_la_CFLAGS = $(GLIB_CFLAGS) $(CRYPTSETUP_CFLAGS) $(NSS_CFLAGS) -Wall -Wextra -Werror libbd_crypto_la_LIBADD = $(GLIB_LIBS) $(CRYPTSETUP_LIBS) $(NSS_LIBS) -lvolume_key ${builddir}/../utils/libbd_utils.la libbd_crypto_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined 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) $(DEVMAPPER_CFLAGS) $(UDEV_CFLAGS) -Wall -Wextra -Werror libbd_dm_la_LIBADD = $(GLIB_LIBS) $(DEVMAPPER_LIBS) $(UDEV_LIBS) -ldmraid ${builddir}/../utils/libbd_utils.la libbd_dm_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined # Dear author of libdmdraid, VERSION really is not a good name for an enum member! libbd_dm_la_CPPFLAGS = -I${builddir}/../../include/ -UVERSION libbd_dm_la_SOURCES = dm.c dm.h check_deps.c check_deps.h endif if WITH_LOOP libbd_loop_la_CFLAGS = $(GLIB_CFLAGS) -Wall -Wextra -Werror libbd_loop_la_LIBADD = $(GLIB_LIBS) ${builddir}/../utils/libbd_utils.la libbd_loop_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined 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) $(DEVMAPPER_CFLAGS) -Wall -Wextra -Werror libbd_lvm_la_LIBADD = -lm $(GLIB_LIBS) $(DEVMAPPER_LIBS) ${builddir}/../utils/libbd_utils.la libbd_lvm_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined libbd_lvm_la_CPPFLAGS = -I${builddir}/../../include/ libbd_lvm_la_SOURCES = lvm.c lvm.h check_deps.c check_deps.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 = -lm $(GLIB_LIBS) $(GIO_LIBS) $(DEVMAPPER_LIBS) ${builddir}/../utils/libbd_utils.la libbd_lvm_dbus_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined libbd_lvm_dbus_la_CPPFLAGS = -I${builddir}/../../include/ libbd_lvm_dbus_la_SOURCES = lvm-dbus.c lvm.h check_deps.c check_deps.h endif if WITH_MDRAID libbd_mdraid_la_CFLAGS = $(GLIB_CFLAGS) $(BYTESIZE_CFLAGS) -Wall -Wextra -Werror libbd_mdraid_la_LIBADD = $(GLIB_LIBS) $(BYTESIZE_LIBS) ${builddir}/../utils/libbd_utils.la libbd_mdraid_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined 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) $(DEVMAPPER_CFLAGS) -Wall -Wextra -Werror libbd_mpath_la_LIBADD = $(GLIB_LIBS) $(DEVMAPPER_LIBS) ${builddir}/../utils/libbd_utils.la libbd_mpath_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined libbd_mpath_la_CPPFLAGS = -I${builddir}/../../include/ libbd_mpath_la_SOURCES = mpath.c mpath.h check_deps.c check_deps.h endif if WITH_SWAP libbd_swap_la_CFLAGS = $(GLIB_CFLAGS) -Wall -Wextra -Werror libbd_swap_la_LIBADD = $(GLIB_LIBS) ${builddir}/../utils/libbd_utils.la libbd_swap_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined libbd_swap_la_CPPFLAGS = -I${builddir}/../../include/ libbd_swap_la_SOURCES = swap.c swap.h check_deps.c check_deps.h endif if WITH_KBD libbd_kbd_la_CFLAGS = $(GLIB_CFLAGS) $(BYTESIZE_CFLAGS) -Wall -Wextra -Werror libbd_kbd_la_LIBADD = $(GLIB_LIBS) $(BYTESIZE_LIBS) ${builddir}/../utils/libbd_utils.la libbd_kbd_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined libbd_kbd_la_CPPFLAGS = -I${builddir}/../../include/ libbd_kbd_la_SOURCES = kbd.c kbd.h check_deps.c check_deps.h endif if WITH_S390 libbd_s390_la_CFLAGS = $(GLIB_CFLAGS) -Wall -Wextra -Werror libbd_s390_la_LIBADD = $(GLIB_LIBS) ${builddir}/../utils/libbd_utils.la libbd_s390_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined 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) $(PARTED_CFLAGS) -Wall -Wextra -Werror libbd_part_la_LIBADD = -lm $(GLIB_LIBS) $(PARTED_LIBS) ${builddir}/../utils/libbd_utils.la ${builddir}/libbd_part_err.la libbd_part_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined libbd_part_la_CPPFLAGS = -I${builddir}/../../include/ libbd_part_la_SOURCES = part.c part.h check_deps.c check_deps.h endif if WITH_PART_O_WITH_FS libbd_part_err_la_CFLAGS = $(GLIB_CFLAGS) $(PARTED_CFLAGS) $(PARTED_FS_CFLAGS) -Wall -Wextra -Werror libbd_part_err_la_LIBADD = $(GLIB_LIBS) $(PARTED_LIBS) $(PARTED_FS_LIBS) ${builddir}/../utils/libbd_utils.la libbd_part_err_la_LDFLAGS = -L${srcdir}/ -version-info 2:0:0 -Wl,--no-undefined libbd_part_err_la_CPPFLAGS = -I${builddir}/../../include/ libbd_part_err_la_SOURCES = part_err.c part_err.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_SWAP libinclude_HEADERS += swap.h endif if WITH_KBD libinclude_HEADERS += kbd.h endif if WITH_PART libinclude_HEADERS += part.h endif if WITH_FS libinclude_HEADERS += fs.h endif noinst_HEADERS = part_err.h if WITH_S390 libinclude_HEADERS += s390.h endif MAINTAINERCLEANFILES = Makefile.in libblockdev-2.16-1/src/plugins/btrfs.c000066400000000000000000001024731323703006100176160ustar00rootroot00000000000000/* * Copyright (C) 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Author: Vratislav Podzimek */ #include #include #include #include #include #include "btrfs.h" #include "check_deps.h" /** * 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) { 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) { g_free (info->path); g_free (info); } BDBtrfsSubvolumeInfo* bd_btrfs_subvolume_info_copy (BDBtrfsSubvolumeInfo *info) { 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) { g_free (info->path); g_free (info); } BDBtrfsFilesystemInfo* bd_btrfs_filesystem_info_copy (BDBtrfsFilesystemInfo *info) { 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) { 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 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 gchar* module_deps[MODULE_DEPS_LAST] = { "btrfs" }; /** * bd_btrfs_check_deps: * * Returns: whether the plugin's runtime dependencies are satisfied or not * * Function checking plugin's runtime dependencies. * */ gboolean bd_btrfs_check_deps () { GError *error = NULL; guint i = 0; gboolean status = FALSE; gboolean ret = TRUE; for (i=0; i < DEPS_LAST; i++) { status = bd_utils_check_util_version (deps[i].name, deps[i].version, deps[i].ver_arg, deps[i].ver_regexp, &error); if (!status) g_warning ("%s", error->message); else g_atomic_int_or (&avail_deps, 1 << i); g_clear_error (&error); ret = ret && status; } for (i=0; i < MODULE_DEPS_LAST; i++) { status = check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, &error); if (!status) { g_warning ("%s", error->message); g_clear_error (&error); } ret = ret && status; } if (!ret) g_warning("Cannot load the BTRFS plugin"); return ret; } /** * bd_btrfs_init: * * Initializes the plugin. **This function is called automatically by the * library's initialization functions.** * */ gboolean bd_btrfs_init () { /* 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 () { /* nothing to do here */ } #define UNUSED __attribute__((unused)) /** * bd_btrfs_is_tech_avail: * @tech: the queried tech * @mode: a bit mask of queried modes of operation for @tech * @error: (out): place to store error (details about why the @tech-@mode combination is not available) * * Returns: whether the @tech-@mode combination is avaible -- supported by the * plugin implementation and having all the runtime dependencies available */ gboolean bd_btrfs_is_tech_avail (BDBtrfsTech tech UNUSED, guint64 mode UNUSED, GError **error UNUSED) { /* 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) g_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) g_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) g_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: (allow-none): label for the volume * @data_level: (allow-none): RAID level for the data or %NULL to use the default * @md_level: (allow-none): RAID level for the metadata or %NULL to use the default * @extra: (allow-none) (array zero-terminated=1): extra options for the volume creation (right now * passed to the 'mkfs.btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the addition (right now * passed to the 'btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the removal (right now * passed to the 'btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the subvolume creation (right now * passed to the 'btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the subvolume deletion (right now * passed to the 'btrfs' utility) * @error: (out): 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): 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 FALSE; regex = g_regex_new ("ID (\\d+) .*", 0, 0, error); if (!regex) { g_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: (allow-none) (array zero-terminated=1): extra options for the setting (right now * passed to the 'btrfs' utility) * @error: (out): 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: (allow-none) (array zero-terminated=1): extra options for the snapshot creation (right now * passed to the 'btrfs' utility) * @error: (out): 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): 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; guint8 i = 0; GPtrArray *dev_infos = g_ptr_array_new (); BDBtrfsDeviceInfo** ret = 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; regex = g_regex_new (pattern, G_REGEX_EXTENDED, 0, error); if (!regex) { g_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) /* error is already populated from the previous call */ return NULL; lines = g_strsplit (output, "\n", 0); g_free (output); 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); if (dev_infos->len == 0) { g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse information about devices"); return NULL; } /* now create the return value -- NULL-terminated array of BDBtrfsDeviceInfo */ ret = g_new0 (BDBtrfsDeviceInfo*, dev_infos->len + 1); for (i=0; i < dev_infos->len; i++) ret[i] = (BDBtrfsDeviceInfo*) g_ptr_array_index (dev_infos, i); ret[i] = NULL; g_ptr_array_free (dev_infos, FALSE); return ret; } /** * bd_btrfs_list_subvolumes: * @mountpoint: a mountpoint of the queried btrfs volume * @snapshots_only: whether to list only snapshot subvolumes or not * @error: (out): 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 = g_ptr_array_new (); BDBtrfsSubvolumeInfo* item = NULL; BDBtrfsSubvolumeInfo* swap_item = NULL; BDBtrfsSubvolumeInfo** ret = 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 (snapshots_only) { argv[4] = "-s"; argv[5] = mountpoint; } else argv[4] = mountpoint; regex = g_regex_new (pattern, G_REGEX_EXTENDED, 0, error); if (!regex) { g_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) { if (g_error_matches (*error, BD_UTILS_EXEC_ERROR, BD_UTILS_EXEC_ERROR_NOOUT)) { /* no output -> no subvolumes */ ret = g_new0 (BDBtrfsSubvolumeInfo*, 1); g_clear_error (error); return ret; } else { /* error is already populated from the call above or simply no output*/ return NULL; } } lines = g_strsplit (output, "\n", 0); g_free (output); 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); if (subvol_infos->len == 0) { g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse information about subvolumes"); 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): 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