1 module core.sys.linux.fcntl;
2 
3 public import core.sys.posix.fcntl;
4 
5 version (linux):
6 extern(C):
7 nothrow:
8 
9 // From linux/falloc.h
10 /// fallocate(2) params
11 enum {
12     /// Allocates and initializes to zero the disk space
13     /// within the specified range, but the file size
14     /// will not be modified.
15     FALLOC_FL_KEEP_SIZE = 0x01,
16     /// Deallocates space (i.e. creates a hole)
17     FALLOC_FL_PUNCH_HOLE = 0x02,
18     /// Newly allocated blocks will be marked as initialized.
19     FALLOC_FL_NO_HIDE_STALE = 0x04,
20     /// Removes a byte range from a file, without leaving a hole
21     FALLOC_FL_COLLAPSE_RANGE = 0x08,
22     /// Zeroes space in the specified byte range
23     FALLOC_FL_ZERO_RANGE = 0x10,
24     /// Increases the file space by inserting a hole
25     /// without overwriting any existing data
26     FALLOC_FL_INSERT_RANGE = 0x20,
27     /// Used to unshare shared blocks within
28     /// the file size without overwriting any existing data
29     FALLOC_FL_UNSHARE_RANGE = 0x40
30 }
31 
32 // From asm-generic/fcntl.h
33 /**
34 
35 Open File Description locks
36 
37 Usually record locks held by a process are released on *any* close and are
38 not inherited across a fork().
39 
40 These cmd values will set locks that conflict with process-associated
41 record  locks, but are "owned" by the open file description, not the
42 process. This means that they are inherited across fork() like BSD (flock)
43 locks, and they are only released automatically when the last reference to
44 the open file against which they were acquired is put.
45 
46 */
47 enum
48 {
49     /// Queries the system if the lock could be placed
50     F_OFD_GETLK  = 36,
51     /// Acquires or releases an open file description lock
52     F_OFD_SETLK  = 37,
53     /// Same as F_OFD_SETLK, but waits if a conflicting lock is held on the file
54     F_OFD_SETLKW = 38
55 }
56 
57 // Linux-specific fallocate
58 // (http://man7.org/linux/man-pages/man2/fallocate.2.html)
59 int fallocate(int fd, int mode, off_t offset, off_t len);