OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libcsupport/] [src/] [ftruncate.c] - Blame information for rev 1026

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
2
 *  ftruncate() - Truncate a File to the Specified Length
3
 *
4
 *  COPYRIGHT (c) 1989-1999.
5
 *  On-Line Applications Research Corporation (OAR).
6
 *
7
 *  The license and distribution terms for this file may be
8
 *  found in the file LICENSE in this distribution or at
9
 *  http://www.OARcorp.com/rtems/license.html.
10
 *
11
 *  ftruncate.c,v 1.9 2002/01/04 18:29:36 joel Exp
12
 */
13
 
14
#if HAVE_CONFIG_H
15
#include "config.h"
16
#endif
17
 
18
#include <unistd.h>
19
#include <errno.h>
20
 
21
#include <rtems/libio_.h>
22
#include <rtems/seterr.h>
23
 
24
int ftruncate(
25
  int     fd,
26
  off_t   length
27
)
28
{
29
  rtems_libio_t                    *iop;
30
  rtems_filesystem_location_info_t  loc;
31
 
32
  rtems_libio_check_fd( fd );
33
  iop = rtems_libio_iop( fd );
34
  rtems_libio_check_is_open(iop);
35
 
36
  /*
37
   *  Now process the ftruncate() request.
38
   */
39
 
40
  /*
41
   *  Make sure we are not working on a directory
42
   */
43
 
44
  loc = iop->pathinfo;
45
  if ( !loc.ops->node_type_h )
46
    rtems_set_errno_and_return_minus_one( ENOTSUP );
47
 
48
  if ( (*loc.ops->node_type_h)( &loc ) == RTEMS_FILESYSTEM_DIRECTORY )
49
    rtems_set_errno_and_return_minus_one( EISDIR );
50
 
51
  rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE );
52
 
53
  if ( !iop->handlers->ftruncate_h )
54
    rtems_set_errno_and_return_minus_one( ENOTSUP );
55
 
56
  return (*iop->handlers->ftruncate_h)( iop, length );
57
}
58
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.