question

Pushpalatha-9083 avatar image
0 Votes"
Pushpalatha-9083 asked SongZhu-MSFT commented

Tape Drive IO calls failure in specific environment

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
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The same code is working in other environments.

Can you provide some details about the working environment to help us determine the problem?

0 Votes 0 ·

Hi.. Thanks for the response. We have found the problem. I have two tape drives. When trying to create tape handle with tape name as Tape0, it was connecting to Tape drive-2 instead of drive-1.Drive-1 have its device symbolic name as Tape1 whereas Drive-2 having it as Tape0.

Is it possible to change the Tape symbolic name of Tape drives? Kindly help!

0 Votes 0 ·

No, you can't. According to the MSDN:

You can open tape drives by using a file name of the following form: "\.\TAPEx" where x is a number that indicates which drive to open, starting with tape drive zero. To open tape drive zero in an application that is written in C or C++, use the following file name: "\.\TAPE0".

So the number of the tape drive starts from 0 and is determined by the system, you cannot change it.

0 Votes 0 ·

0 Answers