docstring says "permission: either 'r', 'w', 'a'" but here it checks for 'U'; maybe check and enforce that permission is actually r, w, or a?