123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #include <limits.h>
- #include <stdlib.h>
- #if !defined __ASSUME_DEVPTS__
- #include <sys/statfs.h>
- #define DEVPTS_SUPER_MAGIC 0x1cd1
- #define DEVFS_SUPER_MAGIC 0x1373
- static int __unix_grantpt (int fd);
- static int pts_name (int fd, char **pts, size_t buf_len);
- extern __typeof(statfs) __libc_statfs;
- 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 (fsbuf.f_type != DEVPTS_SUPER_MAGIC && fsbuf.f_type != DEVFS_SUPER_MAGIC)
- return __unix_grantpt (fd);
- return 0;
- }
- # define grantpt __unix_grantpt
- # include "unix_grantpt.c"
- #else
- int grantpt (attribute_unused int fd)
- {
- return 0;
- }
- #endif
|