Google is committed to advancing racial equity for Black communities. See how.

connect method

  • @override

int connect (int flags, int mode, InterfaceRequest request, [int parentFlags = Flags.fsRights]) override

Connects to this instance of PseudoDir and serves fushsia.io.Directory over fidl.

Implementation

@override
int connect(int flags, int mode, fidl.InterfaceRequest<Node> request,
    [int parentFlags = Flags.fsRights]) {
  if (_isClosed) {
    sendErrorEvent(flags, ZX.ERR_NOT_SUPPORTED, request);
    return ZX.ERR_NOT_SUPPORTED;
  }
  // There should be no modeType* flags set, except for, possibly,
  // modeTypeDirectory when the target is a pseudo dir.
  if ((mode & ~modeProtectionMask) & ~modeTypeDirectory != 0) {
    sendErrorEvent(flags, ZX.ERR_INVALID_ARGS, request);
    return ZX.ERR_INVALID_ARGS;
  }

  var connectFlags = filterForNodeReference(flags);

  if (Flags.isPosix(connectFlags)) {
    // grant POSIX clients additional rights
    var parentRights = parentFlags & Flags.fsRights;
    connectFlags |= parentRights;
    connectFlags &= ~openFlagPosix;
    // Mounting is not supported
    connectFlags &= ~openRightAdmin;
  }

  var status = _validateFlags(connectFlags);
  if (status != ZX.OK) {
    sendErrorEvent(connectFlags, status, request);
    return status;
  }
  var connection = _DirConnection(
      mode, connectFlags, this, fidl.InterfaceRequest(request.passChannel()));
  _connections.add(connection);
  return ZX.OK;
}