mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-07-02 14:07:34 +03:00

In CentOS 7.5 the kernel provided a compatibility wrapper to support O_TMPFILE. This results in the test setup script correctly detecting kernel support. But the ZFS module was built without O_TMPFILE support due to the non-standard CentOS kernel interface. Handle this case by updating the setup check to fail either when the kernel or the ZFS module fail to provide support. The reason will be clearly logged in the test results. Reviewed-by: Chunwei Chen <tuxoko@gmail.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #7528
54 lines
982 B
C
54 lines
982 B
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <errno.h>
|
|
|
|
/* backward compat in case it's not defined */
|
|
#ifndef O_TMPFILE
|
|
#define O_TMPFILE (020000000|O_DIRECTORY)
|
|
#endif
|
|
|
|
/*
|
|
* DESCRIPTION:
|
|
* Check if the kernel support O_TMPFILE.
|
|
*/
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
int fd;
|
|
struct stat buf;
|
|
|
|
if (argc < 2) {
|
|
fprintf(stderr, "Usage: %s dir\n", argv[0]);
|
|
return (2);
|
|
}
|
|
if (stat(argv[1], &buf) < 0) {
|
|
perror("stat");
|
|
return (2);
|
|
}
|
|
if (!S_ISDIR(buf.st_mode)) {
|
|
fprintf(stderr, "\"%s\" is not a directory\n", argv[1]);
|
|
return (2);
|
|
}
|
|
|
|
fd = open(argv[1], O_TMPFILE | O_WRONLY, 0666);
|
|
if (fd < 0) {
|
|
if (errno == EISDIR) {
|
|
fprintf(stderr,
|
|
"The kernel doesn't support O_TMPFILE\n");
|
|
return (1);
|
|
} else if (errno == EOPNOTSUPP) {
|
|
fprintf(stderr,
|
|
"The filesystem doesn't support O_TMPFILE\n");
|
|
return (2);
|
|
}
|
|
perror("open");
|
|
} else {
|
|
close(fd);
|
|
}
|
|
return (0);
|
|
}
|