|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: BSD-3-Clause |
| 3 | + * |
| 4 | + * Copyright © 2024 Keith Packard |
| 5 | + * |
| 6 | + * Redistribution and use in source and binary forms, with or without |
| 7 | + * modification, are permitted provided that the following conditions |
| 8 | + * are met: |
| 9 | + * |
| 10 | + * 1. Redistributions of source code must retain the above copyright |
| 11 | + * notice, this list of conditions and the following disclaimer. |
| 12 | + * |
| 13 | + * 2. Redistributions in binary form must reproduce the above |
| 14 | + * copyright notice, this list of conditions and the following |
| 15 | + * disclaimer in the documentation and/or other materials provided |
| 16 | + * with the distribution. |
| 17 | + * |
| 18 | + * 3. Neither the name of the copyright holder nor the names of its |
| 19 | + * contributors may be used to endorse or promote products derived |
| 20 | + * from this software without specific prior written permission. |
| 21 | + * |
| 22 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 25 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 26 | + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 27 | + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 28 | + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 29 | + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 30 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 31 | + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 32 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 33 | + * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | + */ |
| 35 | + |
| 36 | +#define _DEFAULT_SOURCE |
| 37 | +#include <unistd.h> |
| 38 | +#include <errno.h> |
| 39 | +#include <limits.h> |
| 40 | + |
| 41 | +long |
| 42 | +pathconf (const char *path, int name) |
| 43 | +{ |
| 44 | + (void) path; |
| 45 | + switch (name) { |
| 46 | + case _PC_LINK_MAX: |
| 47 | + return _POSIX_LINK_MAX; |
| 48 | + |
| 49 | + case _PC_MAX_CANON: |
| 50 | + return _POSIX_MAX_CANON; |
| 51 | + |
| 52 | + case _PC_MAX_INPUT: |
| 53 | + return _POSIX_MAX_INPUT; |
| 54 | + |
| 55 | + case _PC_NAME_MAX: |
| 56 | + return _POSIX_NAME_MAX; |
| 57 | + |
| 58 | + case _PC_PATH_MAX: |
| 59 | + return _POSIX_PATH_MAX; |
| 60 | + |
| 61 | + case _PC_PIPE_BUF: |
| 62 | + return _POSIX_PIPE_BUF; |
| 63 | + |
| 64 | + case _PC_CHOWN_RESTRICTED: |
| 65 | +#ifdef _POSIX_CHOWN_RESTRICTED |
| 66 | + return _POSIX_CHOWN_RESTRICTED; |
| 67 | +#else |
| 68 | + return 0; |
| 69 | +#endif |
| 70 | + |
| 71 | + case _PC_NO_TRUNC: |
| 72 | +#ifdef _POSIX_NO_TRUNC |
| 73 | + return _POSIX_NO_TRUNC; |
| 74 | +#else |
| 75 | + return 0; |
| 76 | +#endif |
| 77 | + |
| 78 | + case _PC_VDISABLE: |
| 79 | + return 0; |
| 80 | + |
| 81 | + default: |
| 82 | + errno = EINVAL; |
| 83 | + return -1; |
| 84 | + } |
| 85 | +} |
0 commit comments