* caps_issued_mask - check whether we have all of the caps in the mask * @mask: mask to check against * @allow_impl: whether the caller can also use caps that are implemented but not issued * * This is the bog standard "check whether we have the required caps" operation. * Typically, we only check against the capset that is currently "issued". * In other words, we ignore caps that have been
| 299 | * caps! |
| 300 | */ |
| 301 | bool Inode::caps_issued_mask(unsigned mask, bool allow_impl) |
| 302 | { |
| 303 | int c = snap_caps; |
| 304 | int i = 0; |
| 305 | |
| 306 | if ((c & mask) == mask) |
| 307 | return true; |
| 308 | // prefer auth cap |
| 309 | if (auth_cap && |
| 310 | cap_is_valid(*auth_cap) && |
| 311 | (auth_cap->issued & mask) == mask) { |
| 312 | auth_cap->touch(); |
| 313 | client->cap_hit(); |
| 314 | return true; |
| 315 | } |
| 316 | // try any cap |
| 317 | for (auto &pair : caps) { |
| 318 | Cap &cap = pair.second; |
| 319 | if (cap_is_valid(cap)) { |
| 320 | if ((cap.issued & mask) == mask) { |
| 321 | cap.touch(); |
| 322 | client->cap_hit(); |
| 323 | return true; |
| 324 | } |
| 325 | c |= cap.issued; |
| 326 | i |= cap.implemented; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | if (allow_impl) |
| 331 | c |= i; |
| 332 | |
| 333 | if ((c & mask) == mask) { |
| 334 | // bah.. touch them all |
| 335 | for (auto &pair : caps) { |
| 336 | pair.second.touch(); |
| 337 | } |
| 338 | client->cap_hit(); |
| 339 | return true; |
| 340 | } |
| 341 | |
| 342 | client->cap_miss(); |
| 343 | return false; |
| 344 | } |
| 345 | |
| 346 | int Inode::caps_used() |
| 347 | { |
no test coverage detected