4.115
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief IMFS Change Owner |
---|
5 | * @ingroup IMFS |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-1999. |
---|
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 | #include <unistd.h> |
---|
24 | |
---|
25 | #include <rtems/libio_.h> |
---|
26 | |
---|
27 | int IMFS_chown( |
---|
28 | const rtems_filesystem_location_info_t *loc, |
---|
29 | uid_t owner, |
---|
30 | gid_t group |
---|
31 | ) |
---|
32 | { |
---|
33 | IMFS_jnode_t *jnode; |
---|
34 | #if defined(RTEMS_POSIX_API) |
---|
35 | uid_t st_uid; |
---|
36 | #endif |
---|
37 | |
---|
38 | jnode = (IMFS_jnode_t *) loc->node_access; |
---|
39 | |
---|
40 | /* |
---|
41 | * Verify I am the owner of the node or the super user. |
---|
42 | */ |
---|
43 | |
---|
44 | #if defined(RTEMS_POSIX_API) |
---|
45 | st_uid = geteuid(); |
---|
46 | |
---|
47 | if ( ( st_uid != jnode->st_uid ) && ( st_uid != 0 ) ) |
---|
48 | rtems_set_errno_and_return_minus_one( EPERM ); |
---|
49 | #endif |
---|
50 | |
---|
51 | jnode->st_uid = owner; |
---|
52 | jnode->st_gid = group; |
---|
53 | |
---|
54 | IMFS_update_ctime( jnode ); |
---|
55 | |
---|
56 | return 0; |
---|
57 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.