[Top][All Lists]
[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: |
Sreeji K Das |
Subject: |
Re: Fwd: Re: libc/5055 - [BUG] getpt() does not detect /dev/pts due towrong statfs() |
Date: |
Wed, 18 Jun 2003 18:19:59 +0100 (BST) |
Hi Wolfram
thx for ur sample code. I had similar piece of code
for my testing & it always produced the o/p
fstat.f_type = 7366766
I had been testing my sample script from within a
clearcase view ! Now I accidentally ran it outside the
view & boom ! it worked ! So it looks like clearcase
was the culprit (more specific, I think the mvfs
driver loaded by clarcase has hijacked statfs() ! I
need to debug this further !)
thanks
Sreeji
--- Wolfram Gloger <address@hidden>
wrote: > > 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;
> }
________________________________________________________________________
Want to chat instantly with your online friends? Get the FREE Yahoo!
Messenger http://uk.messenger.yahoo.com/