reflink-0.2.1/0000755000000000000000000000000013352352473013111 5ustar rootroot00000000000000reflink-0.2.1/AUTHORS.rst0000666000000000000000000000023113352352445014767 0ustar rootroot00000000000000======= Credits ======= Development Lead ---------------- * Ruben De Smet Contributors ------------ None yet. Why not be the first? reflink-0.2.1/CONTRIBUTING.rst0000666000000000000000000000623713352352445015565 0ustar rootroot00000000000000.. highlight:: shell ============ Contributing ============ Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. You can contribute in many ways: Types of Contributions ---------------------- Report Bugs ~~~~~~~~~~~ Report bugs at https://gitlab.com/rubdos/pyreflink/issues. If you are reporting a bug, please include: * Your operating system name and version. * Any details about your local setup that might be helpful in troubleshooting. * Detailed steps to reproduce the bug. Fix Bugs ~~~~~~~~ Look through the GitHub issues for bugs. Anything tagged with "bug" and "help wanted" is open to whoever wants to implement it. Implement Features ~~~~~~~~~~~~~~~~~~ Look through the GitHub issues for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it. Write Documentation ~~~~~~~~~~~~~~~~~~~ Python reflink could always use more documentation, whether as part of the official Python reflink docs, in docstrings, or even on the web in blog posts, articles, and such. Submit Feedback ~~~~~~~~~~~~~~~ The best way to send feedback is to file an issue at https://gitlab.com/rubdos/pyreflink/issues. If you are proposing a feature: * Explain in detail how it would work. * Keep the scope as narrow as possible, to make it easier to implement. * Remember that this is a volunteer-driven project, and that contributions are welcome :) Get Started! ------------ Ready to contribute? Here's how to set up `reflink` for local development. 1. Fork the `reflink` repo on GitHub. 2. Clone your fork locally:: $ git clone git@github.com:your_name_here/reflink.git 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: $ mkvirtualenv reflink $ cd reflink/ $ python setup.py develop 4. Create a branch for local development:: $ git checkout -b name-of-your-bugfix-or-feature Now you can make your changes locally. 5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: $ flake8 reflink tests $ python setup.py test or py.test $ tox To get flake8 and tox, just pip install them into your virtualenv. 6. Commit your changes and push your branch to GitHub:: $ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature 7. Submit a pull request through the GitHub website. Pull Request Guidelines ----------------------- Before you submit a pull request, check that it meets these guidelines: 1. The pull request should include tests. 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. 3. The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/rubdos/reflink/pull_requests and make sure that the tests pass for all supported Python versions. Tips ---- To run a subset of tests:: $ py.test tests.test_reflink reflink-0.2.1/HISTORY.rst0000666000000000000000000000066113352352445015012 0ustar rootroot00000000000000======= History ======= 0.2.0 (2018-03-09) ------------------ New features: * APFS/Darwin support * Filenames outside ascii are supported (thank you, Kriskras99) Bug fixes: * Building on newer glibc (thank you, Frankie Dintino) * Better error handling for ENOENT Other changes: * Continuous integration for Windows (AppVeyor), integrated in the GitLab pipeline 0.1.0 (2017-07-27) ------------------ * First release on PyPI. reflink-0.2.1/LICENSE0000666000000000000000000000206113352352445014120 0ustar rootroot00000000000000 MIT License Copyright (c) 2017, Ruben De Smet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. reflink-0.2.1/MANIFEST.in0000666000000000000000000000045013352352445014651 0ustar rootroot00000000000000include AUTHORS.rst include CONTRIBUTING.rst include HISTORY.rst include LICENSE include README.rst recursive-include tests * recursive-include reflink *.c *.h recursive-exclude * __pycache__ recursive-exclude * *.py[co] recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif reflink-0.2.1/PKG-INFO0000644000000000000000000001056713352352473014217 0ustar rootroot00000000000000Metadata-Version: 1.1 Name: reflink Version: 0.2.1 Summary: Python reflink wraps around platform specific reflink implementations Home-page: https://gitlab.com/rubdos/pyreflink Author: Ruben De Smet Author-email: pypi@rubdos.be License: MIT license Description: ============== Python reflink ============== .. image:: https://img.shields.io/pypi/v/reflink.svg :target: https://pypi.python.org/pypi/reflink .. image:: https://gitlab.com/rubdos/pyreflink/badges/master/build.svg :target: https://gitlab.com/rubdos/pyreflink/pipelines .. image:: https://ci.appveyor.com/api/projects/status/ta2rn0irw52ua5sw?svg=true :target: https://ci.appveyor.com/project/RubenDeSmet/pyreflink :alt: Windows build status .. image:: https://readthedocs.org/projects/reflink/badge/?version=latest :target: https://reflink.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://readthedocs.org/projects/reflink/badge/?version=latest :target: https://rubdos.gitlab.io/pyreflink/docs :alt: Documentation Status .. image:: https://gitlab.com/rubdos/pyreflink/badges/master/coverage.svg :target: https://rubdos.gitlab.io/pyreflink/coverage :alt: Coverage report Python wrapper around the ``reflink`` system calls. * Free software: MIT license * Documentation: https://reflink.readthedocs.io. * Documentation for master branch: https://rubdos.gitlab.io/pyreflink/docs Features -------- * Btrfs, XFS, OCFS2 ``reflink`` support. Btrfs is tested the most. * Apple macOS APFS ``clonefile`` support. Little testing, be careful. It might eat data. * A convenience method that checks support for reflinks within a specific directory. Installation ------------ This library is available on `pypi`_:: pip install reflink Quick start example ------------------- To use Python reflink in a project:: from reflink import reflink # Reflink copy 'large_file.img' to 'copy_of_file.img' reflink("large_file.img", "copy_of_file.img") Help wanted ----------- Someone to implement a `Windows/ReFS implementation `__ Support _______ Support on `the GitLab repository `__, feel free to file an issue. Credits --------- This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. .. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage .. _pypi: https://pypi.python.org/pypi/reflink ======= History ======= 0.2.0 (2018-03-09) ------------------ New features: * APFS/Darwin support * Filenames outside ascii are supported (thank you, Kriskras99) Bug fixes: * Building on newer glibc (thank you, Frankie Dintino) * Better error handling for ENOENT Other changes: * Continuous integration for Windows (AppVeyor), integrated in the GitLab pipeline 0.1.0 (2017-07-27) ------------------ * First release on PyPI. Keywords: reflink Platform: UNKNOWN Classifier: Development Status :: 2 - Pre-Alpha Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Natural Language :: English Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 reflink-0.2.1/README.rst0000666000000000000000000000446013352352445014607 0ustar rootroot00000000000000============== Python reflink ============== .. image:: https://img.shields.io/pypi/v/reflink.svg :target: https://pypi.python.org/pypi/reflink .. image:: https://gitlab.com/rubdos/pyreflink/badges/master/build.svg :target: https://gitlab.com/rubdos/pyreflink/pipelines .. image:: https://ci.appveyor.com/api/projects/status/ta2rn0irw52ua5sw?svg=true :target: https://ci.appveyor.com/project/RubenDeSmet/pyreflink :alt: Windows build status .. image:: https://readthedocs.org/projects/reflink/badge/?version=latest :target: https://reflink.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://readthedocs.org/projects/reflink/badge/?version=latest :target: https://rubdos.gitlab.io/pyreflink/docs :alt: Documentation Status .. image:: https://gitlab.com/rubdos/pyreflink/badges/master/coverage.svg :target: https://rubdos.gitlab.io/pyreflink/coverage :alt: Coverage report Python wrapper around the ``reflink`` system calls. * Free software: MIT license * Documentation: https://reflink.readthedocs.io. * Documentation for master branch: https://rubdos.gitlab.io/pyreflink/docs Features -------- * Btrfs, XFS, OCFS2 ``reflink`` support. Btrfs is tested the most. * Apple macOS APFS ``clonefile`` support. Little testing, be careful. It might eat data. * A convenience method that checks support for reflinks within a specific directory. Installation ------------ This library is available on `pypi`_:: pip install reflink Quick start example ------------------- To use Python reflink in a project:: from reflink import reflink # Reflink copy 'large_file.img' to 'copy_of_file.img' reflink("large_file.img", "copy_of_file.img") Help wanted ----------- Someone to implement a `Windows/ReFS implementation `__ Support _______ Support on `the GitLab repository `__, feel free to file an issue. Credits --------- This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. .. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage .. _pypi: https://pypi.python.org/pypi/reflink reflink-0.2.1/docs/0000755000000000000000000000000013352352473014041 5ustar rootroot00000000000000reflink-0.2.1/docs/Makefile0000666000000000000000000001520313352352445015505 0ustar rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = -T -E -D language=en SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/reflink.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/reflink.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/reflink" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/reflink" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." reflink-0.2.1/docs/authors.rst0000666000000000000000000000003413352352445016260 0ustar rootroot00000000000000.. include:: ../AUTHORS.rst reflink-0.2.1/docs/conf.py0000777000000000000000000001066613352352445015357 0ustar rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- # # reflink documentation build configuration file, created by # sphinx-quickstart on Tue Jul 9 22:26:36 2013. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os # Get the project root dir, which is the parent dir of this cwd = os.getcwd() project_root = os.path.dirname(cwd) # Insert the project root dir as the first element in the PYTHONPATH. # This lets us ensure that the source package is imported, and that its # version is used. sys.path.insert(0, project_root) # -- General configuration --------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Python reflink' copyright = u"2017, Ruben De Smet" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # -- Options for HTML output ------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Add any paths that contain custom static files (such as style sheets) # here, relative to this directory. They are copied after the builtin # static files, so a file named "default.css" will overwrite the builtin # "default.css". html_static_path = ['_static'] # Output file base name for HTML help builder. htmlhelp_basename = 'reflinkdoc' # -- Options for LaTeX output ------------------------------------------ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass # [howto/manual]). latex_documents = [ ('index', 'reflink.tex', u'Python reflink Documentation', u'Ruben De Smet', 'manual'), ] # The name of an image file (relative to this directory) to place at # the top of the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings # are parts, not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output ------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'reflink', u'Python reflink Documentation', [u'Ruben De Smet'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ---------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'reflink', u'Python reflink Documentation', u'Ruben De Smet', 'reflink', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False autodoc_mock_imports = ['reflink.backend', 'reflink._backend', 'reflink.linux'] reflink-0.2.1/docs/contributing.rst0000666000000000000000000000004113352352445017300 0ustar rootroot00000000000000.. include:: ../CONTRIBUTING.rst reflink-0.2.1/docs/history.rst0000666000000000000000000000003413352352445016274 0ustar rootroot00000000000000.. include:: ../HISTORY.rst reflink-0.2.1/docs/index.rst0000666000000000000000000000101013352352445015675 0ustar rootroot00000000000000Welcome to Python reflink's documentation! ====================================== Contents: .. toctree:: :maxdepth: 2 readme installation usage modules contributing authors history Quick start example ------------------- To use Python reflink in a project:: from reflink import reflink # Reflink copy 'large_file.img' to 'copy_of_file.img' reflink("large_file.img", "copy_of_file.img") Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` reflink-0.2.1/docs/installation.rst0000666000000000000000000000216013352352445017276 0ustar rootroot00000000000000.. highlight:: shell ============ Installation ============ Stable release -------------- To install Python reflink, run this command in your terminal: .. code-block:: console $ pip install reflink This is the preferred method to install Python reflink, as it will always install the most recent stable release. If you don't have `pip`_ installed, this `Python installation guide`_ can guide you through the process. .. _pip: https://pip.pypa.io .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ From sources ------------ The sources for Python reflink can be downloaded from the `Github repo`_. You can either clone the public repository: .. code-block:: console $ git clone git://gitlab.com/rubdos/pyreflink Or download the `tarball`_: .. code-block:: console $ curl -OL https://gitlab.com/rubdos/pyreflink/tarball/master Once you have a copy of the source, you can install it with: .. code-block:: console $ python setup.py install .. _Github repo: https://gitlab.com/rubdos/pyreflink .. _tarball: https://gitlab.com/rubdos/pyreflink/tarball/master reflink-0.2.1/docs/make.bat0000666000000000000000000001447513352352445015464 0ustar rootroot00000000000000@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. xml to make Docutils-native XML files echo. pseudoxml to make pseudoxml-XML files for display purposes echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) %SPHINXBUILD% 2> nul if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\reflink.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\reflink.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdf" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf cd %BUILDDIR%/.. echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdfja" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf-ja cd %BUILDDIR%/.. echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) if "%1" == "xml" ( %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml if errorlevel 1 exit /b 1 echo. echo.Build finished. The XML files are in %BUILDDIR%/xml. goto end ) if "%1" == "pseudoxml" ( %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml if errorlevel 1 exit /b 1 echo. echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. goto end ) :end reflink-0.2.1/docs/readme.rst0000666000000000000000000000003313352352445016027 0ustar rootroot00000000000000.. include:: ../README.rst reflink-0.2.1/docs/usage.rst0000666000000000000000000000046513352352445015707 0ustar rootroot00000000000000===== Usage ===== To use Python reflink in a project:: import reflink from reflink import reflink reflink("large_file.img", "copy_of_file.img") Raises a ``NotImplementedError`` when the OS does not implement reflink. Raises a ``ReflinkImpossibleError`` when trying to reflink between devices, reflink-0.2.1/reflink/0000755000000000000000000000000013352352473014543 5ustar rootroot00000000000000reflink-0.2.1/reflink/__init__.py0000666000000000000000000000040413352352445016655 0ustar rootroot00000000000000# -*- coding: utf-8 -*- """Top-level package for Python reflink.""" __author__ = """Ruben De Smet""" __email__ = 'pypi@rubdos.be' __version__ = '0.1.3' from .error import ReflinkImpossibleError from .reflink import reflink from .reflink import supported_at reflink-0.2.1/reflink/backend.py0000666000000000000000000000460213352352445016511 0ustar rootroot00000000000000import errno import sys from ._backend import ffi # Ignore PyLintBear (E0611) from ._backend import lib from .error import ReflinkImpossibleError if sys.version_info[0] == 3: unicode = str def clone(oldpath, newpath): if isinstance(oldpath, unicode): oldpath = oldpath.encode(sys.getfilesystemencoding()) if isinstance(newpath, unicode): newpath = newpath.encode(sys.getfilesystemencoding()) newpath_c = ffi.new('char[]', newpath) oldpath_c = ffi.new('char[]', oldpath) rc = lib.reflink_clone_file(oldpath_c, newpath_c) if rc == 0: return # Success! if rc == -1: # ioctl returned an error. # We investigate in Python and throw if lib.errno == errno.EBADF: raise NotImplementedError( "BUG: errno EBADF when handling ioctl error") if lib.errno == errno.EINVAL: raise IOError( "EINVAL when handling ioctl: The filesystem does not support reflinking the ranges of the given files.") if lib.errno == errno.EISDIR: raise IOError("Cannot reflink directories") if lib.errno == errno.EOPNOTSUPP: raise ReflinkImpossibleError("EOPNOTSUPP") if lib.errno == errno.EPERM: raise IOError("EPERM: no permission to write to %s" % newpath) if lib.errno == errno.ETXTBSY: raise IOError("ETXTBSY: cannot reflink from/to swapfiles") if lib.errno == errno.EXDEV: raise ReflinkImpossibleError("EXDEV") if lib.errno == errno.ENOENT: raise FileNotFoundError( "Cannot open source file %s (%i)" % (oldpath, lib.errno)) raise Exception("BUG: errno %s not implemented" % errno.errorcode[lib.errno]) if rc == -3: raise IOError("Cannot open file %s for writing (%i)" % (newpath, lib.errno)) if rc == -2: if lib.errno == errno.ENOENT: raise FileNotFoundError("No such file %s (%i)" % (oldpath, lib.errno)) raise IOError("Cannot open source file %s (%i)" % (oldpath, lib.errno)) if rc == -4: raise NotImplementedError() if rc == -5: raise IOError("Could not copy permissions (errno %s)" % errno.errorcode[lib.errno]) raise IOError("Unknown exception (errno %s)" % errno.errorcode[lib.errno]) reflink-0.2.1/reflink/darwin.c0000666000000000000000000000077613352352445016210 0ustar rootroot00000000000000#include /* NOTE: sys/clonefile.h is available since OS X 10.12 */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 #include /* for clonefile(2) */ #include int reflink_clone_file(char *oldpath, char *newpath) { int rc; rc = clonefile(oldpath, newpath, 0); if (rc == 0) return 0; if (errno == ENOTSUP) { return -4; } return rc; } #else int reflink_clone_file(char *oldpath, char *newpath) { return -4; } #endif reflink-0.2.1/reflink/error.py0000666000000000000000000000006213352352445016247 0ustar rootroot00000000000000class ReflinkImpossibleError(Exception): pass reflink-0.2.1/reflink/linux.c0000666000000000000000000000173713352352445016061 0ustar rootroot00000000000000#include #include #include #include #include #include #include int clone_permissions(char *oldpath, char *newpath) { struct stat st; int rc; rc = stat(oldpath, &st); if (rc) { return rc; } return chmod(newpath, st.st_mode); // Ignore CSecurityBear (race) } int reflink_clone_file(char *oldpath, char *newpath) { #ifdef FICLONE int old_fd = open(oldpath, O_RDONLY); if (old_fd < 0) { return -2; } int new_fd = open(newpath, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); if (new_fd < 0) { close(old_fd); return -3; } int result = ioctl (new_fd, FICLONE, old_fd); close(new_fd); close(old_fd); if (result != 0) { unlink(newpath); return result; } if (clone_permissions(oldpath, newpath)) { unlink(newpath); return -5; } return result; #else return -4; #endif } reflink-0.2.1/reflink/native.py0000666000000000000000000000070613352352445016411 0ustar rootroot00000000000000import sys from cffi import FFI REFLINK_ATTR_PRESERVE = 0x1 REFLINK_ATTR_NONE = 0x0 platform = sys.platform if platform == 'linux2': platform = 'linux' ffibuilder = FFI() with open("reflink/%s.c" % platform) as source_file: ffibuilder.set_source("reflink._backend", source_file.read()) ffibuilder.cdef(""" int reflink_clone_file(char *oldpath, char *newpath); int errno; """) if __file__ == '__main__': ffibuilder.compile(verbose=True) reflink-0.2.1/reflink/reflink.py0000666000000000000000000000400513352352445016551 0ustar rootroot00000000000000# -*- coding: utf-8 -*- """Main module.""" import os from . import backend def reflink(oldpath, newpath): """ Create a reflink from ``newpath`` to ``oldpath``. Raises a ``NotImplementedError`` when the OS does not implement reflink. Raises a ``ReflinkImpossibleError`` when trying to reflink between devices, Raises an ``IOError`` when: * ``oldpath`` is a directory * The user has no permissions to create ``newpath`` * Trying to reflink into a swapfile (ETXTBSY) For debugability's sake, ``reflink`` _can_ throw IOError in other cases, when the underlying system call fails for another reason. However, these reasons cannot be triggered with this basic call. See man `IOCTL-FICLONERANGE(2) `__ and ``backend.py`` for more details on these conditions. Example code: >>> from reflink import reflink >>> reflink("large_file.img", "copy_of_file.img") # doctest: +SKIP >>> """ # raise NotImplementedError when OS does not implement reflink # raise ReflinkImpossibleError when trying to reflink across devices backend.clone(oldpath, newpath) def supported_at(path): """ Returns ``True`` when a path on the filesystem supports reflinking, ``False`` otherwise. Please note that the current implementation verifies this by testing whether it's possible to reflink. """ # Currently, there's no systemcall that tests whether a point in the VFS is supported or not. # We create a file at ``path``, and clone it. a = os.path.join(path, "i_hope_no_one_will_ever_try_this_name.txt") b = os.path.join(path, "i_hope_no_one_will_ever_try_that_name.txt") with open(a, 'w+') as f: f.write(u"abc") try: reflink(a, b) return True except: pass # TODO: there are probably specific exception that we can handle finally: os.unlink(a) if os.path.isfile(b): os.unlink(b) return False reflink-0.2.1/reflink/win32.c0000666000000000000000000000010513352352445015650 0ustar rootroot00000000000000int reflink_clone_file(char *oldpath, char *newpath) { return -4; } reflink-0.2.1/reflink.egg-info/0000755000000000000000000000000013352352473016235 5ustar rootroot00000000000000reflink-0.2.1/reflink.egg-info/PKG-INFO0000644000000000000000000001056713352352473017343 0ustar rootroot00000000000000Metadata-Version: 1.1 Name: reflink Version: 0.2.1 Summary: Python reflink wraps around platform specific reflink implementations Home-page: https://gitlab.com/rubdos/pyreflink Author: Ruben De Smet Author-email: pypi@rubdos.be License: MIT license Description: ============== Python reflink ============== .. image:: https://img.shields.io/pypi/v/reflink.svg :target: https://pypi.python.org/pypi/reflink .. image:: https://gitlab.com/rubdos/pyreflink/badges/master/build.svg :target: https://gitlab.com/rubdos/pyreflink/pipelines .. image:: https://ci.appveyor.com/api/projects/status/ta2rn0irw52ua5sw?svg=true :target: https://ci.appveyor.com/project/RubenDeSmet/pyreflink :alt: Windows build status .. image:: https://readthedocs.org/projects/reflink/badge/?version=latest :target: https://reflink.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://readthedocs.org/projects/reflink/badge/?version=latest :target: https://rubdos.gitlab.io/pyreflink/docs :alt: Documentation Status .. image:: https://gitlab.com/rubdos/pyreflink/badges/master/coverage.svg :target: https://rubdos.gitlab.io/pyreflink/coverage :alt: Coverage report Python wrapper around the ``reflink`` system calls. * Free software: MIT license * Documentation: https://reflink.readthedocs.io. * Documentation for master branch: https://rubdos.gitlab.io/pyreflink/docs Features -------- * Btrfs, XFS, OCFS2 ``reflink`` support. Btrfs is tested the most. * Apple macOS APFS ``clonefile`` support. Little testing, be careful. It might eat data. * A convenience method that checks support for reflinks within a specific directory. Installation ------------ This library is available on `pypi`_:: pip install reflink Quick start example ------------------- To use Python reflink in a project:: from reflink import reflink # Reflink copy 'large_file.img' to 'copy_of_file.img' reflink("large_file.img", "copy_of_file.img") Help wanted ----------- Someone to implement a `Windows/ReFS implementation `__ Support _______ Support on `the GitLab repository `__, feel free to file an issue. Credits --------- This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. .. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage .. _pypi: https://pypi.python.org/pypi/reflink ======= History ======= 0.2.0 (2018-03-09) ------------------ New features: * APFS/Darwin support * Filenames outside ascii are supported (thank you, Kriskras99) Bug fixes: * Building on newer glibc (thank you, Frankie Dintino) * Better error handling for ENOENT Other changes: * Continuous integration for Windows (AppVeyor), integrated in the GitLab pipeline 0.1.0 (2017-07-27) ------------------ * First release on PyPI. Keywords: reflink Platform: UNKNOWN Classifier: Development Status :: 2 - Pre-Alpha Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Natural Language :: English Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 reflink-0.2.1/reflink.egg-info/SOURCES.txt0000644000000000000000000000115513352352473020123 0ustar rootroot00000000000000AUTHORS.rst CONTRIBUTING.rst HISTORY.rst LICENSE MANIFEST.in README.rst setup.cfg setup.py docs/Makefile docs/authors.rst docs/conf.py docs/contributing.rst docs/history.rst docs/index.rst docs/installation.rst docs/make.bat docs/readme.rst docs/usage.rst reflink/__init__.py reflink/backend.py reflink/darwin.c reflink/error.py reflink/linux.c reflink/native.py reflink/reflink.py reflink/win32.c reflink.egg-info/PKG-INFO reflink.egg-info/SOURCES.txt reflink.egg-info/dependency_links.txt reflink.egg-info/not-zip-safe reflink.egg-info/requires.txt reflink.egg-info/top_level.txt tests/__init__.py tests/test_reflink.pyreflink-0.2.1/reflink.egg-info/dependency_links.txt0000644000000000000000000000000113352352473022303 0ustar rootroot00000000000000 reflink-0.2.1/reflink.egg-info/not-zip-safe0000644000000000000000000000000113352352473020463 0ustar rootroot00000000000000 reflink-0.2.1/reflink.egg-info/requires.txt0000644000000000000000000000000513352352473020630 0ustar rootroot00000000000000cffi reflink-0.2.1/reflink.egg-info/top_level.txt0000644000000000000000000000001013352352473020756 0ustar rootroot00000000000000reflink reflink-0.2.1/setup.cfg0000666000000000000000000000062413352352473014740 0ustar rootroot00000000000000[bumpversion] current_version = 0.1.3 commit = True tag = True [bumpversion:file:setup.py] search = version='{current_version}' replace = version='{new_version}' [bumpversion:file:reflink/__init__.py] search = __version__ = '{current_version}' replace = __version__ = '{new_version}' [bdist_wheel] universal = 1 [flake8] exclude = docs [aliases] test = pytest [egg_info] tag_build = tag_date = 0 reflink-0.2.1/setup.py0000666000000000000000000000355413352352445014635 0ustar rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- """The setup script.""" import sys from setuptools import find_packages from setuptools import setup with open('README.rst') as readme_file: readme = readme_file.read() with open('HISTORY.rst') as history_file: history = history_file.read() requirements = [ 'cffi', ] setup_requirements = [ 'cffi', 'pytest-runner', ] test_requirements = [ 'pytest', ] if sys.platform not in ['linux', 'linux2', 'win32', 'darwin']: raise NotImplementedError("Platform %s not supported" % sys.platform) if __name__ == '__main__': setup( name='reflink', version='0.2.1', description="Python reflink wraps around platform specific reflink implementations", long_description=readme + '\n\n' + history, author="Ruben De Smet", author_email='pypi@rubdos.be', url='https://gitlab.com/rubdos/pyreflink', packages=find_packages(include=['reflink']), include_package_data=True, install_requires=requirements, license="MIT license", zip_safe=False, keywords='reflink', classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Natural Language :: English', "Programming Language :: Python :: 2", 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', ], test_suite='tests', tests_require=test_requirements, setup_requires=setup_requirements, cffi_modules=["reflink/native.py:ffibuilder"] ) reflink-0.2.1/tests/0000755000000000000000000000000013352352473014253 5ustar rootroot00000000000000reflink-0.2.1/tests/__init__.py0000666000000000000000000000007613352352445016372 0ustar rootroot00000000000000# -*- coding: utf-8 -*- """Unit test package for reflink.""" reflink-0.2.1/tests/test_reflink.py0000666000000000000000000000511513352352445017323 0ustar rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- """Tests for `reflink` package.""" import os import random import string import subprocess import sys import unittest import pytest from reflink import reflink from reflink import ReflinkImpossibleError from reflink import supported_at @pytest.fixture def btrfs_volume(tmpdir): path = tmpdir.join("volume") with open(path, 'bw+') as f: f.truncate(512 * 1024 ** 2) process = subprocess.call(["mkfs.btrfs", path]) assert process == 0 yield path os.remove(path) @pytest.fixture def btrfs_mount(tmpdir, btrfs_volume): mount = tmpdir.join("mount") os.mkdir(mount) process = subprocess.call(["mount", btrfs_volume, mount]) assert process == 0 yield mount process = subprocess.call(["umount", btrfs_volume]) assert process == 0 os.rmdir(mount) @pytest.fixture def file_on_mount(btrfs_mount): name = ''.join(random.choices(string.ascii_lowercase, k=8)) path = os.path.join(btrfs_mount, name) with open(path, 'bw+') as f: f.write(''.join(random.choices( string.ascii_lowercase, k=100)).encode('utf-8')) yield path os.remove(path) @pytest.mark.btrfs def test_reflink_with_file(btrfs_mount, file_on_mount): target = os.path.join(btrfs_mount, "target") reflink(file_on_mount, target) assert os.path.isfile(target) @pytest.mark.btrfs def test_reflink(btrfs_mount): source = os.path.join(btrfs_mount, "source") target = os.path.join(btrfs_mount, "target") with pytest.raises(FileNotFoundError): reflink(source, target) assert not os.path.isfile(source) assert not os.path.isfile(target) @pytest.mark.btrfs def test_reflink_unicode(btrfs_mount, file_on_mount): target = os.path.join(btrfs_mount, "❤") reflink(file_on_mount, target) assert os.path.isfile(target) @pytest.mark.btrfs def test_reflink_across_devices(btrfs_mount, file_on_mount, tmpdir): target = os.path.join(tmpdir, "target") with pytest.raises(ReflinkImpossibleError): reflink(file_on_mount, target) assert not os.path.isfile(target) @pytest.mark.btrfs def test_supported_at_btrfs(btrfs_mount): assert supported_at(btrfs_mount) @pytest.mark.btrfs def test_btrfs_permissions(btrfs_mount, file_on_mount): target = os.path.join(btrfs_mount, "target") reflink(file_on_mount, target) a = os.stat(file_on_mount) b = os.stat(target) assert a.st_mode == b.st_mode @unittest.skipUnless(sys.platform in ['linux', 'freebsd'], "No /dev support") def test_not_supported_at_dev(): assert not supported_at("/dev")