Skip to content

Commit

Permalink
imp: cgroup: copy definition of CGROUP2_SUPER_MAGIC
Browse files Browse the repository at this point in the history
Problem: Some distros don't seem to have CGROUP2_SUPER_MAGIC defined
in linux/magic.h.

Copy the magic value from a system that has it. Remove the ifndef
CGROUP2_SUPER_MAGIC block since it will now always be defined.
  • Loading branch information
grondo committed Nov 1, 2024
1 parent 4c76388 commit 537cac2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/imp/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#ifndef CGROUP_SUPER_MAGIC
#define CGROUP_SUPER_MAGIC 0x27e0eb
#endif
#ifndef CGROUP2_SUPER_MAGIC
#define CGROUP2_SUPER_MAGIC 0x63677270
#endif
#include <signal.h>

#include "src/libutil/strlcpy.h"
Expand Down Expand Up @@ -123,7 +126,6 @@ static int cgroup_init_mount_dir_and_type (struct cgroup_info *cg)
if (statfs (cg->mount_dir, &fs) < 0)
return -1;

#ifdef CGROUP2_SUPER_MAGIC
/* if cgroup2 fs mounted: unified hierarchy for all users of cgroupfs
*/
if (fs.f_type == CGROUP2_SUPER_MAGIC)
Expand All @@ -141,7 +143,6 @@ static int cgroup_init_mount_dir_and_type (struct cgroup_info *cg)
if (fs.f_type == CGROUP2_SUPER_MAGIC)
return 0;

#endif /* CGROUP2_SUPER_MAGIC */
/* O/w, if /sys/fs/cgroup is mounted as tmpfs, we need to check
* for /sys/fs/cgroup/systemd mounted as cgroupfs (legacy).
*/
Expand Down

0 comments on commit 537cac2

Please sign in to comment.