Compare commits

...
This repository has been archived on 2022-05-27. You can view files and clone it, but cannot push or open issues or pull requests.

3 Commits

Author SHA1 Message Date
fac59a22b0 wip: echo 2021-12-27 16:22:02 +00:00
e598e6a20b wip: cp 2021-12-27 16:21:55 +00:00
6568720c6d added unity submodule 2021-12-27 16:19:47 +00:00
9 changed files with 40 additions and 1 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "extern/Unity"]
path = extern/Unity
url = https://github.com/ThrowTheSwitch/Unity.git

3
examples/cp/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
c
c_cgroup
ml

View File

@ -31,7 +31,37 @@ off_t get_file_size(int fd) {
/*
* Move self to a leaf node of the cgroup.
*/
int leaf_self() {}
int leaf_self() {
int cgroup_fd = open("/proc/self/cgroup", O_RDONLY);
if (cgroup_fd == -1) {
perror("open");
return -1;
}
if (lseek(cgroup_fd, 3, SEEK_SET) == -1) {
perror("lseek");
return -1;
}
char cgroup_root_dir[1024] = "/sys/fs/cgroup";
off_t len;
if ((len = read(cgroup_fd, cgroup_root_dir + 14, 1010)) == -1) {
perror("read");
return -1;
}
cgroup_root_dir[len + 17] = 0x00;
fprintf(stderr, "%s\n", cgroup_root_dir);
int cgroup_dd = open(cgroup_root_dir, O_DIRECTORY);
if (cgroup_dd == -1) {
perror("open");
return -1;
}
return 0;
}
/*
* Perform the copy between the two file descriptors.
@ -112,6 +142,8 @@ int main(int argc, char **argv) {
}
// setup a cgroup for the child
if (leaf_self() == -1)
return -1;
// wait for the child to pause and restart it
int status;

View File

0
examples/echo/echo.c Normal file
View File

0
examples/echo/echo.ml Normal file
View File

View File

View File

1
extern/Unity vendored Submodule

@ -0,0 +1 @@
Subproject commit 8ba01386008196a92ef4fdbdb0b00f2434c79563