1/* 2 * Copyright 2002-2008, Axel D��rfler, axeld@pinc-software.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7#include <fs_interface.h> 8#include <NodeMonitor.h> 9 10#include <unistd.h> 11#include <syscalls.h> 12#include <errno.h> 13 14#include <errno_private.h> 15#include <syscall_utils.h> 16 17 18int 19truncate(const char *path, off_t newSize) 20{ 21 struct stat stat; 22 status_t status; 23 24 stat.st_size = newSize; 25 status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat), 26 B_STAT_SIZE); 27 28 RETURN_AND_SET_ERRNO(status); 29} 30 31 32int 33ftruncate(int fd, off_t newSize) 34{ 35 struct stat stat; 36 status_t status; 37 38 stat.st_size = newSize; 39 status = _kern_write_stat(fd, NULL, false, &stat, sizeof(struct stat), 40 B_STAT_SIZE); 41 42 RETURN_AND_SET_ERRNO(status); 43} 44 45