cfs/src/FsProc_FileMngOps.cc
// RenameOp helper function to check if paths are valid and sets appropriate
// error in req if not.
RenameOp helper function to check if paths are valid and sets appropriate
error in req if not.
RenameOp helper function to check if paths are valid and sets appropriate error in req if not .
inline static bool hasValidPaths(FsReq *req) {
  assert(req->getType() == FsReqType::RENAME);
  auto &srcTokens = req->getPathTokens();
  auto &dstTokens = req->getDstPathTokens();
  if (srcTokens.empty() || dstTokens.empty()) {
    req->setError(FS_REQ_ERROR_POSIX_ENOENT);
    req->setState(FsReqState::RENAME_ERR);
    return false;
  }
  if (isSrcPrefixOfDst(srcTokens, dstTokens)) {
    req->setError(FS_REQ_ERROR_POSIX_EINVAL);
    req->setState(FsReqState::RENAME_ERR);
    return false;
  }
  return true;
}
inline static bool hasValidPaths ( FsReq * req ) { assert ( req -> getType ( ) == FsReqType :: RENAME ) ; auto & srcTokens = req -> getPathTokens ( ) ; auto & dstTokens = req -> getDstPathTokens ( ) ; if ( srcTokens . empty ( ) || dstTokens . empty ( ) ) { req -> setError ( FS_REQ_ERROR_POSIX_ENOENT ) ; req -> setState ( FsReqState :: RENAME_ERR ) ; return false ; } if ( isSrcPrefixOfDst ( srcTokens , dstTokens ) ) { req -> setError ( FS_REQ_ERROR_POSIX_EINVAL ) ; req -> setState ( FsReqState :: RENAME_ERR ) ; return false ; } return true ; }
RenameOp helper function to check if paths are valid and sets appropriate
error in req if not.
RenameOp helper function to check if paths are valid and sets appropriate error in req if not .
// ENOENT: either old or new points to an empty string. // FIXME rename "/" "/" ends up with srcTokens = dstTokens = [""]  which has // size of 1. Instead of returning ENOENT, it ends up returning EINVAL. // EINVAL: The new directory pathname contains a path prefix that names the // old directory. For example, `mv /foo/bar` /foo/bar/blah which should // return EINVAL