4.115
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Rename a MSDOS FileSystem Node |
---|
5 | * @ingroup libfs_msdos MSDOS FileSystem |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * Copyright (C) 2010 Chris Johns <chrisj@rtems.org> |
---|
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.rtems.org/license/LICENSE. |
---|
14 | * |
---|
15 | */ |
---|
16 | #if HAVE_CONFIG_H |
---|
17 | #include "config.h" |
---|
18 | #endif |
---|
19 | |
---|
20 | #include <errno.h> |
---|
21 | #include <stdio.h> |
---|
22 | #include <stdlib.h> |
---|
23 | #include <string.h> |
---|
24 | #include <rtems/libio_.h> |
---|
25 | #include <time.h> |
---|
26 | |
---|
27 | #include "fat.h" |
---|
28 | #include "fat_fat_operations.h" |
---|
29 | #include "fat_file.h" |
---|
30 | |
---|
31 | #include "msdos.h" |
---|
32 | |
---|
33 | /* msdos_rename -- |
---|
34 | * Rename the node by removing the exitsing directory entry and creating a |
---|
35 | * new one. |
---|
36 | */ |
---|
37 | int |
---|
38 | msdos_rename( |
---|
39 | const rtems_filesystem_location_info_t *old_parent_loc, |
---|
40 | const rtems_filesystem_location_info_t *old_loc, |
---|
41 | const rtems_filesystem_location_info_t *new_parent_loc, |
---|
42 | const char *new_name, |
---|
43 | size_t new_namelen |
---|
44 | ) |
---|
45 | { |
---|
46 | int rc = RC_OK; |
---|
47 | fat_file_fd_t *old_fat_fd = old_loc->node_access; |
---|
48 | |
---|
49 | /* |
---|
50 | * create new directory entry as "hard link", copying relevant info from |
---|
51 | * existing file |
---|
52 | */ |
---|
53 | rc = msdos_creat_node(new_parent_loc, |
---|
54 | FAT_HARD_LINK,new_name,new_namelen,S_IFREG, |
---|
55 | old_fat_fd); |
---|
56 | if (rc != RC_OK) |
---|
57 | { |
---|
58 | return rc; |
---|
59 | } |
---|
60 | |
---|
61 | /* |
---|
62 | * mark file removed |
---|
63 | */ |
---|
64 | rc = msdos_set_first_char4file_name(old_loc->mt_entry, |
---|
65 | &old_fat_fd->dir_pos, |
---|
66 | MSDOS_THIS_DIR_ENTRY_EMPTY); |
---|
67 | |
---|
68 | return rc; |
---|
69 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.