2 * Copyright (c) 2018 Apple Inc. All rights reserved.
4 * <rdar://problem/3916036> fsctl HFSIOC_GET_VOL_CREATE_TIME does not return volume cteate time.
8 #include "../../core/hfs_fsctl.h"
10 #include "test-utils.h"
11 #include "disk-image.h"
14 * Just as a good measure we add this check so that compilation does
15 * not break when compiled against older hfs_fsctl.h which did not
16 * include HFSIOC_GET_VOL_CREATE_TIME.
18 #if !defined(HFSIOC_GET_VOL_CREATE_TIME)
19 #define HFSIOC_GET_VOL_CREATE_TIME _IOR('h', 4, time_t)
22 TEST(get_volume_create_time
)
24 int run_get_volume_create_time(__unused test_ctx_t
*ctx
)
27 time_t vol_create_time
;
29 di
= disk_image_get();
31 * Volume create date is stored inside volume header in localtime. The
32 * date is stored as 32-bit integer containing the number of seconds
33 * since midnight, January 1, 1904. We can safely assume that create
34 * date set for the volume will not be epoch.
37 assert_no_err(fsctl(di
->mount_point
, HFSIOC_GET_VOL_CREATE_TIME
,
38 &vol_create_time
, 0));
40 assert_fail("fcntl HFSIOC_GET_VOL_CREATE_TIME failed to set "
41 "volume create time.");