3232#include " common/Strerror_r_wrapper.hh"
3333#include " common/BehaviourConfig.hh"
3434#include " common/Utils.hh"
35+ #include " mgm/Constants.hh"
3536#include " mgm/Access.hh"
3637#include " mgm/convert/ConversionTag.hh"
3738#include " mgm/FileSystem.hh"
@@ -254,12 +255,12 @@ XrdMgmOfsFile::create_cow(int cowType,
254255 gmd->addLocation (fmd->getLocation (i));
255256 }
256257 } else if (cowType == cowUnlink) {
257- int nlink = (fmd->hasAttribute (XrdMgmOfsFile::k_nlink )) ?
258- std::stoi (fmd->getAttribute (XrdMgmOfsFile::k_nlink )) + 1 : 1 ;
259- fmd->setAttribute (k_nlink , std::to_string (nlink));
258+ int nlink = (fmd->hasAttribute (SYS_NUM_LINK )) ?
259+ std::stoi (fmd->getAttribute (SYS_NUM_LINK )) + 1 : 1 ;
260+ fmd->setAttribute (SYS_NUM_LINK , std::to_string (nlink));
260261 gOFS ->eosFileService ->updateStore (fmd.get ());
261262 uint64_t hlTarget = eos::common::FileId::FidToInode (fmd->getId ());
262- gmd->setAttribute (XrdMgmOfsFile::k_mdino , std::to_string (hlTarget));
263+ gmd->setAttribute (SYS_HARD_LINK , std::to_string (hlTarget));
263264 eos_static_debug (" create_cow Unlink %s (%ld) -> %s (%ld)" ,
264265 gmd->getName ().c_str (), gmd->getSize (),
265266 fmd->getName ().c_str (), fmd->getSize ());
@@ -296,19 +297,19 @@ XrdMgmOfsFile::handleHardlinkDelete(std::shared_ptr<eos::IContainerMD> cmd,
296297 long nlink =
297298 -2 ; /* assume this has nothing to do with hard links */
298299
299- if (fmd->hasAttribute (XrdMgmOfsFile::k_mdino )) {
300+ if (fmd->hasAttribute (SYS_HARD_LINK )) {
300301 /* this is a hard link, decrease reference count on underlying file */
301- uint64_t hlTgt = std::stoull (fmd->getAttribute (XrdMgmOfsFile::k_mdino ));
302+ uint64_t hlTgt = std::stoull (fmd->getAttribute (SYS_HARD_LINK ));
302303 uint64_t clock;
303304 /* gmd = the hard link target */
304305 std::shared_ptr<eos::IFileMD> gmd = gOFS ->eosFileService ->getFileMD (
305306 eos::common::FileId::InodeToFid (hlTgt), &clock);
306- nlink = std::stol (gmd->getAttribute (XrdMgmOfsFile::k_nlink )) - 1 ;
307+ nlink = std::stol (gmd->getAttribute (SYS_NUM_LINK )) - 1 ;
307308
308309 if (nlink > 0 ) {
309- gmd->setAttribute (XrdMgmOfsFile::k_nlink , std::to_string (nlink));
310+ gmd->setAttribute (SYS_NUM_LINK , std::to_string (nlink));
310311 } else {
311- gmd->removeAttribute (XrdMgmOfsFile::k_nlink );
312+ gmd->removeAttribute (SYS_NUM_LINK );
312313 }
313314
314315 gOFS ->eosFileService ->updateStore (gmd.get ());
@@ -342,9 +343,9 @@ XrdMgmOfsFile::handleHardlinkDelete(std::shared_ptr<eos::IContainerMD> cmd,
342343 gOFS ->eosFileService ->updateStore (gmd.get ());
343344 }
344345 }
345- } else if (fmd->hasAttribute (
346- XrdMgmOfsFile::k_nlink)) { /* a hard link target */
347- nlink = std::stol (fmd->getAttribute (XrdMgmOfsFile::k_nlink ));
346+ } else if (fmd->hasAttribute (SYS_NUM_LINK)) {
347+ // a hard link target
348+ nlink = std::stol (fmd->getAttribute (SYS_NUM_LINK ));
348349 eos_static_info (" hlnk rm target nlink %ld" , nlink);
349350
350351 if (nlink > 0 ) {
@@ -353,7 +354,7 @@ XrdMgmOfsFile::handleHardlinkDelete(std::shared_ptr<eos::IContainerMD> cmd,
353354 uint64_t ino = eos::common::FileId::FidToInode (fmd->getId ());
354355 snprintf (nameBuf, sizeof (nameBuf), " ...eos.ino...%lx" , ino);
355356 std::string nameBufs (nameBuf);
356- fmd->setAttribute (XrdMgmOfsFile::k_nlink , std::to_string (nlink));
357+ fmd->setAttribute (SYS_NUM_LINK , std::to_string (nlink));
357358 eos_static_info (" hlnk unlink rename %s=>%s new nlink %d" ,
358359 fmd->getName ().c_str (), nameBufs.c_str (), nlink);
359360 cmd->removeFile (nameBufs); // if the target exists, remove it!
@@ -503,7 +504,6 @@ XrdMgmOfsFile::open(eos::common::VirtualIdentity* invid,
503504 Access_Operation acc_op = GetXrdAccessOperation (open_flags);
504505 {
505506 EXEC_TIMING_BEGIN (" IdMap" );
506-
507507 std::string validation_path = spath.c_str ();
508508
509509 if (spath.beginswith (" /zteos64:" )) {
@@ -1025,11 +1025,11 @@ XrdMgmOfsFile::open(eos::common::VirtualIdentity* invid,
10251025 if ((fmd = dmd->findFile (fileName))) {
10261026 /* in case of a hard link, may need to switch to target */
10271027 /* A hard link to another file */
1028- if (fmd->hasAttribute (XrdMgmOfsFile::k_mdino )) {
1028+ if (fmd->hasAttribute (SYS_HARD_LINK )) {
10291029 std::shared_ptr<eos::IFileMD> gmd;
10301030 uint64_t mdino;
10311031
1032- if (eos::common::StringToNumeric (fmd->getAttribute (XrdMgmOfsFile::k_mdino ),
1032+ if (eos::common::StringToNumeric (fmd->getAttribute (SYS_HARD_LINK ),
10331033 mdino)) {
10341034 gmd = gOFS ->eosFileService ->getFileMD (
10351035 eos::common::FileId::InodeToFid (mdino));
@@ -1255,17 +1255,17 @@ XrdMgmOfsFile::open(eos::common::VirtualIdentity* invid,
12551255 }
12561256
12571257 if (!(taccess = dmd->access (vid.uid , vid.gid ,
1258- (isRW) ? W_OK | X_OK : R_OK | X_OK))) {
1259- eos_debug (" fCUid %d dCUid %d uid %d isSharedFile %d isRW %d stdpermcheck %d access %d" ,
1260- fmd ? fmd->getCUid () : 0 , dmd->getCUid (), vid.uid , isSharedFile, isRW,
1261- stdpermcheck, taccess);
1262-
1263- if (!((vid.uid == DAEMONUID) && (isPioReconstruct))) {
1264- // we don't apply this permission check for reconstruction jobs issued via the daemon account
1265- errno = EPERM;
1266- gOFS ->MgmStats .Add (" OpenFailedPermission" , vid.uid , vid.gid , 1 );
1267- return Emsg (epname, error, errno, " open file" , path);
1268- }
1258+ (isRW) ? W_OK | X_OK : R_OK | X_OK))) {
1259+ eos_debug (" fCUid %d dCUid %d uid %d isSharedFile %d isRW %d stdpermcheck %d access %d" ,
1260+ fmd ? fmd->getCUid () : 0 , dmd->getCUid (), vid.uid , isSharedFile, isRW,
1261+ stdpermcheck, taccess);
1262+
1263+ if (!((vid.uid == DAEMONUID) && (isPioReconstruct))) {
1264+ // we don't apply this permission check for reconstruction jobs issued via the daemon account
1265+ errno = EPERM;
1266+ gOFS ->MgmStats .Add (" OpenFailedPermission" , vid.uid , vid.gid , 1 );
1267+ return Emsg (epname, error, errno, " open file" , path);
1268+ }
12691269 }
12701270 }
12711271
0 commit comments