-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add saunafs command on Windows #298
base: dev
Are you sure you want to change the base?
Conversation
20157eb
to
34eaa8d
Compare
For making the saunafs command available on Windows, this commit adds the necessary changes to compile the saunafs command on Windows. Signed-off-by: rolysr <[email protected]>
The `open_master_conn` function was not working properly on Windows when using it with the saunafs tool because it was not properly resolving the inode by a given path on the file system. This commit fixes that issue. Signed-off-by: rolysr <[email protected]>
The makesnapshot command was failing on saunafs tool on Windows because of not correctly resolving the source inode from which the snapshot was going to be created. This commit fixes that issue. Signed-off-by: rolysr <[email protected]>
The previous implementation of recursive remove was not correctly delimiting the path separator for a parent path from a given full path when using the saunafs tool on Windows. This commit fixes that issue. Signed-off-by: rolysr <[email protected]>
34eaa8d
to
add65ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! 👍
As a general comment, I think the changes would have looked better if they were ordered like:
- enough to be able to compile in Windows
- fixes on
open_master_conn
function, including the changes in the protocol. - fixes on each of the tools, single commit or multiple commits, as you see fit.
Though it would be a chore to make it that way now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should also move the file quota_database.cc
file to make the change more consistent.
|
||
#else | ||
#include <signal.h> | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please notice the missing endline.
@@ -25,6 +25,8 @@ | |||
#include <utility> | |||
#include "protocol/quota.h" | |||
#include <master/filesystem_node_types.h> | |||
#include "common/quota_database.h" | |||
#include "master/filesystem_freenode.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should come to an agreement on whether to use quotes or angular in these kind of includes.
inode = current_inode; | ||
return SAUNAFS_STATUS_OK; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are some permission checks missing here.
You could think of this function as several fs_lookup
calls one on top of the other. There are things which are there that are not present here, to mention some:
- call to
verify_session
- call to
fsnodes_get_node_for_operation
(I think this is the one doing the permission check) - checks on the implicit entries (
.
and..
) - call to
fsnodes_namecheck
- entry in
gFsStatsArray
and increasing its count.
Consider the approach to partition the path and call severall fs_lookup
(ignoring the gFsStatsArray
update).
Also notice that some of these add-ups could be applied in fs_full_path_by_inode
.
uint32_t uid = getuid(); | ||
uint32_t gid = getgid(); | ||
#endif | ||
Client::Context *ret = new Client::Context(uid, gid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change required? I don't think we are building the this client in Windows.
int srcname_len = strlen(srcnames[i]); | ||
if (srcnames[i][srcname_len - 1] == '/' || | ||
srcnames[i][srcname_len - 1] == '\\') { | ||
srcnames[i][srcname_len - 1] = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider writing
srcnames[i][srcname_len - 1] = '\0';
to make clearer you are setting the end of the string.
#ifdef _WIN32 | ||
if (GetFullPathName(srcnames[i], PATH_MAX, src, NULL) == | ||
0) { | ||
printf("%s: GetFullPathName error: %lu\n", | ||
srcnames[i], GetLastError()); | ||
return -1; | ||
} | ||
#else | ||
if (realpath(srcnames[i], src) == NULL) { | ||
printf("%s: realpath error on %s: %s\n", srcnames[i], src, | ||
strerr(errno)); | ||
status = -1; | ||
continue; | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct that the Windows code is directly returning while the Linux analogous one is setting up status and continuing?
#ifdef _WIN32 | ||
if (GetFullPathName(srcnames[i], PATH_MAX, src, NULL) == | ||
0) { | ||
printf("%s: GetFullPathName error: %lu\n", | ||
srcnames[i], GetLastError()); | ||
return -1; | ||
} | ||
#else | ||
if (realpath(srcnames[i], src) == NULL) { | ||
printf("%s: realpath error on %s: %s\n", srcnames[i], src, | ||
strerr(errno)); | ||
status = -1; | ||
continue; | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same concern here.
#ifdef _WIN32 | ||
if (GetFullPathName(dir, PATH_MAX, to, NULL) == 0) { | ||
printf("%s: GetFullPathName error: %lu\n", dir, GetLastError()); | ||
return -1; | ||
} | ||
#else | ||
if (realpath(dir, to) == NULL) { | ||
printf("%s: realpath error on %s: %s\n", dir, to, strerr(errno)); | ||
return -1; | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider finding a way to try to not repeat code (and preprocessor directives) in the GetFullPathName
and realpath
consecutive calls.
if (endp == path) { | ||
if ((endp - path) == 2 && path[1] == ':' && path[2] == '\\') { | ||
path[3] = '.'; | ||
path[4] = '\0'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider the case of mountpoints in subfolders.
This PR is related to the corresponding integration of the saunafs tool on a Windows environment. The main changes were:
open_master_conn
function in order to correctly get the corresponding inode from a given Windows file system path.makesnapshot
andrremove
to work on Windows.