code: private INode mkdirsInternal(String src,
                                   PermissionStatus permissions)
      throws IOException {
      src = dir.normalizePath(src);
      
      // tokenize the src into components
      String[] names = INodeDirectory.getPathNames(src);
      
      if (!pathValidator.isValidName(src, names)) {
        numInvalidFilePathOperations++;
        throw new IOException("Invalid directory name: " + src);
      }
  
      // check validity of the username
      checkUserName(permissions);
  
      // convert the names into an array of bytes w/o holding lock
      byte[][] components = INodeDirectory.getPathComponents(names);
      INode[] inodes = new INode[components.length];
  
      writeLock();
      try {
        if (NameNode.stateChangeLog.isDebugEnabled()) {
          NameNode.stateChangeLog.debug("DIR* NameSystem.mkdirs: " + src);
        }
        dir.rootDir.getExistingPathINodes(components, inodes);
        if (isPermissionEnabled
            && isPermissionCheckingEnabled(inodes)) {
          checkTraverse(src, inodes);
        }
        INode lastINode = inodes[inodes.length-1];
        if (lastINode !=null && lastINode.isDirectory()) {
          // all the users of mkdirs() are used to expect 'true' even if
          // a new directory is not created.
          return lastINode;
        }
        if (isInSafeMode()) {
          throw new SafeModeException("Cannot create directory " + src, safeMode);
        }
        if (isPermissionEnabled
            && isPermissionCheckingEnabled(inodes)) {
          checkAncestorAccess(src, inodes, FsAction.WRITE);
        }
  
        // validate that we have enough inodes. This is, at best, a
        // heuristic because the mkdirs() operation migth need to
        // create multiple inodes.
        checkFsObjectLimit();
  
        if (!dir.mkdirs(src, names, components, inodes, inodes.length, permissions, false, now())) {
          throw new IOException("Invalid directory name: " + src);
        }
        return inodes[inodes.length-1];
      } finally {
        writeUnlock();
      }
    }
docs: Create all the necessary directories