@@ -129,8 +129,8 @@ dsearch_find(
129
129
{
130
130
struct stat statbuf ;
131
131
int save_errno ;
132
- unsigned filter_by_type = 0 ;
133
- int exclude_dotdotdot = 0 ;
132
+ ifmt_set_t filter_by_type = 0 ;
133
+ int allowdots = 0 ;
134
134
enum {
135
135
RET_KEY , /* return the key */
136
136
RET_DIR , /* return the dir without the key */
@@ -166,7 +166,7 @@ if (opts)
166
166
else if (Ustrcmp (ele , "dir" ) == 0 )
167
167
ret_mode = RET_DIR ;
168
168
#if 0
169
- /* XXX ret=key is excluded from opts by special-case code in by search_find() */
169
+ /* NOTE ret=key is excluded from opts by special-case code in by search_find() */
170
170
else if (Ustrcmp (ele , "key ") == 0 )
171
171
ret_mode = RET_KEY ;
172
172
#endif
@@ -179,11 +179,19 @@ if (opts)
179
179
else if (Ustrncmp (ele , "filter=" , 7 ) == 0 )
180
180
{
181
181
ele += 7 ;
182
- int i = S_IFMTix_from_name (ele );
183
- if (i >=0 )
184
- filter_by_type |= BIT (i );
185
- else if (Ustrcmp (ele , "subdir" ) == 0 ) filter_by_type |= BIT (S_IFMT_to_index (S_IFDIR )), exclude_dotdotdot = 1 ; /* dir but not "." or ".." */
186
- else if (Ustrcmp (ele , "nodots" ) == 0 ) exclude_dotdotdot = 1 ; /* any but "." or ".." */
182
+ ifmt_set_t m = S_IFMTset_from_name (ele );
183
+ if (m )
184
+ {
185
+ filter_by_type |= m ;
186
+ /* XXX issue immediate deprecation warning */
187
+ #ifndef NO_DIR_IMPLIES_ALLOWDOTS
188
+ /* allow "." or ".." when "dir" rather than "subdir" */
189
+ if (m == S_IFMT_to_set (S_IFDIR ) && ele [0 ] == 'd' )
190
+ allowdots = 1 ;
191
+ #endif
192
+ }
193
+ else if (Ustrcmp (ele , "allowdots" ) == 0 )
194
+ allowdots = 1 ; /* allow "." or ".." */
187
195
else
188
196
{
189
197
* errmsg = string_sprintf ("unknown parameter for dsearch lookup: %s" , ele -= 7 );
@@ -206,15 +214,15 @@ if (ignore_key)
206
214
else if (keystring == NULL || keystring [0 ] == 0 ) /* in case lstat treats "/dir/" the same as "/dir/." */
207
215
return FAIL ;
208
216
209
- DEBUG (D_lookup ) debug_printf_indent (" dsearch_find: %s%sfilterbits=%#x ret=%s key=%s\n" ,
217
+ DEBUG (D_lookup ) debug_printf_indent (" dsearch_find: %s%sfilter_set=%04jx ret=%s key=%s\n" ,
210
218
follow_symlink ? "follow, " : "" ,
211
- exclude_dotdotdot ? "filter=nodots , " : "" ,
212
- filter_by_type ,
219
+ allowdots ? "filter=allowdots , " : "" ,
220
+ ( uintmax_t ) filter_by_type ,
213
221
ret_mode == RET_FULL ? "full" : ret_mode == RET_DIR ? "dir" : "key" ,
214
222
keystring );
215
223
216
224
/* exclude "." and ".." when {filter=subdir} included */
217
- if (exclude_dotdotdot
225
+ if (! allowdots
218
226
&& keystring [0 ] == '.'
219
227
&& (keystring [1 ] == 0
220
228
|| keystring [1 ] == '.' && keystring [2 ] == 0 ))
235
243
if (stat_result >= 0 )
236
244
{
237
245
if (!filter_by_type
238
- || filter_by_type & BIT ( S_IFMT_to_index ( statbuf .st_mode ) ))
246
+ || filter_by_type & S_IFMT_to_set ( statbuf .st_mode ))
239
247
{
240
248
switch (ret_mode )
241
249
{
0 commit comments