Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
38917516
Commit
38917516
authored
11 years ago
by
Eric Cano
Browse files
Options
Downloads
Patches
Plain Diff
Embryo of the Tape::File with AUL support.
parent
03326c68
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
File/File.hh
+120
-0
120 additions, 0 deletions
File/File.hh
File/Structures.cc
+28
-0
28 additions, 0 deletions
File/Structures.cc
File/Structures.hh
+55
-0
55 additions, 0 deletions
File/Structures.hh
with
203 additions
and
0 deletions
File/File.hh
0 → 100644
+
120
−
0
View file @
38917516
// ----------------------------------------------------------------------
// File: File/File.hh
// ----------------------------------------------------------------------
/************************************************************************
* Tape Server *
* Copyright (C) 2013 CERN/Switzerland *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
************************************************************************/
#pragma once
#include
<string>
#include
"Structures.hh"
namespace
Tape
{
/**
* Class managing the reading and writing of files to and from tape.
*/
namespace
AULFile
{
/**
* Class containing all the information related to a file being migrated to
* tape.
*/
class
Information
{
public:
std
::
string
lastKnownPath
;
uint32_t
checksum
;
uint64_t
nsFileId
;
uint64_t
size
;
uint32_t
fseq
;
};
class
BufferTooSmall
:
public
Tape
::
Exception
{
public:
BufferTooSmall
(
const
std
::
string
&
what
)
:
Exception
(
what
)
{}
};
class
WrongChecksum
:
public
Tape
::
Exception
{
public:
WrongChecksum
(
const
std
::
string
&
what
)
:
Exception
(
what
)
{}
};
class
WrongSize
:
public
Tape
::
Exception
{
public:
WrongSize
(
const
std
::
string
&
what
)
:
Exception
(
what
)
{}
};
class
NotReadingAFile
:
public
Tape
::
Exception
{
public:
NotReadingAFile
(
const
std
::
string
&
what
)
:
Exception
(
what
)
{}
};
/**
* Class keeping track of a whole tape read session over an AUL formated
* tape. The session will keep track of the overall coherency of the session
* and check for everything to be coherent. The tape should be mounted in
* the drive before the AULReadSession is started (i.e. constructed).
* Likewise, tape unmount is the business of the user.
*/
class
ReadSession
{
public:
/**
* Constructor of the AULReadSession. It will rewind the tape, and check the
* VSN value. Throws an exception in case of mismatch.
* @param drive
* @param VSN
*/
ReadSession
(
Tape
::
Drive
&
drive
,
std
::
string
VSN
)
throw
(
Tape
::
Exception
);
/**
* Positions the tape for reading the file. Depending on the previous activity,
* it is the duty of this function to determine how to best move to the next
* file. The positioning will then be verified (header will be read).
* As usual, exception is thrown if anything goes wrong.
* @param fileInfo: all relevant information passed by the stager about
* the file.
*/
void
position
(
Tape
::
AULFile
::
Information
fileInfo
)
throw
(
Tape
::
Exception
);
/**
* After positioning at the beginning of a file for readings, this function
* allows the reader to know which block sizes to provide.
* If called before the end of a file read, the file reading will be
* interrupted and positioning to the new file will occur.
* @return the block size in bytes.
*/
size_t
getBlockSize
()
throw
(
Tape
::
Exception
);
/**
* Read data from the file. The buffer should equal to or bigger than the
* block size. Will try to actually fill up the provided buffer (this
* function can trigger several read on the tape side).
* This function will throw exceptions when problems arise (especially
* at end of file in case of size or checksum mismatch.
* After end of file, a new call to read without a call to position
* will throw NotReadingAFile.
* @param buff pointer to the data buffer
* @param len size of the buffer
* @return The amount of data actually copied. Zero at end of file.
*/
size_t
read
(
void
*
buff
,
size_t
len
)
throw
(
Tape
::
Exception
);
};
/**
TODO
*/
class
WriteSession
{
};
};
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
File/Structures.cc
0 → 100644
+
28
−
0
View file @
38917516
// ----------------------------------------------------------------------
// File: File/Structures.cc
// ----------------------------------------------------------------------
/************************************************************************
* Tape Server *
* Copyright (C) 2013 CERN/Switzerland *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
************************************************************************/
#include
"Structures.hh"
void
Tape
::
AULFile
::
VOL1
::
fill
(
std
::
string
vsn
)
{
setString
(
label
,
"VOL1"
);
setString
(
VSN
,
vsn
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
File/Structures.hh
0 → 100644
+
55
−
0
View file @
38917516
// ----------------------------------------------------------------------
// File: File/Structures.hh
// ----------------------------------------------------------------------
/************************************************************************
* Tape Server *
* Copyright (C) 2013 CERN/Switzerland *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
************************************************************************/
#pragma once
#include
<string>
namespace
Tape
{
namespace
AULFile
{
class
VOL1
{
public:
char
label
[
4
];
char
VSN
[
6
];
/* TODO: finish */
/**
* Fills up all fields of the VOL1 structure with proper values and data provided.
* @param VSN the tape serial number
*/
void
fill
(
std
::
string
_VSN
);
/**
* Throws an exception if the structure does not match expectations.
*/
void
verify
();
};
template
<
size_t
n
>
/**
* Templated helper function to set a space padded string into a
* fixed sized field of a header structure.
*/
void
setString
(
char
(
&
t
)[
n
],
const
std
::
string
&
s
)
{
size_t
written
=
s
.
copy
(
t
,
n
);
if
(
written
<
n
)
{
memset
(
t
[
written
],
' '
,
n
-
written
);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment