/* Change the ownership and access permission of the slave pseudo terminal associated with the master pseudo terminal specified by FD. */ int grantpt (int fd) { #if !defined __ASSUME_DEVPTS__ struct statfs fsbuf; # ifdef PATH_MAX char _buf[PATH_MAX]; # else char _buf[512]; # endif char *buf = _buf; if (pts_name (fd, &buf, sizeof (_buf))) return -1; if (statfs (buf, &fsbuf) < 0) return -1; /* If the slave pseudo terminal lives on a `devpts' filesystem, the ownership and access permission are already set. */ if (fsbuf.f_type != DEVPTS_SUPER_MAGIC && fsbuf.f_type != DEVFS_SUPER_MAGIC) return __unix_grantpt (fd); #endif return 0; }
/* Change the ownership and access permission of the slave pseudo terminal associated with the master pseudo terminal specified by FD. */ int grantpt (int fd) { struct statfs fsbuf; char _buf[PATH_MAX]; char *buf = _buf; if (pts_name (fd, &buf, sizeof (_buf))) return -1; if (__libc_statfs (buf, &fsbuf) < 0) return -1; /* If the slave pseudo terminal lives on a `devpts' filesystem, the ownership and access permission are already set. */ if (fsbuf.f_type != DEVPTS_SUPER_MAGIC && fsbuf.f_type != DEVFS_SUPER_MAGIC) return __unix_grantpt (fd); return 0; }
/* Change the ownership and access permission of the slave pseudo terminal associated with the master pseudo terminal specified by FD. */ int grantpt (int fd) { struct statfs fsbuf; #ifdef PATH_MAX char _buf[PATH_MAX]; #else char _buf[512]; #endif char *buf = _buf; if (__builtin_expect (pts_name (fd, &buf, sizeof (_buf)), 0)) { int save_errno = errno; /* Check, if the file descriptor is valid. pts_name returns the wrong errno number, so we cannot use that. */ if (__libc_fcntl (fd, F_GETFD) == -1 && errno == EBADF) return -1; /* If the filedescriptor is no TTY, grantpt has to set errno to EINVAL. */ if (save_errno == ENOTTY) __set_errno (EINVAL); else __set_errno (save_errno); return -1; } if (__statfs (buf, &fsbuf) < 0) return -1; /* If the slave pseudo terminal lives on a `devpts' filesystem, the ownership and access permission are already set. */ if (fsbuf.f_type == DEVPTS_SUPER_MAGIC || fsbuf.f_type == DEVFS_SUPER_MAGIC) return 0; return __unix_grantpt (fd); }