@@ -154,9 +154,10 @@ struct my_statx
154
154
#define STATX_MODE 0x00000002U
155
155
#endif
156
156
157
- #ifndef STATX_ALL
158
- #define STATX_ALL (STATX_BTIME | STATX_BASIC_STATS)
159
- #endif
157
+ //
158
+ // STATX_ALL is deprecated; use a different name to avoid confusion.
159
+ //
160
+ #define LOCAL_STATX_ALL (STATX_BASIC_STATS | STATX_BTIME)
160
161
161
162
#ifndef AT_FDCWD
162
163
#define AT_FDCWD -100
@@ -632,8 +633,19 @@ static void copy_statx_attributes(JNIEnv* env, struct my_statx* buf, jobject att
632
633
(* env )-> SetLongField (env , attrs , attrs_st_atime_sec , (jlong )buf -> stx_atime .tv_sec );
633
634
(* env )-> SetLongField (env , attrs , attrs_st_mtime_sec , (jlong )buf -> stx_mtime .tv_sec );
634
635
(* env )-> SetLongField (env , attrs , attrs_st_ctime_sec , (jlong )buf -> stx_ctime .tv_sec );
635
- (* env )-> SetLongField (env , attrs , attrs_st_birthtime_sec , (jlong )buf -> stx_btime .tv_sec );
636
- (* env )-> SetLongField (env , attrs , attrs_st_birthtime_nsec , (jlong )buf -> stx_btime .tv_nsec );
636
+ if ((buf -> stx_mask & STATX_BTIME ) != 0 ) {
637
+ // Birth time was filled in so use it
638
+ (* env )-> SetLongField (env , attrs , attrs_st_birthtime_sec ,
639
+ (jlong )buf -> stx_btime .tv_sec );
640
+ (* env )-> SetLongField (env , attrs , attrs_st_birthtime_nsec ,
641
+ (jlong )buf -> stx_btime .tv_nsec );
642
+ } else {
643
+ // Birth time was not filled in: fall back to last modification time
644
+ (* env )-> SetLongField (env , attrs , attrs_st_birthtime_sec ,
645
+ (jlong )buf -> stx_mtime .tv_sec );
646
+ (* env )-> SetLongField (env , attrs , attrs_st_birthtime_nsec ,
647
+ (jlong )buf -> stx_mtime .tv_nsec );
648
+ }
637
649
(* env )-> SetLongField (env , attrs , attrs_st_atime_nsec , (jlong )buf -> stx_atime .tv_nsec );
638
650
(* env )-> SetLongField (env , attrs , attrs_st_mtime_nsec , (jlong )buf -> stx_mtime .tv_nsec );
639
651
(* env )-> SetLongField (env , attrs , attrs_st_ctime_nsec , (jlong )buf -> stx_ctime .tv_nsec );
@@ -687,7 +699,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_stat0(JNIEnv* env, jclass this,
687
699
#if defined(__linux__ )
688
700
struct my_statx statx_buf ;
689
701
int flags = AT_STATX_SYNC_AS_STAT ;
690
- unsigned int mask = STATX_ALL ;
702
+ unsigned int mask = LOCAL_STATX_ALL ;
691
703
692
704
if (my_statx_func != NULL ) {
693
705
// Prefer statx over stat64 on Linux if it's available
@@ -748,7 +760,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_lstat0(JNIEnv* env, jclass this,
748
760
#if defined(__linux__ )
749
761
struct my_statx statx_buf ;
750
762
int flags = AT_STATX_SYNC_AS_STAT | AT_SYMLINK_NOFOLLOW ;
751
- unsigned int mask = STATX_ALL ;
763
+ unsigned int mask = LOCAL_STATX_ALL ;
752
764
753
765
if (my_statx_func != NULL ) {
754
766
// Prefer statx over stat64 on Linux if it's available
@@ -779,7 +791,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_fstat(JNIEnv* env, jclass this, jint fd,
779
791
#if defined(__linux__ )
780
792
struct my_statx statx_buf ;
781
793
int flags = AT_EMPTY_PATH | AT_STATX_SYNC_AS_STAT ;
782
- unsigned int mask = STATX_ALL ;
794
+ unsigned int mask = LOCAL_STATX_ALL ;
783
795
784
796
if (my_statx_func != NULL ) {
785
797
// statx supports FD use via dirfd iff pathname is an empty string and the
@@ -812,7 +824,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_fstatat0(JNIEnv* env, jclass this, jint dfd
812
824
#if defined(__linux__ )
813
825
struct my_statx statx_buf ;
814
826
int flags = AT_STATX_SYNC_AS_STAT ;
815
- unsigned int mask = STATX_ALL ;
827
+ unsigned int mask = LOCAL_STATX_ALL ;
816
828
817
829
if (my_statx_func != NULL ) {
818
830
// Prefer statx over stat64 on Linux if it's available
0 commit comments