[BZ,18234] struct stat is not posix conform

Message ID 555E04B0.1020801@arm.com
State Committed
Headers

Commit Message

Szabolcs Nagy May 21, 2015, 4:15 p.m. UTC
  On 21/05/15 05:29, Siddhesh Poyarekar wrote:
> On Wed, May 20, 2015 at 06:55:02PM +0100, Szabolcs Nagy wrote:
>> i guess it's ok for consistency if i fix struct stat64
>> too to use __USE_XOPEN2K8.
>>
>> i will run some tests and come back with a patch
> 
> I also think it would be appropriate to change this code in other
> architectures (microblaze and nacl IIRC) to make all of them
> consistent.  It is a mechanical enough change IMO that all arch
> maintainer acks is not necessary.
> 

here is the patch with consistent __USE_XOPEN2K8

ok to commit?

2015-05-21  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	[BZ #18234]
	* conform/data/sys/stat.h-data (struct stat): Add tests for st_atim,
	st_mtim and st_ctim members.

	* sysdeps/nacl/bits/stat.h (struct stat, struct stat64): Make
	st_atim, st_ctim, st_mtim visible under __USE_XOPEN2K8 only.

	* sysdeps/unix/sysv/linux/generic/bits/stat.h (struct stat,):
	(struct stat64): Likewise.

	* sysdeps/unix/sysv/linux/ia64/bits/stat.h (struct stat,):
	(struct stat64): Likewise.

	* sysdeps/unix/sysv/linux/microblaze/bits/stat.h (struct stat,):
	(struct stat64): Likewise.
  

Comments

Siddhesh Poyarekar May 21, 2015, 4:23 p.m. UTC | #1
On Thu, May 21, 2015 at 05:15:44PM +0100, Szabolcs Nagy wrote:
> On 21/05/15 05:29, Siddhesh Poyarekar wrote:
> > On Wed, May 20, 2015 at 06:55:02PM +0100, Szabolcs Nagy wrote:
> >> i guess it's ok for consistency if i fix struct stat64
> >> too to use __USE_XOPEN2K8.
> >>
> >> i will run some tests and come back with a patch
> > 
> > I also think it would be appropriate to change this code in other
> > architectures (microblaze and nacl IIRC) to make all of them
> > consistent.  It is a mechanical enough change IMO that all arch
> > maintainer acks is not necessary.
> > 
> 
> here is the patch with consistent __USE_XOPEN2K8
> 
> ok to commit?
> 
> 2015-05-21  Szabolcs Nagy  <szabolcs.nagy@arm.com>
> 
> 	[BZ #18234]
> 	* conform/data/sys/stat.h-data (struct stat): Add tests for st_atim,
> 	st_mtim and st_ctim members.
> 
> 	* sysdeps/nacl/bits/stat.h (struct stat, struct stat64): Make
> 	st_atim, st_ctim, st_mtim visible under __USE_XOPEN2K8 only.
> 
> 	* sysdeps/unix/sysv/linux/generic/bits/stat.h (struct stat,):
> 	(struct stat64): Likewise.
> 
> 	* sysdeps/unix/sysv/linux/ia64/bits/stat.h (struct stat,):
> 	(struct stat64): Likewise.
> 
> 	* sysdeps/unix/sysv/linux/microblaze/bits/stat.h (struct stat,):
> 	(struct stat64): Likewise.

The Changelog entry lines should not have the extra newlines.  Looks
fine to me other than that.  It doesn't look like you have commit
access, so I'll commit it tomorrow for you.

Siddhesh

> diff --git a/conform/data/sys/stat.h-data b/conform/data/sys/stat.h-data
> index 631daa4..f5b17a3 100644
> --- a/conform/data/sys/stat.h-data
> +++ b/conform/data/sys/stat.h-data
> @@ -39,6 +39,11 @@ element {struct stat} off_t st_size
>  element {struct stat} time_t st_atime
>  element {struct stat} time_t st_mtime
>  element {struct stat} time_t st_ctime
> +#if defined XOPEN2K8 || defined POSIX2008
> +element {struct stat} {struct timespec} st_atim
> +element {struct stat} {struct timespec} st_mtim
> +element {struct stat} {struct timespec} st_ctim
> +#endif
>  #if !defined POSIX && !defined POSIX2008
>  element {struct stat} blksize_t st_blksize
>  element {struct stat} blkcnt_t st_blocks
> diff --git a/sysdeps/nacl/bits/stat.h b/sysdeps/nacl/bits/stat.h
> index 0cd3500..9b89b15 100644
> --- a/sysdeps/nacl/bits/stat.h
> +++ b/sysdeps/nacl/bits/stat.h
> @@ -42,7 +42,7 @@ struct stat
>      __off_t st_size;		/* Size of file, in bytes.  */
>      __blksize_t st_blksize;	/* Optimal block size for I/O.  */
>      __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
> -#if defined __USE_MISC || defined __USE_XOPEN2K8
> +#if defined __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -81,7 +81,7 @@ struct stat64
>      __off_t st_size;		/* Size of file, in bytes.  */
>      __blksize_t st_blksize;	/* Optimal block size for I/O.  */
>      __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
> -# if defined __USE_MISC || defined __USE_XOPEN2K8
> +# if defined __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> diff --git a/sysdeps/unix/sysv/linux/generic/bits/stat.h b/sysdeps/unix/sysv/linux/generic/bits/stat.h
> index 42cb198..4c32f66 100644
> --- a/sysdeps/unix/sysv/linux/generic/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/generic/bits/stat.h
> @@ -66,7 +66,7 @@ struct stat
>      __blksize_t st_blksize;	/* Optimal block size for I/O.  */
>      int __pad2;
>      __field64(__blkcnt_t, __blkcnt64_t, st_blocks);  /* 512-byte blocks */
> -#ifdef __USE_MISC
> +#ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -107,7 +107,7 @@ struct stat64
>      __blksize_t st_blksize;	/* Optimal block size for I/O.  */
>      int __pad2;
>      __blkcnt64_t st_blocks;	/* Nr. 512-byte blocks allocated.  */
> -#ifdef __USE_MISC
> +#ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> diff --git a/sysdeps/unix/sysv/linux/ia64/bits/stat.h b/sysdeps/unix/sysv/linux/ia64/bits/stat.h
> index c14cd7b..ed79676 100644
> --- a/sysdeps/unix/sysv/linux/ia64/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/ia64/bits/stat.h
> @@ -41,7 +41,7 @@ struct stat
>      int pad0;
>      __dev_t st_rdev;		/* Device number, if device.  */
>      __off_t st_size;		/* Size of file, in bytes.  */
> -#ifdef __USE_MISC
> +#ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -80,7 +80,7 @@ struct stat64
>      int pad0;
>      __dev_t st_rdev;		/* Device number, if device.  */
>      __off_t st_size;		/* Size of file, in bytes.  */
> -#ifdef __USE_MISC
> +#ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> diff --git a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h b/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
> index d45b275..df2d306 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
> +++ b/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
> @@ -50,7 +50,7 @@ struct stat
>          __blksize_t     st_blksize; /* Optimal block size for I/O.  */
>          int             __pad3;
>          __blkcnt_t      st_blocks;  /* Number 512-byte blocks allocated.  */
> -#ifdef __USE_MISC
> +#ifdef __USE_XOPEN2K8
>          /* Nanosecond resolution timestamps are stored in a format
>           * equivalent to 'struct timespec'. This is the type used
>           * whenever possible but the Unix namespace rules do not allow the
> @@ -135,7 +135,7 @@ struct stat64
>          __blksize_t             st_blksize; /* Optimal block size for I/O.  */
>          int                     __pad3;
>          __blkcnt64_t            st_blocks;  /* Number 512-byte blocks allocated.  */
> -#ifdef __USE_MISC
> +#ifdef __USE_XOPEN2K8
>          /* Nanosecond resolution timestamps are stored in a format
>           * equivalent to 'struct timespec'. This is the type used
>           * whenever possible but the Unix namespace rules do not allow the
  
Carlos O'Donell May 21, 2015, 6 p.m. UTC | #2
On 05/21/2015 12:15 PM, Szabolcs Nagy wrote:
> On 21/05/15 05:29, Siddhesh Poyarekar wrote:
>> On Wed, May 20, 2015 at 06:55:02PM +0100, Szabolcs Nagy wrote:
>>> i guess it's ok for consistency if i fix struct stat64
>>> too to use __USE_XOPEN2K8.
>>>
>>> i will run some tests and come back with a patch
>>
>> I also think it would be appropriate to change this code in other
>> architectures (microblaze and nacl IIRC) to make all of them
>> consistent.  It is a mechanical enough change IMO that all arch
>> maintainer acks is not necessary.
>>
> 
> here is the patch with consistent __USE_XOPEN2K8
> 
> ok to commit?
> 
> 2015-05-21  Szabolcs Nagy  <szabolcs.nagy@arm.com>
> 
> 	[BZ #18234]
> 	* conform/data/sys/stat.h-data (struct stat): Add tests for st_atim,
> 	st_mtim and st_ctim members.
> 
> 	* sysdeps/nacl/bits/stat.h (struct stat, struct stat64): Make
> 	st_atim, st_ctim, st_mtim visible under __USE_XOPEN2K8 only.
> 
> 	* sysdeps/unix/sysv/linux/generic/bits/stat.h (struct stat,):
> 	(struct stat64): Likewise.
> 
> 	* sysdeps/unix/sysv/linux/ia64/bits/stat.h (struct stat,):
> 	(struct stat64): Likewise.
> 
> 	* sysdeps/unix/sysv/linux/microblaze/bits/stat.h (struct stat,):
> 	(struct stat64): Likewise.
> 

Modulo the ChangeLog problem pointed out by Siddhesh this also looks good to me.

Cheers,
Carlos.
  
Szabolcs Nagy May 22, 2015, 9:24 a.m. UTC | #3
On 21/05/15 17:23, Siddhesh Poyarekar wrote:
> On Thu, May 21, 2015 at 05:15:44PM +0100, Szabolcs Nagy wrote:
>> here is the patch with consistent __USE_XOPEN2K8
>>
>> ok to commit?
>>
>> 2015-05-21  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>>
>> 	[BZ #18234]
>> 	* conform/data/sys/stat.h-data (struct stat): Add tests for st_atim,
>> 	st_mtim and st_ctim members.
>>
>> 	* sysdeps/nacl/bits/stat.h (struct stat, struct stat64): Make
>> 	st_atim, st_ctim, st_mtim visible under __USE_XOPEN2K8 only.
>>
>> 	* sysdeps/unix/sysv/linux/generic/bits/stat.h (struct stat,):
>> 	(struct stat64): Likewise.
>>
>> 	* sysdeps/unix/sysv/linux/ia64/bits/stat.h (struct stat,):
>> 	(struct stat64): Likewise.
>>
>> 	* sysdeps/unix/sysv/linux/microblaze/bits/stat.h (struct stat,):
>> 	(struct stat64): Likewise.
> 
> The Changelog entry lines should not have the extra newlines.  Looks
> fine to me other than that.  It doesn't look like you have commit
> access, so I'll commit it tomorrow for you.
> 

thanks, that would be nice.

changelog, without empty lines:

2015-05-22  Szabolcs Nagy  <szabolcs.nagy@arm.com>

 	[BZ #18234]
 	* conform/data/sys/stat.h-data (struct stat): Add tests for st_atim,
 	st_mtim and st_ctim members.
 	* sysdeps/nacl/bits/stat.h (struct stat, struct stat64): Make
 	st_atim, st_ctim, st_mtim visible under __USE_XOPEN2K8 only.
 	* sysdeps/unix/sysv/linux/generic/bits/stat.h (struct stat,):
 	(struct stat64): Likewise.
 	* sysdeps/unix/sysv/linux/ia64/bits/stat.h (struct stat,):
 	(struct stat64): Likewise.
 	* sysdeps/unix/sysv/linux/microblaze/bits/stat.h (struct stat,):
 	(struct stat64): Likewise.
  

Patch

diff --git a/conform/data/sys/stat.h-data b/conform/data/sys/stat.h-data
index 631daa4..f5b17a3 100644
--- a/conform/data/sys/stat.h-data
+++ b/conform/data/sys/stat.h-data
@@ -39,6 +39,11 @@  element {struct stat} off_t st_size
 element {struct stat} time_t st_atime
 element {struct stat} time_t st_mtime
 element {struct stat} time_t st_ctime
+#if defined XOPEN2K8 || defined POSIX2008
+element {struct stat} {struct timespec} st_atim
+element {struct stat} {struct timespec} st_mtim
+element {struct stat} {struct timespec} st_ctim
+#endif
 #if !defined POSIX && !defined POSIX2008
 element {struct stat} blksize_t st_blksize
 element {struct stat} blkcnt_t st_blocks
diff --git a/sysdeps/nacl/bits/stat.h b/sysdeps/nacl/bits/stat.h
index 0cd3500..9b89b15 100644
--- a/sysdeps/nacl/bits/stat.h
+++ b/sysdeps/nacl/bits/stat.h
@@ -42,7 +42,7 @@  struct stat
     __off_t st_size;		/* Size of file, in bytes.  */
     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
     __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
-#if defined __USE_MISC || defined __USE_XOPEN2K8
+#if defined __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -81,7 +81,7 @@  struct stat64
     __off_t st_size;		/* Size of file, in bytes.  */
     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
     __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
-# if defined __USE_MISC || defined __USE_XOPEN2K8
+# if defined __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
diff --git a/sysdeps/unix/sysv/linux/generic/bits/stat.h b/sysdeps/unix/sysv/linux/generic/bits/stat.h
index 42cb198..4c32f66 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/stat.h
@@ -66,7 +66,7 @@  struct stat
     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
     int __pad2;
     __field64(__blkcnt_t, __blkcnt64_t, st_blocks);  /* 512-byte blocks */
-#ifdef __USE_MISC
+#ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -107,7 +107,7 @@  struct stat64
     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
     int __pad2;
     __blkcnt64_t st_blocks;	/* Nr. 512-byte blocks allocated.  */
-#ifdef __USE_MISC
+#ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
diff --git a/sysdeps/unix/sysv/linux/ia64/bits/stat.h b/sysdeps/unix/sysv/linux/ia64/bits/stat.h
index c14cd7b..ed79676 100644
--- a/sysdeps/unix/sysv/linux/ia64/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/ia64/bits/stat.h
@@ -41,7 +41,7 @@  struct stat
     int pad0;
     __dev_t st_rdev;		/* Device number, if device.  */
     __off_t st_size;		/* Size of file, in bytes.  */
-#ifdef __USE_MISC
+#ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -80,7 +80,7 @@  struct stat64
     int pad0;
     __dev_t st_rdev;		/* Device number, if device.  */
     __off_t st_size;		/* Size of file, in bytes.  */
-#ifdef __USE_MISC
+#ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
diff --git a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h b/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
index d45b275..df2d306 100644
--- a/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/microblaze/bits/stat.h
@@ -50,7 +50,7 @@  struct stat
         __blksize_t     st_blksize; /* Optimal block size for I/O.  */
         int             __pad3;
         __blkcnt_t      st_blocks;  /* Number 512-byte blocks allocated.  */
-#ifdef __USE_MISC
+#ifdef __USE_XOPEN2K8
         /* Nanosecond resolution timestamps are stored in a format
          * equivalent to 'struct timespec'. This is the type used
          * whenever possible but the Unix namespace rules do not allow the
@@ -135,7 +135,7 @@  struct stat64
         __blksize_t             st_blksize; /* Optimal block size for I/O.  */
         int                     __pad3;
         __blkcnt64_t            st_blocks;  /* Number 512-byte blocks allocated.  */
-#ifdef __USE_MISC
+#ifdef __USE_XOPEN2K8
         /* Nanosecond resolution timestamps are stored in a format
          * equivalent to 'struct timespec'. This is the type used
          * whenever possible but the Unix namespace rules do not allow the