Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
40f99fdc
Unverified
Commit
40f99fdc
authored
Feb 23, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: add copy_struct_from_client()
Which is our variant of copy_struct_from_user() that Aleksa and I added to the kernel. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
8302a79b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
utils.h
src/lxc/utils.h
+18
-0
No files found.
src/lxc/utils.h
View file @
40f99fdc
...
...
@@ -243,4 +243,22 @@ __hidden extern int safe_mount_beneath_at(int beneat_fd, const char *src, const
const
char
*
fstype
,
unsigned
int
flags
,
const
void
*
data
);
__hidden
__lxc_unused
int
print_r
(
int
fd
,
const
char
*
path
);
static
inline
int
copy_struct_from_client
(
__u32
server_size
,
void
*
dst
,
__u32
client_size
,
const
void
*
src
)
{
__u32
size
=
min
(
server_size
,
client_size
);
__u32
rest
=
min
(
server_size
,
client_size
)
-
size
;
/* Deal with trailing bytes. */
if
(
client_size
<
server_size
)
{
memset
(
dst
+
size
,
0
,
rest
);
}
else
if
(
client_size
>
server_size
)
{
/* TODO: Actually come up with a nice way to test for 0. */
return
0
;
}
memcpy
(
dst
,
src
,
size
);
return
0
;
}
#endif
/* __LXC_UTILS_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment