12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #include <limits.h>
- #include <stdlib.h>
- #if !defined __ASSUME_DEVPTS__
- #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);
- #endif
- 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 (fsbuf.f_type != DEVPTS_SUPER_MAGIC && fsbuf.f_type != DEVFS_SUPER_MAGIC)
- return __unix_grantpt (fd);
- #endif
- return 0;
- }
- #if !defined __ASSUME_DEVPTS__
- # define grantpt __unix_grantpt
- # include "unix_grantpt.c"
- #endif
|