1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2004-2009 Oracle. All rights reserved. 5 * 6 * $Id$ 7 */ 8 9#include "db_config.h" 10 11#include "db_int.h" 12 13/* 14 * __os_truncate -- 15 * Truncate the file. 16 */ 17int 18__os_truncate(env, fhp, pgno, pgsize) 19 ENV *env; 20 DB_FH *fhp; 21 db_pgno_t pgno; 22 u_int32_t pgsize; 23{ 24 IFileMgr *pIFileMgr; 25 off_t offset; 26 int ret; 27 28 FILE_MANAGER_CREATE(env, pIFileMgr, ret); 29 if (ret != 0) 30 return (ret); 31 32 /* 33 * Truncate a file so that "pgno" is discarded from the end of the 34 * file. 35 */ 36 offset = (off_t)pgsize * pgno; 37 38 LAST_PANIC_CHECK_BEFORE_IO(env); 39 40 if (IFILE_Truncate(fhp->ifp, offset) == SUCCESS) 41 ret = 0; 42 else 43 FILE_MANAGER_ERR(env, pIFileMgr, NULL, "IFILE_Truncate", ret); 44 45 IFILEMGR_Release(pIFileMgr); 46 47 return (ret); 48} 49