18 #include <ndb_global.h>
20 #include "Filename.hpp"
21 #include "ErrorHandlingMacros.hpp"
22 #include "RefConvert.hpp"
23 #include "DebuggerNames.hpp"
26 #include <signaldata/FsOpenReq.hpp>
28 static const char* fileExtension[] = {
40 static const Uint32 noOfExtensions =
sizeof(fileExtension)/
sizeof(
char*);
46 Filename::~Filename(){
50 Filename::set(
Ndbfs* fs,
51 BlockReference blockReference,
52 const Uint32 filenumber[4],
bool dir,
57 const Uint32
type = FsOpenReq::getSuffix(filenumber);
58 const Uint32 version = FsOpenReq::getVersion(filenumber);
64 fs->get_base_path(FsOpenReq::BP_BACKUP).
c_str());
65 m_base_name = theName + fs->get_base_path(FsOpenReq::BP_BACKUP).
length();
70 fs->get_base_path(FsOpenReq::BP_FS).
c_str());
71 m_base_name = theName + fs->get_base_path(FsOpenReq::BP_FS).
length();
76 const Uint32 diskNo = FsOpenReq::v1_getDisk(filenumber);
77 const Uint32
table = FsOpenReq::v1_getTable(filenumber);
78 const Uint32 frag = FsOpenReq::v1_getFragment(filenumber);
79 const Uint32 S_val = FsOpenReq::v1_getS(filenumber);
80 const Uint32 P_val = FsOpenReq::v1_getP(filenumber);
88 const char* blockName = getBlockName( refToMain(blockReference) );
89 if (blockName == NULL){
90 ERROR_SET(ecError, NDBD_EXIT_AFS_PARAMETER,
"",
"No Block Name");
97 if (table < 0xffffffff){
102 if (frag < 0xffffffff){
104 strcat(theName, buf);
108 if (S_val < 0xffffffff){
110 strcat(theName, buf);
115 strcat(theName, buf);
121 const Uint32 seq = FsOpenReq::v2_getSequence(filenumber);
122 const Uint32 nodeId = FsOpenReq::v2_getNodeId(filenumber);
123 const Uint32 count = FsOpenReq::v2_getCount(filenumber);
126 DIR_SEPARATOR, seq, DIR_SEPARATOR);
127 strcat(theName, buf);
128 if(count == 0xffffffff) {
130 seq, nodeId); strcat(theName, buf);
133 seq, count, nodeId); strcat(theName, buf);
139 const Uint32 diskNo = FsOpenReq::v1_getDisk(filenumber);
142 ERROR_SET(ecError, NDBD_EXIT_AFS_PARAMETER,
"",
"Invalid disk specification");
146 strcat(theName, buf);
152 copy((Uint32*)&buf[0], ptr);
153 if(buf[0] == DIR_SEPARATOR[0])
155 strncpy(theName, buf, PATH_MAX);
156 m_base_name = theName;
162 while((b= strchr(b,
'/')) && b)
167 Uint32 bp = FsOpenReq::v4_getBasePath(filenumber);
169 fs->get_base_path(bp).
c_str(),
buf);
170 m_base_name = theName + fs->get_base_path(bp).
length();
176 Uint32 tableId = FsOpenReq::v5_getTableId(filenumber);
177 Uint32 lcpNo = FsOpenReq::v5_getLcpNo(filenumber);
178 Uint32 fragId = FsOpenReq::v5_getFragmentId(filenumber);
179 BaseString::snprintf(buf,
sizeof(buf),
"LCP%s%d%sT%dF%d", DIR_SEPARATOR, lcpNo, DIR_SEPARATOR, tableId, fragId);
180 strcat(theName, buf);
185 Uint32 bp = FsOpenReq::v5_getLcpNo(filenumber);
187 fs->get_base_path(bp).
c_str());
191 ERROR_SET(ecError, NDBD_EXIT_AFS_PARAMETER,
"",
"Wrong version");
193 if (type >= noOfExtensions){
194 ERROR_SET(ecError, NDBD_EXIT_AFS_PARAMETER,
"",
"File Type doesn't exist");
197 strcat(theName, fileExtension[type]);
200 for(
int l = strlen(theName) - 1; l >= 0; l--){
201 if(theName[l] == DIR_SEPARATOR[0]){