Cache file_has_aclinfo failure, when it's trivial to do. Like file_has_aclinfo, but when F's st_dev says it's on a file system lacking ACL support, return 0 with ENOTSUP immediately. */
| 3235 | Like file_has_aclinfo, but when F's st_dev says it's on a file |
| 3236 | system lacking ACL support, return 0 with ENOTSUP immediately. */ |
| 3237 | static int |
| 3238 | file_has_aclinfo_cache (char const *file, struct fileinfo *f, |
| 3239 | struct aclinfo *ai, int flags) |
| 3240 | { |
| 3241 | /* If UNSUPPORTED_SCONTEXT, these variables hold the |
| 3242 | st_dev and associated info for the most recently processed device |
| 3243 | for which file_has_aclinfo failed indicating lack of support. */ |
| 3244 | static int unsupported_return; |
| 3245 | static char *unsupported_scontext; |
| 3246 | static int unsupported_scontext_err; |
| 3247 | static dev_t unsupported_device; |
| 3248 | |
| 3249 | if (f->stat_ok && unsupported_scontext |
| 3250 | && f->stat.st_dev == unsupported_device) |
| 3251 | { |
| 3252 | ai->buf = ai->u._gl_acl_ch; |
| 3253 | ai->size = 0; |
| 3254 | ai->scontext = unsupported_scontext; |
| 3255 | ai->scontext_err = unsupported_scontext_err; |
| 3256 | errno = ENOTSUP; |
| 3257 | return unsupported_return; |
| 3258 | } |
| 3259 | |
| 3260 | errno = 0; |
| 3261 | int n = file_has_aclinfo (file, ai, flags); |
| 3262 | int err = errno; |
| 3263 | if (f->stat_ok && n <= 0 && !acl_errno_valid (err) |
| 3264 | && (!(flags & ACL_GET_SCONTEXT) || !acl_errno_valid (ai->scontext_err))) |
| 3265 | { |
| 3266 | unsupported_return = n; |
| 3267 | unsupported_scontext = ai->scontext; |
| 3268 | unsupported_scontext_err = ai->scontext_err; |
| 3269 | unsupported_device = f->stat.st_dev; |
| 3270 | } |
| 3271 | return n; |
| 3272 | } |
| 3273 | |
| 3274 | /* Cache has_capability failure, when it's trivial to do. |
| 3275 | Like has_capability, but when F's st_dev says it's on a file |