1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Configurable Pathname Varables |
---|
5 | * @ingroup libcsupport |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2011. |
---|
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 <rtems/libio_.h> |
---|
22 | #include <rtems/seterr.h> |
---|
23 | |
---|
24 | #include <unistd.h> |
---|
25 | #include <errno.h> |
---|
26 | |
---|
27 | /** |
---|
28 | * POSIX 1003.1b - 5.7.1 - Configurable Pathname Varables |
---|
29 | */ |
---|
30 | long fpathconf( |
---|
31 | int fd, |
---|
32 | int name |
---|
33 | ) |
---|
34 | { |
---|
35 | long return_value; |
---|
36 | rtems_libio_t *iop; |
---|
37 | const rtems_filesystem_limits_and_options_t *the_limits; |
---|
38 | |
---|
39 | LIBIO_GET_IOP( fd, iop ); |
---|
40 | |
---|
41 | /* |
---|
42 | * Now process the information request. |
---|
43 | */ |
---|
44 | |
---|
45 | the_limits = iop->pathinfo.mt_entry->pathconf_limits_and_options; |
---|
46 | |
---|
47 | switch ( name ) { |
---|
48 | case _PC_LINK_MAX: |
---|
49 | return_value = the_limits->link_max; |
---|
50 | break; |
---|
51 | case _PC_MAX_CANON: |
---|
52 | return_value = the_limits->max_canon; |
---|
53 | break; |
---|
54 | case _PC_MAX_INPUT: |
---|
55 | return_value = the_limits->max_input; |
---|
56 | break; |
---|
57 | case _PC_NAME_MAX: |
---|
58 | return_value = the_limits->name_max; |
---|
59 | break; |
---|
60 | case _PC_PATH_MAX: |
---|
61 | return_value = the_limits->path_max; |
---|
62 | break; |
---|
63 | case _PC_PIPE_BUF: |
---|
64 | return_value = the_limits->pipe_buf; |
---|
65 | break; |
---|
66 | case _PC_CHOWN_RESTRICTED: |
---|
67 | return_value = the_limits->posix_chown_restrictions; |
---|
68 | break; |
---|
69 | case _PC_NO_TRUNC: |
---|
70 | return_value = the_limits->posix_no_trunc; |
---|
71 | break; |
---|
72 | case _PC_VDISABLE: |
---|
73 | return_value = the_limits->posix_vdisable; |
---|
74 | break; |
---|
75 | case _PC_ASYNC_IO: |
---|
76 | return_value = the_limits->posix_async_io; |
---|
77 | break; |
---|
78 | case _PC_PRIO_IO: |
---|
79 | return_value = the_limits->posix_prio_io; |
---|
80 | break; |
---|
81 | case _PC_SYNC_IO: |
---|
82 | return_value = the_limits->posix_sync_io; |
---|
83 | break; |
---|
84 | default: |
---|
85 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
86 | break; |
---|
87 | } |
---|
88 | |
---|
89 | return return_value; |
---|
90 | } |
---|