]>
git.saurik.com Git - apple/security.git/blob - RegressionTests/SecAtomicFile/SecAtomicFile.cpp
2 // Copyright 2017 Apple. All rights reserved.
5 #include "AtomicFile.h"
10 fill_disk(const char *path
)
12 int fd
= ::open(path
, O_CREAT
|O_RDWR
, 0600);
14 errx(1, "failed to create fill file");
16 uint8 buffer
[1024] = {};
17 ::memset(reinterpret_cast<void *>(buffer
), 0x77, sizeof(buffer
));
19 for (unsigned count
= 0; count
< 1000; count
++) {
20 if (::write(fd
, buffer
, sizeof(buffer
)) != sizeof(buffer
)) {
21 warn("write fill file failed");
26 warn("close fill file failed");
31 main(int argc
, char **argv
)
39 AtomicFile
file(argv
[1]);
41 RefPointer
<AtomicTempFile
> temp
= file
.write();
44 uint8 buffer
[1024] = {};
45 ::memset(reinterpret_cast<void *>(buffer
), 0xff, sizeof(buffer
));
47 for (count
= 0; count
< 1000; count
++) {
48 temp
->write(AtomicFile::FromEnd
, 0, buffer
, sizeof(buffer
));
57 errx(1, "failed to create new file");