switch (permChar) { case 'r': specBits = specBits.or(Bits.READ); break; case 'w': specBits = specBits.or(Bits.WRITE); break; case 'x': specBits = specBits.or(Bits.EXECUTE); break; default: switch (targetChar) { case 'u': ownerBits = ownerBits.or(specBits); break; case 'g': groupBits = groupBits.or(specBits); break; case 'o': otherBits = otherBits.or(specBits); break; case 'a': ownerBits = ownerBits.or(specBits); groupBits = groupBits.or(specBits); otherBits = otherBits.or(specBits); break; default:
/** * Updates permitted actions based on the mode bits. * * For example, if bits imply READ, then READ is added to permitted actions, otherwise, * READ is removed from permitted actions. * Same logic applies to WRITE and EXECUTE. * * @param bits the mode bits */ public void updateByModeBits(Mode.Bits bits) { // Each index equals to corresponding AclAction's ordinal. // E.g. Mode.Bits.READ corresponds to AclAction.READ, the former has index 0 in indexedBits, // the later has ordinal 0 in AclAction. Mode.Bits[] indexedBits = new Mode.Bits[]{ Mode.Bits.READ, Mode.Bits.WRITE, Mode.Bits.EXECUTE }; for (int i = 0; i < 3; i++) { if (bits.imply(indexedBits[i])) { mActions.set(i); } else { mActions.clear(i); } } }
Mode.Bits bits = Mode.Bits.fromString(actions); for (AclAction action : bits.toAclActionSet()) { builder.addAction(action);
Long ufsLastModified = ufsStatus.getLastModifiedTime(); if (resolution.getShared()) { mode.setOtherBits(mode.getOtherBits().or(mode.getOwnerBits()));
switch (permChar) { case 'r': specBits = specBits.or(Bits.READ); break; case 'w': specBits = specBits.or(Bits.WRITE); break; case 'x': specBits = specBits.or(Bits.EXECUTE); break; default: switch (targetChar) { case 'u': ownerBits = ownerBits.or(specBits); break; case 'g': groupBits = groupBits.or(specBits); break; case 'o': otherBits = otherBits.or(specBits); break; case 'a': ownerBits = ownerBits.or(specBits); groupBits = groupBits.or(specBits); otherBits = otherBits.or(specBits); break; default:
Mode mode = new Mode(ufsMode); if (resolution.getShared()) { mode.setOtherBits(mode.getOtherBits().or(mode.getOwnerBits()));
@Override public boolean checkPermission(String user, List<String> groups, Inode<?> inode, Mode.Bits permission) { short mode = inode.getMode(); if (user.equals(inode.getOwner())) { return Mode.extractOwnerBits(mode).imply(permission); } if (groups.contains(inode.getGroup())) { return Mode.extractGroupBits(mode).imply(permission); } return Mode.extractOtherBits(mode).imply(permission); }
/** * @param mode the digital representation of a {@link Mode} * @return the owner {@link Bits} */ public static Bits extractOwnerBits(short mode) { return Bits.values()[(mode >>> 6) & 7]; }
/** * Sets {@link Mode} bits using a digital representation. * * @param n the digital representation of a {@link Mode} */ public void fromShort(short n) { Bits[] v = Bits.values(); set(v[(n >>> 6) & 7], v[(n >>> 3) & 7], v[n & 7]); }
/** * @param mode the digital representation of a {@link Mode} * @return the other {@link Bits} */ public static Bits extractOtherBits(short mode) { return Bits.values()[mode & 7]; }
/** * @param mode the digital representation of a {@link Mode} * @return the group {@link Bits} */ public static Bits extractGroupBits(short mode) { return Bits.values()[(mode >>> 3) & 7]; }
/** * @return the complement of these bits */ public Bits not() { return SVALS[7 - ordinal()]; } }
/** * Applies the given umask {@link Mode} to this mode. * * @param umask the umask to apply * @return the updated object */ private Mode applyUMask(Mode umask) { mOwnerBits = mOwnerBits.and(umask.mOwnerBits.not()); mGroupBits = mGroupBits.and(umask.mGroupBits.not()); mOtherBits = mOtherBits.and(umask.mOtherBits.not()); return this; }
Mode mode = new Mode(ufsMode); if (resolution.getShared()) { mode.setOtherBits(mode.getOtherBits().or(mode.getOwnerBits()));
Long ufsLastModified = context.getUfsStatus().getLastModifiedTime(); if (resolution.getShared()) { mode.setOtherBits(mode.getOtherBits().or(mode.getOwnerBits()));