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

connect method

*[<Null safety>](https://dart.dev/null-safety)*
  • @override

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

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.fsRightsDefault]) {
  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);

  // Explicitly expand OPEN_FLAG_POSIX into new equivalent flags.
  // TODO(fxbug.dev/40862): Remove entire branch when OPEN_FLAG_POSIX is removed.
  if ((connectFlags & openFlagPosix) != 0) {
    connectFlags |= openFlagPosixWritable | openFlagPosixExecutable;
    connectFlags &= ~openFlagPosix;
  }

  // Grant POSIX clients additional rights.
  if (Flags.isPosixWritable(connectFlags)) {
    connectFlags |= parentFlags & openRightWritable;
  }
  if (Flags.isPosixExecutable(connectFlags)) {
    connectFlags |= parentFlags & openRightExecutable;
  }
  // Clear any remaining POSIX right expansion flags.
  connectFlags &= ~(openFlagPosixWritable | openFlagPosixExecutable);

  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;
}