source: rtems/c/src/exec/libfs/src/imfs/imfs_link.c @ c058578

4.104.114.84.95
Last change on this file since c058578 was c058578, checked in by Joel Sherrill <joel.sherrill@…>, on 11/01/00 at 21:02:46

2000-11-01 Joel Sherrill <joel@…>

  • src/imfs/Makefile.am, src/imfs/deviceio.c, src/imfs/imfs_chown.c, src/imfs/imfs_config.c, src/imfs/imfs_creat.c, src/imfs/imfs_debug.c, src/imfs/imfs_directory.c, src/imfs/imfs_eval.c, src/imfs/imfs_fchmod.c, src/imfs/imfs_free.c, src/imfs/imfs_fsunmount.c, src/imfs/imfs_gtkn.c, src/imfs/imfs_init.c, src/imfs/imfs_initsupp.c, src/imfs/imfs_link.c, src/imfs/imfs_mknod.c, src/imfs/imfs_mount.c, src/imfs/imfs_readlink.c, src/imfs/imfs_rmnod.c, src/imfs/imfs_stat.c, src/imfs/imfs_symlink.c, src/imfs/imfs_unixstub.c, src/imfs/imfs_unlink.c, src/imfs/imfs_unmount.c, src/imfs/imfs_utime.c, src/imfs/ioman.c, src/imfs/memfile.c, src/imfs/miniimfs_init.c: assoc.h, error.h, libio_.h, libio.h, and libcsupport.h moved from libc to lib/include/rtems and now must be referenced as <rtems/XXX.h>. Now we do not have to reach up and over to libc to pick them up.
  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  IMFS_link
3 *
4 *  The following rouine creates a new link node under parent with the
5 *  name given in name.  The link node is set to point to the node at
6 *  to_loc.
7 *
8 *  COPYRIGHT (c) 1989-1999.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.OARcorp.com/rtems/license.html.
14 *
15 *  $Id$
16 */
17
18#include <errno.h>
19#include "imfs.h"
20#include <rtems/libio_.h>
21
22int IMFS_link(
23  rtems_filesystem_location_info_t  *to_loc,      /* IN */
24  rtems_filesystem_location_info_t  *parent_loc,  /* IN */
25  const char                        *token        /* IN */
26)
27{
28  IMFS_types_union   info;
29  IMFS_jnode_t      *new_node;
30  char               new_name[ IMFS_NAME_MAX + 1 ];
31  int                i;
32
33  /*
34   *  Verify this node can be linked to.
35   */
36
37  info.hard_link.link_node = to_loc->node_access;
38  if ( info.hard_link.link_node->st_nlink >= LINK_MAX )
39    set_errno_and_return_minus_one( EMLINK );
40 
41  /*
42   * Remove any separators at the end of the string.
43   */
44
45  IMFS_get_token( token, new_name, &i );
46
47  /*
48   *  Create a new link node.
49   */
50
51  new_node = IMFS_create_node(
52    parent_loc,
53    IMFS_HARD_LINK,
54    new_name,
55    ( S_IFLNK | ( S_IRWXU | S_IRWXG | S_IRWXO )),
56    &info
57  );
58
59  if ( !new_node )
60    set_errno_and_return_minus_one( ENOMEM );
61
62  /*
63   * Increment the link count of the node being pointed to.
64   */
65
66  info.hard_link.link_node->st_nlink++;
67  IMFS_update_ctime( info.hard_link.link_node );
68
69  return 0;
70}
71
Note: See TracBrowser for help on using the repository browser.