Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Reading the serial number of a hard disk managed by devb-eide.: (6 Items)
   
Reading the serial number of a hard disk managed by devb-eide.  
Hi,

I'd like to retrieve the serial number of the hard disk (compact flash) my system
is currently running from.  I can't find a QNX6 utility that provides this info.

Since my device is managed by the process devb-eide,
I explored devctl() and checked dcmd_all.h and dcmd_blk.h
for commands that could be used to get some device info,
but I did not find what I was looking for.

Can someone help?

Re: Reading the serial number of a hard disk managed by devb-eide.  
Try to parse output of sloginfo,

devb-eide logs some information on its startup, and one of those is a serial number.

PKY

> Hi,
> 
> I'd like to retrieve the serial number of the hard disk (compact flash) my 
> system
> is currently running from.  I can't find a QNX6 utility that provides this 
> info.
> 
> Since my device is managed by the process devb-eide,
> I explored devctl() and checked dcmd_all.h and dcmd_blk.h
> for commands that could be used to get some device info,
> but I did not find what I was looking for.
> 
> Can someone help?
> 


Re: Reading the serial number of a hard disk managed by devb-eide.  
> Try to parse output of sloginfo,
> 
> devb-eide logs some information on its startup, and one of those is a serial 
> number.
> 
> PKY
> 

Yes you are right, it is in /dev/slog

Although I'd like to know how to query devb-eide directly,
else with /dev/slog I'll always need to test this behavior 
with every release because there are no guaranties that devb-eide 
will behave the same with sloginfo.

but /dev/slog might be my first implementation...
Re: Reading the serial number of a hard disk managed by devb-eide.  
> Hi,
> 
> I'd like to retrieve the serial number of the hard disk (compact flash) 
> 
> Can someone help?
> 


The code below returns:
The dcmd argument isn't a valid command for this device. 
DCMD_CAM_DEV_SERIAL_NUMBER failed. Cause: Inappropriate I/O control operation. DevErrorInfo=0

> Can someone help more? 
-------------------------------------------------------------------------------------------

#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/neutrino.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/dcmd_cam.h>
#include <devctl.h>


int main( int argc, char  *argv[] )
{

    int    FileDescriptor = 0;
    int    Error          = 0;
    int    DevInfo        = 0;
    char   CamAnswer[256] = "";


    if(( FileDescriptor = open("/dev/hd0", O_RDONLY)) == -1)
    {
        fprintf( stderr, "Unable to open /dev/hd0. Cause %s\n", strerror( errno ));
        exit( EXIT_FAILURE );
    }
    if((Error = devctl( FileDescriptor, DCMD_CAM_DEV_SERIAL_NUMBER, CamAnswer, 256, &DevInfo)) != EOK)
    {
    	switch( Error )
    	{
    	case EAGAIN: fprintf( stderr, "The devctl() command couldn't be completed because the device driver was in use by 
another process, or the driver was unable to carry out the request due to an outstanding command in progress.\n"); break
;
    	case EBADF:  fprintf( stderr, "Invalid open file descriptor, filedes. \n"); break;
    	case EINTR:  fprintf( stderr, "The devctl() function was interrupted by a signal.\n"); break;
    	case EINVAL: fprintf( stderr, "The device driver detected an error in dev_data_ptr or n_bytes.\n"); break;
    	case EIO:    fprintf( stderr, "The devctl() function couldn't complete because of a hardware error. \n"); break;
    	case ENOSYS: fprintf( stderr, "The device doesn't support the dcmd command. \n"); break;
    	case ENOTTY: fprintf( stderr, "The dcmd argument isn't a valid command for this device. \n"); break;
    	case EPERM:  fprintf( stderr, "The process doesn't have sufficient permission to carry out the requested command.\n
"); break;
    	default:     fprintf( stderr, "Undocumented failure\n"); break;
    	}
    	
        fprintf( stderr, "DCMD_CAM_DEV_SERIAL_NUMBER failed. Cause: %s. DevErrorInfo=%d\n", strerror(Error), DevInfo);
        exit( EXIT_FAILURE );
    }

    CamAnswer[255] = 0;  // Make sure the string is terminated
    printf("SERIAL_NUMBER is %s\n",CamAnswer);

    
    return EXIT_SUCCESS;
}


Re: Reading the serial number of a hard disk managed by devb-eide.  
According to QNX this will only work with    devb-eide V6.4.1   (which I'm not running)

The suggested course of action for earlier versions is 
to build the ATA message and use the pass through interface of devb-eide



> > Hi,
> > 
> > I'd like to retrieve the serial number of the hard disk (compact flash) 
> > 
> > Can someone help?
> > 
> 
> 
> The code below returns:
> The dcmd argument isn't a valid command for this device. 
> DCMD_CAM_DEV_SERIAL_NUMBER failed. Cause: Inappropriate I/O control operation.
>  DevErrorInfo=0
> 
> > Can someone help more? 
> ------------------------------------------------------------------------------
> -------------
> 
>     if((Error = devctl( FileDescriptor, DCMD_CAM_DEV_SERIAL_NUMBER, CamAnswer,
>  256, &DevInfo)) != EOK)

> 
>     CamAnswer[255] = 0;  // Make sure the string is terminated
>     printf("SERIAL_NUMBER is %s\n",CamAnswer);
> 
>     
>     return EXIT_SUCCESS;
> }
> 
> 


Re: Reading the serial number of a hard disk managed by devb-eide.  
I have validated that it works with the Neutrino 6.4.1 VM that QSSL published.
uname -a = QNX localhost 6.4.1 2009/05/20-17:35

The output is :
SERIAL_NUMBER is VMware Virtual IDE Hard Drive        @^0000000000000000001