]>
git.saurik.com Git - apple/hfs.git/blob - tests/cases/test-cas-bsdflags.c
8 #include <sys/sysctl.h>
10 #include <sys/xattr.h>
11 #include <sys/mount.h>
12 #include <sys/param.h>
14 #include <System/sys/fsctl.h>
16 #include "hfs-tests.h"
17 #include "test-utils.h"
18 #include "disk-image.h"
23 cas_bsd_flags(int fd
, uint32_t expected_flags
, uint32_t new_flags
)
25 struct fsioc_cas_bsdflags cas
;
27 cas
.expected_flags
= expected_flags
;
28 cas
.new_flags
= new_flags
;
29 cas
.actual_flags
= ~0; /* poison */
31 assert_no_err(ffsctl(fd
, FSIOC_CAS_BSDFLAGS
, &cas
, 0));
32 return (cas
.expected_flags
== cas
.actual_flags
);
35 int run_cas_bsdflags(__unused test_ctx_t
*ctx
)
37 disk_image_t
*di
= disk_image_get();
42 asprintf(&file
, "%s/cas_bsdflags.data", di
->mount_point
);
44 assert_with_errno((fd
= open(file
,
45 O_CREAT
| O_RDWR
| O_TRUNC
, 0666)) >= 0);
47 assert_no_err(fchflags(fd
, UF_HIDDEN
));
48 assert_no_err(fstat(fd
, &sb
));
49 assert(sb
.st_flags
== UF_HIDDEN
);
51 assert(cas_bsd_flags(fd
, 0, UF_NODUMP
) == false);
52 assert_no_err(fstat(fd
, &sb
));
53 assert(sb
.st_flags
== UF_HIDDEN
);
55 assert(cas_bsd_flags(fd
, UF_HIDDEN
, UF_NODUMP
) == true);
56 assert_no_err(fstat(fd
, &sb
));
57 assert(sb
.st_flags
== UF_NODUMP
);
59 assert(cas_bsd_flags(fd
, UF_NODUMP
, 0) == true);
60 assert_no_err(fstat(fd
, &sb
));
61 assert(sb
.st_flags
== 0);
64 assert_no_err(unlink(file
));