HUGETLBFS_UNLINKED_FD(3)
π HUGETLBFS_UNLINKED_FD π
okay bestie, so this one is a Library Functions Manual page (section 3, we love a (3)), and it's all about two little functions: hugetlbfs_unlinked_fd and hugetlbfs_unlinked_fd_for_size. their whole job? getting you a file descriptor for a brand new unlinked file in hugetlbfs. that's it, that's the gig. π
β¨ NAME β¨
hugetlbfs_unlinked_fd, hugetlbfs_unlinked_fd_for_size β Obtain a file descriptor for a new unlinked file in hugetlbfs
no cap, that's literally what they do. π
πΈ SYNOPSIS πΈ
#include <hugetlbfs.h>
int hugetlbfs_unlinked_fd(void);
int hugetlbfs_unlinked_fd_for_size(long page_size);
look at those signatures, they're so clean, they're giving minimalist icon. β¨
π¦ DESCRIPTION π¦
so these functions hand you back an open file descriptor for a unique, newly-created file sitting in a hugetlbfs filesystem. and here's the part that's actually the whole point β to avoid leaking hugepages, the file gets unlinked automatically before the function returns. so by the time you even have the fd in your hands, the directory entry is already gone. it's giving commitment issues but make it responsible. π
for hugetlbfs_unlinked_fd, it just uses the default huge page size (go check gethugepagesize(3) for that one).
for hugetlbfs_unlinked_fd_for_size, you must pass in a valid huge page size (peep gethugepagesizes(3) for the list of what counts as valid). so like, pick a real one, bestie. π«Ά
π₯ RETURN VALUE π₯
- on success, you get a valid open file descriptor back. iconic, we love that for you. π
- on failure,
-1gets returned, anderrnomay be set appropriately. so like, check it. don't be that person. π
π SEE ALSO π
gethugepagesize(3), gethugepagesizes(3), mkstemp(3), libhugetlbfs(7)
go read those too, they're the supporting cast and they ate. π
π AUTHORS π
libhugetlbfs was written by various people on the libhugetlbfs-devel mailing list. a whole committee of legends, honestly. π
quick reminder bestie: thoselong page_sizevibes are not optional for the_for_sizeone. it needs a valid huge page size or it's not gonna have a good time. no guessing, no vibes-based page sizes. π«
and that's the whole page!! mwah π this version is dated March 7, 2012, straight from the Library Functions Manual era, and it covers HUGETLBFS_UNLINKED_FD(3) β stay hydrated, unlink responsibly, and slay π§π
π¦ where this page comes from
- debian bookworm: libhugetlbfs-dev 2.23-5 Β· LGPL-2.1-only
- debian trixie: libhugetlbfs-dev 2.24-1+b1 Β· LGPL-2.1-only
- nixpkgs unstable: libhugetlbfs 2.24
- opensuse-leap 16.0: libhugetlbfs-devel 2.24.0.g1322884-160000.3.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libhugetlbfs-devel 2.24.0.g1322884-160000.3.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libhugetlbfs-devel 2.24.0.g1322884-160000.3.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libhugetlbfs-devel 2.24.0.g1322884-160000.3.2 Β· LGPL-2.1-or-later
- ubuntu jammy: libhugetlbfs-dev 2.23-4 Β· LGPL-2.1-only
- ubuntu noble: libhugetlbfs-dev 2.23-5build1 Β· LGPL-2.1-only
- ubuntu questing: libhugetlbfs-dev 2.24-1
- ubuntu resolute: libhugetlbfs-dev 2.24-1build1 Β· LGPL-2.1-only
- ubuntu stonking: libhugetlbfs-dev 2.24-1build1 Β· LGPL-2.1-only
- Copyright 2012 Cray Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms