-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
FUSE (WIP) #891
base: master
Are you sure you want to change the base?
FUSE (WIP) #891
Changes from all commits
4c23e78
0121d28
ce23224
eb815f4
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 |
---|---|---|
|
@@ -40,6 +40,11 @@ extern "C" { | |
|
||
#ifndef __MLIBC_ABI_ONLY | ||
|
||
#define MNT_FORCE 1 | ||
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. Double define |
||
#define MNT_DETACH (1<<1) | ||
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. Styling is wrong (see the constants defined earlier in the file. |
||
#define MNT_EXPIRE (1<<2) | ||
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. We should move these defines outside the MLIBC_ABI_ONLY define. Also please make sure these new defines match Linux. Better yet, we should really move these to an abi-bit header, as I'm pretty sure that at least some of the constants in this file don't match Linux. |
||
#define UMOUNT_NOFOLLOW (1<<3) | ||
|
||
int mount(const char *source, const char *target, | ||
const char *fstype, unsigned long flags, const void *data); | ||
int umount(const char *target); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,16 @@ | |
namespace mlibc { | ||
|
||
int sys_mount(const char *source, const char *target, | ||
const char *fstype, unsigned long, const void *) { | ||
const char *fstype, unsigned long, const void *data) { | ||
SignalGuard sguard; | ||
|
||
managarm::posix::MountRequest<MemoryAllocator> req(getSysdepsAllocator()); | ||
req.set_path(frg::string<MemoryAllocator>(getSysdepsAllocator(), source)); | ||
req.set_target_path(frg::string<MemoryAllocator>(getSysdepsAllocator(), target)); | ||
req.set_fs_type(frg::string<MemoryAllocator>(getSysdepsAllocator(), fstype)); | ||
if(data){ | ||
req.set_arguments(frg::string<MemoryAllocator>(getSysdepsAllocator(), (char*)data)); | ||
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. Is the extra data always a string? (Is it just the mount options as specified by 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. I'm not aware of any cases in which this data isn't a string, but I don't think it's is required to be a string. This is mainly a temporary measure until I can think of a better way to approach this. 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.
I think that, practically speaking, we would be fine by just interpreting this as a string in almost any occasion. However, I don't think it's technically correct. 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. That seems fine to me then. Since the man page directs you to 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. I might check the source later, but it's not very high-priority for me. I was thinking about implementing some sort of fs-specific argument decoding dispatch mechanism, but I'm not sure how I'd go about doing this and it'd probably require the sysdep to be aware of every possible filesystem - which would be impractical at best 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. I'm just throwing around ideas here, but isn't it also possible to have a |
||
} | ||
|
||
auto [offer, send_head, send_tail, recv_resp] = | ||
exchangeMsgsSync( | ||
|
@@ -37,6 +40,40 @@ int sys_mount(const char *source, const char *target, | |
auto resp = *bragi::parse_head_only<managarm::posix::SvrResponse>(recv_resp, getSysdepsAllocator()); | ||
if(resp.error() == managarm::posix::Errors::FILE_NOT_FOUND) | ||
return ENOENT; | ||
else if(resp.error() == managarm::posix::Errors::UNKNOWN_FILESYSTEM) | ||
return ENODEV; | ||
__ensure(resp.error() == managarm::posix::Errors::SUCCESS); | ||
return 0; | ||
} | ||
|
||
int sys_umount2(const char *target, int flags) { | ||
SignalGuard sguard; | ||
|
||
managarm::posix::Umount2Request<MemoryAllocator> req(getSysdepsAllocator()); | ||
req.set_target(frg::string<MemoryAllocator>(getSysdepsAllocator(), target)); | ||
req.set_flags(flags); | ||
|
||
auto [offer, send_head, send_tail, recv_resp] = | ||
exchangeMsgsSync( | ||
getPosixLane(), | ||
helix_ng::offer( | ||
helix_ng::sendBragiHeadTail(req, getSysdepsAllocator()), | ||
helix_ng::recvInline() | ||
) | ||
); | ||
|
||
HEL_CHECK(offer.error()); | ||
HEL_CHECK(send_head.error()); | ||
HEL_CHECK(send_tail.error()); | ||
HEL_CHECK(recv_resp.error()); | ||
|
||
auto resp = *bragi::parse_head_only<managarm::posix::SvrResponse>(recv_resp, getSysdepsAllocator()); | ||
if(resp.error() == managarm::posix::Errors::ILLEGAL_ARGUMENTS) | ||
return EINVAL; | ||
else if(resp.error() == managarm::posix::Errors::FILE_NOT_FOUND) | ||
return ENOENT; | ||
else if(resp.error() == managarm::posix::Errors::NOT_A_MOUNTPOINT) | ||
return EINVAL; | ||
__ensure(resp.error() == managarm::posix::Errors::SUCCESS); | ||
return 0; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef _GNU_SOURCE | ||
#define _GNU_SOURCE | ||
#endif | ||
#include <string.h> | ||
#include <errno.h> | ||
#include <assert.h> | ||
|
||
int main(void) { | ||
#if !defined(__GLIBC__) || (__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 32) | ||
const char *s = strerrordesc_np(EINVAL); | ||
assert(!strcmp(s, "Invalid argument (EINVAL)")); | ||
assert(strerrordesc_np(0) == NULL); | ||
#endif | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef _GNU_SOURCE | ||
#define _GNU_SOURCE | ||
#endif | ||
#include <string.h> | ||
#include <errno.h> | ||
#include <assert.h> | ||
|
||
int main(void) { | ||
#if !defined(__GLIBC__) || (__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 32) | ||
const char *s = strerrorname_np(EINVAL); | ||
assert(!strcmp(s, "EINVAL")); | ||
assert(strerrorname_np(0) == NULL); | ||
#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.
Shouldn't this be indented one more?
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.
The case statements I replaced were on the same indentation level - but I can indent it a level more of desired