Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
98f97e6f
Commit
98f97e6f
authored
Mar 13, 2014
by
Eric Cano
Browse files
Added possibility to find a SCSI device in the list by following a symlink
parent
44420e9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
castor/tape/tapeserver/SCSI/Device.cpp
View file @
98f97e6f
...
...
@@ -60,6 +60,20 @@ SCSI::DeviceVector::DeviceVector(System::virtualWrapper& sysWrapper) : m_sysWrap
sysWrapper
.
closedir
(
dirp
);
}
SCSI
::
DeviceInfo
&
SCSI
::
DeviceVector
::
findBySymlink
(
std
::
string
path
)
{
struct
stat
sbuff
;
castor
::
exception
::
Errnum
::
throwOnMinusOne
(
m_sysWrapper
.
stat
(
path
.
c_str
(),
&
sbuff
),
std
::
string
(
"Could not stat path: "
)
+
path
);
for
(
std
::
vector
<
DeviceInfo
>::
iterator
i
=
begin
();
i
!=
end
();
i
++
)
{
if
(
i
->
nst
==
sbuff
||
i
->
st
==
sbuff
)
{
return
*
i
;
}
}
throw
SCSI
::
DeviceVector
::
NotFound
(
std
::
string
(
"Could not find tape device pointed to by "
)
+
path
);
}
std
::
string
SCSI
::
DeviceVector
::
readfile
(
std
::
string
path
)
{
int
fd
;
castor
::
exception
::
Errnum
::
throwOnMinusOne
(
...
...
castor/tape/tapeserver/SCSI/Device.hpp
View file @
98f97e6f
...
...
@@ -23,7 +23,8 @@
*****************************************************************************/
#pragma once
#include
<string>
#include
<vector>
#include
<regex.h>
#include
<sys/types.h>
...
...
@@ -32,6 +33,7 @@
#include
"../exception/Exception.hpp"
#include
"../utils/Regex.hpp"
#include
"Constants.hpp"
#include
<string>
namespace
castor
{
namespace
tape
{
...
...
@@ -54,12 +56,16 @@ namespace SCSI {
major
=
-
1
;
minor
=
-
1
;
}
int
major
;
int
minor
;
unsigned
int
major
;
unsigned
int
minor
;
bool
operator
!=
(
const
DeviceFile
&
b
)
const
{
return
major
!=
b
.
major
||
minor
!=
b
.
minor
;
}
bool
operator
==
(
const
struct
stat
&
sbuff
)
const
{
return
major
==
major
(
sbuff
.
st_rdev
)
&&
minor
==
minor
(
sbuff
.
st_rdev
);
}
};
DeviceFile
sg
;
DeviceFile
st
;
...
...
@@ -83,6 +89,21 @@ namespace SCSI {
* (all code using templates must be in the header file)
*/
DeviceVector
(
castor
::
tape
::
System
::
virtualWrapper
&
sysWrapper
);
/**
* Find an array element that shares the same device files as one pointed
* to as a path. This is designed to be used with a symlink like:
* /dev/tape_T10D6116 -> /dev/nst0
*/
DeviceInfo
&
findBySymlink
(
std
::
string
path
);
/**
* Exception for previous function
*/
class
NotFound
:
public
castor
::
tape
::
Exception
{
public:
NotFound
(
const
std
::
string
&
what
)
:
castor
::
tape
::
Exception
(
what
)
{}
};
private:
castor
::
tape
::
System
::
virtualWrapper
&
m_sysWrapper
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment