Tape Drive IO calls failure in specific environment

Pushpalatha 1 Reputation point
2021-04-20T07:34:56.057+00:00

I am trying to run tape calls in one of my tape setups. But PrepareTape and GetTapeStatus calls are failed even after getting a successful handle.

The following is the sample code I am using,

HANDLE tapeHandle = CreateFile(tapeName, GENERIC_ALL, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE | FILE_FLAG_BACKUP_SEMANTICS, 0);
if (tapeHandle > 0)
{
DWORD prepareTApeSuccess = PrepareTape(tapeHandle, TAPE_LOAD, FALSE);
if (prepareTApeSuccess == NO_ERROR)
{
cout << "Prepare Tape successsfully executed" << endl;
}
else
{
cout << "Prepare Tape Failed with the error :" << prepareTApeSuccess <<"::"<< GetLastError() << endl;
}
}

In the above code, PrepareTape returns ERROR_NO_MEDIA_IN_DRIVE error always.

Then in the CreateFile, I have changed the CreateFile as below,
CreateFile(tapeName, GENERIC_ALL, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_ARCHIVE | FILE_FLAG_BACKUP_SEMANTICS, 0); //(removed FILE_SHARE_READ | FILE_SHARE_WRITE)

and called GetTapeStatus function, but it returns the same 1112 (ERROR_NO_MEDIA_IN_DRIVE).

So I am stuck here. I am trying this code in the following environment,

Tape Library: HPE Tape Library
Tape Drive: HPE LTO Ultrium -8
Machine: Windows 2019 (tape Library is connected to this machine)

The same code is working in other environments. Anything I need to check in code or environment side.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
1,909 questions
{count} votes