source: rtems/c/src/lib/libc/truncate.c @ 7edb9281

4.104.114.84.95
Last change on this file since 7edb9281 was 07a3253d, checked in by Joel Sherrill <joel.sherrill@…>, on 11/23/98 at 19:07:58

Added base version of file system infrastructure. This includes a major
overhaul of the RTEMS system call interface. This base file system is
the "In-Memory File System" aka IMFS.

The design and implementation was done by the following people:

+ Joel Sherrill (joel@…)
+ Jennifer Averett (jennifer@…)
+ Steve "Mr Mount" Salitasc (salitasc@…)
+ Kerwin Wade (wade@…)

PROBLEMS
========

+ It is VERY likely that merging this will break the UNIX port. This

can/will be fixed.

+ There is likely some reentrancy/mutual exclusion needed.

+ Eventually, there should be a "mini-IMFS" description table to

eliminate links, symlinks, etc to save memory. All you need to
have "classic RTEMS" functionality is technically directories
and device IO. All the rest could be left out to save memory.

  • Property mode set to 100644
File size: 834 bytes
Line 
1/*
2 *  truncate() - Truncate a File to the Specified Length
3 *
4 *  This routine is not defined in the POSIX 1003.1b standard but is
5 *  commonly supported on most UNIX and POSIX systems.  It is provided
6 *  for compatibility.
7 *
8 *  COPYRIGHT (c) 1989-1998.
9 *  On-Line Applications Research Corporation (OAR).
10 *  Copyright assigned to U.S. Government, 1994.
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.OARcorp.com/rtems/license.html.
15 *
16 *  $Id$
17 */
18
19#include <unistd.h>
20#include <errno.h>
21#include <fcntl.h>
22
23int truncate(
24  const char  *path,
25  off_t        length
26)
27{
28  int status;
29  int fd;
30
31  fd = open( path, O_WRONLY );
32  if ( fd == -1 )
33    return -1;
34
35  status = ftruncate( fd, length );
36
37  (void) close( fd );
38
39  return status;
40}
41
Note: See TracBrowser for help on using the repository browser.