void writer(int num) { unsigned char *buffr= malloc(TEST_PAGE_SIZE); uint i; for (i= 0; i < number_of_tests; i++) { uint end; uint page= get_len(number_of_pages); pagecache_read(&pagecache, &file1, page, 3, buffr, PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_WRITE, 0); end= check_page(buffr, page * TEST_PAGE_SIZE, 1, page, num); put_rec(buffr, end, get_len(record_length_limit), num); pagecache_write(&pagecache, &file1, page, 3, buffr, PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_WRITE_UNLOCK, PAGECACHE_UNPIN, PAGECACHE_WRITE_DELAY, 0, LSN_IMPOSSIBLE); if (i % flush_divider == 0) flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE); } free(buffr); }
void lemur::file::Keyfile::put( const char* key, const void* value, int valueSize ) { assert( key && "key cannot be null" ); assert( value && "value cannot be null" ); int len = strlen(key); // fix for UTF-8 int error = put_rec( _handle, const_cast<char*>(key), len, static_cast<char*>(const_cast<void*>(value)), valueSize ); if( error ) LEMUR_THROW( LEMUR_KEYFILE_IO_ERROR, "Caught an internal error while putting record for key: " + key ); }
void process_counts(char *fname, Elf64_Sym *symtab, int symcount, int symstart, char *strtab) { long num_entry; counts_entry *pc; long i, id1, id2; char *name1, *name2; char *count_strtab; pc = open_counts_file(fname, &num_entry, &count_strtab); if (!dump_flag) { if (carray == 0) { if ((carray = (counts_entry *)calloc(num_entry, sizeof(counts_entry))) == 0) { ASSERT(0, "Cannot allocate temporary array"); } } } for (i = 0; i < num_entry; i++) { if (dump_flag) { name1 = get_name(pc[i].caller, pc[i].caller_name_idx, symtab, symcount, symstart, strtab, count_strtab); name2 = get_name(pc[i].callee, pc[i].callee_name_idx, symtab, symcount, symstart, strtab, count_strtab); printf("%s\t%s\t%d\n", name1, name2, pc[i].count); } else put_rec(&pc[i], i); } if (sort_flag) { char *v; #define NOT_VISITED 1 v = MALLOC(num_entry); ASSERT(v, "fail to malloc visited array of carray"); memset(v, NOT_VISITED, num_entry); qsort(carray, num_entry, sizeof(counts_entry), (int (*) ()) c_cmp); for (i = 0; i < num_entry; i++) { if (v[i]) { name1 = get_name(carray[i].caller, carray[i].caller_name_idx, symtab, symcount, symstart, strtab, count_strtab); name2 = get_name(carray[i].callee, carray[i].callee_name_idx, symtab, symcount, symstart, strtab, count_strtab); printf("%s\t%s\t%d\n",name1, name2, carray[i].count); if (verbose_flag) { int j, k; long total; total = 0; for (j = i+1; j < num_entry; j++) { if (carray[i].caller == carray[j].caller) { if (total == 0) { for (k = 0; k < strlen(name1); k++) { printf(" "); } printf("\t "); } name2 = get_name(carray[j].callee, carray[j].callee_name_idx, symtab, symcount, symstart, strtab, count_strtab); printf(" %s/%d", name2, carray[j].count); total += carray[j].count; v[j] = !NOT_VISITED; } } if (total != 0) printf(" total - %d\n", total + carray[i].count); } } } } if (callgraph_flag) { build_call_graph(pc, num_entry, symtab, symcount, symstart, strtab, count_strtab); } }
void do_link() { MINODE *pip; // Destination MINODE *mip; // Destination MINODE *sip; // Destination char buf[BLOCK_SIZE]; u32 pino; u32 mino; u32 src_ino; int dev; int i; u32 ino; // We're using pathName as first file path and parameter as second file path. if (dir_name(pathName)) { // We're given some directories to traverse. pino = getino(&dev, dir_name(pathName)); } else { // We're not given directories to traverse. pino = running->cwd->ino; dev = running->cwd->dev; } if (-1 == pino) { printf("Error: Could not find folder '%s'\n", dir_name(pathName)); return; } pip = iget(dev, pino); mino = getfileino(pip, base_name(pathName)); iput(pip); if (-1 == mino) { printf("Error: Could not find '%s'\n", pathName); return; } mip = iget(dev, mino); // Finally have the minode for the dest file. if (FILE_MODE != (MASK_MODE & (mip->INODE).i_mode)) { printf("Error: %s is not a file. Has mode %x\n", pathName, (mip->INODE).i_mode); iput(mip); return; } else if (dir_name(parameter) && -1 == getino(&dev, dir_name(parameter))) { // Couldn't find the inode for the dir folder we were looking for. printf("Error: Couldn't find host folder '%s'\n", dir_name(parameter)); iput(mip); return; } else if (-1 != getino(&dev, parameter)) { // something already exists where we want to make the link. printf("Error: '%s' already exists\n", parameter); iput(mip); return; } if (!(dir_name(parameter))) { sip = iget(mip->dev, getino(&dev, ".")); // This is actually the parent of the link src. } else { sip = iget(mip->dev, getino(&dev, dir_name(parameter))); // This is actually the parent of the link src. } if (-1 == put_rec(sip, base_name(parameter), mino)) { printf("Didn't succeed in placing '%s' record\n", parameter); iput(mip); iput(sip); return; } (mip->INODE).i_links_count++; sip->dirty = 1; mip->dirty = 1; iput(sip); iput(mip); }