1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @brief Configurable Pathname Varables |
---|
7 | * @ingroup libcsupport |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * COPYRIGHT (c) 1989-2011. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * Redistribution and use in source and binary forms, with or without |
---|
15 | * modification, are permitted provided that the following conditions |
---|
16 | * are met: |
---|
17 | * 1. Redistributions of source code must retain the above copyright |
---|
18 | * notice, this list of conditions and the following disclaimer. |
---|
19 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
20 | * notice, this list of conditions and the following disclaimer in the |
---|
21 | * documentation and/or other materials provided with the distribution. |
---|
22 | * |
---|
23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
33 | * POSSIBILITY OF SUCH DAMAGE. |
---|
34 | */ |
---|
35 | |
---|
36 | #ifdef HAVE_CONFIG_H |
---|
37 | #include "config.h" |
---|
38 | #endif |
---|
39 | |
---|
40 | #include <rtems/libio_.h> |
---|
41 | #include <rtems/seterr.h> |
---|
42 | |
---|
43 | #include <unistd.h> |
---|
44 | #include <errno.h> |
---|
45 | |
---|
46 | /** |
---|
47 | * POSIX 1003.1b - 5.7.1 - Configurable Pathname Varables |
---|
48 | */ |
---|
49 | long fpathconf( |
---|
50 | int fd, |
---|
51 | int name |
---|
52 | ) |
---|
53 | { |
---|
54 | long return_value; |
---|
55 | rtems_libio_t *iop; |
---|
56 | const rtems_filesystem_limits_and_options_t *the_limits; |
---|
57 | |
---|
58 | LIBIO_GET_IOP( fd, iop ); |
---|
59 | |
---|
60 | /* |
---|
61 | * Now process the information request. |
---|
62 | */ |
---|
63 | |
---|
64 | the_limits = iop->pathinfo.mt_entry->pathconf_limits_and_options; |
---|
65 | |
---|
66 | switch ( name ) { |
---|
67 | case _PC_LINK_MAX: |
---|
68 | return_value = the_limits->link_max; |
---|
69 | break; |
---|
70 | case _PC_MAX_CANON: |
---|
71 | return_value = the_limits->max_canon; |
---|
72 | break; |
---|
73 | case _PC_MAX_INPUT: |
---|
74 | return_value = the_limits->max_input; |
---|
75 | break; |
---|
76 | case _PC_NAME_MAX: |
---|
77 | return_value = the_limits->name_max; |
---|
78 | break; |
---|
79 | case _PC_PATH_MAX: |
---|
80 | return_value = the_limits->path_max; |
---|
81 | break; |
---|
82 | case _PC_PIPE_BUF: |
---|
83 | return_value = the_limits->pipe_buf; |
---|
84 | break; |
---|
85 | case _PC_CHOWN_RESTRICTED: |
---|
86 | return_value = the_limits->posix_chown_restrictions; |
---|
87 | break; |
---|
88 | case _PC_NO_TRUNC: |
---|
89 | return_value = the_limits->posix_no_trunc; |
---|
90 | break; |
---|
91 | case _PC_VDISABLE: |
---|
92 | return_value = the_limits->posix_vdisable; |
---|
93 | break; |
---|
94 | case _PC_ASYNC_IO: |
---|
95 | return_value = the_limits->posix_async_io; |
---|
96 | break; |
---|
97 | case _PC_PRIO_IO: |
---|
98 | return_value = the_limits->posix_prio_io; |
---|
99 | break; |
---|
100 | case _PC_SYNC_IO: |
---|
101 | return_value = the_limits->posix_sync_io; |
---|
102 | break; |
---|
103 | default: |
---|
104 | errno = EINVAL; |
---|
105 | return_value = -1; |
---|
106 | break; |
---|
107 | } |
---|
108 | |
---|
109 | rtems_libio_iop_drop( iop ); |
---|
110 | return return_value; |
---|
111 | } |
---|