-
-
Notifications
You must be signed in to change notification settings - Fork 637
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
Redbean: Support for unshare() mount() prctl() in Lua #801
base: master
Are you sure you want to change the base?
Conversation
Thank you for the patch! Overall, this PR looks good to me, but there are a couple of things that need to be fixed. This looks strange:
Why would the result of lua_tostring be converted to Also the closing bracket in the comments should have a slightly different character:
Tests would be ideal, but these two may be difficult to test (although you may still be able to test for some basic parameters). The documentation is in tool/net/help.txt; I can update it after this PR is merged or you can add it there yourself as part of the same PR. |
Thank you so much for the lovely and relevant feedback 🐈 |
I added corrections for the relevant feedback. |
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.
Approval for copyright.
|
||
// unix.umount(target: str[, flags: int) | ||
// ├─→ true | ||
// ├─→ nil, unix.Errrno |
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.
Minor tweak, but the character should be └
(as n prctl
).
|
||
// unix.mount(source:str, target:str, filesystemtype: str[, mountflags: int[, data: str]]) | ||
// ├─→ true | ||
// ├─→ nil, unix.Errno |
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.
Minor tweak, but the character should be └
(as n prctl
).
luaL_optinteger(L, 4, 0), luaL_optstring(L, 5, NULL))); | ||
} | ||
|
||
// unix.umount(target: str[, flags: int) |
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.
Missing closing ]
.
// unix.prctl(option: int[, arg2: int[, arg3: int[, arg4: int[, arg5: int]]]]) | ||
// ├─→ result: int | ||
// └─→ nil, unix.Errno | ||
static int LuaUnixPrctl(lua_State *L) { |
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.
None of the get-like prctl variants are going to work, as there is no way to get the values back to the Lua layer. These values either need to be returned as prctl results (it seems like most of them are stored as arg2, so may be need to be returned as a string or number) or need to be taken as one table parameter, in which case the table can be modified to pass the values back. The first option is going to be more consistent with how the rest of unix.* functions operate.
I'm not familiar with the implementation details of prctl to access its coverage in cosmopolitan, but I'm sure @jart can comment on that.
faa6285
to
2c4b887
Compare
These changes should extend Redbean's Lua's functionality to add additional unix syscalls per requested here #794.
I wasn't able to find any direct support for the
unshare
syscall in the Cosmopolitan C lib, so for now I am opening this pull request as incomplete without support for it.Few notes I have to leave for the maintainers:
unix
module so please let me know if there's any other way to implement it.