#!/usr/bin/env python3 """Probe NFC write open-flags / opcode. Not part of the library.""" from __future__ import annotations import os import struct import sys import unittest sys.path.insert(0, "/home/ubuntu/workspace/vmware_nbd_tests") os.environ.pop("LD_PRELOAD", None) from openvixdisklib import nfc_open from tests.integration.base import TestBase NFC_AIO_MSG_ERROR = 1 NFC_AIO_MSG_IO = 7 def recvn(sock, size): buf = bytearray() while len(buf) < size: chunk = sock.recv(size - len(buf)) if not chunk: raise RuntimeError(f"closed, got {len(buf)}/{size}") buf.extend(chunk) return bytes(buf) def open_rw(session, disk_path, oflag): sock = nfc_open.takeover_authd_socket(session.authd_sock) nfc_open._handshake(sock, "vddk", "nbdmode", nfc_open.NFC_PROTOCOL_VERSION) disk = nfc_open.NfcDisk( sock, disk_path, handle=0, sector_size=nfc_open.NFC_SECTOR_SIZE) nfc_open._aio_prepare(disk) path_b = disk_path.encode("utf-8") open_body = struct.pack( "= 36: chunk_len = struct.unpack_from("