4.115
Last change
on this file since cf36b70 was
cf36b70,
checked in by Sebastian Huber <sebastian.huber@…>, on 12/31/14 at 09:56:05
|
IMFS: Replace node union with individual struct
This reduces the average node size.
Add and use IMFS_GENERIC_INITIALIZER().
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief IMFS Create a New Symbolic Link Node |
---|
5 | * @ingroup IMFS |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2009. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
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.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include "imfs.h" |
---|
22 | |
---|
23 | #include <stdlib.h> |
---|
24 | #include <string.h> |
---|
25 | |
---|
26 | int IMFS_symlink( |
---|
27 | const rtems_filesystem_location_info_t *parentloc, |
---|
28 | const char *name, |
---|
29 | size_t namelen, |
---|
30 | const char *target |
---|
31 | ) |
---|
32 | { |
---|
33 | char *dup_target; |
---|
34 | IMFS_jnode_t *new_node; |
---|
35 | |
---|
36 | /* |
---|
37 | * Duplicate link name |
---|
38 | */ |
---|
39 | dup_target = strdup(target); |
---|
40 | if (dup_target == NULL) { |
---|
41 | rtems_set_errno_and_return_minus_one(ENOMEM); |
---|
42 | } |
---|
43 | |
---|
44 | /* |
---|
45 | * Create a new link node. |
---|
46 | */ |
---|
47 | new_node = IMFS_create_node( |
---|
48 | parentloc, |
---|
49 | IMFS_SYM_LINK, |
---|
50 | name, |
---|
51 | namelen, |
---|
52 | ( S_IFLNK | ( S_IRWXU | S_IRWXG | S_IRWXO )), |
---|
53 | dup_target |
---|
54 | ); |
---|
55 | |
---|
56 | if (new_node == NULL) { |
---|
57 | free(dup_target); |
---|
58 | rtems_set_errno_and_return_minus_one(ENOMEM); |
---|
59 | } |
---|
60 | |
---|
61 | return 0; |
---|
62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.