static void powerdown_cleanup(int toi_or_resume) { if (!toi_or_resume) return; CLOSE_FILE(lid_file); CLOSE_FILE(alarm_file); CLOSE_FILE(epoch_file); }
int main(int argc, char**argv){ CREATE_FILE(TEST_FILE, DATA_FOR_FILE, DATASIZE_FOR_FILE); /*unlink*/ REMOVE_EXISTING_FILEPATH(TEST_FILE); CREATE_FILE(TEST_FILE2, DATA_FOR_FILE, DATASIZE_FOR_FILE); int ret; TEST_OPERATION_RESULT( link(TEST_FILE2, TEST_FILE), &ret, ret!=-1); /*now we have 2 hardlinks for a single file*/ /*compare files*/ int fd1, fd2; char *data1, *data2; off_t filesize1, filesize2; MMAP_READONLY_SHARED_FILE(TEST_FILE, 0, &fd1, data1); MMAP_READONLY_SHARED_FILE(TEST_FILE2, 0, &fd2, data2); GET_FILE_SIZE(TEST_FILE, &filesize1); GET_FILE_SIZE(TEST_FILE2, &filesize2); TEST_OPERATION_RESULT( (filesize1==filesize2), &ret, ret==1); CMP_MEM_DATA(data1, data2, filesize1); //check stat data struct stat st1; struct stat st2; TEST_OPERATION_RESULT( stat(TEST_FILE, &st1), &ret, ret==0); TEST_OPERATION_RESULT( stat(TEST_FILE2, &st2), &ret, ret==0); TEST_OPERATION_RESULT( st1.st_nlink==st2.st_nlink, &ret, ret!=0); TEST_OPERATION_RESULT( st1.st_ino==st2.st_ino, &ret, ret!=0); MUNMAP_FILE(data1, filesize1); MUNMAP_FILE(data2, filesize2); CLOSE_FILE(fd1); CLOSE_FILE(fd2); test_zrt_issue_67(TMP_TEST_DIR, TMP_TEST_FILE); test_zrt_issue_67(TMP_TEST_DIR, TMP_TEST_FILE); test_zrt_issue_70(); test_zrt_issue_77(TMP_TEST_DIR, TMP_TEST_FILE); return 0; }
LockedFile::~LockedFile(void) { CLOSE_FILE(m_fileDescriptor); if(m_bOwnsFile) { doRemoveFile(m_filePath); } }
void mmap_test(off_t offset) { int fd; char* data; MMAP_READONLY_SHARED_FILE(MMAP_FILE, offset, &fd, data) fprintf(stderr, "expected data:%s\n", DATA_FOR_MMAP+offset); fprintf(stderr, "mmaped data :%s\n", ((char*)data+offset)); off_t filesize; GET_FILE_SIZE(MMAP_FILE, &filesize); CMP_MEM_DATA( DATA_FOR_MMAP+offset, data+offset, filesize-offset ); MUNMAP_FILE(data, filesize); CLOSE_FILE(fd); }
void abstract_fstream::close() { CLOSE_FILE(FH); }