Skip to content

Commit b763d73

Browse files
authored
sys::memfd additional flags related to the hugetlb filesystem support. (#2252)
1 parent da45140 commit b763d73

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

changelog/2252.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added new `MemFdCreateFlag` constants to `sys::memfd` on Linux and Android related to hugetlbfs support.

src/sys/memfd.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,49 @@ libc_bitflags!(
2929
///
3030
/// [`memfd_create(2)`]: https://man7.org/linux/man-pages/man2/memfd_create.2.html
3131
MFD_ALLOW_SEALING;
32+
/// Anonymous file will be created using huge pages. It should be safe now to
33+
/// combine with [`MFD_ALLOW_SEALING`] too.
34+
/// However, despite its presence, on FreeBSD it is unimplemented for now (ENOSYS).
35+
///
36+
/// See also the hugetlb filesystem in [`memfd_create(2)`].
37+
///
38+
/// [`memfd_create(2)`]: https://man7.org/linux/man-pages/man2/memfd_create.2.html
39+
#[cfg(linux_android)]
40+
MFD_HUGETLB;
41+
/// Following are to be used with [`MFD_HUGETLB`], indicating the desired hugetlb size.
42+
///
43+
/// See also the hugetlb filesystem in [`memfd_create(2)`].
44+
///
45+
/// [`memfd_create(2)`]: https://man7.org/linux/man-pages/man2/memfd_create.2.html
46+
#[cfg(linux_android)]
47+
MFD_HUGE_1MB;
48+
/// hugetlb size of 2MB.
49+
#[cfg(linux_android)]
50+
MFD_HUGE_2MB;
51+
/// hugetlb size of 8MB.
52+
#[cfg(linux_android)]
53+
MFD_HUGE_8MB;
54+
/// hugetlb size of 16MB.
55+
#[cfg(linux_android)]
56+
MFD_HUGE_16MB;
57+
/// hugetlb size of 32MB.
58+
#[cfg(linux_android)]
59+
MFD_HUGE_32MB;
60+
/// hugetlb size of 256MB.
61+
#[cfg(linux_android)]
62+
MFD_HUGE_256MB;
63+
/// hugetlb size of 512MB.
64+
#[cfg(linux_android)]
65+
MFD_HUGE_512MB;
66+
/// hugetlb size of 1GB.
67+
#[cfg(linux_android)]
68+
MFD_HUGE_1GB;
69+
/// hugetlb size of 2GB.
70+
#[cfg(linux_android)]
71+
MFD_HUGE_2GB;
72+
/// hugetlb size of 16GB.
73+
#[cfg(linux_android)]
74+
MFD_HUGE_16GB;
3275
}
3376
);
3477

0 commit comments

Comments
 (0)