@@ -129,8 +129,8 @@ dsearch_find(
129129{
130130struct stat statbuf ;
131131int 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 ;
134134enum {
135135 RET_KEY , /* return the key */
136136 RET_DIR , /* return the dir without the key */
@@ -166,7 +166,7 @@ if (opts)
166166 else if (Ustrcmp (ele , "dir" ) == 0 )
167167 ret_mode = RET_DIR ;
168168 #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() */
170170 else if (Ustrcmp (ele , "key ") == 0 )
171171 ret_mode = RET_KEY ;
172172 #endif
@@ -179,11 +179,19 @@ if (opts)
179179 else if (Ustrncmp (ele , "filter=" , 7 ) == 0 )
180180 {
181181 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 ".." */
187195 else
188196 {
189197 * errmsg = string_sprintf ("unknown parameter for dsearch lookup: %s" , ele -= 7 );
@@ -206,15 +214,15 @@ if (ignore_key)
206214else if (keystring == NULL || keystring [0 ] == 0 ) /* in case lstat treats "/dir/" the same as "/dir/." */
207215 return FAIL ;
208216
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" ,
210218 follow_symlink ? "follow, " : "" ,
211- exclude_dotdotdot ? "filter=nodots , " : "" ,
212- filter_by_type ,
219+ allowdots ? "filter=allowdots , " : "" ,
220+ ( uintmax_t ) filter_by_type ,
213221 ret_mode == RET_FULL ? "full" : ret_mode == RET_DIR ? "dir" : "key" ,
214222 keystring );
215223
216224/* exclude "." and ".." when {filter=subdir} included */
217- if (exclude_dotdotdot
225+ if (! allowdots
218226 && keystring [0 ] == '.'
219227 && (keystring [1 ] == 0
220228 || keystring [1 ] == '.' && keystring [2 ] == 0 ))
235243if (stat_result >= 0 )
236244 {
237245 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 ))
239247 {
240248 switch (ret_mode )
241249 {
0 commit comments