-
Notifications
You must be signed in to change notification settings - Fork 465
Mac: Handle projection changes where git deletes folders that are still in the projection #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -281,24 +281,37 @@ PrjFS_Result PrjFS_WritePlaceholderDirectory( | |
| return PrjFS_Result_EInvalidArgs; | ||
| } | ||
|
|
||
| PrjFS_Result result = PrjFS_Result_Invalid; | ||
| char fullPath[PrjFSMaxPath]; | ||
| CombinePaths(s_virtualizationRootFullPath.c_str(), relativePath, fullPath); | ||
|
|
||
| if (mkdir(fullPath, 0777)) | ||
| { | ||
| switch(errno) | ||
| { | ||
| // TODO(Mac): Return more specific error codes for other failure scenarios | ||
| case ENOENT: // A component of the path prefix does not exist or path is an empty string | ||
| result = PrjFS_Result_EPathNotFound; | ||
| break; | ||
| default: | ||
| result = PrjFS_Result_EIOError; | ||
| break; | ||
| } | ||
|
|
||
| goto CleanupAndFail; | ||
| } | ||
|
|
||
| if (!InitializeEmptyPlaceholder(fullPath)) | ||
| { | ||
| result = PrjFS_Result_EIOError; | ||
| goto CleanupAndFail; | ||
| } | ||
|
|
||
| return PrjFS_Result_Success; | ||
|
|
||
| CleanupAndFail: | ||
| // TODO: cleanup the directory on disk if needed | ||
| return PrjFS_Result_EIOError; | ||
| return result; | ||
| } | ||
|
|
||
| PrjFS_Result PrjFS_WritePlaceholderFile( | ||
|
|
@@ -323,23 +336,37 @@ PrjFS_Result PrjFS_WritePlaceholderFile( | |
| return PrjFS_Result_EInvalidArgs; | ||
| } | ||
|
|
||
| PrjFS_Result result = PrjFS_Result_Invalid; | ||
| PrjFSFileXAttrData fileXattrData = {}; | ||
|
|
||
| char fullPath[PrjFSMaxPath]; | ||
| CombinePaths(s_virtualizationRootFullPath.c_str(), relativePath, fullPath); | ||
|
|
||
| // Mode "wbx" means | ||
| // - Create an empty file if none exists | ||
| // - Fail if a file already exists at this path | ||
| FILE* file = fopen(fullPath, "wbx"); | ||
| // Mode "wx" means: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove the "b" here?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When I was digging into the documentation for From the Mac manpage for
The linux documentation had a few more details:
From this it sounds like C's Let me know if you'd rather I leave it in as it doesn't appear to be hurting anything.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, I was looking at more generic docs that said that if you don't specify "b", it can translate some of the characters as you read/write, which we don't want. If it's a noop on Mac, then this is fine. |
||
| // - "w": Open for writing. The stream is positioned at the beginning of the file. Create the file if it does not exist. | ||
| // - "x": If the file already exists, fopen() fails, and sets errno to EEXIST. | ||
| FILE* file = fopen(fullPath, "wx"); | ||
| if (nullptr == file) | ||
| { | ||
| switch(errno) | ||
| { | ||
| // TODO(Mac): Return more specific error codes for other failure scenarios | ||
| case ENOENT: // A directory component in fullPath does not exist or is a dangling symbolic link. | ||
| result = PrjFS_Result_EPathNotFound; | ||
| break; | ||
| case EEXIST: // The file already exists | ||
| default: | ||
| result = PrjFS_Result_EIOError; | ||
| break; | ||
| } | ||
|
|
||
| goto CleanupAndFail; | ||
| } | ||
|
|
||
| // Expand the file to the desired size | ||
| if (ftruncate(fileno(file), fileSize)) | ||
| { | ||
| result = PrjFS_Result_EIOError; | ||
| goto CleanupAndFail; | ||
| } | ||
|
|
||
|
|
@@ -354,12 +381,14 @@ PrjFS_Result PrjFS_WritePlaceholderFile( | |
| &fileXattrData, | ||
| PrjFSFileXAttrName)) | ||
| { | ||
| result = PrjFS_Result_EIOError; | ||
| goto CleanupAndFail; | ||
| } | ||
|
|
||
| // TODO(Mac): Only call chmod if fileMode is different than the default file mode | ||
| if (chmod(fullPath, fileMode)) | ||
| { | ||
| result = PrjFS_Result_EIOError; | ||
| goto CleanupAndFail; | ||
| } | ||
|
|
||
|
|
@@ -375,7 +404,7 @@ PrjFS_Result PrjFS_WritePlaceholderFile( | |
| file = nullptr; | ||
| } | ||
|
|
||
| return PrjFS_Result_EIOError; | ||
| return result; | ||
| } | ||
|
|
||
| PrjFS_Result PrjFS_WriteSymLink( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.