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 PseudoFile and serves fushsia.io.File 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 MODE_TYPE_* flags set, except for, possibly,
  // MODE_TYPE_FILE when the target is a pseudo file.
  if ((mode & ~modeProtectionMask) & ~modeTypeFile != 0) {
    sendErrorEvent(flags, ZX.ERR_INVALID_ARGS, request);
    return ZX.ERR_INVALID_ARGS;
  }

  var connectFlags = filterForNodeReference(flags);
  var status = _validateFlags(parentFlags, connectFlags);
  if (status != ZX.OK) {
    sendErrorEvent(connectFlags, status, request);
    return status;
  }

  var connection = _FileConnection(
      capacity: _capacity,
      flags: connectFlags,
      file: this,
      mode: mode,
      request: fidl.InterfaceRequest<File>(request.passChannel()));

  // [connection] will also send on_open success event.
  _connections.add(connection);
  return ZX.OK;
}