@@ -143,6 +143,47 @@ char *strchr(char*,char);
143
143
# define IS_WIN32 0
144
144
#endif
145
145
146
+ #ifdef HAVE_GETATTRLIST
147
+ struct getattrlist_args {
148
+ const char * path ;
149
+ int fd ;
150
+ struct attrlist * list ;
151
+ void * buf ;
152
+ size_t size ;
153
+ unsigned int options ;
154
+ };
155
+
156
+ static void *
157
+ nogvl_getattrlist (void * args )
158
+ {
159
+ struct getattrlist_args * arg = args ;
160
+ return (void * )(VALUE )getattrlist (arg -> path , arg -> list , arg -> buf , arg -> size , arg -> options );
161
+ }
162
+
163
+ static int
164
+ gvl_getattrlist (struct getattrlist_args * args , const char * path )
165
+ {
166
+ args -> path = path ;
167
+ return IO_WITHOUT_GVL_INT (nogvl_getattrlist , args );
168
+ }
169
+
170
+ # ifdef HAVE_FGETATTRLIST
171
+ static void *
172
+ nogvl_fgetattrlist (void * args )
173
+ {
174
+ struct getattrlist_args * arg = args ;
175
+ return (void * )(VALUE )fgetattrlist (arg -> fd , arg -> list , arg -> buf , arg -> size , arg -> options );
176
+ }
177
+
178
+ static int
179
+ gvl_fgetattrlist (struct getattrlist_args * args , int fd )
180
+ {
181
+ args -> fd = fd ;
182
+ return IO_WITHOUT_GVL_INT (nogvl_fgetattrlist , args );
183
+ }
184
+ # endif
185
+ #endif
186
+
146
187
#if NORMALIZE_UTF8PATH
147
188
# if defined HAVE_FGETATTRLIST || !defined HAVE_GETATTRLIST
148
189
# define need_normalization (dirp , path ) need_normalization(dirp)
@@ -155,10 +196,15 @@ need_normalization(DIR *dirp, const char *path)
155
196
# if defined HAVE_FGETATTRLIST || defined HAVE_GETATTRLIST
156
197
u_int32_t attrbuf [SIZEUP32 (fsobj_tag_t )];
157
198
struct attrlist al = {ATTR_BIT_MAP_COUNT , 0 , ATTR_CMN_OBJTAG ,};
199
+ struct getattrlist_args args ;
200
+ args .list = & al ;
201
+ args .buf = attrbuf ;
202
+ args .size = sizeof (attrbuf );
203
+ args .options = 0 ;
158
204
# if defined HAVE_FGETATTRLIST
159
- int ret = fgetattrlist ( dirfd ( dirp ), & al , attrbuf , sizeof ( attrbuf ), 0 );
205
+ int ret = gvl_fgetattrlist ( & args , dirfd ( dirp ) );
160
206
# else
161
- int ret = getattrlist ( path , & al , attrbuf , sizeof ( attrbuf ), 0 );
207
+ int ret = gvl_getattrlist ( & args , path );
162
208
# endif
163
209
if (!ret ) {
164
210
const fsobj_tag_t * tag = (void * )(attrbuf + 1 );
@@ -555,7 +601,12 @@ dir_initialize(rb_execution_context_t *ec, VALUE dir, VALUE dirname, VALUE enc)
555
601
else if (e == EIO ) {
556
602
u_int32_t attrbuf [1 ];
557
603
struct attrlist al = {ATTR_BIT_MAP_COUNT , 0 };
558
- if (getattrlist (path , & al , attrbuf , sizeof (attrbuf ), FSOPT_NOFOLLOW ) == 0 ) {
604
+ struct getattrlist_args args ;
605
+ args .list = & al ;
606
+ args .buf = attrbuf ;
607
+ args .size = sizeof (attrbuf );
608
+ args .options = FSOPT_NOFOLLOW ;
609
+ if (gvl_getattrlist (& args , path ) == 0 ) {
559
610
dp -> dir = opendir_without_gvl (path );
560
611
}
561
612
}
@@ -2134,14 +2185,19 @@ is_case_sensitive(DIR *dirp, const char *path)
2134
2185
const vol_capabilities_attr_t * const cap = attrbuf [0 ].cap ;
2135
2186
const int idx = VOL_CAPABILITIES_FORMAT ;
2136
2187
const uint32_t mask = VOL_CAP_FMT_CASE_SENSITIVE ;
2137
-
2188
+ struct getattrlist_args args ;
2189
+ args .list = & al ;
2190
+ args .buf = attrbuf ;
2191
+ args .size = sizeof (attrbuf );
2192
+ args .options = FSOPT_NOFOLLOW ;
2138
2193
# if defined HAVE_FGETATTRLIST
2139
- if (fgetattrlist (dirfd (dirp ), & al , attrbuf , sizeof (attrbuf ), FSOPT_NOFOLLOW ))
2140
- return -1 ;
2194
+ int ret = gvl_fgetattrlist (& args , dirfd (dirp ));
2141
2195
# else
2142
- if (getattrlist (path , & al , attrbuf , sizeof (attrbuf ), FSOPT_NOFOLLOW ))
2143
- return -1 ;
2196
+ int ret = gvl_getattrlist (& args , path );
2144
2197
# endif
2198
+ if (ret )
2199
+ return -1 ;
2200
+
2145
2201
if (!(cap -> valid [idx ] & mask ))
2146
2202
return -1 ;
2147
2203
return (cap -> capabilities [idx ] & mask ) != 0 ;
@@ -2164,7 +2220,12 @@ replace_real_basename(char *path, long base, rb_encoding *enc, int norm_p, int f
2164
2220
IF_NORMALIZE_UTF8PATH (VALUE utf8str = Qnil );
2165
2221
2166
2222
* type = path_noent ;
2167
- if (getattrlist (path , & al , attrbuf , sizeof (attrbuf ), FSOPT_NOFOLLOW )) {
2223
+ struct getattrlist_args args ;
2224
+ args .list = & al ;
2225
+ args .buf = attrbuf ;
2226
+ args .size = sizeof (attrbuf );
2227
+ args .options = FSOPT_NOFOLLOW ;
2228
+ if (gvl_getattrlist (& args , path )) {
2168
2229
if (!to_be_ignored (errno ))
2169
2230
sys_warning (path , enc );
2170
2231
return path ;
@@ -3700,12 +3761,17 @@ rb_dir_s_empty_p(VALUE obj, VALUE dirname)
3700
3761
{
3701
3762
u_int32_t attrbuf [SIZEUP32 (fsobj_tag_t )];
3702
3763
struct attrlist al = {ATTR_BIT_MAP_COUNT , 0 , ATTR_CMN_OBJTAG ,};
3703
- if (getattrlist (path , & al , attrbuf , sizeof (attrbuf ), 0 ) != 0 )
3764
+ struct getattrlist_args args ;
3765
+ args .list = & al ;
3766
+ args .buf = attrbuf ;
3767
+ args .size = sizeof (attrbuf );
3768
+ args .options = 0 ;
3769
+ if (gvl_getattrlist (& args , path ) != 0 )
3704
3770
rb_sys_fail_path (orig );
3705
3771
if (* (const fsobj_tag_t * )(attrbuf + 1 ) == VT_HFS ) {
3706
3772
al .commonattr = 0 ;
3707
3773
al .dirattr = ATTR_DIR_ENTRYCOUNT ;
3708
- if (getattrlist ( path , & al , attrbuf , sizeof ( attrbuf ), 0 ) == 0 ) {
3774
+ if (gvl_getattrlist ( & args , path ) == 0 ) {
3709
3775
if (attrbuf [0 ] >= 2 * sizeof (u_int32_t ))
3710
3776
return RBOOL (attrbuf [1 ] == 0 );
3711
3777
if (false_on_notdir ) return Qfalse ;
0 commit comments