]>
git.saurik.com Git - apple/hfs.git/blob - tests/cases/test-set-create-time.c
6 #include "test-utils.h"
7 #include "disk-image.h"
11 static disk_image_t
*di
;
13 int run_set_create_time(__unused test_ctx_t
*ctx
)
15 di
= disk_image_get();
18 asprintf(&file
, "%s/set-create-time.data", di
->mount_point
);
22 assert_with_errno((fd
= open(file
, O_CREAT
| O_RDWR
, 0666)) >= 0);
26 struct timespec cr_time
, mod_time
;
29 { 2000, 0 }, // Create time after mod time
33 struct attrlist attrlist
= {
34 .bitmapcount
= ATTR_BIT_MAP_COUNT
,
35 .commonattr
= ATTR_CMN_CRTIME
| ATTR_CMN_MODTIME
,
38 assert_no_err(fsetattrlist(fd
, &attrlist
, (char *)&attrs
+ 4, sizeof(attrs
) - 4, 0));
40 assert_no_err(fgetattrlist(fd
, &attrlist
, &attrs
, sizeof(attrs
), 0));
42 assert(attrs
.cr_time
.tv_sec
== 2000 && attrs
.mod_time
.tv_sec
== 1000);