Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/stdlib/ptsname.c
| Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | ||||||||||||
| * permissions upon creation. | * permissions upon creation. | |||||||||||
| * | * | |||||||||||
| * Just make sure `fildes' actually points to a real PTY master device. | * Just make sure `fildes' actually points to a real PTY master device. | |||||||||||
| */ | */ | |||||||||||
| __strong_reference(__isptmaster, grantpt); | __strong_reference(__isptmaster, grantpt); | |||||||||||
| __strong_reference(__isptmaster, unlockpt); | __strong_reference(__isptmaster, unlockpt); | |||||||||||
| /* | /* | |||||||||||
| * ptsname_r(): return the pathname of the slave pseudo-terminal device | * posix_ptsname_r(): return the pathname of the slave pseudo-terminal device | |||||||||||
| * associated with the specified master. | * associated with the specified master. | |||||||||||
| * POSIX-compliant: returns 0 on success, error number on failure. | ||||||||||||
| */ | */ | |||||||||||
| int | int | |||||||||||
| __ptsname_r(int fildes, char *buffer, size_t buflen) | posix_ptsname_r(int fildes, char *buffer, size_t buflen) | |||||||||||
| { | { | |||||||||||
| if (buffer == NULL) { | ||||||||||||
| errno = EINVAL; | ||||||||||||
| return (errno); | ||||||||||||
| } | ||||||||||||
| if (buflen <= sizeof(_PATH_DEV)) { | if (buflen <= sizeof(_PATH_DEV)) { | |||||||||||
| errno = ERANGE; | errno = ERANGE; | |||||||||||
| return (-1); | return (errno); | |||||||||||
| } | } | |||||||||||
| /* Make sure fildes points to a master device. */ | /* Make sure fildes points to a master device. */ | |||||||||||
| if (__isptmaster(fildes) != 0) | if (__isptmaster(fildes) != 0) | |||||||||||
| return (-1); | return (errno); | |||||||||||
| memcpy(buffer, _PATH_DEV, sizeof(_PATH_DEV)); | memcpy(buffer, _PATH_DEV, sizeof(_PATH_DEV)); | |||||||||||
| buffer += sizeof(_PATH_DEV) - 1; | buffer += sizeof(_PATH_DEV) - 1; | |||||||||||
| buflen -= sizeof(_PATH_DEV) - 1; | buflen -= sizeof(_PATH_DEV) - 1; | |||||||||||
| if (fdevname_r(fildes, buffer, buflen) == NULL) { | if (fdevname_r(fildes, buffer, buflen) == NULL) { | |||||||||||
| if (errno == EINVAL) | if (errno == EINVAL) | |||||||||||
| errno = ERANGE; | errno = ERANGE; | |||||||||||
| return (-1); | return (errno); | |||||||||||
| } | } | |||||||||||
| return (0); | return (0); | |||||||||||
| } | } | |||||||||||
| __strong_reference(__ptsname_r, ptsname_r); | /* | |||||||||||
| * Prior to FreeBSD 16 we returned -1 on error, not an error number as is now | ||||||||||||
| * specified by POSIX. | ||||||||||||
| */ | ||||||||||||
| int | ||||||||||||
| ptsname_r(int fildes, char *buffer, size_t buflen) | ||||||||||||
kibUnsubmitted Not Done Inline Actions
kib: | ||||||||||||
| { | ||||||||||||
| if (posix_ptsname_r(fildes, buffer, buflen) != 0) | ||||||||||||
| return (-1); | ||||||||||||
| return (0); | ||||||||||||
| } | ||||||||||||
Not Done Inline ActionsIf you have the symbol listed in the Symbol.map, why do you need the manual specification of the symver for it? kib: If you have the symbol listed in the Symbol.map, why do you need the manual specification of… | ||||||||||||
| /* | /* | |||||||||||
| * ptsname(): return the pathname of the slave pseudo-terminal device | * ptsname(): return the pathname of the slave pseudo-terminal device | |||||||||||
| * associated with the specified master. | * associated with the specified master. | |||||||||||
| */ | */ | |||||||||||
| char * | char * | |||||||||||
| ptsname(int fildes) | ptsname(int fildes) | |||||||||||
| { | { | |||||||||||
| static char pt_slave[sizeof(_PATH_DEV) + SPECNAMELEN]; | static char pt_slave[sizeof(_PATH_DEV) + SPECNAMELEN]; | |||||||||||
| if (__ptsname_r(fildes, pt_slave, sizeof(pt_slave)) == 0) | if (posix_ptsname_r(fildes, pt_slave, sizeof(pt_slave)) == 0) | |||||||||||
| return (pt_slave); | return (pt_slave); | |||||||||||
| return (NULL); | return (NULL); | |||||||||||
| } | } | |||||||||||
Not Done Inline ActionsThis is excessive and does not complain at the right target. Presence or absence of this warning is controlled by the _POSIX_C_SOURCE knob, and not by the application source. kib: This is excessive and does not complain at the right target.
Presence or absence of this… | ||||||||||||