NetBSD-Bugs archive

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

Re: lib/44807: something broken in stat(2)



The following reply was made to PR lib/44807; it has been noted by GNATS.

From: christos%zoulas.com@localhost (Christos Zoulas)
To: gnats-bugs%NetBSD.org@localhost, lib-bug-people%netbsd.org@localhost, 
        gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Cc: 
Subject: Re: lib/44807: something broken in stat(2)
Date: Wed, 30 Mar 2011 14:38:39 -0400

 On Mar 30,  6:15pm, jruohonen%iki.fi@localhost (Jukka Ruohonen) wrote:
 -- Subject: lib/44807: something broken in stat(2)
 
 | >Number:         44807
 | >Category:       lib
 | >Synopsis:       something broken in stat(2)
 | >Confidential:   no
 | >Severity:       serious
 | >Priority:       high
 | >Responsible:    lib-bug-people
 | >State:          open
 | >Class:          sw-bug
 | >Submitter-Id:   net
 | >Arrival-Date:   Wed Mar 30 18:15:00 +0000 2011
 | >Originator:     Jukka Ruohonen
 | >Release:        5.1 - 5.99.48
 | >Organization:
 | -
 | >Description:
 | 
 | Another one caught by automated tests.
 | 
 | Something related to stat(2) is seriously broken somewhere. For instance,
 | opening "/dev/bpf" and stat'ing it either fails or reports odd results.
 | 
 | While I haven't done any analysis, it seems that this might be related to
 | the old, closed, bugs:
 | 
 |      PR kern/37550: fstat(1) not reporting open descriptors properly
 |      PR kern/37878: fdclone(9) suspected of not working well with fstat(1)
 | 
 | Given that those were fixed, it seems that this is again a regression.
 | 
 | >How-To-Repeat:
 | 
 | To add more weirdness, the following program prints a value 0 on 5.99.48,
 | but the fstat(2) fails on 5.1.
 
 It works as expected. /dev/bpf is a cloner, so you get a new instance each
 time you run. The instance does not have a place in the filesystem, so you
 get the "right" information as far as that is concerned.
 
 $ ./a.out
 dev=[23, 12761]        # major 23 always
 mode=0 # correct
 ino=0  # correct
 nlink=0        # correct
 uid=0  # correct
 gid=0  # correct
 rdev=[0, 0]    # irrelevant
 a=[1301510133, 111864879] Wed Mar 30 14:35:33 2011 # correct times
 m=[1301510133, 111864879] Wed Mar 30 14:35:33 2011 # correct times
 c=[1301510133, 111864879] Wed Mar 30 14:35:33 2011 # correct times
 birth=[1301510133, 111864879] Wed Mar 30 14:35:33 2011 # correct times
 size=0 # correct
 blocks=0       # correct
 blksize=0      # correct
 flags=0        # correct
 gen=0  # correct
 
 Now fchown on the fd does not work, so :-)
 
 
 christos
 
 ----
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdio.h>
 #include <time.h>
 #include <string.h>
 #include <fcntl.h>
 #include <stdlib.h>
 int
 main(void)
 {
         struct stat st;
         int fd, rv;
 
         (void)memset(&st, 0, sizeof(struct stat));
 
         fd = open("/dev/bpf", O_RDONLY);
 
         if (fd < 0)
                 return EXIT_FAILURE;
 
         rv = fstat(fd, &st);
         (void)close(fd);
 
         if (rv < 0)
                 return EXIT_FAILURE;
 
 #define PR(t,f) printf(#f "=%ll" #t "\n", \
     (long long)st.st_ ## f)
 #define PRT(f)  printf(#f "=[%llu, %llu] %s", \
     (long long)st.st_ ## f ## timespec.tv_sec, \
     (long long)st.st_ ## f ## timespec.tv_nsec, \
     ctime(&st.st_ ## f ## timespec.tv_sec))
 #define PRD(f)  printf(#f "=[%llu, %llu]\n", \
     (long long)major(st.st_ ## f), \
     (long long)minor(st.st_ ## f))
 
         PRD(dev);
         PR(o,mode);
         PR(d,ino);
         PR(d,nlink);
         PR(u,uid);
         PR(u,gid);
         PRD(rdev);
         PRT(a);
         PRT(m);
         PRT(c);
         PRT(birth);
         PR(u,size);
         PR(u,blocks);
         PR(u,blksize);
         PR(x,flags);
         PR(u,gen);
 
         return EXIT_SUCCESS;
 }
 
 


Home | Main Index | Thread Index | Old Index