Index: modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java (revision 278633eced6d8039b5be4a18eefe6c65650aba4f) +++ modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java (revision ) @@ -117,7 +117,7 @@ */ public final class IgfsImpl implements IgfsEx { /** Default permissions for file system entry. */ - private static final String PERMISSION_DFLT_VAL = "0777"; + static final String PERMISSION_DFLT_VAL = "0777"; /** Index generator for async format threads. */ private static final AtomicInteger FORMAT_THREAD_IDX_GEN = new AtomicInteger(); @@ -1018,17 +1018,9 @@ // Resolve mode. final IgfsMode mode = resolveMode(path); - // Prepare properties. - final Map dirProps, fileProps; + final Map dirProps = DFLT_DIR_META; + final Map fileProps = props == null ? null : new HashMap<>(props); - if (props == null) { - dirProps = DFLT_DIR_META; - - fileProps = null; - } - else - dirProps = fileProps = new HashMap<>(props); - // Prepare context for DUAL mode. IgfsSecondaryFileSystemCreateContext secondaryCtx = null; @@ -1110,19 +1102,11 @@ if (ids.size() == 1) throw new IgfsPathIsDirectoryException("Failed to open file (not a file): " + path); - final Map dirProps, fileProps; + Map fileProps = props == null ? null : new HashMap<>(props); - if (props == null) { - dirProps = DFLT_DIR_META; - - fileProps = null; - } - else - dirProps = fileProps = new HashMap<>(props); - IgfsEntryInfo res = meta.append( path, - dirProps, + DFLT_DIR_META, create, cfg.getBlockSize(), null/*affKey*/, \ No newline at end of file Index: modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java (revision 278633eced6d8039b5be4a18eefe6c65650aba4f) +++ modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java (revision ) @@ -2990,7 +2990,7 @@ */ IgfsCreateResult create( final IgfsPath path, - Map dirProps, + final Map dirProps, final boolean overwrite, final int blockSize, final @Nullable IgniteUuid affKey, @@ -3258,6 +3258,8 @@ // Second step: create middle directories. long curTime = System.currentTimeMillis(); + Map middleDirProps = null; + while (curIdx < pathIds.count() - 1) { lastCreatedPath = new IgfsPath(lastCreatedPath, curPart); @@ -3278,7 +3280,11 @@ else { accessTime = curTime; modificationTime = curTime; - props = dirProps; + + if (middleDirProps == null) + middleDirProps = IgfsUtils.addWriteExecuteDirPermissions(dirProps); + + props = middleDirProps; } procMap.put(curId, new IgfsMetaDirectoryCreateProcessor(accessTime, modificationTime, props, \ No newline at end of file Index: modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java (revision 278633eced6d8039b5be4a18eefe6c65650aba4f) +++ modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java (revision ) @@ -960,4 +960,42 @@ private static boolean hasFlag(byte flags, byte flag) { return (flags & flag) == flag; } + + /** + * Adds write and execute (like "chmod u+wx") permission to the given property map. + * + * @param leafDirProps The original properties. + * @return Modified properties with fixed permission. + */ + public static Map addWriteExecuteDirPermissions(Map leafDirProps) { + String perm = leafDirProps.get(PROP_PERMISSION); + + if (perm == null || perm.length() < 3) + perm = IgfsImpl.PERMISSION_DFLT_VAL; // Directory default. + else { + String ownerDigit = perm.substring(perm.length() - 3, perm.length() - 2); + + assert ownerDigit.length() == 1; + + int owner3Bits = Integer.parseInt(ownerDigit); + + assert owner3Bits >= 0 && owner3Bits <= 7; + + owner3Bits |= 3; // add write & execute permission. + + char[] permArr = perm.toCharArray(); + + char fixedOwnerCh = Integer.toString(owner3Bits).charAt(0); + + permArr[perm.length() - 3] = fixedOwnerCh; + + perm = new String(permArr); + } + + Map map2 = new HashMap<>(leafDirProps); + + map2.put(PROP_PERMISSION, perm); + + return map2; + } } \ No newline at end of file Index: modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java (revision 278633eced6d8039b5be4a18eefe6c65650aba4f) +++ modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java (revision ) @@ -34,6 +34,7 @@ import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.UUID; import java.util.concurrent.Callable; @@ -418,5 +419,25 @@ }, IgfsException.class, null); assertTrue("Unexpected cause: " + err, err instanceof IgfsException); + } + + /** + * Checks permission correction method. + */ + public void testAddWriteExecuteDirPermissions() { + Map prop = new HashMap<>(); + + prop.put(IgfsUtils.PROP_PERMISSION, "0455"); + prop.put("foo", "bar"); + + Map m = IgfsUtils.addWriteExecuteDirPermissions(prop); + + assertEquals("0755", m.get(IgfsUtils.PROP_PERMISSION)); + assertEquals("bar", m.get("foo")); // Check another property is present. + + // Test empty map: + m = IgfsUtils.addWriteExecuteDirPermissions(Collections.emptyMap()); + + assertEquals("0777", m.get(IgfsUtils.PROP_PERMISSION)); } } \ No newline at end of file