mergerfs/src/fs_getdents64.cpp
trapexit 2f3e807e9d
Some checks failed
CodeQL / Analyze (push) Has been cancelled
mkdocs / deploy (push) Has been cancelled
Add getdents based readdir functions for Linux (#1533)
2025-09-23 23:51:21 -05:00

44 lines
1.2 KiB
C++

/*
ISC License
Copyright (c) 2020, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "to_neg_errno.hpp"
#if defined __linux__
#include <unistd.h>
#include <sys/syscall.h>
#endif
namespace fs
{
ssize_t
getdents64(const int fd_,
void *dirp_,
const size_t count_)
{
#if defined SYS_getdents64
ssize_t rv;
rv = ::syscall(SYS_getdents64,fd_,dirp_,count_);
return ::to_neg_errno(rv);
#else
return -ENOTSUP;
#endif
}
}