Loading...
Searching...
No Matches
XrdOucN2No2p Class Reference
Inheritance diagram for XrdOucN2No2p:
Collaboration diagram for XrdOucN2No2p:

## Public Member Functions

| XrdOucN2No2p (XrdSysError *erp, const char *lroot, const char *pfx, int fnmax, char sc)
virtual | ~XrdOucN2No2p ()
virtual int | lfn2pfn (const char *lfn, char *buff, int blen)
virtual int | lfn2rfn (const char *lfn, char *buff, int blen)
virtual int | pfn2lfn (const char *pfn, char *buff, int blen)
Public Member Functions inherited from XrdOucName2Name
| XrdOucName2Name ()
| Constructor.
virtual | ~XrdOucName2Name ()
| Destructor.

## Detailed Description

Definition at line 68 of file XrdOucN2No2p.cc.

## Constructor & Destructor Documentation

## XrdOucN2No2p()

XrdOucN2No2p::XrdOucN2No2p | ( | XrdSysError * | erp,
|  | const char * | lroot,
|  | const char * | pfx,
|  | int | fnmax,
|  | char | sc )

inline

Definition at line 78 of file XrdOucN2No2p.cc.

: eDest(erp), sChar(sc),
oidPfx(strdup(pfx)), oidPsz(strlen(pfx)), oidMax(fnmax)
{if (!lroot) {lRoot = 0; lRLen = 0;}
else {lRoot = strdup(lroot);
lRLen = strlen(lroot);
if (lRoot[lRLen-1] == '/')
{lRoot[lRLen-1] = 0; lRLen--;}
}
}
eDest
static XrdSysError eDest(0,"crypto_")

## ~XrdOucN2No2p()

virtual XrdOucN2No2p::~XrdOucN2No2p | ( |  | ) |

inline virtual

Definition at line 90 of file XrdOucN2No2p.cc.

{if (oidPfx) free(oidPfx);
if (lRoot) free(lRoot);
}

## Member Function Documentation

## lfn2pfn()

int XrdOucN2No2p::lfn2pfn | ( | const char * | lfn,
|  | char * | buff,
|  | int | blen )

virtual

Map a logical file name to a physical file name.

Parameters

  lfn | -> Logical file name.
  buff | -> Buffer where the physical file name of an existing file is to be placed. It must end with a null byte.
  blen | The length of the buffer.

Returns
  Success: Zero. Failure: An errno number describing the failure; typically EINVAL - The supplied lfn is invalid. ENAMETOOLONG - The buffer is too small for the pfn.

Implements XrdOucName2Name.

Definition at line 108 of file XrdOucN2No2p.cc.

{
// If have a local root then prefix result with it (make sure it fits)
//
if (lRoot)
{if (lRLen >= blen-1) return ENAMETOOLONG;
strcpy(buff, lRoot);
buff += lRLen; blen -= lRLen;
}
// Now just to the transformation so that we can ref the oid as a file
//
return pfn2lfn(lfn, buff, blen);
}
XrdOucN2No2p::pfn2lfn
virtual int pfn2lfn(const char *pfn, char *buff, int blen)
Definition XrdOucN2No2p.cc:127

References pfn2lfn().

Here is the call graph for this function:

## lfn2rfn()

virtual int XrdOucN2No2p::lfn2rfn | ( | const char * | lfn,
|  | char * | buff,
|  | int | blen )

inline virtual

Map a logical file name to the name the file would have in a remote storage system (e.g. Mass Storage System at a remote location).

Parameters

  lfn | -> Logical file name.
  buff | -> Buffer where the remote file name is to be placed. It need not actually exist in that location but could be created there with that name. It must end with a null byte.
  blen | The length of the buffer.

Returns
  Success: Zero. Failure: An errno number describing the failure; typically EINVAL - The supplied lfn is invalid. ENAMETOOLONG - The buffer is too small for the pfn.

Implements XrdOucName2Name.

Definition at line 74 of file XrdOucN2No2p.cc.

{return -ENOTSUP;}

## pfn2lfn()

int XrdOucN2No2p::pfn2lfn | ( | const char * | pfn,
|  | char * | buff,
|  | int | blen )

virtual

Map a physical file name to it's logical file name.

Parameters

  pfn | -> Physical file name. This is always a valid name of either an existing file or a file that could been created.
  buff | -> Buffer where the logical file name is to be placed. It need not actually exist but could be created with that name. It must end with a null byte.
  blen | The length of the buffer.

Returns
  Success: Zero. Failure: An errno number describing the failure; typically EINVAL - The supplied lfn is invalid. ENAMETOOLONG - The buffer is too small for the pfn.

Implements XrdOucName2Name.

Definition at line 127 of file XrdOucN2No2p.cc.

{
const char *sP;
char *bP;
std::string pstr;
int pfnLen = strlen(pfn);
// If the pfn starts with a slash then do nothing
//
if (*pfn == '/')
{if (pfnLen >= blen) return ENAMETOOLONG;
strcpy(buff, pfn);
return 0;
}
// If there are any slashes in the object id we need to remove them
//
if ((sP = index(pfn, '/')))
{pstr = pfn;
std::replace(pstr.begin(), pstr.end(), '/', sChar);
pfn = pstr.c_str();
}
// Create the object distribution subpath. The format is based on the
// actual length of the object id and what we can use in this file system.
// We make special allowances for short object ID's that can screw this up.
//
if (pfnLen <= oidMax)
{unsigned long hVal = XrdOucHashVal2(pfn, pfnLen);
unsigned long sVal = ((int)sizeof(unsigned long) > 4 ? 32 : 16);
char subP[8];
if (pfnLen <= (int)sizeof(unsigned long)) hVal = hVal ^ (hVal >> sVal);
subP[1] = h2c[(hVal & 0x0f)]; hVal >>= 4; subP[0] = h2c[(hVal & 0x0f)];
subP[2] = '/'; hVal >>= 4;
subP[4] = h2c[(hVal & 0x0f)]; hVal >>= 4; subP[3] = h2c[(hVal & 0x0f)];
subP[5] = '/'; subP[6] = 0;
int n = snprintf(buff, blen, "%s%s%s", oidPfx, subP, pfn);
return (n < blen ? 0 : ENAMETOOLONG);
}
// The object id is longer than what is allowed for a file name. So, we
// convert the name to a number of directories using object id fragments.
// Check if we even have a chance here (note we may be one byte too many).
//
if ((oidPsz + pfnLen + (pfnLen/oidMax)) >= blen) return ENAMETOOLONG;
// Prepare to segement the oid
//
strcpy(buff, oidPfx); bP = buff + oidPsz; blen -= oidPsz;
// Copy over segments separated by a slash
//
while(blen > oidMax && pfnLen > oidMax)
{strncpy(bP, pfn, oidMax);
bP += oidMax; blen -= oidMax;
pfn += oidMax; pfnLen -= oidMax;
if (blen > 0) {*bP++ = '/'; blen--;}
}
// Copy the final segment if we have room
//
if (blen <= pfnLen) return ENAMETOOLONG;
strcpy(bP, pfn);
return 0;
}
XrdOucHashVal2
unsigned long XrdOucHashVal2(const char *KeyVal, int KeyLen)
Definition XrdOucHashVal.cc:40

References XrdOucHashVal2().

Referenced by lfn2pfn().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file:

- XrdOucN2No2p.cc