summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/linux/opcmciasystem.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiecore/linux/opcmciasystem.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/linux/opcmciasystem.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie2/opiecore/linux/opcmciasystem.cpp b/libopie2/opiecore/linux/opcmciasystem.cpp
index 445d903..2b0c01d 100644
--- a/libopie2/opiecore/linux/opcmciasystem.cpp
+++ b/libopie2/opiecore/linux/opcmciasystem.cpp
@@ -161,100 +161,102 @@ OPcmciaSystem* OPcmciaSystem::instance()
}
OPcmciaSystem::CardIterator OPcmciaSystem::iterator() const
{
return OPcmciaSystem::CardIterator( _interfaces );
}
/*======================================================================================
* OPcmciaSocket
*======================================================================================*/
OPcmciaSocket::OPcmciaSocket( int major, int socket, QObject* parent, const char* name )
:QObject( parent, name ), _major( major ), _socket( socket )
{
qDebug( "OPcmciaSocket::OPcmciaSocket()" );
init();
}
OPcmciaSocket::~OPcmciaSocket()
{
qDebug( "OPcmciaSocket::~OPcmciaSocket()" );
cleanup();
}
/* internal */ void OPcmciaSocket::init()
{
// open control socket and gather file descriptor
if ( _major )
{
dev_t dev = makedev( _major, _socket );
#ifdef OPCMCIA_DEBUG
QString filename = "/tmp/opcmciasystem-debug";
if ( QFile::exists( filename ) )
#else
QString filename = QString().sprintf( "/tmp/opcmciasystem-%d", ::getpid() );
if ( ::mknod( (const char*) filename, ( S_IFCHR|S_IREAD|S_IWRITE ), dev ) == 0 )
#endif
{
_fd = ::open( (const char*) filename, O_RDONLY);
if ( !_fd )
{
qWarning( "OPcmciaSocket::init() - can't open control socket (%s)", strerror( errno ) );
}
+#ifndef OPCMCIA_DEBUG
else
{
::unlink( (const char*) filename );
}
+#endif
}
else
{
qWarning( "OPcmciaSocket::init() - can't create device node '%s' (%s)", (const char*) filename, strerror( errno ) );
}
}
}
/* internal */ void OPcmciaSocket::cleanup()
{
// close control socket
}
/* internal */ bool OPcmciaSocket::getTuple( cisdata_t tuple ) const
{
_ioctlarg.tuple.DesiredTuple = tuple;
_ioctlarg.tuple.Attributes = TUPLE_RETURN_COMMON;
_ioctlarg.tuple.TupleOffset = 0;
int result;
result = ::ioctl(_fd, DS_GET_FIRST_TUPLE, &_ioctlarg);
if ( result != 0 )
{
qWarning( "OPcmciaSocket::getTuple() - DS_GET_FIRST_TUPLE failed (%s)", strerror( errno ) );
return false;
}
result = ::ioctl(_fd, DS_GET_TUPLE_DATA, &_ioctlarg);
if ( result != 0 )
{
qWarning( "OPcmciaSocket::getTuple() - DS_GET_TUPLE_DATA failed (%s)", strerror( errno ) );
return false;
}
result = ::ioctl( _fd, DS_PARSE_TUPLE, &_ioctlarg );
if ( result != 0 )
{
qWarning( "OPcmciaSocket::getTuple() - DS_PARSE_TUPLE failed (%s)", strerror( errno ) );
return false;
}
return true;
}
int OPcmciaSocket::number() const
{
return _socket;