bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: Re: libc/5055 - [BUG] getpt() does not detect /dev/pts due towr


From: Wolfram Gloger
Subject: Re: Fwd: Re: libc/5055 - [BUG] getpt() does not detect /dev/pts due towrong statfs()
Date: Wed, 18 Jun 2003 17:14:17 +0200 (MDT)

> 2) Then the following code is executed:
> if (fd != -1)
> {
>   struct statfs fsbuf;
>   static int devpts_mounted;
> 
>   /* Check that the /dev/pts filesystem is mounted
>    or if /dev is a devfs filesystem (this implies
> /dev/pts).  */
>    if (devpts_mounted
>        || (__statfs (_PATH_DEVPTS, &fsbuf) == 0
>         && fsbuf.f_type == DEVPTS_SUPER_MAGIC)
>        || (__statfs (_PATH_DEV, &fsbuf) == 0
>        && fsbuf.f_type == DEVFS_SUPER_MAGIC))
> 
> In the above, _PATH_DEVPTS is defined as :
> #define _PATH_DEVPTS _PATH_DEV "pts"
> ie. "/dev/pts"
> So the above statfs() stats "/dev/pts", which is a
> directory in the filesystem.
> On my system:
>  $ mount|grep pts
>   none on /dev/pts type devpts (rw,gid=5,mode=620)
>  $ ls -ld /dev/pts
>  drwxr-xr-x    2 root     root            0 Jun 10
> 16:07 /dev/pts/
> 
> Due to the above (/dev/ is not devfs and /dev/pts is a
> directory), the magic is not what's expected.

Hold it there -- statfs should definitely work on a directory too.
The appended program yields on my 2.4.21 system:

f_type=1cd1 PTS_MAGIC=1cd1

If it doesn't on your's, there may be a kernel bug in the statfs
syscall.

Regards,
Wolfram.

#include <stdio.h>
#include <sys/vfs.h>
#define DEVPTS_SUPER_MAGIC 0x1cd1
int main()
{
    struct statfs sf;

    if (statfs("/dev/pts", &sf) == 0) {
        printf("f_type=%lx PTS_MAGIC=%lx\n", sf.f_type, DEVPTS_SUPER_MAGIC);
    }
    return 0;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]