2 * Copyright (c) 2016 Apple, Inc. All rights reserved.
4 * Test HFS defrag fsctls
8 #include <sys/ioccom.h>
10 #include <sys/mount.h>
15 #include <sys/errno.h>
20 #include "../../core/hfs_fsctl.h"
21 #include "hfs-tests.h"
22 #include "test-utils.h"
24 #include "disk-image.h"
26 TEST(defrag
, .run_as_root
= true)
28 int run_defrag(__unused test_ctx_t
*ctx
)
31 // The root file system needs to be HFS
34 assert(statfs("/tmp", &sfs
) == 0);
35 if (strcmp(sfs
.f_fstypename
, "hfs")) {
36 printf("test-defrag needs hfs as root file system - skipping.\n");
40 /* These two should pass */
41 uint32_t enable_defrag
= 1;
42 assert_no_err(fsctl("/tmp", HFSIOC_FORCE_ENABLE_DEFRAG
, &enable_defrag
, 0));
44 uint32_t max_file_size
= 50 * 1024 * 1024;
45 assert_no_err(fsctl("/tmp", HFSIOC_SET_MAX_DEFRAG_SIZE
, &max_file_size
, 0));
47 /* This should fail */
48 max_file_size
= 500 * 1024 * 1024;
49 int err
= fsctl("/tmp", HFSIOC_SET_MAX_DEFRAG_SIZE
, &max_file_size
, 0);