123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #include <limits.h>
- #include <stdlib.h>
- #include <sys/statfs.h>
- #define DEVPTS_SUPER_MAGIC 0x1cd1
- #define DEVFS_SUPER_MAGIC 0x1373
- int __unix_grantpt (int fd);
- static int pts_name (int fd, char **pts, size_t buf_len);
- int
- grantpt (int fd)
- {
- 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 (fsbuf.f_type == DEVPTS_SUPER_MAGIC || fsbuf.f_type == DEVFS_SUPER_MAGIC)
- return 0;
- return __unix_grantpt (fd);
- }
- #define grantpt __unix_grantpt
- #include "unix_grantpt.c"
|