mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
Fix compilation error with recent XFS headers.
Merge of master-melb:xfs-cmds:24584a by kenmcd.
This commit is contained in:
+38
-40
@@ -41,13 +41,11 @@
|
|||||||
#include <xfs/libxfs.h>
|
#include <xfs/libxfs.h>
|
||||||
#include <xfs/handle.h>
|
#include <xfs/handle.h>
|
||||||
#include <xfs/jdm.h>
|
#include <xfs/jdm.h>
|
||||||
#include <ext2fs/ext2_fs.h>
|
|
||||||
|
|
||||||
|
#define EXT2_SUPER_MAGIC 0xEF53
|
||||||
#define XFS_XFLAG_IMMUTABLE 0x00000008
|
|
||||||
#define XFS_XFLAG_APPEND 0x00000010
|
|
||||||
#define EXT2_IMMUTABLE_FL 0x00000010
|
#define EXT2_IMMUTABLE_FL 0x00000010
|
||||||
#define EXT2_APPEND_FL 0x00000020
|
#define EXT2_APPEND_FL 0x00000020
|
||||||
|
#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
|
||||||
|
|
||||||
extern const char *__progname;
|
extern const char *__progname;
|
||||||
|
|
||||||
@@ -86,7 +84,7 @@ static int fsetflag(const char *path, int fd, int on, int immutable)
|
|||||||
} else if (stfs.f_type == EXT2_SUPER_MAGIC) {
|
} else if (stfs.f_type == EXT2_SUPER_MAGIC) {
|
||||||
if (on)
|
if (on)
|
||||||
e2flags |= e2fl;
|
e2flags |= e2fl;
|
||||||
else
|
else
|
||||||
e2flags &= ~e2fl;
|
e2flags &= ~e2fl;
|
||||||
if (ioctl(fd, EXT2_IOC_SETFLAGS, &e2flags) < 0) {
|
if (ioctl(fd, EXT2_IOC_SETFLAGS, &e2flags) < 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
@@ -586,7 +584,7 @@ static int test_immutable(const char *dir)
|
|||||||
|
|
||||||
asprintf(&linkpath, "%s/immutable.d/file.link", dir);
|
asprintf(&linkpath, "%s/immutable.d/file.link", dir);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (link(path, linkpath) != -1) {
|
if (link(path, linkpath) != -1) {
|
||||||
fprintf(stderr, "link(%s, %s) did not fail\n", path, linkpath);
|
fprintf(stderr, "link(%s, %s) did not fail\n", path, linkpath);
|
||||||
fail++;
|
fail++;
|
||||||
unlink(linkpath);
|
unlink(linkpath);
|
||||||
@@ -639,7 +637,7 @@ static int test_immutable(const char *dir)
|
|||||||
fprintf(stderr, "mknod(%s, S_IFCHR|0666, %lld) did not fail\n", path, (long long int)st.st_rdev);
|
fprintf(stderr, "mknod(%s, S_IFCHR|0666, %lld) did not fail\n", path, (long long int)st.st_rdev);
|
||||||
fail++;
|
fail++;
|
||||||
unlink(path);
|
unlink(path);
|
||||||
} else if (errno != EACCES) {
|
} else if (errno != EACCES) {
|
||||||
fprintf(stderr, "mknod(%s, S_IFCHR|0666, %lld) did not set errno == EACCESS\n", path, (long long int)st.st_rdev);
|
fprintf(stderr, "mknod(%s, S_IFCHR|0666, %lld) did not set errno == EACCESS\n", path, (long long int)st.st_rdev);
|
||||||
fail++;
|
fail++;
|
||||||
}
|
}
|
||||||
@@ -657,7 +655,7 @@ static int test_immutable(const char *dir)
|
|||||||
fprintf(stderr, "mkdir(%s, 0777) did not set errno == EACCES\n", path);
|
fprintf(stderr, "mkdir(%s, 0777) did not set errno == EACCES\n", path);
|
||||||
fail++;
|
fail++;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(path);
|
free(path);
|
||||||
asprintf(&path, "%s/immutable.d/dir/newfile-%d", dir, getuid());
|
asprintf(&path, "%s/immutable.d/dir/newfile-%d", dir, getuid());
|
||||||
if ((fd = open(path, O_RDWR|O_CREAT, 0666)) == -1) {
|
if ((fd = open(path, O_RDWR|O_CREAT, 0666)) == -1) {
|
||||||
@@ -818,7 +816,7 @@ static int test_immutable(const char *dir)
|
|||||||
} else if (errno != EPERM) {
|
} else if (errno != EPERM) {
|
||||||
fprintf(stderr, "rmdir(%s) did not set errno == EPERM\n", path);
|
fprintf(stderr, "rmdir(%s) did not set errno == EPERM\n", path);
|
||||||
fail++;
|
fail++;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(path);
|
free(path);
|
||||||
return fail;
|
return fail;
|
||||||
@@ -1534,7 +1532,7 @@ static int test_append(const char *dir)
|
|||||||
|
|
||||||
asprintf(&linkpath, "%s/append-only.d/file.link-%d", dir, getuid());
|
asprintf(&linkpath, "%s/append-only.d/file.link-%d", dir, getuid());
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (link(path, linkpath) == -1) {
|
if (link(path, linkpath) == -1) {
|
||||||
fprintf(stderr, "link(%s, %s) failed: %s\n", path, linkpath, strerror(errno));
|
fprintf(stderr, "link(%s, %s) failed: %s\n", path, linkpath, strerror(errno));
|
||||||
fail++;
|
fail++;
|
||||||
} else if (unlink(linkpath) != -1) {
|
} else if (unlink(linkpath) != -1) {
|
||||||
@@ -1591,7 +1589,7 @@ static int test_append(const char *dir)
|
|||||||
if (mknod(path, S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH, st.st_rdev) == -1) {
|
if (mknod(path, S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH, st.st_rdev) == -1) {
|
||||||
fprintf(stderr, "mknod(%s, S_IFCHR|0666, %lld) failed: %s\n", path, (long long int)st.st_rdev, strerror(errno));
|
fprintf(stderr, "mknod(%s, S_IFCHR|0666, %lld) failed: %s\n", path, (long long int)st.st_rdev, strerror(errno));
|
||||||
fail++;
|
fail++;
|
||||||
} else if (unlink(path) != -1) {
|
} else if (unlink(path) != -1) {
|
||||||
fprintf(stderr, "unlink(%s) did not fail\n", path);
|
fprintf(stderr, "unlink(%s) did not fail\n", path);
|
||||||
fail++;
|
fail++;
|
||||||
}
|
}
|
||||||
@@ -1607,7 +1605,7 @@ static int test_append(const char *dir)
|
|||||||
fprintf(stderr, "rmdir(%s) did not fail\n", path);
|
fprintf(stderr, "rmdir(%s) did not fail\n", path);
|
||||||
fail++;
|
fail++;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(path);
|
free(path);
|
||||||
asprintf(&path, "%s/append-only.d/newdir-%d/newfile-%d", dir, getuid(), getuid());
|
asprintf(&path, "%s/append-only.d/newdir-%d/newfile-%d", dir, getuid(), getuid());
|
||||||
if ((fd = open(path, O_RDWR|O_CREAT, 0666)) == -1) {
|
if ((fd = open(path, O_RDWR|O_CREAT, 0666)) == -1) {
|
||||||
@@ -1633,7 +1631,7 @@ static int test_append(const char *dir)
|
|||||||
} else
|
} else
|
||||||
chown(path, 0, 0);
|
chown(path, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(path);
|
free(path);
|
||||||
asprintf(&path, "%s/append-only.d/dir/newfile-%d", dir, getuid());
|
asprintf(&path, "%s/append-only.d/dir/newfile-%d", dir, getuid());
|
||||||
if ((fd = open(path, O_RDWR|O_CREAT, 0666)) == -1) {
|
if ((fd = open(path, O_RDWR|O_CREAT, 0666)) == -1) {
|
||||||
@@ -1790,7 +1788,7 @@ static int test_append(const char *dir)
|
|||||||
} else if (errno != EPERM) {
|
} else if (errno != EPERM) {
|
||||||
fprintf(stderr, "rmdir(%s) did not set errno == EPERM\n", path);
|
fprintf(stderr, "rmdir(%s) did not set errno == EPERM\n", path);
|
||||||
fail++;
|
fail++;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(path);
|
free(path);
|
||||||
return fail;
|
return fail;
|
||||||
@@ -1873,7 +1871,7 @@ static int check_test_area(const char *dir)
|
|||||||
__progname, path);
|
__progname, path);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(path);
|
free(path);
|
||||||
asprintf(&path, "%s/append-only.d/file", dir);
|
asprintf(&path, "%s/append-only.d/file", dir);
|
||||||
if (stat(path, &st) == -1) {
|
if (stat(path, &st) == -1) {
|
||||||
@@ -1928,7 +1926,7 @@ static int create_test_area(const char *dir)
|
|||||||
if (getuid()) {
|
if (getuid()) {
|
||||||
fprintf(stderr, "%s: you are not root, go away.\n", __progname);
|
fprintf(stderr, "%s: you are not root, go away.\n", __progname);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat(dir, &st) == 0) {
|
if (stat(dir, &st) == 0) {
|
||||||
fprintf(stderr, "%s: Test area directory %s must not exist for test area creation.\n",
|
fprintf(stderr, "%s: Test area directory %s must not exist for test area creation.\n",
|
||||||
@@ -1949,35 +1947,35 @@ static int create_test_area(const char *dir)
|
|||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
asprintf(&path, "%s/empty-immutable.d", dir);
|
asprintf(&path, "%s/empty-immutable.d", dir);
|
||||||
if (mkdir(path, 0777) != 0) {
|
if (mkdir(path, 0777) != 0) {
|
||||||
fprintf(stderr, "%s: error creating directory %s: %s\n", __progname, path, strerror(errno));
|
fprintf(stderr, "%s: error creating directory %s: %s\n", __progname, path, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
asprintf(&path, "%s/append-only.d", dir);
|
asprintf(&path, "%s/append-only.d", dir);
|
||||||
if (mkdir(path, 0777) != 0) {
|
if (mkdir(path, 0777) != 0) {
|
||||||
fprintf(stderr, "%s: error creating directory %s: %s\n", __progname, path, strerror(errno));
|
fprintf(stderr, "%s: error creating directory %s: %s\n", __progname, path, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
asprintf(&path, "%s/empty-append-only.d", dir);
|
asprintf(&path, "%s/empty-append-only.d", dir);
|
||||||
if (mkdir(path, 0777) != 0) {
|
if (mkdir(path, 0777) != 0) {
|
||||||
fprintf(stderr, "%s: error creating directory %s: %s\n", __progname, path, strerror(errno));
|
fprintf(stderr, "%s: error creating directory %s: %s\n", __progname, path, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
asprintf(&path, "%s/immutable.d/dir", dir);
|
asprintf(&path, "%s/immutable.d/dir", dir);
|
||||||
if (mkdir(path, 0777) != 0) {
|
if (mkdir(path, 0777) != 0) {
|
||||||
fprintf(stderr, "%s: error creating directory %s: %s\n", __progname, path, strerror(errno));
|
fprintf(stderr, "%s: error creating directory %s: %s\n", __progname, path, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
asprintf(&path, "%s/append-only.d/dir", dir);
|
asprintf(&path, "%s/append-only.d/dir", dir);
|
||||||
if (mkdir(path, 0777) != 0) {
|
if (mkdir(path, 0777) != 0) {
|
||||||
fprintf(stderr, "%s: error creating directory %s: %s\n", __progname, path, strerror(errno));
|
fprintf(stderr, "%s: error creating directory %s: %s\n", __progname, path, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
@@ -2030,7 +2028,7 @@ static int create_test_area(const char *dir)
|
|||||||
close(fd);
|
close(fd);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
asprintf(&path, "%s/append-only.f", dir);
|
asprintf(&path, "%s/append-only.f", dir);
|
||||||
@@ -2095,7 +2093,7 @@ static int create_test_area(const char *dir)
|
|||||||
close(fd);
|
close(fd);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
asprintf(&path, "%s/empty-immutable.d", dir);
|
asprintf(&path, "%s/empty-immutable.d", dir);
|
||||||
if ((fd = open(path, O_RDONLY)) == -1) {
|
if ((fd = open(path, O_RDONLY)) == -1) {
|
||||||
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
@@ -2105,10 +2103,10 @@ static int create_test_area(const char *dir)
|
|||||||
close(fd);
|
close(fd);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
asprintf(&path, "%s/append-only.d", dir);
|
asprintf(&path, "%s/append-only.d", dir);
|
||||||
if ((fd = open(path, O_RDONLY)) == -1) {
|
if ((fd = open(path, O_RDONLY)) == -1) {
|
||||||
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
@@ -2134,10 +2132,10 @@ static int create_test_area(const char *dir)
|
|||||||
close(fd);
|
close(fd);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
asprintf(&path, "%s/empty-append-only.d", dir);
|
asprintf(&path, "%s/empty-append-only.d", dir);
|
||||||
if ((fd = open(path, O_RDONLY)) == -1) {
|
if ((fd = open(path, O_RDONLY)) == -1) {
|
||||||
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
@@ -2147,7 +2145,7 @@ static int create_test_area(const char *dir)
|
|||||||
close(fd);
|
close(fd);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
free(path);
|
free(path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2175,44 +2173,44 @@ static int remove_test_area(const char *dir)
|
|||||||
if ((fd = open(path, O_RDONLY)) == -1) {
|
if ((fd = open(path, O_RDONLY)) == -1) {
|
||||||
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
||||||
err = 1;
|
err = 1;
|
||||||
} else {
|
} else {
|
||||||
if (fsetflag(path, fd, 0, 1))
|
if (fsetflag(path, fd, 0, 1))
|
||||||
perror("fsetflag");
|
perror("fsetflag");
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
asprintf(&path, "%s/empty-immutable.d", dir);
|
asprintf(&path, "%s/empty-immutable.d", dir);
|
||||||
if ((fd = open(path, O_RDONLY)) == -1) {
|
if ((fd = open(path, O_RDONLY)) == -1) {
|
||||||
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
||||||
err = 1;
|
err = 1;
|
||||||
} else {
|
} else {
|
||||||
if (fsetflag(path, fd, 0, 1))
|
if (fsetflag(path, fd, 0, 1))
|
||||||
perror("fsetflag");
|
perror("fsetflag");
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
asprintf(&path, "%s/append-only.d", dir);
|
asprintf(&path, "%s/append-only.d", dir);
|
||||||
if ((fd = open(path, O_RDONLY)) == -1) {
|
if ((fd = open(path, O_RDONLY)) == -1) {
|
||||||
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
||||||
err = 1;
|
err = 1;
|
||||||
} else {
|
} else {
|
||||||
if (fsetflag(path, fd, 0, 0))
|
if (fsetflag(path, fd, 0, 0))
|
||||||
perror("fsetflag");
|
perror("fsetflag");
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
asprintf(&path, "%s/empty-append-only.d", dir);
|
asprintf(&path, "%s/empty-append-only.d", dir);
|
||||||
if ((fd = open(path, O_RDONLY)) == -1) {
|
if ((fd = open(path, O_RDONLY)) == -1) {
|
||||||
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
fprintf(stderr, "%s: error opening %s: %s\n", __progname, path, strerror(errno));
|
||||||
err = 1;
|
err = 1;
|
||||||
} else {
|
} else {
|
||||||
if (fsetflag(path, fd, 0, 0))
|
if (fsetflag(path, fd, 0, 0))
|
||||||
perror("fsetflag");
|
perror("fsetflag");
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
@@ -2224,7 +2222,7 @@ static int remove_test_area(const char *dir)
|
|||||||
if (fsetflag(path, fd, 0, 0))
|
if (fsetflag(path, fd, 0, 0))
|
||||||
perror("fsetflag");
|
perror("fsetflag");
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
@@ -2235,7 +2233,7 @@ static int remove_test_area(const char *dir)
|
|||||||
} else {
|
} else {
|
||||||
if (fsetflag(path, fd, 0, 1))
|
if (fsetflag(path, fd, 0, 1))
|
||||||
perror("fsetflag");
|
perror("fsetflag");
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
@@ -2316,7 +2314,7 @@ int main(int argc, char **argv)
|
|||||||
puts("PASS.");
|
puts("PASS.");
|
||||||
|
|
||||||
if (!getuid() && !failed) {
|
if (!getuid() && !failed) {
|
||||||
if (setgroups(0, NULL) != 0)
|
if (setgroups(0, NULL) != 0)
|
||||||
perror("setgroups");
|
perror("setgroups");
|
||||||
if (setgid(65534) != 0)
|
if (setgid(65534) != 0)
|
||||||
perror("setgid");
|
perror("setgid");
|
||||||
@@ -2328,7 +2326,7 @@ int main(int argc, char **argv)
|
|||||||
failed = 1;
|
failed = 1;
|
||||||
} else
|
} else
|
||||||
puts("PASS.");
|
puts("PASS.");
|
||||||
|
|
||||||
printf("testing append-only as non-root...");
|
printf("testing append-only as non-root...");
|
||||||
if ((ret = test_append(argv[argc-1])) != 0) {
|
if ((ret = test_append(argv[argc-1])) != 0) {
|
||||||
printf("FAILED! (%d tests failed)\n", ret);
|
printf("FAILED! (%d tests failed)\n", ret);
|
||||||
|
|||||||
Reference in New Issue
Block a user