]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/filesystem/test/issues/fchmodat_AT_SYMLINK_NOFOLLOW_6659.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / filesystem / test / issues / fchmodat_AT_SYMLINK_NOFOLLOW_6659.cpp
CommitLineData
7c673cae
FG
1// Test program to demonstrate that Linux does not support AT_SYMLINK_NOFOLLOW
2
3// Copyright Duncan Exon Smith 2012
4
5// Distributed under the Boost Software License, Version 1.0.
6// See http://www.boost.org/LICENSE_1_0.txt
7
8// Test this by running:
9//
10// rm -rf data && mkdir data && g++ -otest-fchmodat fchmodat_AT_SYMLINK_NOFOLLOW_6659.cpp && (cd data && ../test-fchmodat)
11//
12// If no assertions go off, then it looks like fchmodat is supported,
13// but AT_SYMLINK_NOFOLLOW is not supported.
14
15#include <fstream>
16#include <cassert>
17#include <fcntl.h>
18#include <sys/stat.h>
19#include <cerrno>
20
21#ifdef NDEBUG
1e59de90 22#error This program depends on assert() so makes no sense if NDEBUG is defined
7c673cae
FG
23#endif
24
1e59de90 25int main(int argc, char* argv[])
7c673cae 26{
1e59de90
TL
27 {
28 std::ofstream file("out");
29 file << "contents";
30 }
7c673cae
FG
31
32 assert(!::symlink("out", "sym"));
33
34 assert(!::fchmodat(AT_FDCWD, "out", S_IRUSR | S_IWUSR | S_IXUSR, 0));
35 assert(!::fchmodat(AT_FDCWD, "sym", S_IRUSR | S_IWUSR | S_IXUSR, 0));
36
37 assert(::fchmodat(AT_FDCWD, "sym", S_IRUSR | S_IWUSR | S_IXUSR, AT_SYMLINK_NOFOLLOW) == -1);
38 assert(errno == ENOTSUP);
39
40 return 0;
41}