Skip to content

Commit

Permalink
Retry failed calls to vn_getpath
Browse files Browse the repository at this point in the history
  • Loading branch information
wilbaker committed Sep 14, 2018
1 parent efa70da commit 4c38ca0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ProjFS.Mac/PrjFSKext/PrjFSKext/KauthHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "Locks.hpp"
#include "PrjFSProviderUserClient.hpp"

static const int MAX_GETPATH_ENOENT_RETRIES = 1024;

// Function prototypes
static int HandleVnodeOperation(
kauth_cred_t credential,
Expand Down Expand Up @@ -659,10 +661,23 @@ static bool TrySendRequestAndWaitForResponse(

char vnodePath[PrjFSMaxPath];
int vnodePathLength = PrjFSMaxPath;
if (vn_getpath(vnode, vnodePath, &vnodePathLength))

// TODO(Mac): Issue #271 - Reduce reliance on vn_getpath
int retryCount = 0;
int getPathResult = vn_getpath(vnode, vnodePath, &vnodePathLength);
while (getPathResult && retryCount < MAX_GETPATH_ENOENT_RETRIES)
{
getPathResult = vn_getpath(vnode, vnodePath, &vnodePathLength);
++retryCount;
}

if (getPathResult)
{
KextLog_Error("Unable to resolve a vnode to its path");

// Default error code is EACCES. See errno.h for more codes.
*kauthResult = KAUTH_RESULT_DENY;
*kauthError = EAGAIN;
return false;
}

Expand Down

0 comments on commit 4c38ca0

Please sign in to comment.