?
Solved

Get SCSI tape status

Posted on 2003-03-09
5
Medium Priority
?
433 Views
Last Modified: 2010-04-21
Can anybody tell me how and what ioctl command is to be used to get the SCSI tape status (available space and used space)?




0
Comment
Question by:jowelle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Expert Comment

by:kruemelmo
ID: 8110405
See the man page st(4):

SYNOPSIS
       #include <sys/mtio.h>

       int ioctl(int fd, int request [, (void *)arg3]);
       int ioctl(int fd, MTIOCTOP, (struct mtop *)mt_cmd);
       int ioctl(int fd, MTIOCGET, (struct mtget *)mt_status);
       int ioctl(int fd, MTIOCPOS, (struct mtpos *)mt_pos);

In order to find the available space and used space, you need to know the total space. As far as I know there is not command to get the tape capacity; you can get the tape drive type, but you have to know the capacity on your own because teh SCSI tape interface is generic and works for many different tape drives.

Find the space used by issuing the MTEOM ioctl - the tape will move to the end of data on the tape - and then use MTIOCPOS to get the current block number. Use MTIOCGET to get the block size. You can then find the "current byte".

I haven't tried it, but I would think it should work.

Moritz




0
 

Accepted Solution

by:
kruemelmo earned 150 total points
ID: 8110457
..adding some pseudo code:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mtio.h>

...

   int fd;
   struct mtget mt_status;
   struct mtpos mt_pos;
   struct mtop mt_cmd;

   fd = open("/dev/tape", O_RDWR);
   if (fd < 0)
      perror("opening tape device");
   mt_cmd.mt_op = MTEOM;
   mt_cmd.mt_count = 1;
   if (ioctl(fd, MTIOCTOP, &mt_cmd))
      perror("EOM");
   if (ioctl(fd, MTIOCGET, &mt_status))
      perror("MTIOCGET");
   if (ioctl(fd, MTIOCPOS, &mt_pos))
      perror("MTIOCPOS");
   // used bytes is now
   // (mt_status.mt_dsreg & MT_ST_BLKSIZE_MASK) * mt_pos.mt_blkno;
   // this might not fit into a long!
0
 

Author Comment

by:jowelle
ID: 8115573
Thanks for the information.
I thought there is an MTIOCGETSIZE ioctl...
0
 

Author Comment

by:jowelle
ID: 8116041
Is it possible to go to the
last block of the tape or the
end of the reel?
0
 

Expert Comment

by:kruemelmo
ID: 8117800
Hi howelle,

the MTEOM operation shown above goes to the last block on tape (end of media). I have no idea how to get to the end of the reel. After all, the remaining part of the tape may not ever have been written to so it might be unformatted...

You could, of course, go to end of media, remember the file number, and then write to the tape until error message - then you know what you want to know...

Greetings and thanks for accepting the answer,
Moritz
0

Featured Post

What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question