@@ -128,8 +128,8 @@ dsearch_find(
128128{
129129struct stat statbuf ;
130130int 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 ;
133133enum {
134134 RET_KEY , /* return the key */
135135 RET_DIR , /* return the dir without the key */
@@ -165,7 +165,7 @@ if (opts)
165165 else if (Ustrcmp (ele , "dir" ) == 0 )
166166 ret_mode = RET_DIR ;
167167 #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() */
169169 else if (Ustrcmp (ele , "key ") == 0 )
170170 ret_mode = RET_KEY ;
171171 #endif
@@ -178,11 +178,19 @@ if (opts)
178178 else if (Ustrncmp (ele , "filter=" , 7 ) == 0 )
179179 {
180180 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 ".." */
186194 else
187195 {
188196 * errmsg = string_sprintf ("unknown parameter for dsearch lookup: %s" , ele -= 7 );
@@ -205,15 +213,15 @@ if (ignore_key)
205213else if (keystring == NULL || keystring [0 ] == 0 ) /* in case lstat treats "/dir/" the same as "/dir/." */
206214 return FAIL ;
207215
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" ,
209217 follow_symlink ? "follow, " : "" ,
210- exclude_dotdotdot ? "filter=nodots , " : "" ,
211- filter_by_type ,
218+ allowdots ? "filter=allowdots , " : "" ,
219+ ( uintmax_t ) filter_by_type ,
212220 ret_mode == RET_FULL ? "full" : ret_mode == RET_DIR ? "dir" : "key" ,
213221 keystring );
214222
215223/* exclude "." and ".." when {filter=subdir} included */
216- if (exclude_dotdotdot
224+ if (! allowdots
217225 && keystring [0 ] == '.'
218226 && (keystring [1 ] == 0
219227 || keystring [1 ] == '.' && keystring [2 ] == 0 ))
234242if (stat_result >= 0 )
235243 {
236244 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 ))
238246 {
239247 switch (ret_mode )
240248 {
0 commit comments