]>
git.saurik.com Git - apple/hfs.git/blob - tests/cases/test-external-jnl.c
5 // Created by Chris Suter on 8/11/15.
9 #include <TargetConditionals.h>
11 #if !TARGET_OS_EMBEDDED
14 #include <sys/mount.h>
20 #include "hfs-tests.h"
21 #include "disk-image.h"
23 #include "../core/hfs_format.h"
24 #include "test-utils.h"
26 #define DISK_IMAGE_1 "/tmp/external-jnl1.sparseimage"
27 #define DISK_IMAGE_2 "/tmp/external-jnl2.sparseimage"
31 int run_external_jnl(__unused test_ctx_t
*ctx
)
36 disk_image_t
*di1
= disk_image_create(DISK_IMAGE_1
,
38 .size
= 64 * 1024 * 1024
41 = disk_image_create(DISK_IMAGE_2
,
43 .partition_type
= EXTJNL_CONTENT_TYPE_UUID
,
44 .size
= 8 * 1024 * 1024
47 unmount(di1
->mount_point
, 0);
49 assert(!systemx("/sbin/newfs_hfs", SYSTEMX_QUIET
, "-J", "-D", di2
->disk
, di1
->disk
, NULL
));
51 assert(!systemx("/usr/sbin/diskutil", SYSTEMX_QUIET
, "mount", di1
->disk
, NULL
));
53 free((char *)di1
->mount_point
);
54 di1
->mount_point
= NULL
;
56 struct statfs
*mntbuf
;
57 int i
, n
= getmntinfo(&mntbuf
, 0);
58 for (i
= 0; i
< n
; ++i
) {
59 if (!strcmp(mntbuf
[i
].f_mntfromname
, di1
->disk
)) {
60 di1
->mount_point
= strdup(mntbuf
[i
].f_mntonname
);
68 asprintf(&path
, "%s/test", di1
->mount_point
);
69 int fd
= open(path
, O_RDWR
| O_CREAT
, 0666);
70 assert_with_errno(fd
>= 0);
71 assert_no_err(close(fd
));
72 assert_no_err(unlink(path
));