]> git.saurik.com Git - apple/hfs.git/blob - tests/cases/test-log2phys.m
hfs-556.100.11.tar.gz
[apple/hfs.git] / tests / cases / test-log2phys.m
1 #include <fcntl.h>
2 #include <limits.h>
3 #include <unistd.h>
4 #include <spawn.h>
5 #include <sys/stat.h>
6 #include <TargetConditionals.h>
7
8 #import <Foundation/Foundation.h>
9
10 #include "hfs-tests.h"
11 #include "test-utils.h"
12 #include "disk-image.h"
13
14 TEST(log2phys)
15
16 static disk_image_t *di;
17
18 int run_log2phys(__unused test_ctx_t *ctx)
19 {
20 di = disk_image_get();
21 char *file;
22 asprintf(&file, "%s/log2phys.data", di->mount_point);
23
24 int fd = open(file, O_RDWR | O_CREAT, 0666);
25
26 struct log2phys l2p = {
27 .l2p_contigbytes = OFF_MAX,
28 };
29
30 assert_no_err(ftruncate(fd, 1000));
31 assert_no_err(fcntl(fd, F_LOG2PHYS_EXT, &l2p));
32
33 l2p.l2p_contigbytes = -1;
34 assert_with_errno(fcntl(fd, F_LOG2PHYS_EXT, &l2p) == -1 && errno == EINVAL);
35
36 assert_no_err(close(fd));
37 free(file);
38
39 return 0;
40 }