]> git.saurik.com Git - apple/hfs.git/blob - tests/cases/test-get-volume-create-time.c
hfs-522.0.9.tar.gz
[apple/hfs.git] / tests / cases / test-get-volume-create-time.c
1 /*
2 * Copyright (c) 2018 Apple Inc. All rights reserved.
3 *
4 * <rdar://problem/3916036> fsctl HFSIOC_GET_VOL_CREATE_TIME does not return volume cteate time.
5 */
6 #include <unistd.h>
7
8 #include "../../core/hfs_fsctl.h"
9 #include "hfs-tests.h"
10 #include "test-utils.h"
11 #include "disk-image.h"
12
13 /*
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.
17 */
18 #if !defined(HFSIOC_GET_VOL_CREATE_TIME)
19 #define HFSIOC_GET_VOL_CREATE_TIME _IOR('h', 4, time_t)
20 #endif
21
22 TEST(get_volume_create_time)
23
24 int run_get_volume_create_time(__unused test_ctx_t *ctx)
25 {
26 disk_image_t *di;
27 time_t vol_create_time;
28
29 di = disk_image_get();
30 /*
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.
35 */
36 vol_create_time = 0;
37 assert_no_err(fsctl(di->mount_point, HFSIOC_GET_VOL_CREATE_TIME,
38 &vol_create_time, 0));
39 if (!vol_create_time)
40 assert_fail("fcntl HFSIOC_GET_VOL_CREATE_TIME failed to set "
41 "volume create time.");
42 return 0;
43 }