Skip to content

Commit

Permalink
util/misc: use memfd helpers over direct ioctls
Browse files Browse the repository at this point in the history
Use the memfd helpers rather than directly invoking ioctls. This
consolidates error handling in the helper.

Signed-off-by: David Rheinsberg <[email protected]>
  • Loading branch information
dvdhrm committed Jul 30, 2024
1 parent 9c2d3e3 commit a72b668
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/util/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ int misc_memfd(const char *name, unsigned int uflags, unsigned int useals) {
_c_cleanup_(c_closep) int fd = -1;
unsigned int flags = uflags;
unsigned int seals = useals;
unsigned int kseals;
struct stat st;
int r;

Expand Down Expand Up @@ -126,11 +127,11 @@ int misc_memfd(const char *name, unsigned int uflags, unsigned int useals) {
* into the kernel again.
*/
if (seals) {
r = fcntl(fd, MISC_F_GET_SEALS);
if (r < 0)
return error_origin(-errno);
r = misc_memfd_get_seals(fd, &kseals);
if (r)
return error_fold(r);

if (seals & ~r) {
if (seals & ~kseals) {
r = misc_memfd_add_seals(fd, seals);
if (r)
return error_fold(r);
Expand Down

0 comments on commit a72b668

Please sign in to comment.