DWORD open_files(void) { datafile = CreateFile( DATA_FILE, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); lasterror = check_file_handle(datafile); if (lasterror != ERROR_SUCCESS) return (int)lasterror; solutionfile = CreateFile( SOLUTION_FILE, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); lasterror = check_file_handle(solutionfile); if (lasterror != ERROR_SUCCESS) return (int)lasterror; datamap = CreateFileMapping(datafile, NULL, PAGE_READONLY, 0, 0, NULL); lasterror = GetLastError(); if (datamap == NULL || lasterror != ERROR_SUCCESS) return (int)lasterror; solutionmap = CreateFileMapping(solutionfile, NULL, PAGE_READONLY, 0, 0, NULL); lasterror = GetLastError(); if (solutionmap == NULL || lasterror != ERROR_SUCCESS) return (int)lasterror; return ERROR_SUCCESS; }
void check_file (const char *file_name, const void *buf, size_t size) { int fd; CHECK ((fd = open (file_name)) > 1, "open \"%s\" for verification", file_name); check_file_handle (fd, file_name, buf, size); msg ("close \"%s\"", file_name); close (fd); }
static bool_t L1_Translate_m (USDCallback_cl *self, USD_StreamID sid /* IN */, USD_ClientID cid /* IN */, const FileIO_Request *req /* IN */, USD_Extent *extent /* OUT */, uint32_t *notification /* OUT */) { L1_st *l1_st = self->st; ext2fs_st *st = l1_st->ext2fs_st; Client_st *cur; Ext2_Handle handle; struct inode *ino; bool_t rc; FTRC("entered: self=%p, st=%p.\n", self, st); if (req->op != FileIO_Op_Read) ntsc_dbgstop(); /* ClientID is actually a pointer to our per-client state record */ /* This is securely provided by USD and so can be trusted. */ cur = (Client_st *)(word_t)cid; if (req->nblocks == 0) { /* Prefetch */ uint32_t dummy; rc = USDCallback$Translate(l1_st->l2_callback, sid, cid, req, extent, &dummy); return False; } /* req->user1 should be the EXT2 handle - needs to be checked */ handle = req->user1; /* Optimise out the callback for small files */ if (!check_file_handle(cur, handle)) return False; ino = cur->handles[handle].ino; if (S_ISDIR(ino->i_mode)) { *notification = (word_t)ino; } else { *notification = 0; } if ((req->blockno + req->nblocks) <= EXT2_NDIR_BLOCKS) { rc = translate(st, ino, req, extent); } else { uint32_t dummy; rc = USDCallback$Translate(l1_st->l2_callback, sid, cid, req, extent, &dummy); } /* Reduce the transfer size to the max contig. len */ ((FileIO_Request *)req)->nblocks = extent->len; /* Scale by FS block size */ extent->base *= 2 /* XXX PRB: should use logical block size */; extent->len *= 2; FTRC("leaving, returning true.\n"); return rc; }