15e2ef462SAxel Dörfler/*
25e2ef462SAxel Dörfler * Copyright 2002-2008, Axel D��rfler, axeld@pinc-software.de. All rights reserved.
35e2ef462SAxel Dörfler * Distributed under the terms of the MIT License.
45e2ef462SAxel Dörfler */
5bc45af20SAxel Dörfler
6bc45af20SAxel Dörfler
720e40af9SAxel Dörfler#include <fs_interface.h>
85e2ef462SAxel Dörfler#include <NodeMonitor.h>
920e40af9SAxel Dörfler
10bc45af20SAxel Dörfler#include <unistd.h>
11bc45af20SAxel Dörfler#include <syscalls.h>
12bc45af20SAxel Dörfler#include <errno.h>
13bc45af20SAxel Dörfler
14ae901935SOliver Tappe#include <errno_private.h>
154d5c5a7eSAugustin Cavalier#include <syscall_utils.h>
16bc45af20SAxel Dörfler
17bc45af20SAxel Dörfler
18bc45af20SAxel Dörflerint
19bc45af20SAxel Dörflertruncate(const char *path, off_t newSize)
20bc45af20SAxel Dörfler{
21bc45af20SAxel Dörfler	struct stat stat;
22bc45af20SAxel Dörfler	status_t status;
23bc45af20SAxel Dörfler
24bc45af20SAxel Dörfler	stat.st_size = newSize;
25383cdedbSIngo Weinhold	status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat),
265e2ef462SAxel Dörfler		B_STAT_SIZE);
27bc45af20SAxel Dörfler
28bc45af20SAxel Dörfler	RETURN_AND_SET_ERRNO(status);
29bc45af20SAxel Dörfler}
30bc45af20SAxel Dörfler
31bc45af20SAxel Dörfler
32bc45af20SAxel Dörflerint
33bc45af20SAxel Dörflerftruncate(int fd, off_t newSize)
34bc45af20SAxel Dörfler{
35bc45af20SAxel Dörfler	struct stat stat;
36bc45af20SAxel Dörfler	status_t status;
37bc45af20SAxel Dörfler
38bc45af20SAxel Dörfler	stat.st_size = newSize;
39383cdedbSIngo Weinhold	status = _kern_write_stat(fd, NULL, false, &stat, sizeof(struct stat),
405e2ef462SAxel Dörfler		B_STAT_SIZE);
41bc45af20SAxel Dörfler
42bc45af20SAxel Dörfler	RETURN_AND_SET_ERRNO(status);
43bc45af20SAxel Dörfler}
44bc45af20SAxel Dörfler
45