]>
git.saurik.com Git - apple/hfs.git/blob - tests/cases/test-sparse-dev.c
5 // Created by Chris Suter on 8/14/15.
9 #include <TargetConditionals.h>
11 #if !TARGET_OS_EMBEDDED
13 #include <sys/mount.h>
14 #include <sys/fcntl.h>
17 #include "hfs-tests.h"
18 #include "disk-image.h"
19 #include "test-utils.h"
23 int run_sparse_dev(__unused test_ctx_t
*ctx
)
25 disk_image_t
*di
= disk_image_create("/tmp/sparse-dev.sparseimage",
26 &(disk_image_opts_t
) {
27 .size
= 64 * 1024 * 1024
31 asprintf(&path
, "%s/child.sparseimage", di
->mount_point
);
33 disk_image_t
*child
= disk_image_create(path
,
34 &(disk_image_opts_t
) {
35 .size
= 256 * 1024 * 1024
40 asprintf(&path
, "%s/test.file", child
->mount_point
);
42 int fd
= open(path
, O_CREAT
| O_RDWR
, 0777);
43 assert_with_errno(fd
>= 0);
45 assert(ftruncate(fd
, 128 * 1024 * 1024) == -1 && errno
== ENOSPC
);
48 assert_no_err(statfs(child
->mount_point
, &sfs
));
50 assert(sfs
.f_bfree
* sfs
.f_bsize
< 64 * 1024 * 1024);
53 assert_no_err (close(fd
));
58 #endif // !TARGET_OS_EMBEDDED