Skip to content

Commit 1d80a57

Browse files
authored
IOCTL definitions to fix compilation on FreeBSD
1 parent 2c088b6 commit 1d80a57

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

fuseparts/_fusemodule.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,45 @@
2828
#include <Python.h>
2929
#include <fuse.h>
3030
#include <sys/ioctl.h>
31+
#ifndef _UAPI_ASM_GENERIC_IOCTL_H
32+
/* Essential IOCTL defitions from Linux /include/uapi/asm-generic/ioctl.h
33+
to fix compilation errors on FreeBSD
34+
Mikhail Zakharov <zmey20000@thoo.com> 2018.10.22 */
35+
36+
#define _IOC_NRBITS 8
37+
#define _IOC_TYPEBITS 8
38+
39+
#ifndef _IOC_SIZEBITS
40+
# define _IOC_SIZEBITS 14
41+
#endif
42+
43+
#ifndef _IOC_DIRBITS
44+
# define _IOC_DIRBITS 2
45+
#endif
46+
47+
#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
48+
#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
49+
50+
#define _IOC_NRSHIFT 0
51+
#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
52+
#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
53+
#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
54+
55+
#ifndef _IOC_NONE
56+
# define _IOC_NONE 0U
57+
#endif
58+
59+
#ifndef _IOC_WRITE
60+
# define _IOC_WRITE 1U
61+
#endif
62+
63+
#ifndef _IOC_READ
64+
# define _IOC_READ 2U
65+
#endif
66+
67+
#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
68+
#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
69+
#endif
3170

3271

3372
#ifndef FUSE_VERSION

0 commit comments

Comments
 (0)