Tom Seddon Tom Seddon - 3 months ago 9
C Question

F_SEAL_SEAL undeclared, even when headers are included

I'm trying to use file sealing on Linux. Here's an example C program.

#define _GNU_SOURCE
#include <unistd.h>
#include <fcntl.h>

int main(void) {
(void)F_SEAL_SEAL;
}


You can build it using
gcc -Wall -o ./linux_file_sealing linux_file_sealing.c
or similar.

When I build it, I get an error about
F_SEAL_SEAL
.

gcc -Wall -o ./linux_file_sealing linux_file_sealing.c
linux_file_sealing.c: In function ‘main’:
linux_file_sealing.c:7:19: error: ‘F_SEAL_SEAL’ undeclared (first use in this function)
printf("%d\n",F_SEAL_SEAL);
^
linux_file_sealing.c:7:19: note: each undeclared identifier is reported only once for each function it appears in


I'm including
unistd.h
and
fcntl.h
, as per the man page... so what else should I be doing, and where is that described?

(The man pages just say that sealing is "Linux-specific", but give no further details. This is the reason for including the
GNU_SOURCE
define, which is how you get the other Linux-specific stuff, but for
F_SEAL_SEAL
it seems to make no difference.)

(Ubuntu 16.04 LTS, Linux 4.4.0-36)

Answer

You want

#include <linux/fcntl.h>

instead of

#include <fcntl.h>