Skip to content

Commit d1e2e0e

Browse files
authored
gh-93475: Expose FICLONE and FICLONERANGE constants in fcntl (#93478)
1 parent 46fde1f commit d1e2e0e

File tree

6 files changed

+24
-2
lines changed

6 files changed

+24
-2
lines changed

Doc/library/fcntl.rst

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ descriptor.
5050
constants, which allow to duplicate a file descriptor, the latter setting
5151
``FD_CLOEXEC`` flag in addition.
5252

53+
.. versionchanged:: 3.12
54+
On Linux >= 4.5, the :mod:`fcntl` module exposes the ``FICLONE`` and
55+
``FICLONERANGE`` constants, which allow to share some data of one file with
56+
another file by reflinking on some filesystems (e.g., btrfs, OCFS2, and
57+
XFS). This behavior is commonly referred to as "copy-on-write".
58+
5359
The module defines the following functions:
5460

5561

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Expose ``FICLONE`` and ``FICLONERANGE`` constants in :mod:`fcntl`. Patch by
2+
Illia Volochii.

Modules/fcntlmodule.c

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#ifdef HAVE_SYS_FILE_H
99
#include <sys/file.h>
1010
#endif
11+
#ifdef HAVE_LINUX_FS_H
12+
#include <linux/fs.h>
13+
#endif
1114

1215
#include <sys/ioctl.h>
1316
#include <fcntl.h>
@@ -572,6 +575,12 @@ all_ins(PyObject* m)
572575
#ifdef F_GETPIPE_SZ
573576
if (PyModule_AddIntMacro(m, F_GETPIPE_SZ)) return -1;
574577
#endif
578+
#ifdef FICLONE
579+
if (PyModule_AddIntMacro(m, FICLONE)) return -1;
580+
#endif
581+
#ifdef FICLONERANGE
582+
if (PyModule_AddIntMacro(m, FICLONERANGE)) return -1;
583+
#endif
575584

576585
/* OS X specifics */
577586
#ifdef F_FULLFSYNC

configure

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

+2-1
Original file line numberDiff line numberDiff line change
@@ -2504,7 +2504,8 @@ AC_DEFINE(STDC_HEADERS, 1, [Define to 1 if you have the ANSI C header files.])
25042504
# checks for header files
25052505
AC_CHECK_HEADERS([ \
25062506
alloca.h asm/types.h bluetooth.h conio.h crypt.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \
2507-
ieeefp.h io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/memfd.h linux/random.h linux/soundcard.h \
2507+
ieeefp.h io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/fs.h linux/memfd.h \
2508+
linux/random.h linux/soundcard.h \
25082509
linux/tipc.h linux/wait.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty.h \
25092510
sched.h setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \
25102511
sys/endian.h sys/epoll.h sys/event.h sys/eventfd.h sys/file.h sys/ioctl.h sys/kern_control.h \

pyconfig.h.in

+3
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,9 @@
685685
/* Define if compiling using Linux 4.1 or later. */
686686
#undef HAVE_LINUX_CAN_RAW_JOIN_FILTERS
687687

688+
/* Define to 1 if you have the <linux/fs.h> header file. */
689+
#undef HAVE_LINUX_FS_H
690+
688691
/* Define to 1 if you have the <linux/memfd.h> header file. */
689692
#undef HAVE_LINUX_MEMFD_H
690693

0 commit comments

Comments
 (0)