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