4.115
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief IMFS Rename |
---|
5 | * @ingroup IMFS |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2010. |
---|
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.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include "imfs.h" |
---|
22 | |
---|
23 | int IMFS_rename( |
---|
24 | const rtems_filesystem_location_info_t *oldparentloc, |
---|
25 | const rtems_filesystem_location_info_t *oldloc, |
---|
26 | const rtems_filesystem_location_info_t *newparentloc, |
---|
27 | const char *name, |
---|
28 | size_t namelen |
---|
29 | ) |
---|
30 | { |
---|
31 | int rv = 0; |
---|
32 | IMFS_jnode_t *node = oldloc->node_access; |
---|
33 | IMFS_jnode_t *new_parent = newparentloc->node_access; |
---|
34 | |
---|
35 | /* |
---|
36 | * FIXME: Due to insufficient checks we can create inaccessible nodes with |
---|
37 | * this operation. |
---|
38 | */ |
---|
39 | |
---|
40 | if ( node->Parent != NULL ) { |
---|
41 | if ( namelen < IMFS_NAME_MAX ) { |
---|
42 | memcpy( node->name, name, namelen ); |
---|
43 | node->name [namelen] = '\0'; |
---|
44 | |
---|
45 | IMFS_remove_from_directory( node ); |
---|
46 | IMFS_add_to_directory( new_parent, node ); |
---|
47 | IMFS_update_ctime( node ); |
---|
48 | } else { |
---|
49 | errno = ENAMETOOLONG; |
---|
50 | rv = -1; |
---|
51 | } |
---|
52 | } else { |
---|
53 | errno = EINVAL; |
---|
54 | rv = -1; |
---|
55 | } |
---|
56 | |
---|
57 | return rv; |
---|
58 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.