Subject: port-sparc/8406: lstat of "/" fails in SunOS emulation environment
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jarle@runit.no>
List: netbsd-bugs
Date: 09/14/1999 04:46:51
>Number:         8406
>Category:       port-sparc
>Synopsis:       lstat of "/" fails in SunOS emulation environment
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-sparc-maintainer (NetBSD/sparc Portmaster)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 14 03:35:00 1999
>Last-Modified:
>Originator:     Jarle Greipsland
>Organization:
	
>Release:        NetBSD-1.4.1
>Environment:
	
System: NetBSD ugle.ntnu.no 1.4.1 NetBSD 1.4.1 (UGLE) #0: Sun Sep 12 02:28:36 MEST 1999 jarle@ugle.ntnu.no:/usr/src/sys/arch/sparc/compile/UGLE sparc


>Description:
On one of our NetBSD/sparc sytems we use a commercial backup application,
and this application for whatever reason does an lstat on the root directory.
This lstat system call fails under NetBSD-1.4.1, but worked fine under
NetBSD-1.3.2.
	
>How-To-Repeat:

Compile the following code on a SunOS system, and then run it under
NetBSD-1.4.1 with a properly configured SunOS emulation environment:

#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>

#include <errno.h>

extern int sys_nerr;
extern char *sys_errlist[];
extern int errno;

int
main(int argc, char **argv)
{
        struct stat sb;
        int c;

        if (argc != 2) {
                fprintf(stderr, "Wrong number of arguments\n");
                exit(1);
        }
        c = lstat(argv[1], &sb);
        if (c != 0) {
                fprintf(stderr, "errno = %d, %s\n", errno, sys_errlist[errno]);
                exit(-1);
        } else {
                fprintf(stderr, "OK\n");
        }
}

On the SunOS system:
% ./a.out /
OK
%

On the NetBSD-1.4.1 system:
% ./a.out /
errno = 21, Is a directory
%

AFAICT this only happens when the parameter to lstat is "/".  Other
combinations such as "/." or "/./" seems to work fine.  Other directories 
work fine as well.

>Fix:
Unknown to me.
	
>Audit-Trail:
>Unformatted: