1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00
guile/doc
Tomas Volf e1690f3fd2
Add copy-on-write support to scm_copy_file.
On modern file-systems (BTRFS, ZFS) it is possible to copy a file using
copy-on-write method.  For large files it has the advantage of being
much faster and saving disk space (since identical extents are not
duplicated).  This feature is stable and for example coreutils' `cp'
does use it automatically (see --reflink).

This commit adds support for this feature into our copy-file procedure.
Same as `cp', it defaults to 'auto, meaning the copy-on-write is
attempted, and in case of failure the regular copy is performed.

No tests are provided, because the behavior depends on the system,
underlying file-system and its configuration.  That makes it challenging
to write a test for it.  Manual testing was performed instead:

    $ btrfs filesystem du /tmp/cow*
         Total   Exclusive  Set shared  Filename
      36.00KiB    36.00KiB       0.00B  /tmp/cow

    $ cat cow-test.scm
    (copy-file "/tmp/cow" "/tmp/cow-unspecified")
    (copy-file "/tmp/cow" "/tmp/cow-always" #:copy-on-write 'always)
    (copy-file "/tmp/cow" "/tmp/cow-auto" #:copy-on-write 'auto)
    (copy-file "/tmp/cow" "/tmp/cow-never" #:copy-on-write 'never)
    (copy-file "/tmp/cow" "/dev/shm/cow-unspecified")
    (copy-file "/tmp/cow" "/dev/shm/cow-auto" #:copy-on-write 'auto)
    (copy-file "/tmp/cow" "/dev/shm/cow-never" #:copy-on-write 'never)
    $ ./meta/guile -s cow-test.scm

    $ btrfs filesystem du /tmp/cow*
         Total   Exclusive  Set shared  Filename
      36.00KiB       0.00B    36.00KiB  /tmp/cow
      36.00KiB       0.00B    36.00KiB  /tmp/cow-always
      36.00KiB       0.00B    36.00KiB  /tmp/cow-auto
      36.00KiB    36.00KiB       0.00B  /tmp/cow-never
      36.00KiB       0.00B    36.00KiB  /tmp/cow-unspecified

    $ sha1sum /tmp/cow* /dev/shm/cow*
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /tmp/cow
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /tmp/cow-always
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /tmp/cow-auto
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /tmp/cow-never
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /tmp/cow-unspecified
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /dev/shm/cow-auto
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /dev/shm/cow-never
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /dev/shm/cow-unspecified

This commit also adds to new failure modes for (copy-file).

Failure to copy-on-write when 'always was passed in:

    scheme@(guile-user)> (copy-file "/tmp/cow" "/dev/shm/cow" #:copy-on-write 'always)
    ice-9/boot-9.scm:1676:22: In procedure raise-exception:
    In procedure copy-file: copy-on-write failed: Invalid cross-device link

Passing in invalid value for the #:copy-on-write keyword argument:

    scheme@(guile-user)> (copy-file "/tmp/cow" "/dev/shm/cow" #:copy-on-write 'nevr)
    ice-9/boot-9.scm:1676:22: In procedure raise-exception:
    In procedure copy-file: invalid value for #:copy-on-write: nevr

* NEWS: Add note for copy-file supporting copy-on-write.
* configure.ac: Check for linux/fs.h.
* doc/ref/posix.texi (File System)[copy-file]: Document the new
signature.
* libguile/filesys.c (clone_file): New function cloning a file using
FICLONE, if supported.
(k_copy_on_write): New keyword.
(sym_always, sym_auto, sym_never): New symbols.
(scm_copy_file2): Renamed from scm_copy_file.  New #:copy-on-write
keyword argument.  Attempt copy-on-write copy by default.
(scm_copy_file): Call scm_copy_file2.
* libguile/filesys.h: Add scm_copy_file2 as SCM_INTERNAL.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-03-12 14:04:41 +01:00
..
r5rs Revert recent change to r5rs.texi 2023-08-17 14:37:30 +02:00
ref Add copy-on-write support to scm_copy_file. 2024-03-12 14:04:41 +01:00
.gitignore More `.gitignore'. 2008-04-07 23:48:48 +02:00
BUGS Move doc files into guile-core distribution (6) 2001-03-09 09:20:46 +00:00
ChangeLog-2008 Rename ChangeLog' files to ChangeLog-2008'. 2008-09-12 21:49:58 +02:00
ChangeLog-guile-doc Move doc files into guile-core distribution (6) 2001-03-09 09:20:46 +00:00
gendocs_template Update Gnulib to v0.1-5703-g356a414e8c and add 'posix_spawn' module. 2023-01-18 22:50:18 +01:00
gendocs_template_min Update Gnulib to v0.1-5703-g356a414e8c and add 'posix_spawn' module. 2023-01-18 22:50:18 +01:00
goops.mail Initial revision 2000-08-22 15:54:19 +00:00
groupings.alist Change Guile license to LGPLv3+ 2009-06-17 00:22:09 +01:00
guile-api.alist Remove traces of 'scm_memory_error'. 2020-02-10 00:10:10 +01:00
guile.1 Update effective version to 3.0 2017-05-22 14:15:40 +02:00
hacks.el * hacks.el: Some handy helper functions for working on the manual. 1998-10-15 21:48:23 +00:00
Makefile.am Remove doc/example-smob/ 2014-04-28 17:46:59 +02:00
NEWS merge from 1.8 branch 2006-04-16 23:18:55 +00:00
README Remove doc/example-smob/ 2014-04-28 17:46:59 +02:00
recipe-guidelines.txt * Added recipe-guidelines.txt. 2001-04-20 11:20:06 +00:00
release.org Update release.org 2020-01-15 21:15:47 +01:00
texinfo.tex autotooling, version bump to 0.7 2008-05-20 12:10:18 +02:00
THANKS * Grammar fix. 2001-06-27 18:12:46 +00:00
use-cases.fig Created a usecase diagram for Guile. 2001-05-24 08:46:50 +00:00
use-cases.txt Created a usecase diagram for Guile. 2001-05-24 08:46:50 +00:00

This directory contains documentation on the Guile core.         -*-text-*-

The documentation consists of the following manuals.

- The Guile Tutorial (guile-tut.texi) contains a tutorial introduction
  to using Guile.

- The Guile Reference Manual (guile.texi) contains (or is intended to
  contain) reference documentation on all aspects of Guile.

- The Revised^5 Report on the Algorithmic Language Scheme (r5rs.texi).

Please be aware that this is all very much work in progress (apart
from the Revised^5 Report).  Bug reports and contributions are
welcome!

The `sources' directory includes some stuff relevant to the Guile
reference manual, and which may eventually be folded in to it.  It's
not immediately relevant, however, which is why it's not in this
directory.

The Revised^4 Report (r4rs.texi) is no longer in this distribution, as
it is completely superseded by the Revised^5 Report.  If you need to
consult R4RS, it is still widely available, for example at
http://www-swiss.ai.mit.edu/projects/info/SchemeDocs/r4rs/.