NetBSD Problem Report #18255

Received: (qmail 3845 invoked by uid 605); 10 Sep 2002 14:05:35 -0000
Message-Id: <200209101405.g8AE5UW11088@rose.ehynan.com>
Date: Tue, 10 Sep 2002 10:05:31 -0400 (EDT)
From: "Edward V. Hynan Jr." <ehynan@rose.ehynan.com>
Sender: gnats-bugs-owner@netbsd.org
Reply-To: ehynan@rose.ehynan.com
To: gnats-bugs@gnats.netbsd.org
Subject: stat(2) manual page inaccurate
X-Send-Pr-Version: 3.95

>Number:         18255
>Category:       misc
>Synopsis:       stat(2) manual page inaccurate
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          closed
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 10 14:06:00 +0000 2002
>Closed-Date:    Tue Jun 14 12:20:21 +0000 2005
>Last-Modified:  Tue Jun 14 12:20:21 +0000 2005
>Originator:     Edward V. Hynan Jr.
>Release:        NetBSD 1.5.3
>Organization:

>Environment:


System: NetBSD rose 1.5.3 NetBSD 1.5.3 (ROSE) #0: Tue Sep 3 04:03:13 EDT 2002 toor@rose:/stella/NetBSD-1.5.3/rose/usr/src/sys/arch/i386/compile/ROSE i386
Architecture: i386
Machine: i386
>Description:

The stat(2) manual page, /usr/share/man/man2/stat.2, includes a definition
of struct stat that is not accurate.  The typedef'd types for the
st_{blocks,blksize} fields do not agree with sys/stat.h, nor does the
description of the time related fields.  The latter does not describe
the preprocessor macros conditional on !_POSIX_SOURCE && !_XOPEN_SOURCE.
Also, macros for st_{a,m,c}time{,nsec}, conditional on the above, are not shown.

>How-To-Repeat:
Invoke man 2 stat, and compare to /usr/include/sys/stat.h.
>Fix:
A patch is included below.  The form of the changes follow the FreeBSD stat(2),
but of course the content is from the NetBSD sys/stat.h.

BEGIN_PATCH
*** stat.2.orig	Mon Sep  9 22:38:56 2002
--- stat.2	Mon Sep  9 23:34:51 2002
***************
*** 96,107 ****
      uid_t     st_uid;     /* user-id of owner */
      gid_t     st_gid;     /* group-id of owner */
      dev_t     st_rdev;    /* device type, for special file inode */
      struct timespec st_atimespec;  /* time of last access */
      struct timespec st_mtimespec;  /* time of last data modification */
      struct timespec st_ctimespec;  /* time of last file status change */
      off_t     st_size;    /* file size, in bytes */
!     int64_t   st_blocks;  /* blocks allocated for file */
!     u_int32_t st_blksize; /* optimal file sys I/O ops blocksize */
      u_int32_t st_flags;   /* user defined flags for file */
      u_int32_t st_gen;     /* file generation number */
  };
--- 96,116 ----
      uid_t     st_uid;     /* user-id of owner */
      gid_t     st_gid;     /* group-id of owner */
      dev_t     st_rdev;    /* device type, for special file inode */
+ #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
      struct timespec st_atimespec;  /* time of last access */
      struct timespec st_mtimespec;  /* time of last data modification */
      struct timespec st_ctimespec;  /* time of last file status change */
+ #else
+     time_t    st_atime;            /* time of last access */
+     long      st_atimensec;        /* nsec of last access */
+     time_t    st_mtime;            /* time of last data modification */
+     long      st_mtimensec;        /* nsec of last data modification */
+     time_t    st_ctime;            /* time of last file status change */
+     long      st_ctimensec;        /* nsec of last file status change */
+ #endif
      off_t     st_size;    /* file size, in bytes */
!     blkcnt_t  st_blocks;  /* blocks allocated for file */
!     blksize_t st_blksize; /* optimal file sys I/O ops blocksize */
      u_int32_t st_flags;   /* user defined flags for file */
      u_int32_t st_gen;     /* file generation number */
  };
***************
*** 142,147 ****
--- 151,172 ----
  .Xr write 2
  system calls.
  .El
+ .Pp
+ If
+ .Dv _POSIX_SOURCE
+ and
+ .Dv _XOPEN_SOURCE
+ are not defined, the time-related fields are defined as:
+ .Bd -literal
+ #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
+ #define st_atime        st_atimespec.tv_sec
+ #define st_atimensec    st_atimespec.tv_nsec
+ #define st_mtime        st_mtimespec.tv_sec
+ #define st_mtimensec    st_mtimespec.tv_nsec
+ #define st_ctime        st_ctimespec.tv_sec
+ #define st_ctimensec    st_ctimespec.tv_nsec
+ #endif
+ .Ed
  .Pp
  The size-related fields of the
  .Fa struct stat
END_PATCH



>Release-Note:
>Audit-Trail:
From: Peter Postma <peter@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/18255 CVS commit: src/lib/libc/sys
Date: Tue, 14 Jun 2005 12:10:02 +0000 (UTC)

 Module Name:	src
 Committed By:	peter
 Date:		Tue Jun 14 12:10:02 UTC 2005

 Modified Files:
 	src/lib/libc/sys: stat.2

 Log Message:
 - Correct the fields in the stat structure. From PR/18255.
 - Document the st_birthtime field.

 Reviewed by wiz.


 To generate a diff of this commit:
 cvs rdiff -r1.33 -r1.34 src/lib/libc/sys/stat.2

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: peter@netbsd.org
State-Changed-When: Tue, 14 Jun 2005 12:20:21 +0000
State-Changed-Why:
fixed, thanks


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.