source: rtems/c/src/lib/libc/imfs_stat.c @ e5d6705e

4.104.114.84.95
Last change on this file since e5d6705e was e5d6705e, checked in by Joel Sherrill <joel.sherrill@…>, on 06/30/00 at 12:33:13

Patch from Chris Johns <cjohns@…> to add support for
stat()'ing a symbolic link. This is needed to support the port
of the BSD commands like ls to RTEMS.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  IMFS_stat
3 * 
4 *  This routine provides a stat for the IMFS file system.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <errno.h>
17#include "imfs.h"
18#include "libio_.h"
19
20int IMFS_stat(
21  rtems_filesystem_location_info_t *loc,
22  struct stat                      *buf
23)
24{
25  IMFS_jnode_t   *the_jnode;
26  IMFS_device_t  *io;
27
28  the_jnode = loc->node_access;
29
30
31  switch ( the_jnode->type ) {
32
33    case IMFS_DEVICE:
34      io          = &the_jnode->info.device;
35      buf->st_dev = rtems_filesystem_make_dev_t( io->major, io->minor );
36      break;
37
38    case IMFS_MEMORY_FILE:
39      buf->st_size = the_jnode->info.file.size;
40      break;
41   
42    case IMFS_SYM_LINK:
43      buf->st_size = 0;
44      break;
45   
46    default:
47      set_errno_and_return_minus_one( ENOTSUP );
48      break;
49  }
50
51  buf->st_mode  = the_jnode->st_mode;
52  buf->st_nlink = the_jnode->st_nlink;
53  buf->st_ino   = the_jnode->st_ino;
54  buf->st_uid   = the_jnode->st_uid;
55  buf->st_gid   = the_jnode->st_gid;
56
57  buf->st_atime = the_jnode->stat_atime;
58  buf->st_mtime = the_jnode->stat_mtime;
59  buf->st_ctime = the_jnode->stat_ctime;
60
61  return 0;
62}
Note: See TracBrowser for help on using the repository browser.